". "
";
}

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 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) . " days"; } else { $t = round($t) . " hour"; } } else { $t = round($t) . " minutes"; } $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 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 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); ?> &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 list_archs() { global $addr, $url; echo "
[Back to list of logs] [">View rpm -qa of builder]
\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", "pinguin", "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", "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" # 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 "
"; } function dump_qa($plain) { global $url, $idx, $addr, $rpmqa_path; if (!isset($idx) || !isset($addr[$idx])) return false; $a = $addr[$idx]; $a = preg_replace("|^/|", "", $a); $a = preg_replace("|/|", "-", $a); echo ; 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(); } $f = fopen("$rpmqa_path/$a.txt", "r"); 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.1 2002/01/14 17:16:48 malekith Exp $

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