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",
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";
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";
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]);
237 $t = round($t) . " days";
239 $t = round($t) . " hour";
242 $t = round($t) . " minutes";
244 $u = "$big_url&cnt=$cnt&off=$off&id=$h";
245 echo "<tr><td bgcolor=#CCCCCC><a ".
248 "[<a href=\"$u&action=text\">text</a> | ".
249 "<a href=\"$u&action=tail\">tail</a>]".
250 "</td><td bgcolor=#CCCCCC align=right>".
251 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
253 echo "</table></div>\n";
255 $back = "<<< Page back";
256 $forward = "Page forward >>>";
258 echo "<p align=center><table width=90%><tr><td align=left width=25%>";
264 echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$back</a>\n";
269 echo "</td><td width=50% align=center>";
271 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
274 echo "</td><td align=right width=25%>";
275 if ($off + $cnt < count($list)) {
279 echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$forward</a>\n";
283 echo "</td></tr></table></p>";
289 function local_list_logs()
291 global $idx, $addr, $ok;
292 global $root_directory, $big_url, $ns;
295 $list = directory_list();
301 echo "<h1>Listing of $addr[$idx]/OK "
302 ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
304 echo "<h1>Listing of $addr[$idx]/FAIL "
305 ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
308 echo "<div align=center><table border=0 cellspacing=1 ".
309 "cellpadding=3 bgcolor=#000000 width=90%>\n";
310 echo "<tr><th bgcolor=#CCCCFF align=left width=60%>Log File ".
311 "[<a href=\"$big_url&ns=1\">sort</a>]</th>".
312 "<th bgcolor=#CCCCFF align=right width=15%>Size</th> ".
313 "<th bgcolor=#CCCCFF align=left>Age ".
314 "[<a href=\"$big_url&ns=0\">sort</a>]</th>".
317 function cmp($f1, $f2) {
318 global $root_directory;
320 return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
331 for ($i = $off; $i < $cnt + $off; $i++) {
332 if (!isset($list[$i]))
334 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
335 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
336 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
337 $s = filesize("$root_directory$list[$i]");
338 $t = $now - filemtime("$root_directory$list[$i]");
344 $t = round($t) . " days";
346 $t = round($t) . " hour";
349 $t = round($t) . " minutes";
351 $u = "$big_url&cnt=$cnt&off=$off&id=$h";
352 echo "<tr><td bgcolor=#CCCCCC><a ".
355 "[<a href=\"$u&action=text\">text</a> | ".
356 "<a href=\"$u&action=tail\">tail</a>]".
357 "</td><td bgcolor=#CCCCCC align=right>".
358 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
360 echo "</table></div>\n";
362 $back = "<<< Page back";
363 $forward = "Page forward >>>";
365 echo "<p align=center><table width=90%><tr><td align=left width=25%>";
371 echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$back</a>\n";
376 echo "</td><td width=50% align=center>";
378 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
381 echo "</td><td align=right width=25%>";
382 if ($off + $cnt < count($list)) {
386 echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$forward</a>\n";
390 echo "</td></tr></table></p>";
395 global $idx, $addr, $ok;
396 global $ftp_conn, $big_url, $ns, $id;
397 global $buildlogs_server;
408 for ($i = 0; $i < count($list); $i++) {
409 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
416 mydie("cannot find specified file: $id");
425 function local_file_name()
427 global $idx, $addr, $ok;
428 global $root_directory, $big_url, $ns, $id;
429 global $buildlogs_server;
434 $list = directory_list();
440 for ($i = 0; $i < count($list); $i++) {
441 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
448 mydie("cannot find specified file: $id");
456 function dump_log($tail)
458 global $idx, $addr, $ok, $url;
459 global $ftp_conn, $big_url, $ns, $id, $cnt, $off;
460 global $buildlogs_server;
467 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
468 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
472 echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
474 function one_item($h, $t) {
475 echo "<tr><td bgcolor=#ccccff>$h:</td>".
476 "<td bgcolor=#cccccc>$t</td></tr>";
479 function href($h, $c) {
480 return "<a href=\"$h\">$c</a>";
483 one_item("Status", ($ok == 1 ?
484 "<font color=green><b>OK</b></font>" :
485 "<font color=red><b>Failed</b></a>"));
486 one_item("Source URL",
487 href("ftp://$buildlogs_server$f",
488 "ftp://$buildlogs_server$f"));
490 $bu = "$big_url&cnt=$cnt&off=$off";
492 one_item("text/plain URL",
493 href("$bu&id=$id&action=text",
496 one_item("full text",
501 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
502 one_item("Date", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)));
504 echo "<tr><td>Here:</td><td>" .
505 "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
506 "http://" . getenv("SERVER_NAME") .
507 getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
510 echo "</table><h2>Content:</h2>";
516 # what can I say beside PHP suxx? how the fuck should I create
517 # bidirectional pipe? gotta use wget
519 if (preg_match("/\.bz2$/", $f)) {
520 $filter = "| bzcat 2>&1";
521 } elseif (preg_match("/\.gz$/", $f)) {
522 $filter = "| zcat 2>&1";
527 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
529 $cmd = "$cmd | tail -n 100";
530 $fd = popen($cmd, "r");
532 while (($s = fgets($fd, 1000)) != false) {
533 $s = htmlspecialchars($s);
543 [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
546 [<a href="<?php echo "$bu&action=qa"
547 ?>">View rpm -qa of builder</a>]
556 function local_dump_log($tail)
558 global $idx, $addr, $ok, $url;
559 global $root_directory, $big_url, $ns, $id, $cnt, $off;
560 global $buildlogs_server;
562 $f = local_file_name();
567 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
568 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
572 echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
574 function one_item($h, $t) {
575 echo "<tr><td bgcolor=#ccccff>$h:</td>".
576 "<td bgcolor=#cccccc>$t</td></tr>";
579 function href($h, $c) {
580 return "<a href=\"$h\">$c</a>";
583 one_item("Status", ($ok == 1 ?
584 "<font color=green><b>OK</b></font>" :
585 "<font color=red><b>Failed</b></a>"));
586 one_item("Source URL",
587 href("ftp://$buildlogs_server$f",
588 "ftp://$buildlogs_server$f"));
590 $bu = "$big_url&cnt=$cnt&off=$off";
592 one_item("text/plain URL",
593 href("$bu&id=$id&action=text",
596 one_item("full text",
601 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
602 one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory$f")));
604 echo "<tr><td>Here:</td><td>" .
605 "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
606 "http://" . getenv("SERVER_NAME") .
607 getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
610 echo "</table><h2>Content:</h2>";
612 # what can I say beside PHP suxx? how the fuck should I create
613 # bidirectional pipe? gotta use wget
615 if (preg_match("/\.bz2$/", $f)) {
616 $cmd = "bzcat $root_directory$f";
617 } elseif (preg_match("/\.gz$/", $f)) {
618 $cmd = "zcat $root_directory$f";
620 $cmd = "cat $root_directory$f";
624 $cmd = "$cmd | tail -n 100";
625 $fd = popen($cmd, "r");
627 while (($s = fgets($fd, 1000)) != false) {
628 $s = htmlspecialchars($s);
638 [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
641 [<a href="<?php echo "$bu&action=qa"
642 ?>">View rpm -qa of builder</a>]
653 global $buildlogs_server;
655 header("Content-type: text/plain");
662 echo "# src : ftp://$buildlogs_server$f\n";
664 date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)) . "\n";
669 if (preg_match("/\.bz2$/", $f)) {
670 $filter = "| bzcat 2>&1";
671 } elseif (preg_match("/\.gz$/", $f)) {
672 $filter = "| zcat 2>&1";
677 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
678 $fd = popen($cmd, "r");
679 while (($s = fgets($fd, 1000)) != false) {
686 function local_dump_text()
688 global $root_directory;
689 global $buildlogs_server;
691 header("Content-type: text/plain");
693 $f = local_file_name();
698 echo "# src : ftp://$buildlogs_server$f\n";
700 date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n";
702 if (preg_match("/\.bz2$/", $f)) {
704 } elseif (preg_match("/\.gz$/", $f)) {
710 $fd = popen("$cmd $root_directory$f", "r");
711 while (($s = fgets($fd, 1000)) != false) {
718 function list_archs()
720 global $addr, $url, $idx;
722 echo "<table width=100% border=0>\n";
723 echo "<tr><td bgcolor=#cccccc nowrap=1>Failed</td><td bgcolor=#cccccc>Ok</td></tr>\n";
724 for ($i = 0; $i < count($addr); $i++)
725 echo "<tr><td nowrap=1>".
726 "<a href=\"$url?idx=$i&ok=0\">$addr[$i]</a></td><td nowrap=1>".
727 "[<a href=\"$url?idx=$i&ok=1\">OK</a>]</td>".
728 #"<td>[<a href=\"$url?idx=$i&action=qa\">qa</a>]</td>".
730 echo "</table><hr />\n";
731 echo "<div align=\"center\"><a href=\"$url\">main()</a><hr />\n";
732 echo "<a href=\"http://www.pld.org.pl/\"><img src=powpld.png ".
733 "alt=\"Powered by PLD Linux\" border=0></a><br />\n" .
735 "<a href=\"mailto:feedback@pld.org.pl\">PLD Team</a>\n".
739 echo "<div align=center><small>";
740 $pow = array("vim", "php", "brain", "power", "electricity",
741 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
742 "voodoo magic", "Linux", "x-files", "X", "foobar",
743 "/dev/null", "/dev/zero", "/dev/drzewo",
744 "Leppe'", "matrix", "Neo", "PDP-11",
745 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
746 "foobarbaz", "ed", "Joe", "Unix conspiracy",
747 "overclock", "The Right Thing",
748 "The Bad Thing", "Star Treck", "NSA", "NASA",
749 "achelon", "VAX", "Real Programmer",
750 "Real Operating System", "Real Computer",
751 "computron", "bogon", "quantum bogodynamics",
752 "BOFH", "/dev/ill", "nasi tu byli",
753 "Paranoid Android", "Lunatic Corp"
754 # feel free to add sth if you change this file ;)
758 for ($i = 0; $i < $max; $i++) {
759 $x = rand(0, count($pow) - 1);
760 if ($pow[$x] == "") $i--;
761 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
765 echo "</small></div>";
769 if ($qa_addr[$idx] != "") {
770 echo "<form action=\"index.php\" method=\"post\">";
771 echo "<input type=hidden name=idx value=$idx />";
772 echo "<input type=hidden name=action value=sqa />";
773 echo "<input type=text size=14 name=str /><br/>";
774 echo "<input type=submit name=submit value=\"Search rpmqa!\" />";
782 global $idx, $qa_addr, $qa_base;
784 if (!isset($idx) || !isset($qa_addr[$idx]))
789 if ($qa_addr[$idx] == "")
792 return fopen("$qa_base$qa_addr[$idx]", "r");
797 global $url, $idx, $qa_addr, $str;
800 echo "<h1>Search results for '$str' in $qa_addr[$idx]</h1>";
805 echo "Sorry, cannot open.";
807 while (($s = fgets($f, 1000)) != false) {
808 if (stristr($s, $str))
816 function dump_qa($plain)
818 global $url, $idx, $qa_addr;
825 header("Content-type: text/plain");
826 echo "# rpm -qa of $a\n";
828 echo "<h1>rpm -qa of $a</h1>";
829 echo "<a href=\"$url?idx=$idx&action=qatxt\">text/plain "
835 echo "Sorry, cannot open.";
837 while (($s = fgets($f, 1000)) != false) {
849 <table border=0 width=100%><tr><td width=20%> </td><td>
851 <p>Welcome to PLD Build Logs WWW interface.</p><p>
852 Feel free to email bug reports, complaints and feature requests
853 <!-- ech... niech strace... -->
854 <a href="mailto:malekith /at/ pld-linux org">to us</a>. Positive opinions are also
855 <a href="mailto:malekith /at/ pld-linux org">welcome</a> ;)</p>
856 <p>Version: $Id: index.php,v 1.12 2002/06/21 13:13:35 ankry Exp $</p>
857 </td><td width=20%> </td></tr>
862 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
863 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
864 header("Cache-Control: no-cache, must-revalidate");
865 header("Pragma: no-cache");
869 if ($action == "text") {
871 } else if ($action == "qatxt") {
875 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
877 echo "</td><td valign=top>";
881 else if ($action == "sqa")
884 local_dump_log($action == "tail");
885 else if (isset($idx))
889 echo "</td></tr></table>";
895 if ($action == "text") {
897 } else if ($action == "qatxt") {
901 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
903 echo "</td><td valign=top>";
908 dump_log($action == "tail");
909 else if (isset($idx))
913 echo "</td></tr></table>";