2 $buildlogs_server = "buildlogs.pld.org.pl";
17 $qa_base = "http://ftp.pld.org.pl/.stat/builder";
20 "/kenny/rpmqa-nest-i386.txt",
21 "/kenny/rpmqa-nest-i586.txt",
22 "/kenny/rpmqa-nest-i686.txt",
24 "/ep/rpmqa-ra-i386.txt",
25 "/ep/rpmqa-ra-i586.txt",
26 "/ep/rpmqa-ra-i686.txt",
27 "/mifgate/rpmqa-ra-alpha.txt",
28 "/team/rpmqa-ra-sparc.txt",
31 $local = 1; /* $local=0 for FTP */
32 $root_directory = "/home/services/ftp/pub/logs";
33 /* It should be set */
39 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
40 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
41 <html xmlns="http://www.w3.org/1999/xhtml">
43 <title>PLD Build Logs</title>
44 <style TYPE="text/css"><!--
45 A { text-decoration: none; }
46 A:hover { text-decoration: underline; }
47 H1 { font-family: arial,helvetica,sans-serif;
50 H2 { font-family: arial,helvetica,sans-serif;
53 BODY,TD { font-family: arial,helvetica,sans-serif;
55 TH { font-family: arial,helvetica,sans-serif;
61 <!-- Diffrent color for visited link doesn't make much sense here...
62 this page is autogenerated and it might be misleading after some
63 build log changes. -->
64 <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
70 echo "<table cellpadding=10><tr><td bgcolor=\"#000000\">".
71 "<font color=\"#cccccc\"><pre>";
76 echo "</pre></font></td></tr></table>\n";
81 echo "</body></html>";
87 echo "Fatal error: $msg";
92 global $idx, $addr, $buildlogs_server, $ok;
93 global $ftp_conn, $big_url, $url, $ns;
96 if (!isset($idx) || !isset($addr[$idx]))
105 $a = "$addr[$idx]/OK";
107 $a = "$addr[$idx]/FAIL";
115 $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
117 $ftp = ftp_connect($buildlogs_server);
120 mydie("cannot connect to $buildlogs_server");
124 if (ftp_login($ftp, "anonymous",
125 "buildlogs-iface@pld.org.pl") == false) {
127 mydie("cannot ftp login to $buildlogs_server");
131 $list = ftp_nlist($ftp, $a);
132 if ($list == false) {
134 mydie("cannot list $a");
143 function directory_list()
145 global $idx, $addr, $buildlogs_server, $ok;
146 global $root_directory, $big_url, $url, $ns;
149 if (!isset($idx) || !isset($addr[$idx]))
158 $a = "$addr[$idx]/OK";
160 $a = "$addr[$idx]/FAIL";
168 $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
170 $dir = opendir("$root_directory$a");
172 while ($file = readdir($dir)) {
173 if (($file != ".") && ($file != "..")) {
174 $list[$i] = "$a/$file";
184 global $idx, $addr, $ok;
185 global $ftp_conn, $big_url, $ns;
194 echo "<h1>Listing of $addr[$idx]/OK "
195 ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
197 echo "<h1>Listing of $addr[$idx]/FAIL "
198 ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
201 echo "<div align=center><table border=0 cellspacing=1 ".
202 "cellpadding=3 bgcolor=#000000 width=90%>\n";
203 echo "<tr><th bgcolor=#CCCCFF align=left width=60%>Log File ".
204 "[<a href=\"$big_url&ns=1\">sort</a>]</th>".
205 "<th bgcolor=#CCCCFF align=right width=15%>Size</th> ".
206 "<th bgcolor=#CCCCFF align=left>Age ".
207 "[<a href=\"$big_url&ns=0\">sort</a>]</th>".
210 function cmp($f1, $f2) {
213 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
224 for ($i = $off; $i < $cnt + $off; $i++) {
225 if (!isset($list[$i]))
227 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
228 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
229 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
230 $s = ftp_size($ftp_conn, $list[$i]);
231 $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
254 $t = $t . " minutes";
259 $u = "$big_url&off=$off&id=$h";
260 echo "<tr><td bgcolor=#CCCCCC><a ".
263 "[<a href=\"$u&action=text\">text</a> | ".
264 "<a href=\"$u&action=tail\">tail</a>]".
265 "</td><td bgcolor=#CCCCCC align=right>".
266 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
268 echo "</table></div>\n";
270 $back = "<<< Page back";
271 $forward = "Page forward >>>";
273 echo "<p align=center><table width=90%><tr><td align=left width=25%>";
279 echo "<a href=\"$big_url&off=$noff\">$back</a>\n";
284 echo "</td><td width=50% align=center>";
286 if ($qa_addr[$idx] != "")
287 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
293 echo "</td><td align=right width=25%>";
294 if ($off + $cnt < count($list)) {
298 echo "<a href=\"$big_url&off=$noff\">$forward</a>\n";
302 echo "</td></tr></table></p>";
308 function local_list_logs()
310 global $idx, $addr, $ok;
311 global $root_directory, $big_url, $ns;
314 $list = directory_list();
320 echo "<h1>Listing of $addr[$idx]/OK "
321 ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
323 echo "<h1>Listing of $addr[$idx]/FAIL "
324 ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
327 echo "<div align=center><table border=0 cellspacing=1 ".
328 "cellpadding=3 bgcolor=#000000 width=90%>\n";
329 echo "<tr><th bgcolor=#CCCCFF align=left width=60%>Log File ".
330 "[<a href=\"$big_url&ns=1\">sort</a>]</th>".
331 "<th bgcolor=#CCCCFF align=right width=15%>Size</th> ".
332 "<th bgcolor=#CCCCFF align=left>Age ".
333 "[<a href=\"$big_url&ns=0\">sort</a>]</th>".
336 function cmp($f1, $f2) {
337 global $root_directory;
339 return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
350 for ($i = $off; $i < $cnt + $off; $i++) {
351 if (!isset($list[$i]))
353 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
354 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
355 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
356 $s = filesize("$root_directory$list[$i]");
357 $t = $now - filemtime("$root_directory$list[$i]");
380 $t = $t . " minutes";
385 $u = "$big_url&off=$off&id=$h";
386 echo "<tr><td bgcolor=#CCCCCC><a ".
389 "[<a href=\"$u&action=text\">text</a> | ".
390 "<a href=\"$u&action=tail\">tail</a>]".
391 "</td><td bgcolor=#CCCCCC align=right>".
392 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
394 echo "</table></div>\n";
396 $back = "<<< Page back";
397 $forward = "Page forward >>>";
399 echo "<p align=center><table width=90%><tr><td align=left width=25%>";
405 echo "<a href=\"$big_url&off=$noff\">$back</a>\n";
410 echo "</td><td width=50% align=center>";
412 if ($qa_addr[$idx] != "")
413 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
419 echo "</td><td align=right width=25%>";
420 if ($off + $cnt < count($list)) {
424 echo "<a href=\"$big_url&off=$noff\">$forward</a>\n";
428 echo "</td></tr></table></p>";
433 global $idx, $addr, $ok;
434 global $ftp_conn, $big_url, $ns, $id;
435 global $buildlogs_server;
446 for ($i = 0; $i < count($list); $i++) {
447 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
454 mydie("cannot find specified file: $id");
463 function local_file_name()
465 global $idx, $addr, $ok;
466 global $root_directory, $big_url, $ns, $id;
467 global $buildlogs_server;
472 $list = directory_list();
478 for ($i = 0; $i < count($list); $i++) {
479 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
486 mydie("cannot find specified file: $id");
494 function dump_log($tail)
496 global $idx, $addr, $ok, $url;
497 global $ftp_conn, $big_url, $ns, $id, $cnt, $off;
498 global $buildlogs_server;
505 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
506 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
510 echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
512 function one_item($h, $t) {
513 echo "<tr><td bgcolor=#ccccff>$h:</td>".
514 "<td bgcolor=#cccccc>$t</td></tr>";
517 function href($h, $c) {
518 return "<a href=\"$h\">$c</a>";
521 one_item("Status", ($ok == 1 ?
522 "<font color=green><b>OK</b></font>" :
523 "<font color=red><b>Failed</b></a>"));
524 one_item("Source URL",
525 href("ftp://$buildlogs_server$f",
526 "ftp://$buildlogs_server$f"));
528 $bu = "$big_url&off=$off";
530 one_item("text/plain URL",
531 href("$bu&id=$id&action=text",
534 one_item("full text",
539 if ($qa_addr[$idx] != "") {
540 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
542 one_item("rpm -qa of builder", "Not available");
544 one_item("Date", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)));
546 echo "<tr><td>Here:</td><td>" .
547 "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
548 "http://" . getenv("SERVER_NAME") .
549 getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
552 echo "</table><h2>Content:</h2>";
558 # what can I say beside PHP suxx? how the fuck should I create
559 # bidirectional pipe? gotta use wget
561 if (preg_match("/\.bz2$/", $f)) {
562 $filter = "| bzcat 2>&1";
563 } elseif (preg_match("/\.gz$/", $f)) {
564 $filter = "| zcat 2>&1";
569 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
571 $cmd = "$cmd | tail -n 100";
572 $fd = popen($cmd, "r");
574 while (($s = fgets($fd, 1000)) != false) {
575 $s = htmlspecialchars($s);
585 [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
588 [<a href="<?php echo "$bu&action=qa"
589 ?>">View rpm -qa of builder</a>]
598 function local_dump_log($tail)
600 global $idx, $addr, $ok, $url;
601 global $root_directory, $big_url, $ns, $id, $cnt, $off;
602 global $buildlogs_server;
604 $f = local_file_name();
609 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
610 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
614 echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
616 function one_item($h, $t) {
617 echo "<tr><td bgcolor=#ccccff>$h:</td>".
618 "<td bgcolor=#cccccc>$t</td></tr>";
621 function href($h, $c) {
622 return "<a href=\"$h\">$c</a>";
625 one_item("Status", ($ok == 1 ?
626 "<font color=green><b>OK</b></font>" :
627 "<font color=red><b>Failed</b></a>"));
628 one_item("Source URL",
629 href("ftp://$buildlogs_server$f",
630 "ftp://$buildlogs_server$f"));
632 $bu = "$big_url&off=$off";
634 one_item("text/plain URL",
635 href("$bu&id=$id&action=text",
638 one_item("full text",
643 if ($qa_addr[$idx] != "") {
644 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
646 one_item("rpm -qa of builder", "Not available");
648 one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory$f")));
650 echo "<tr><td>Here:</td><td>" .
651 "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
652 "http://" . getenv("SERVER_NAME") .
653 getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
656 echo "</table><h2>Content:</h2>";
658 # what can I say beside PHP suxx? how the fuck should I create
659 # bidirectional pipe? gotta use wget
661 if (preg_match("/\.bz2$/", $f)) {
662 $cmd = "bzcat $root_directory$f";
663 } elseif (preg_match("/\.gz$/", $f)) {
664 $cmd = "zcat $root_directory$f";
666 $cmd = "cat $root_directory$f";
670 $cmd = "$cmd | tail -n 100";
671 $fd = popen($cmd, "r");
673 while (($s = fgets($fd, 1000)) != false) {
674 $s = htmlspecialchars($s);
684 [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
687 [<a href="<?php echo "$bu&action=qa"
688 ?>">View rpm -qa of builder</a>]
699 global $buildlogs_server;
701 header("Content-type: text/plain");
708 echo "# src : ftp://$buildlogs_server$f\n";
710 date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)) . "\n";
715 if (preg_match("/\.bz2$/", $f)) {
716 $filter = "| bzcat 2>&1";
717 } elseif (preg_match("/\.gz$/", $f)) {
718 $filter = "| zcat 2>&1";
723 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
724 $fd = popen($cmd, "r");
725 while (($s = fgets($fd, 1000)) != false) {
732 function local_dump_text()
734 global $root_directory;
735 global $buildlogs_server;
737 header("Content-type: text/plain");
739 $f = local_file_name();
744 echo "# src : ftp://$buildlogs_server$f\n";
746 date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n";
748 if (preg_match("/\.bz2$/", $f)) {
750 } elseif (preg_match("/\.gz$/", $f)) {
756 $fd = popen("$cmd $root_directory$f", "r");
757 while (($s = fgets($fd, 1000)) != false) {
764 function list_archs()
766 global $addr, $url, $idx;
768 echo "<table width=100% border=0>\n";
769 echo "<tr><td bgcolor=#cccccc nowrap=1>Failed</td><td bgcolor=#cccccc>Ok</td></tr>\n";
770 for ($i = 0; $i < count($addr); $i++)
771 echo "<tr><td nowrap=1>".
772 "<a href=\"$url?idx=$i&ok=0\">$addr[$i]</a></td><td nowrap=1>".
773 "[<a href=\"$url?idx=$i&ok=1\">OK</a>]</td>".
774 #"<td>[<a href=\"$url?idx=$i&action=qa\">qa</a>]</td>".
776 echo "</table><hr />\n";
777 echo "<div align=\"center\"><a href=\"$url\">main()</a><hr />\n";
778 echo "<a href=\"http://www.pld.org.pl/\"><img src=powpld.png ".
779 "alt=\"Powered by PLD Linux\" border=0></a><br />\n" .
781 "<a href=\"mailto:feedback@pld.org.pl\">PLD Team</a>\n".
785 echo "<div align=center><small>";
786 $pow = array("vim", "php", "brain", "power", "electricity",
787 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
788 "voodoo magic", "Linux", "x-files", "X", "foobar",
789 "/dev/null", "/dev/zero", "/dev/drzewo",
790 "Leppe'", "matrix", "Neo", "PDP-11",
791 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
792 "foobarbaz", "ed", "Joe", "Unix conspiracy",
793 "overclock", "The Right Thing",
794 "The Bad Thing", "Star Treck", "NSA", "NASA",
795 "achelon", "VAX", "Real Programmer",
796 "Real Operating System", "Real Computer",
797 "computron", "bogon", "quantum bogodynamics",
798 "BOFH", "/dev/ill", "nasi tu byli",
799 "Paranoid Android", "Lunatic Corp"
800 # feel free to add sth if you change this file ;)
804 for ($i = 0; $i < $max; $i++) {
805 $x = rand(0, count($pow) - 1);
806 if ($pow[$x] == "") $i--;
807 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
811 echo "</small></div>";
815 if ($qa_addr[$idx] != "") {
816 echo "<form action=\"index.php\" method=\"post\">";
817 echo "<input type=hidden name=idx value=$idx />";
818 echo "<input type=hidden name=action value=sqa />";
819 echo "<input type=text size=14 name=str /><br/>";
820 echo "<input type=submit name=submit value=\"Search rpmqa!\" />";
828 global $idx, $qa_addr, $qa_base;
830 if (!isset($idx) || !isset($qa_addr[$idx]))
835 if ($qa_addr[$idx] == "")
838 return fopen("$qa_base$qa_addr[$idx]", "r");
843 global $url, $idx, $qa_addr, $str;
846 echo "<h1>Search results for '$str' in $qa_addr[$idx]</h1>";
851 echo "Sorry, cannot open.";
853 while (($s = fgets($f, 1000)) != false) {
854 if (stristr($s, $str))
862 function dump_qa($plain)
864 global $url, $idx, $qa_addr;
871 header("Content-type: text/plain");
872 echo "# rpm -qa of $a\n";
874 echo "<h1>rpm -qa of $a</h1>";
875 echo "<a href=\"$url?idx=$idx&action=qatxt\">text/plain "
881 echo "Sorry, cannot open.";
883 while (($s = fgets($f, 1000)) != false) {
895 <table border=0 width=100%><tr><td width=20%> </td><td>
897 <p>Welcome to PLD Build Logs WWW interface.</p><p>
898 Feel free to email bug reports, complaints and feature requests
899 <!-- ech... niech strace... -->
900 <a href="mailto:malekith /at/ pld-linux org">to us</a>. Positive opinions are also
901 <a href="mailto:malekith /at/ pld-linux org">welcome</a> ;)</p>
902 <p>Version: $Id: index.php,v 1.16 2002/09/20 14:55:34 ankry Exp $</p>
903 </td><td width=20%> </td></tr>
908 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
909 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
910 header("Cache-Control: no-cache, must-revalidate");
911 header("Pragma: no-cache");
915 if ($action == "text") {
917 } else if ($action == "qatxt") {
921 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
923 echo "</td><td valign=top>";
927 else if ($action == "sqa")
930 local_dump_log($action == "tail");
931 else if (isset($idx))
935 echo "</td></tr></table>";
941 if ($action == "text") {
943 } else if ($action == "qatxt") {
947 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
949 echo "</td><td valign=top>";
954 dump_log($action == "tail");
955 else if (isset($idx))
959 echo "</td></tr></table>";