\n";
echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
?>
PLD Build Logs
' ."\n";?>
".
"";
}
function end_pre()
{
echo " |
\n";
}
function trailer()
{
echo "";
}
function mydie($msg)
{
echo "Fatal error: $msg";
}
function list_logs()
{
global $database;
global $arch, $dist, $ok;
global $big_url, $ns;
global $off, $cnt, $root_directory, $url;
$big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt";
if ($ok == 1) {
echo ""._("Listing of")." $dist/$arch/OK "
."("._("fail").")
\n";
} else {
echo ""._("Listing of")." $dist/$arch/FAIL "
."("._("ok").")
\n";
}
echo "\n";
echo ""._("No.")." | ".
""._("Log File").
"["._("sort")."] | ".
""._("Size")." | ".
""._("Age").
"["._("sort")."] | ".
"
";
if ($ns != 1) $ns = 0;
if (!isset($ok)) $ok = 0;
// if (!isset($off)) $off = 0;
// if (!isset($cnt)) $cnt = 50;
if ($ns == 0) $order = "mtime DESC";
else $order = "name";
$query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE "
. "dist = '$dist' AND arch = '$arch' AND ok = $ok ORDER BY $order LIMIT $cnt OFFSET $off";
try {
$dbh = new PDO("$database");
} catch (PDOException $e) {
mydie("new PDO: " . $e->getMessage());
}
$now = time();
$i = $off;
foreach ($dbh->query("$query") as $row) {
$name = $row["name"];
$id = $row["id"];
$dist = $row["dist"];
$arch = $row["arch"];
$f = $name;
$name_url = urlencode($name);
$t = $now - $row["mtime"];
$s = $row["size"];
$h = $row["log_id"];
$t /= 60;
if ($t >= 60) {
$t /= 60;
if ($t >= 24) {
$t /= 24;
$t = round($t);
$t = $t . " " . ngettext("day","days",$t);
} else {
$t = round($t);
$t = $t . " " . ngettext("hour","hours",$t);
}
} else {
$t = round($t);
$t = $t . " " . ngettext("minute","minutes",$t);
}
$u = "$url?dist=$dist&arch=$arch&ok=$ok&name=$name_url&id=$id";
echo "".($i+1).". | ".
"$f ".
"["._("text")." | ".
""._("tail")."]".
" | ".
"$s | $t |
\n";
$i++;
}
$count = $i - $off;
echo "
\n";
$backarr = "<<< ";
$back = _("Page back");
$forward = _("Page forward");
$forwardarr = " >>>";
echo "";
if ($off > 0) {
$noff = $off - $count;
if ($noff < 0)
$noff = 0;
$hrefurl = "";
echo "$hrefurl$backarr | $hrefurl$back";
} else {
echo "$backarr | $back";
}
echo " | \n";
if (isset($dist) && isset($arch)) {
echo "["._("View rpm -qa of builder")."]";
} else {
echo " ";
}
echo " | \n";
if ($cnt == $count) {
$noff = $off + $cnt;
if ($noff < 0)
$noff = 0;
$hrefurl = "";
echo "$hrefurl$forward | $hrefurl$forwardarr";
} else {
echo "$forward | $forwardarr";
}
echo " | \n
";
}
function file_name()
{
global $ok, $dist, $arch, $name, $name_url, $id;
if (isset($name) && isset($ok) && isset($arch) && isset($dist)) {
if (isset($id) && $id != '') {
$name = $name . ",$id";
}
$w = $ok ? "OK" : "FAIL";
return "$dist/$arch/$w/$name.bz2";
}
}
function dump_log($tail)
{
global $ok, $url, $dist, $arch, $name, $name_url;
global $root_directory, $big_url, $ns, $id, $cnt, $off;
global $buildlogs_server;
$f = file_name();
if ($f == false)
return;
$df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
$df = preg_replace("/\.(bz2|gz)$/", "", $df);
echo "$df
";
echo "";
function one_item($h, $t) {
echo "$h: | ".
"$t |
";
}
function href($h, $c) {
return "$c";
}
one_item(_("Status"), ($ok == 1 ?
""._("OK")."" :
""._("Failed").""));
one_item(_("Source URL"),
href("ftp://$buildlogs_server/$f",
"ftp://$buildlogs_server/$f"));
$big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt";
$bu = "$big_url&off=$off";
one_item(_("text/plain URL"),
href("$bu&name=$name_url&id=$id&action=text",
_("View!")));
if ($tail) {
one_item(_("full text"),
href("$bu&name=$name_url&id=$id",
_("View!")));
}
if (isset($dist) && isset($arch)) {
one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!")));
} else {
one_item(_("rpm -qa of builder"), _("Not available"));
}
one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory/$f")));
/*
echo "Here: | " .
"".
"http://" . getenv("SERVER_NAME") .
getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id" .
" |
"; */
# what can I say beside PHP suxx? how the fuck should I create
# bidirectional pipe? gotta use wget
if (preg_match("/\.bz2$/", $f)) {
$filter = "bzcat";
} elseif (preg_match("/\.gz$/", $f)) {
$filter = "zcat";
} else {
$filter = "cat";
}
$cmd = "$filter '$root_directory/$f'";
if ($tail)
$cmd = "$cmd | tail -n 100";
$fd = popen($cmd, "r");
$toc = array();
ob_start();
$err_count = 0;
while (($s = fgets($fd, 102400)) != false) {
if (strlen($s) > 800) {
$s = chunk_split($s, 800, "\n ");
$s = trim($s);
}
$s = htmlspecialchars($s);
// highlight errors
if (preg_match("/errors?:/i", $s)) {
$err_count++;
$toc[] = "error $err_count";
$err[] = $s;
$s = "$s";
} elseif (substr($s, 0, 2) == "+ ") {
// shell verbose
$s = "$s";
} elseif (preg_match("/^Executing\(%(?P\w+)\)/", $s, $m)) {
// rpm build section
$toc[] = $m['section'];
$err[] = $s;
$s = "$s";
} elseif (preg_match("/^Processing files: (?P(?P.+)-[^-]+-[^-]+)/", $s, $m)) {
// processing files
$toc[] = "files ".$m['name'];
$err[] = $s;
$s = "$s";
}
echo $s;
}
pclose($fd);
$code = ob_get_contents();
ob_end_clean();
echo "
";
if (!empty($toc)) {
echo ""._("Toc:")."
";
echo "";
foreach ($toc as $i => $section) {
$id = str_replace(" ", "-", $section);
echo "- {$section}
";
echo "{$err[$i]}
";
}
echo "
";
}
echo ""._("Content:")."
";
start_pre();
echo $code;
end_pre();
?>
\n";
echo ""._("Failed")." | "._("Ok")." |
\n";
foreach ($addr as $dist => $ddist) {
foreach ($ddist as $arch) {
echo "".
"
$dist/$arch | ".
"[OK] | ".
#"[qa] | ".
"
\n";
}
}
echo "
\n";
echo "\n";
# smile ;)
echo "";
$pow = array("vim", "php", "brain", "power", "electricity",
"coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
"voodoo magic", "Linux", "x-files", "X", "foobar",
"/dev/null", "/dev/zero", "/dev/drzewo",
"Leppe'", "matrix", "Neo", "PDP-11",
"Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
"foobarbaz", "ed", "Joe", "Unix conspiracy",
"overclock", "The Right Thing",
"The Bad Thing", "Star Treck", "NSA", "NASA",
"achelon", "VAX", "Real Programmer",
"Real Operating System", "Real Computer",
"computron", "bogon", "quantum bogodynamics",
"BOFH", "/dev/ill", "nasi tu byli",
"Paranoid Android", "Lunatic Corp", "Parallel thinking",
"sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
"Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3",
"synergy", "six Cray XMT Supercomputers"
# feel free to add sth if you change this file ;)
);
echo _("Powered by")." ";
$max = 1;
for ($i = 0; $i < $max; $i++) {
$x = rand(0, count($pow) - 1);
if ($pow[$x] == "") $i--;
else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
$pow[$x] = "";
}
echo "
";
echo "";
echo "Your IP: " . $_SERVER['REMOTE_ADDR'];
echo "
";
if (isset($dist) && isset($arch)) {
echo "";
}
}
function get_qa()
{
global $dist, $arch;
if (!isset($dist) || !isset($arch))
return false;
$addr = "http://ftp1.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt";
return fopen("$addr", "r");
}
function search_qa()
{
global $url, $str, $dist, $arch;
$f = get_qa();
echo ""._("Search results for")." '$str' "._("in")." $dist/$arch
";
start_pre();
if ($f == 0) {
echo _("Sorry, cannot open.");
} else {
while (($s = fgets($f, 1000)) != false) {
if (stristr($s, $str))
echo $s;
}
echo "/* EOF */";
}
end_pre();
}
function dump_qa($plain)
{
global $url, $dist, $arch;
$f = get_qa();
if ($plain) {
header("Content-type: text/plain");
echo _("# rpm -qa of")." $dist/$arch\n";
} else {
echo ""._("rpm -qa of")." $a
";
echo ""._("text/plain version")."";
start_pre();
}
if ($f == 0) {
echo _("Sorry, cannot open.");
} else {
while (($s = fgets($f, 1000)) != false) {
echo $s;
}
}
if (!$plain)
end_pre();
}
function adv_search()
{
global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns;
$big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt";
echo "\n";
/* Shut up warnings */
if (!isset($_POST["n2"])) $_POST["n2"] = "";
if (!isset($_POST["age1"])) $_POST["age1"] = "";
if (!isset($_POST["age2"])) $_POST["age2"] = "";
if (!isset($_POST["size1"])) $_POST["size1"] = "";
if (!isset($_POST["size2"])) $_POST["size2"] = "";
echo "\n";
}
function welcome()
{
?>
|
=_("Welcome!")?>
=_("Welcome to PLD Build Logs WWW interface.")?>
=_("Feel free to email bug reports, complaints and feature requests ")?>
=_("to us")?>. =_("Positive opinions are also")?>
=_("welcome")?> ;)
Version: $Id: index.php,v 1.21 2013/09/07 16:58:53 glen Exp $
| |
";
list_archs();
echo " | ";
flush();
if ($action == "qa")
dump_qa(0);
else if ($action == "sqa")
search_qa();
else if (isset($id) || isset($name))
dump_log($action == "tail");
else if (isset($dist))
list_logs();
else
welcome();
echo " |
";
trailer();
}
?>