\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 "". "". " ". "". ""; 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 "". "\n"; $i++; } $count = $i - $off; echo "
"._("No.").""._("Log File"). "["._("sort")."]"._("Size").""._("Age"). "["._("sort")."]
".($i+1).".$f ". "["._("text")." | ". ""._("tail")."]". "". "$s$t
\n"; $backarr = "<<< "; $back = _("Page back"); $forward = _("Page forward"); $forwardarr = " >>>"; echo "

\n\n\n
"; if ($off > 0) { $noff = $off - $count; if ($noff < 0) $noff = 0; $hrefurl = ""; echo "$hrefurl$backarr$hrefurl$back"; } else { echo "$backarr$back"; } echo ""; if (isset($dist) && isset($arch)) { echo "["._("View rpm -qa of builder")."]"; } else { echo " "; } echo ""; if ($cnt == $count) { $noff = $off + $cnt; if ($noff < 0) $noff = 0; $hrefurl = ""; echo "$hrefurl$forward$hrefurl$forwardarr"; } else { echo "$forward$forwardarr"; } echo "

"; } 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); list($name, $id) = explode(',', $df); if ($name != 'command') { $gitweb_url = "http://git.pld-linux.org/?p=packages/$name.git;a=summary"; $name = "$name"; } echo "

$name $id

"; echo ""; function one_item($h, $t) { echo "". ""; } 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 ""; */ # 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'"; $fd = popen($cmd, "r"); $toc = array(); $err = array(); $first_cut = false; $first_cut_done = false; $time = ""; $out_buf = array(); $out_buf_size = 0; $err_count = 0; while (($s = fgets($fd, 102400)) != false) { $toc_elem = false; $err_elem = false; $s = htmlspecialchars($s); // highlight errors if (preg_match("/(?:fail|error(s|\sCS\d+)?):/i", $s)) { $first_cut = true; $err_count++; $toc_elem = "error $err_count"; $err_elem = $s; $s = "$s"; } elseif (preg_match("/(?:undefined reference to|recipe for target '.*?' failed)/i", $s)) { $first_cut = true; $err_count++; $toc_elem = "error $err_count"; $err_elem = $s; $s = "$s"; } elseif (preg_match("#^\+ /usr/bin/make\b.*\b(?Pcheck)\b#", $s, $m)) { // rpm build section $toc_elem = "make {$m['target']}"; $err_elem = $s; $s = "$s"; } elseif (preg_match('/^(?P- For complete changelog see:) (?P.+)$/', $s, $m)) { // rpm changelog link $link = "{$m['link']}"; $s = "{$m['line']} $link
"; } elseif (preg_match('/^(?P\* \w{3} \w{3} [ \d]{2} \d{4} .*?) (?P[a-z0-9]{7})$/', $s, $m)) { // rpm changelogs $url = "http://git.pld-linux.org/?p=packages/{$name_url}.git;a=commitdiff;h={$m['hash']}"; $link = "{$m['hash']}"; $s = "{$m['line']} $link
"; } elseif (substr($s, 0, 2) == "+ ") { // shell verbose $s = "$s"; } elseif (preg_match("/^Executing\(%(?P
\w+)\)/", $s, $m)) { // rpm build section $toc_elem = $m['section']; $err_elem = $s; $s = "$s"; } elseif (preg_match("/^Processing files: (?P(?P.+)-[^-]+-[^-]+)/", $s, $m)) { $first_cut = true; // processing files $toc_elem = "files ".$m['name']; $err_elem = $s; $s = "$s"; } elseif (preg_match("/^ended at: (?P.+), done in (?P
$h:$t
Here:" . "". "http://" . getenv("SERVER_NAME") . getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id" . "
"; if (!empty($toc)) { echo "

"._("Toc:")."

"; echo ""; } echo "

"._("Content:")."

"; start_pre(); echo $code; end_pre(); ?>
[] [">]
\n"; echo ""._("Failed").""._("Ok")."\n"; foreach ($addr as $dist => $ddist) { echo "
\n"; foreach ($ddist as $arch) { echo "". " $dist/$arch". "[OK]". #"[qa]". "\n"; } } echo "
\n"; echo "
"; echo ""._("Advanced Search")."
\n"; echo "main()
\n"; echo "
\n" . "(c) 2002-". date("Y") . " ". "PLD Team
\n". '$Revision: 1.37 $'. "
\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 "
"; echo ""; echo ""; echo ""; echo "
"; echo ""; 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, "Query done at:")) { echo "rpmqa database from " . strstr($s, ":") . "\n"; continue; } if (stristr($s, $str)) echo $s; } echo "\n/* 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 "
"; echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $i = 1; foreach ($addr as $dist => $ddist) { foreach ($ddist as $arch) { echo "\n"; $name="as0_".$i; if (!isset($_POST["$name"])) { $check = " "; } else { $check=" checked='checked'"; } echo "\n"; $name="as1_".$i; if (!isset($_POST["$n2"])) { $check = " "; } else { $check=" checked='checked'"; } echo "\n"; echo "\n"; $i++; } } echo "\n"; echo ""; echo "\n"; echo "
"._("Package name")."
"._("Days").""._("From").": "._("To").":
"._("Size").""._("From").": "._("To").":
"._("Search logs:")."
"._("Failed").""._("OK")."
 
\n"; // if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) || // isset($_POST["size1"]) || isset($_POST["size2"]) if (($_POST["n2"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") || ($_POST["size1"]!="") || ($_POST["size2"]!="")) { $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 "; if ($_POST["n2"] != "") { $n = addslashes($_POST["n2"]); $query .= "AND name LIKE '$n%' "; } $now = time(); if ($_POST["age1"] != "") { $age = $now - (int)$_POST["age1"] * 24 * 3600; $query .= "AND mtime > $age "; } if ($_POST["age2"] != "") { $age = $now - (int)$_POST["age2"] * 24 * 3600; $query .= "AND mtime < $age "; } if ($_POST["size1"] != "") { $size = (int)$_POST["size1"]; $query .= "AND size > $size "; } if ($_POST["size2"] != "") { $size = (int)$_POST["size2"]; $query .= "AND size < $size "; } $or = "AND ("; $i = 1; foreach ($addr as $dist => $ddist) { foreach ($ddist as $arch) { for ($j = 0; $j < 2; $j++) { if (isset($_POST["as" . $j . "_" .$i])) { $query .= "$or (dist = '$dist' AND arch = '$arch' AND ok = $j)"; $or = " OR "; } } $i++; } } if ($or == " OR ") $query .= ")"; // if (!isset($cnt)) $cnt = 50; // if (!isset($off)) $off = 0; if (!isset($ns)) $ns = 0; switch ($ns) { case 0: $query .= " ORDER BY mtime DESC"; break; case 1: $query .= " ORDER BY name"; break; case 2: $query .= " ORDER BY dist, arch, name"; break; } $query .= " LIMIT $cnt OFFSET $off "; try { $dbh = new PDO("$database"); } catch (PDOException $e) { mydie("new PDO: " . $e->getMessage()); } $result = $dbh->query("$query")->fetchAll(); if ($result == FALSE) { echo _("Nothing found"); } else { echo "\n"; echo ""; echo "". " ". "". ""; $i = $off; // for ($i = $off; $i < $off + $count; $i++) { foreach ($result as $row) { $dist = $row["dist"]; $arch = $row["arch"]; $name = $row["name"]; $name_url = urlencode($name); $id = $row["id"]; $f = $name; $t = $now - $row["mtime"]; $s = $row["size"]; $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); } // $big_url = "$url?idx=$i&ok=$j&ns=$ns&cnt=$cnt"; $ok = $row["ok"]; $u = "$url?dist=$dist&arch=$arch&name=$name_url&ok=$ok&id=$id"; $b = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&off=$off&cnt=$cnt"; $builder = "$dist/$arch/". $fail_or_ok[$ok]; echo ""; echo ""; echo "\n"; $i++; } echo "
"._("Builder"). "["._("sort")."]"._("Log File"). "["._("sort")."]"._("Size").""._("Age"). "["._("sort")."]
$builder$f ". "["._("text")." | ". ""._("tail")."]". "". "$s$t
\n"; $backarr = "<<< "; $back = _("Page back"); $forward = _("Page forward"); $forwardarr = " >>>"; } // FIXME /* echo "

\n\n\n
"; if ($off > 0) { $noff = $off - $cnt; if ($noff < 0) $noff = 0; $hrefurl = ""; echo "$hrefurl$backarr$hrefurl$back"; } else { echo "$backarr$back"; } echo ""; echo ""; if ($off + $cnt < count($list)) { $noff = $off + $cnt; if ($noff < 0) $noff = 0; $hrefurl = ""; echo "$hrefurl$forward$hrefurl$forwardarr"; } else { echo "$forward$forwardarr"; } echo "

"; */ } else { echo _("Enter something!"); } echo "
\n"; } function welcome() { ?>
 

. ;)

 
"; 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(); } ?>