". "
";
}

function end_pre()
{
	echo "
\n"; } function trailer() { echo ""; } function mydie($msg) { echo "Fatal error: $msg"; } function open_ftp() { global $idx, $addr, $buildlogs_server, $ok; global $ftp_conn, $big_url, $url, $ns; global $off, $cnt; if (!isset($idx) || !isset($addr[$idx])) return false; if ($ok != 1) $ok = 0; if ($ns != 1) $ns = 0; if ($ok == 1) { $a = "$addr[$idx]/OK"; } else { $a = "$addr[$idx]/FAIL"; } if (!isset($off)) $off = 0; if (!isset($cnt)) $cnt = 16; $big_url = "$url?idx=$idx&ok=$ok&ns=$ns"; $ftp = ftp_connect($buildlogs_server); if ($ftp == false) { mydie("cannot connect to $buildlogs_server"); return false; } if (ftp_login($ftp, "anonymous", "buildlogs-iface@pld.org.pl") == false) { ftp_quit($ftp); mydie("cannot ftp login to $buildlogs_server"); return false; } $list = ftp_nlist($ftp, $a); if ($list == false) { ftp_quit($ftp); mydie("cannot list $a"); return false; } $ftp_conn = $ftp; return $list; } function directory_list() { global $idx, $addr, $buildlogs_server, $ok; global $root_directory, $big_url, $url, $ns; global $off, $cnt; if (!isset($idx) || !isset($addr[$idx])) return false; if ($ok != 1) $ok = 0; if ($ns != 1) $ns = 0; if ($ok == 1) { $a = "$addr[$idx]/OK"; } else { $a = "$addr[$idx]/FAIL"; } if (!isset($off)) $off = 0; if (!isset($cnt)) $cnt = 16; $big_url = "$url?idx=$idx&ok=$ok&ns=$ns"; $dir = opendir("$root_directory$a"); $i = 0; while ($file = readdir($dir)) { if (($file != ".") && ($file != "..")) { $list[$i] = "$a/$file"; $i++; } } closedir($dir); return $list; } function list_logs() { global $idx, $addr, $ok; global $ftp_conn, $big_url, $ns; global $off, $cnt; $list = open_ftp(); if ($list == false) return; if ($ok == 1) { echo "

Listing of $addr[$idx]/OK " ."(fail)

"; } else { echo "

Listing of $addr[$idx]/FAIL " ."(ok)

"; } echo "
\n"; echo "". " ". "". ""; function cmp($f1, $f2) { global $ftp_conn; return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1); } if ($ns != 1) { $ns = 0; usort($list, cmp); } else { sort($list); } $now = time(); for ($i = $off; $i < $cnt + $off; $i++) { if (!isset($list[$i])) continue; $h = bin2hex(mhash(MHASH_MD5, $list[$i])); $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]); $f = preg_replace("/\.(bz2|gz)$/", "", $f); $s = ftp_size($ftp_conn, $list[$i]); $t = $now - ftp_mdtm($ftp_conn, $list[$i]); $t /= 60; if ($t >= 60) { $t /= 60; if ($t >= 24) { $t /= 24; $t = round($t); if ($t > 1) { $t = $t . " days"; } else { $t = $t . " day"; } } else { $t = round($t); if ($t > 1) { $t = $t . " hours"; } else { $t = $t . " hour"; } } } else { $t = round($t); if ($t != 1) { $t = $t . " minutes"; } else { $t = $t . " minute"; } } $u = "$big_url&cnt=$cnt&off=$off&id=$h"; echo "\n"; } echo "
Log File ". "[sort]SizeAge ". "[sort]
". "$f ". "[text | ". "tail]". "". "$s$t
\n"; $back = "<<< Page back"; $forward = "Page forward >>>"; echo "

"; if ($off > 0) { $noff = $off - $cnt; if ($noff < 0) $noff = 0; echo "$back\n"; } else { echo "$back\n"; } echo ""; echo "[View rpm -qa of ". "builder]\n"; echo ""; if ($off + $cnt < count($list)) { $noff = $off + $cnt; if ($noff < 0) $noff = 0; echo "$forward\n"; } else { echo "$forward\n"; } echo "

"; ftp_quit($ftp_conn); $ftp_conn = 0; } function local_list_logs() { global $idx, $addr, $ok; global $root_directory, $big_url, $ns; global $off, $cnt; $list = directory_list(); if ($list == false) return; if ($ok == 1) { echo "

Listing of $addr[$idx]/OK " ."(fail)

"; } else { echo "

Listing of $addr[$idx]/FAIL " ."(ok)

"; } echo "
\n"; echo "". " ". "". ""; function cmp($f1, $f2) { global $root_directory; return filemtime("$root_directory$f2") - filemtime("$root_directory$f1"); } if ($ns != 1) { $ns = 0; usort($list, cmp); } else { sort($list); } $now = time(); for ($i = $off; $i < $cnt + $off; $i++) { if (!isset($list[$i])) continue; $h = bin2hex(mhash(MHASH_MD5, $list[$i])); $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]); $f = preg_replace("/\.(bz2|gz)$/", "", $f); $s = filesize("$root_directory$list[$i]"); $t = $now - filemtime("$root_directory$list[$i]"); $t /= 60; if ($t >= 60) { $t /= 60; if ($t >= 24) { $t /= 24; $t = round($t); if ($t > 1) { $t = $t . " days"; } else { $t = $t . " day"; } } else { $t = round($t); if ($t > 1) { $t = $t . " hours"; } else { $t = $t . " hour"; } } } else { $t = round($t); if ($t != 1) { $t = $t . " minutes"; } else { $t = $t . " minute"; } } $u = "$big_url&cnt=$cnt&off=$off&id=$h"; echo "\n"; } echo "
Log File ". "[sort]SizeAge ". "[sort]
". "$f ". "[text | ". "tail]". "". "$s$t
\n"; $back = "<<< Page back"; $forward = "Page forward >>>"; echo "

"; if ($off > 0) { $noff = $off - $cnt; if ($noff < 0) $noff = 0; echo "$back\n"; } else { echo "$back\n"; } echo ""; echo "[View rpm -qa of ". "builder]\n"; echo ""; if ($off + $cnt < count($list)) { $noff = $off + $cnt; if ($noff < 0) $noff = 0; echo "$forward\n"; } else { echo "$forward\n"; } echo "

"; } function file_name() { global $idx, $addr, $ok; global $ftp_conn, $big_url, $ns, $id; global $buildlogs_server; if (!isset($id)) return false; $list = open_ftp(); if ($list == false) return false; $f = false; for ($i = 0; $i < count($list); $i++) { $h = bin2hex(mhash(MHASH_MD5, $list[$i])); if ($h == $id) { $f = $list[$i]; } } if ($f == false) { mydie("cannot find specified file: $id"); ftp_quit($ftp_conn); return false; } return $f; } function local_file_name() { global $idx, $addr, $ok; global $root_directory, $big_url, $ns, $id; global $buildlogs_server; if (!isset($id)) return false; $list = directory_list(); if ($list == false) return false; $f = false; for ($i = 0; $i < count($list); $i++) { $h = bin2hex(mhash(MHASH_MD5, $list[$i])); if ($h == $id) { $f = $list[$i]; } } if ($f == false) { mydie("cannot find specified file: $id"); return false; } return $f; } function dump_log($tail) { global $idx, $addr, $ok, $url; global $ftp_conn, $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 "". ""; } 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")); $bu = "$big_url&cnt=$cnt&off=$off"; one_item("text/plain URL", href("$bu&id=$id&action=text", "View!")); if ($tail) { one_item("full text", href("$bu&&id=$id", "View!")); } one_item("rpm -qa of builder", href("$bu&action=qa", "View!")); one_item("Date", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f))); /* echo ""; */ echo "
$h:$t
Here:" . "". "http://" . getenv("SERVER_NAME") . getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id" . "

Content:

"; ftp_quit($ftp_conn); $ftp_conn = 0; # 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 2>&1"; } elseif (preg_match("/\.gz$/", $f)) { $filter = "| zcat 2>&1"; } else { $filter = ""; } $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter"; if ($tail) $cmd = "$cmd | tail -n 100"; $fd = popen($cmd, "r"); start_pre(); while (($s = fgets($fd, 1000)) != false) { $s = htmlspecialchars($s); echo $s; } end_pre(); pclose($fd); ?>
[Back to list of logs] [">View rpm -qa of builder]
$df"; 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")); $bu = "$big_url&cnt=$cnt&off=$off"; one_item("text/plain URL", href("$bu&id=$id&action=text", "View!")); if ($tail) { one_item("full text", href("$bu&&id=$id", "View!")); } one_item("rpm -qa of builder", href("$bu&action=qa", "View!")); one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory$f"))); /* echo ""; */ echo "
$h:$t
Here:" . "". "http://" . getenv("SERVER_NAME") . getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id" . "

Content:

"; # what can I say beside PHP suxx? how the fuck should I create # bidirectional pipe? gotta use wget if (preg_match("/\.bz2$/", $f)) { $cmd = "bzcat $root_directory$f"; } elseif (preg_match("/\.gz$/", $f)) { $cmd = "zcat $root_directory$f"; } else { $cmd = "cat $root_directory$f"; } if ($tail) $cmd = "$cmd | tail -n 100"; $fd = popen($cmd, "r"); start_pre(); while (($s = fgets($fd, 1000)) != false) { $s = htmlspecialchars($s); echo $s; } end_pre(); pclose($fd); ?>
[Back to list of logs] [">View rpm -qa of builder]
&1"; } elseif (preg_match("/\.gz$/", $f)) { $filter = "| zcat 2>&1"; } else { $filter = ""; } $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter"; $fd = popen($cmd, "r"); while (($s = fgets($fd, 1000)) != false) { echo $s; } pclose($fd); } function local_dump_text() { global $root_directory; global $buildlogs_server; header("Content-type: text/plain"); $f = local_file_name(); if ($f == false) return; echo "# src : ftp://$buildlogs_server$f\n"; echo "# date : " . date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n"; if (preg_match("/\.bz2$/", $f)) { $cmd = "bzcat"; } elseif (preg_match("/\.gz$/", $f)) { $cmd = "zcat"; } else { $cmd = "cat"; } $fd = popen("$cmd $root_directory$f", "r"); while (($s = fgets($fd, 1000)) != false) { echo $s; } pclose($fd); } function list_archs() { global $addr, $url, $idx; echo "\n"; echo "\n"; for ($i = 0; $i < count($addr); $i++) echo "". #"". "\n"; echo "
FailedOk
". "$addr[$i]". "[OK][qa]

\n"; echo "
main()
\n"; echo "
\n" . "(c) 2002 ". "PLD Team\n". "
\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" # 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 "
"; global $qa_addr; if ($qa_addr[$idx] != "") { echo "
"; echo ""; echo ""; echo "
"; echo ""; echo "
"; } } function get_qa() { global $idx, $qa_addr, $qa_base; if (!isset($idx) || !isset($qa_addr[$idx])) return false; $a = $qa_addr[$idx]; if ($qa_addr[$idx] == "") return false; else return fopen("$qa_base$qa_addr[$idx]", "r"); } function search_qa() { global $url, $idx, $qa_addr, $str; $f = get_qa(); echo "

Search results for '$str' in $qa_addr[$idx]

"; 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, $idx, $qa_addr; $a = $qa_addr[$idx]; $f = get_qa(); if ($plain) { header("Content-type: text/plain"); echo "# rpm -qa of $a\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 welcome() { ?>
 

Zdrastwuj!

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.13 2002/06/23 19:59:00 misiek Exp $

 
"; list_archs(); echo ""; flush(); if ($action == "qa") dump_qa(0); else if ($action == "sqa") search_qa(); else if (isset($id)) local_dump_log($action == "tail"); else if (isset($idx)) local_list_logs(); else welcome(); echo ""; trailer(); } } else { if ($action == "text") { dump_text(); } else if ($action == "qatxt") { dump_qa(1); } else { myheader(); echo "
"; list_archs(); echo ""; flush(); if ($action == "qa") dump_qa(0); else if (isset($id)) dump_log($action == "tail"); else if (isset($idx)) list_logs(); else welcome(); echo "
"; trailer(); } } ?>