]> git.pld-linux.org Git - projects/buildlogs.git/blob - obsolete/buildlogs/index.php
added missing "{"s
[projects/buildlogs.git] / obsolete / buildlogs / index.php
1 <?php
2 $buildlogs_server = "buildlogs.pld.org.pl";
3 $url = "index.php";
4 $addr = array(
5         "/nest/athlon",
6         "/nest/i386",
7         "/nest/i586",
8         "/nest/i686",
9         "/nest/ppc",
10         "/ra/i386",
11         "/ra/i586",
12         "/ra/i686",
13         "/ra/alpha",
14         "/ra/sparc",
15         "/ra/ppc"
16 );
17 $qa_base = "http://ftp.pld.org.pl/.stat/builder";
18 $qa_addr = array(
19         "",
20         "/kenny/rpmqa-nest-i386.txt",
21         "/kenny/rpmqa-nest-i586.txt",
22         "/kenny/rpmqa-nest-i686.txt",
23         "",
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",
29         ""
30 );
31 $local = 1; /* $local=0 for FTP */ 
32 $root_directory = "/home/services/ftp/pub/logs";
33 /* It should be set */
34
35
36 function myheader()
37 {
38 ?>
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">
42  <head>
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; 
48      font-size: 20pt; 
49      font-weight: bold;}
50 H2 { font-family: arial,helvetica,sans-serif; 
51      font-size: 18pt; 
52      font-weight: bold;}
53 BODY,TD { font-family: arial,helvetica,sans-serif; 
54           font-size: 13pt; }
55 TH { font-family: arial,helvetica,sans-serif; 
56      font-size: 13pt; 
57      font-weight: bold; }
58 //-->
59 </style>
60  </head>
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">
65 <?php
66 }
67
68 function start_pre()
69 {
70         echo "<table cellpadding=10><tr><td bgcolor=\"#000000\">".
71                 "<font color=\"#cccccc\"><pre>";
72 }
73
74 function end_pre()
75 {
76         echo "</pre></font></td></tr></table>\n";
77 }
78
79 function trailer()
80 {
81         echo "</body></html>";
82 }
83
84
85 function mydie($msg)
86 {
87         echo "Fatal error: $msg";
88 }
89
90 function open_ftp()
91 {
92         global $idx, $addr, $buildlogs_server, $ok;
93         global $ftp_conn, $big_url, $url, $ns;
94         global $off, $cnt;
95         
96         if (!isset($idx) || !isset($addr[$idx]))
97                 return false;
98         
99         if ($ok != 1)
100                 $ok = 0;
101         if ($ns != 1)
102                 $ns = 0;
103                 
104         if ($ok == 1) {
105                 $a = "$addr[$idx]/OK";
106         } else {
107                 $a = "$addr[$idx]/FAIL";
108         }
109         
110         if (!isset($off))
111                 $off = 0;
112         if (!isset($cnt))
113                 $cnt = 16;
114                 
115         $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
116         
117         $ftp = ftp_connect($buildlogs_server);
118         
119         if ($ftp == false) {
120                 mydie("cannot connect to $buildlogs_server");
121                 return false;
122         }
123
124         if (ftp_login($ftp, "anonymous", 
125                       "buildlogs-iface@pld.org.pl") == false) {
126                 ftp_quit($ftp);
127                 mydie("cannot ftp login to $buildlogs_server");
128                 return false;
129         }
130
131         $list = ftp_nlist($ftp, $a);
132         if ($list == false) {
133                 ftp_quit($ftp);
134                 mydie("cannot list $a");
135                 return false;
136         }
137
138         $ftp_conn = $ftp;
139         
140         return $list;
141 }
142
143 function directory_list()
144 {
145         global $idx, $addr, $buildlogs_server, $ok;
146         global $root_directory, $big_url, $url, $ns;
147         global $off, $cnt;
148         
149         if (!isset($idx) || !isset($addr[$idx]))
150                 return false;
151         
152         if ($ok != 1)
153                 $ok = 0;
154         if ($ns != 1)
155                 $ns = 0;
156                 
157         if ($ok == 1) {
158                 $a = "$addr[$idx]/OK";
159         } else {
160                 $a = "$addr[$idx]/FAIL";
161         }
162         
163         if (!isset($off))
164                 $off = 0;
165         if (!isset($cnt))
166                 $cnt = 16;
167                 
168         $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
169         
170         $dir = opendir("$root_directory$a");
171         $i = 0;
172         while ($file = readdir($dir)) {
173                 if (($file != ".") && ($file != "..")) {
174                         $list[$i] = "$a/$file";
175                         $i++;
176                 }
177         }
178         closedir($dir);
179         return $list;
180 }
181
182 function list_logs()
183 {
184         global $idx, $addr, $ok;
185         global $ftp_conn, $big_url, $ns;
186         global $off, $cnt;
187
188         $list = open_ftp();
189
190         if ($list == false)
191                 return;
192         
193         if ($ok == 1) {
194                 echo "<h1>Listing of $addr[$idx]/OK "
195                         ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
196         } else {
197                 echo "<h1>Listing of $addr[$idx]/FAIL "
198                         ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
199         }
200         
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>".
208                  "</th></tr>";
209         
210         function cmp($f1, $f2) {
211                 global $ftp_conn;
212
213                 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
214         }
215
216         if ($ns != 1) {
217                 $ns = 0;
218                 usort($list, cmp);
219         } else {
220                 sort($list);
221         }
222         
223         $now = time();
224         for ($i = $off; $i < $cnt + $off; $i++) {
225                 if (!isset($list[$i]))
226                         continue;
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]);
232                 $t /= 60;
233                 if ($t >= 60) {
234                         $t /= 60;
235                         if ($t >= 24) {
236                                 $t /= 24;
237                                 $t = round($t);
238                                 if ($t > 1) {
239                                         $t = $t . " days";
240                                 } else {
241                                         $t = $t . " day";
242                                 }
243                         } else {
244                                 $t = round($t);
245                                 if ($t > 1) {
246                                         $t = $t . " hours";
247                                 } else {
248                                         $t = $t . " hour";
249                                 }
250                         }
251                 } else {
252                         $t = round($t);
253                         if ($t != 1) {
254                                 $t = $t . " minutes";
255                         } else {
256                                 $t = $t . " minute";
257                         }
258                 }
259                 $u = "$big_url&off=$off&id=$h";
260                 echo "<tr><td bgcolor=#CCCCCC><a ".
261                         "href=\"$u\">".
262                      "$f</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";
267         }
268         echo "</table></div>\n";
269
270         $back = "&lt;&lt;&lt; Page back";
271         $forward = "Page forward &gt;&gt;&gt;";
272
273         echo "<p align=center><table width=90%><tr><td align=left width=25%>";
274
275         if ($off > 0) {
276                 $noff = $off - $cnt;
277                 if ($noff < 0)  
278                         $noff = 0;
279                 echo "<a href=\"$big_url&off=$noff\">$back</a>\n";
280         } else {
281                 echo "$back\n";
282         }
283
284         echo "</td><td width=50% align=center>";
285
286         if ($qa_addr[$idx] != "")
287                 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
288                         "builder</a>]\n";
289         } else {
290                 echo "&nbsp;";
291         }
292
293         echo "</td><td align=right width=25%>";
294         if ($off + $cnt < count($list)) {
295                 $noff = $off + $cnt;
296                 if ($noff < 0)  
297                         $noff = 0;
298                 echo "<a href=\"$big_url&off=$noff\">$forward</a>\n";
299         } else {
300                 echo "$forward\n";
301         }
302         echo "</td></tr></table></p>";
303
304         ftp_quit($ftp_conn);
305         $ftp_conn = 0;
306 }
307
308 function local_list_logs()
309 {
310         global $idx, $addr, $ok;
311         global $root_directory, $big_url, $ns;
312         global $off, $cnt;
313
314         $list = directory_list();
315
316         if ($list == false)
317                 return;
318         
319         if ($ok == 1) {
320                 echo "<h1>Listing of $addr[$idx]/OK "
321                         ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
322         } else {
323                 echo "<h1>Listing of $addr[$idx]/FAIL "
324                         ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
325         }
326         
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>".
334                  "</th></tr>";
335         
336         function cmp($f1, $f2) {
337                 global $root_directory;
338                 
339         return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
340         }
341
342         if ($ns != 1) {
343                 $ns = 0;
344                 usort($list, cmp);
345         } else {
346                 sort($list);
347         }
348         
349         $now = time();
350         for ($i = $off; $i < $cnt + $off; $i++) {
351                 if (!isset($list[$i]))
352                         continue;
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]");
358                 $t /= 60;
359                 if ($t >= 60) {
360                         $t /= 60;
361                         if ($t >= 24) {
362                                 $t /= 24;
363                                 $t = round($t);
364                                 if ($t > 1) {
365                                         $t = $t . " days";
366                                 } else {
367                                         $t = $t . " day";
368                                 }
369                         } else {
370                                 $t = round($t);
371                                 if ($t > 1) {
372                                         $t = $t . " hours";
373                                 } else {
374                                         $t = $t . " hour";
375                                 }
376                         }
377                 } else {
378                         $t = round($t);
379                         if ($t != 1) {
380                                 $t = $t . " minutes";
381                         } else {
382                                 $t = $t . " minute";
383                         }
384                 }
385                 $u = "$big_url&off=$off&id=$h";
386                 echo "<tr><td bgcolor=#CCCCCC><a ".
387                         "href=\"$u\">".
388                      "$f</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";
393         }
394         echo "</table></div>\n";
395
396         $back = "&lt;&lt;&lt; Page back";
397         $forward = "Page forward &gt;&gt;&gt;";
398
399         echo "<p align=center><table width=90%><tr><td align=left width=25%>";
400
401         if ($off > 0) {
402                 $noff = $off - $cnt;
403                 if ($noff < 0)  
404                         $noff = 0;
405                 echo "<a href=\"$big_url&off=$noff\">$back</a>\n";
406         } else {
407                 echo "$back\n";
408         }
409
410         echo "</td><td width=50% align=center>";
411
412         if ($qa_addr[$idx] != "")
413                 echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
414                         "builder</a>]\n";
415         } else {
416                 echo "&nbsp;";
417         }
418  
419         echo "</td><td align=right width=25%>";
420         if ($off + $cnt < count($list)) {
421                 $noff = $off + $cnt;
422                 if ($noff < 0)  
423                         $noff = 0;
424                 echo "<a href=\"$big_url&off=$noff\">$forward</a>\n";
425         } else {
426                 echo "$forward\n";
427         }
428         echo "</td></tr></table></p>";
429 }
430
431 function file_name()
432 {
433         global $idx, $addr, $ok;
434         global $ftp_conn, $big_url, $ns, $id;
435         global $buildlogs_server;
436
437         if (!isset($id))
438                 return false;
439                 
440         $list = open_ftp();
441
442         if ($list == false)
443                 return false;
444
445         $f = false;
446         for ($i = 0; $i < count($list); $i++) {
447                 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
448                 if ($h == $id) {
449                         $f = $list[$i];
450                 }
451         }
452
453         if ($f == false) {
454                 mydie("cannot find specified file: $id");
455                 ftp_quit($ftp_conn);
456                 return false;
457         }
458
459         return $f;
460 }
461
462
463 function local_file_name()
464 {
465         global $idx, $addr, $ok;
466         global $root_directory, $big_url, $ns, $id;
467         global $buildlogs_server;
468
469         if (!isset($id))
470                 return false;
471                 
472         $list = directory_list();
473
474         if ($list == false)
475                 return false;
476
477         $f = false;
478         for ($i = 0; $i < count($list); $i++) {
479                 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
480                 if ($h == $id) {
481                         $f = $list[$i];
482                 }
483         }
484
485         if ($f == false) {
486                 mydie("cannot find specified file: $id");
487                 return false;
488         }
489
490         return $f;
491 }
492
493
494 function dump_log($tail)
495 {
496         global $idx, $addr, $ok, $url;
497         global $ftp_conn, $big_url, $ns, $id, $cnt, $off;
498         global $buildlogs_server;
499
500         $f = file_name();
501
502         if ($f == false)
503                 return;
504
505         $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
506         $df = preg_replace("/\.(bz2|gz)$/", "", $df);
507         
508         echo "<h1>$df</h1>";
509
510         echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
511
512         function one_item($h, $t) {
513                 echo "<tr><td bgcolor=#ccccff>$h:</td>".
514                          "<td bgcolor=#cccccc>$t</td></tr>";
515         }
516
517         function href($h, $c) {
518                 return "<a href=\"$h\">$c</a>";
519         }
520         
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"));
527
528         $bu = "$big_url&off=$off";
529         
530         one_item("text/plain URL", 
531                  href("$bu&id=$id&action=text",
532                       "View!"));
533         if ($tail) {
534                 one_item("full text", 
535                          href("$bu&&id=$id",
536                               "View!"));
537         }
538
539         if ($qa_addr[$idx] != "") {
540                 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
541         } else {
542                 one_item("rpm -qa of builder", "Not available");
543         }
544         one_item("Date", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)));
545         /*
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>" .
550              "</td></tr>"; */
551
552         echo "</table><h2>Content:</h2>";
553         
554         ftp_quit($ftp_conn);
555         $ftp_conn = 0;
556         
557         
558         # what can I say beside PHP suxx? how the fuck should I create
559         # bidirectional pipe? gotta use wget
560         
561         if (preg_match("/\.bz2$/", $f)) {
562                 $filter = "| bzcat 2>&1";
563         } elseif (preg_match("/\.gz$/", $f)) {
564                 $filter = "| zcat 2>&1";
565         } else {
566                 $filter = "";
567         }
568
569         $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
570         if ($tail)
571                 $cmd = "$cmd | tail -n 100";
572         $fd = popen($cmd, "r");
573         start_pre();
574         while (($s = fgets($fd, 1000)) != false) {
575                 $s = htmlspecialchars($s);
576                 echo $s;
577         }
578         end_pre();
579         pclose($fd);
580
581 ?>
582         <table width=100%>
583          <tr>
584           <td align=left>
585            [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
586           </td>
587           <td align=right>
588            [<a href="<?php echo "$bu&action=qa" 
589                 ?>">View rpm -qa of builder</a>]
590           </td>
591          </tr>
592         </table>
593 <?php
594
595 }
596
597
598 function local_dump_log($tail)
599 {
600         global $idx, $addr, $ok, $url;
601         global $root_directory, $big_url, $ns, $id, $cnt, $off;
602         global $buildlogs_server;
603
604         $f = local_file_name();
605
606         if ($f == false)
607                 return;
608
609         $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
610         $df = preg_replace("/\.(bz2|gz)$/", "", $df);
611         
612         echo "<h1>$df</h1>";
613
614         echo "<table border=0 cellpadding=3 cellspacing=1 bgcolor=#000000>";
615
616         function one_item($h, $t) {
617                 echo "<tr><td bgcolor=#ccccff>$h:</td>".
618                          "<td bgcolor=#cccccc>$t</td></tr>";
619         }
620
621         function href($h, $c) {
622                 return "<a href=\"$h\">$c</a>";
623         }
624         
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"));
631
632         $bu = "$big_url&off=$off";
633         
634         one_item("text/plain URL", 
635                  href("$bu&id=$id&action=text",
636                       "View!"));
637         if ($tail) {
638                 one_item("full text", 
639                          href("$bu&&id=$id",
640                               "View!"));
641         }
642         
643         if ($qa_addr[$idx] != "") {
644                 one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
645         } else {
646                 one_item("rpm -qa of builder", "Not available");
647         }
648         one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory$f")));
649         /*
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>" .
654              "</td></tr>"; */
655
656         echo "</table><h2>Content:</h2>";
657         
658         # what can I say beside PHP suxx? how the fuck should I create
659         # bidirectional pipe? gotta use wget
660         
661         if (preg_match("/\.bz2$/", $f)) {
662                 $cmd = "bzcat $root_directory$f";
663         } elseif (preg_match("/\.gz$/", $f)) {
664                 $cmd = "zcat $root_directory$f";
665         } else {
666                 $cmd = "cat $root_directory$f";
667         }
668
669         if ($tail)
670                 $cmd = "$cmd | tail -n 100";
671         $fd = popen($cmd, "r");
672         start_pre();
673         while (($s = fgets($fd, 1000)) != false) {
674                 $s = htmlspecialchars($s);
675                 echo $s;
676         }
677         end_pre();
678         pclose($fd);
679
680 ?>
681         <table width=100%>
682          <tr>
683           <td align=left>
684            [<a href="<?php echo $bu; ?>">Back to list of logs</a>]
685           </td>
686           <td align=right>
687            [<a href="<?php echo "$bu&action=qa" 
688                 ?>">View rpm -qa of builder</a>]
689           </td>
690          </tr>
691         </table>
692 <?php
693
694 }
695
696 function dump_text()
697 {
698         global $ftp_conn;
699         global $buildlogs_server;
700         
701         header("Content-type: text/plain");
702
703         $f = file_name();
704
705         if ($f == false)
706                 return;
707
708         echo "# src  : ftp://$buildlogs_server$f\n";
709         echo "# date : " .  
710                 date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)) . "\n";
711
712         ftp_quit($ftp_conn);
713         $ftp_conn = 0;
714         
715         if (preg_match("/\.bz2$/", $f)) {
716                 $filter = "| bzcat 2>&1";
717         } elseif (preg_match("/\.gz$/", $f)) {
718                 $filter = "| zcat 2>&1";
719         } else {
720                 $filter = "";
721         }
722
723         $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 $filter";
724         $fd = popen($cmd, "r");
725         while (($s = fgets($fd, 1000)) != false) {
726                 echo $s;
727         }
728         pclose($fd);
729 }
730
731
732 function local_dump_text()
733 {
734         global $root_directory;
735         global $buildlogs_server;
736         
737         header("Content-type: text/plain");
738
739         $f = local_file_name();
740
741         if ($f == false)
742                 return;
743
744         echo "# src  : ftp://$buildlogs_server$f\n";
745         echo "# date : " .  
746                 date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n";
747
748         if (preg_match("/\.bz2$/", $f)) {
749                 $cmd = "bzcat";
750         } elseif (preg_match("/\.gz$/", $f)) {
751                 $cmd = "zcat";
752         } else {
753                 $cmd = "cat";
754         }
755
756         $fd = popen("$cmd $root_directory$f", "r");
757         while (($s = fgets($fd, 1000)) != false) {
758                 echo $s;
759         }
760         pclose($fd);
761 }
762
763
764 function list_archs()
765 {
766         global $addr, $url, $idx;
767
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>".
775                      "</tr>\n";
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" .
780              "<small>(c) 2002 ".
781              "<a href=\"mailto:feedback@pld.org.pl\">PLD&nbsp;Team</a>\n".
782              "</small></div>\n";
783         
784         # smile ;)
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 ;)
801                      );
802         echo "Powered by ";
803         $max = 1;
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 ? "." : ", ");
808                 $pow[$x] = "";
809         }
810                 
811         echo "</small></div>";
812         
813         global $qa_addr;
814
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!\" />";
821         echo "</form>";
822         }
823
824 }
825
826 function get_qa()
827 {
828         global $idx, $qa_addr, $qa_base;
829         
830         if (!isset($idx) || !isset($qa_addr[$idx]))
831                 return false;
832
833         $a = $qa_addr[$idx];
834         
835         if ($qa_addr[$idx] == "")
836                 return false;
837         else
838                 return fopen("$qa_base$qa_addr[$idx]", "r");
839 }
840
841 function search_qa()
842 {
843         global $url, $idx, $qa_addr, $str;
844
845         $f = get_qa();
846         echo "<h1>Search results for '$str' in $qa_addr[$idx]</h1>";
847
848         start_pre();
849
850         if ($f == 0) {
851                 echo "Sorry, cannot open.";
852         } else {
853                 while (($s = fgets($f, 1000)) != false) {
854                         if (stristr($s, $str))
855                                 echo $s;
856                 }
857                 echo "/* EOF */";
858         }
859         end_pre();
860 }
861
862 function dump_qa($plain)
863 {
864         global $url, $idx, $qa_addr;
865         
866         $a = $qa_addr[$idx];
867
868         $f = get_qa();
869         
870         if ($plain) {
871                 header("Content-type: text/plain"); 
872                 echo "# rpm -qa of $a\n";
873         } else {
874                 echo "<h1>rpm -qa of $a</h1>";
875                 echo "<a href=\"$url?idx=$idx&action=qatxt\">text/plain "
876                         ."version</a>";
877                 start_pre();
878         }
879
880         if ($f == 0) {
881                 echo "Sorry, cannot open.";
882         } else {
883                 while (($s = fgets($f, 1000)) != false) {
884                         echo $s;
885                 }
886         }
887         
888         if (!$plain)
889                 end_pre();
890 }
891
892 function welcome()
893 {
894 ?>
895 <table border=0 width=100%><tr><td width=20%>&nbsp;</td><td>
896 <h1>Zdrastwuj!</h1>
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%>&nbsp;</td></tr>
904 </table>
905 <?php
906 }
907
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");
912
913 //phpinfo();
914 if ($local) {
915         if ($action == "text") {
916                 local_dump_text();
917         } else if ($action == "qatxt") {
918                 dump_qa(1);
919         } else {
920                 myheader();
921                 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
922                 list_archs();
923                 echo "</td><td valign=top>";
924                 flush();
925                 if ($action == "qa")
926                         dump_qa(0);
927                 else if ($action == "sqa")
928                         search_qa();
929                 else if (isset($id))
930                         local_dump_log($action == "tail");
931                 else if (isset($idx))
932                         local_list_logs();
933                 else 
934                         welcome();
935                 echo "</td></tr></table>";
936                 trailer();
937         }
938 }
939 else {
940
941         if ($action == "text") {
942                 dump_text();
943         } else if ($action == "qatxt") {
944                 dump_qa(1);
945         } else {
946                 myheader();
947                 echo "<table cellpadding=10 width=100%><tr><td valign=top width=10%>";
948                 list_archs();
949                 echo "</td><td valign=top>";
950                 flush();
951                 if ($action == "qa")
952                         dump_qa(0);
953                 else if (isset($id))
954                         dump_log($action == "tail");
955                 else if (isset($idx))
956                         list_logs();
957                 else 
958                         welcome();
959                 echo "</td></tr></table>";
960                 trailer();
961         }
962 }
963 ?>
This page took 0.136082 seconds and 4 git commands to generate.