]> git.pld-linux.org Git - projects/buildlogs.git/blob - obsolete/buildlogs/index.php
ia64 starts
[projects/buildlogs.git] / obsolete / buildlogs / index.php
1 <?php
2 $buildlogs_server = "buildlogs.pld-linux.org";
3 $url = "index.php";
4 $addr = array(
5         "/ac/SRPMS",
6         "/ac/i386",
7         "/ac/i586",
8         "/ac/i686",
9         "/ac/athlon",
10         "/ac/amd64",
11         "/ac/ia64",
12         "/ac/alpha",    
13         "/ac/sparc",
14         "/ac/ppc",
15         "/ra/i386",
16         "/ra/i586",
17         "/ra/i686",
18         "/ra/alpha",    
19         "/ra/sparc",
20         "/ra/ppc",
21         "/nest/i386",
22         "/nest/i686",
23         "/nest/athlon",
24         "/nest/alpha",
25         "/nest/ppc"
26 );
27 $qa_addr = array(
28         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-SRPMS.txt",
29         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-i386.txt",
30         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-i586.txt",
31         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-i686.txt",
32         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-athlon.txt",
33         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-amd64.txt",
34         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-ia64.txt",
35         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-alpha.txt",   
36         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-sparc.txt",
37         "http://ftp.pld-linux.org/dists/ac/.stat/builder/ac/rpmqa-ppc.txt",
38         "http://ftp.pld-linux.org/dists/ra/.stat/builder/liniowiec/rpmqa-ra-i386.txt",
39         "http://ftp.pld-linux.org/dists/ra/.stat/builder/liniowiec/rpmqa-ra-i586.txt",
40         "http://ftp.pld-linux.org/dists/ra/.stat/builder/liniowiec/rpmqa-ra-i686.txt",
41         "http://ftp.pld-linux.org/dists/ra/.stat/builder/fly/rpmqa-ra-alpha.txt",       
42         "http://ftp.pld-linux.org/dists/ra/.stat/builder/ares/rpmqa-ra-sparc.txt",
43         "http://ftp.pld-linux.org/dists/ra/.stat/builder/an2/rpmqa-ra-ppc.txt",
44         "http://ftp.nest.pld-linux.org/.stat/builder/kenny/rpmqa-nest-i386.txt",
45         "http://ftp.nest.pld-linux.org/.stat/builder/kenny/rpmqa-nest-i686.txt",
46         "",
47         "http://ftp.nest.pld-linux.org/.stat/builder/alpha/rpmqa-nest-alpha.txt",
48         "http://ftp.nest.pld-linux.org/.stat/builder/an2/rpmqa-nest-ppc.txt"
49 );
50 $local = 1; /* $local=0 for FTP */ 
51 $root_directory = "/home/services/ftp/pub/pld-buildlogs";
52 $ftp_conn = 0;
53 /* It should be set */
54
55 $langs["en_US"]["charset"]="ISO-8859-1";
56 $langs["pl_PL"]["charset"]="ISO-8859-2";
57
58 $lang="en_US";
59 if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
60 {
61   $rows=explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
62   $rows=explode(",",$rows[0]);
63   $lang_detected=rtrim($rows[0]);
64 } else if (preg_match("/opera/i",$_SERVER["HTTP_USER_AGENT"]))
65 {
66   $lang_detected=preg_replace("/.*\[(.*)\].*/i","\\1",$_SERVER["HTTP_USER_AGENT"]);
67 }
68
69 // FIXME - some array
70 $lang_detected=preg_replace("/^pl$/i","pl_PL",$lang_detected);
71
72 if (isset($lang_detected) && isset($langs[$lang_detected]))
73 {
74   $lang=$lang_detected;
75 }
76
77 if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"];
78 if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"];
79
80 putenv("LANG=$lang");
81 setlocale(LC_ALL,$lang);
82 bindtextdomain("messages","locale");
83 textdomain("messages");
84
85 if (isset($_GET["idx"]))$idx=$_GET["idx"];
86 if (isset($_GET["ok"]))$ok=$_GET["ok"];
87 else $ok="";
88 if (isset($_GET["ns"]))$ns=$_GET["ns"];
89 else $ns="";
90 if (isset($_GET["cnt"]))$cnt=$_GET["cnt"];
91 if (isset($_GET["action"]))$action=$_GET["action"];
92 else $action="";
93 if (isset($_GET["off"]))$off=$_GET["off"];
94 if (isset($_GET["id"]))$id=$_GET["id"];
95
96 if (isset($_POST["str"]))$str=$_POST["str"];
97 if (isset($_POST["idx"]))$idx=$_POST["idx"];
98 if (isset($_POST["action"]))$action=$_POST["action"];
99
100 function myheader()
101 {
102 echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
103 echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
104 ?>
105 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
106     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
107 <html xmlns="http://www.w3.org/1999/xhtml">
108  <head>
109   <title>PLD Build Logs</title>
110   <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
111   <style type="text/css"><!--
112 A { text-decoration: none; }
113 A:hover { text-decoration: underline; }
114 H1 { font-family: arial,helvetica,sans-serif; 
115      font-size: 20pt; 
116      font-weight: bold;}
117 H2 { font-family: arial,helvetica,sans-serif; 
118      font-size: 18pt; 
119      font-weight: bold;}
120 BODY,TD { font-family: arial,helvetica,sans-serif; 
121           font-size: 13pt; }
122 TH { font-family: arial,helvetica,sans-serif; 
123      font-size: 13pt; 
124      font-weight: bold; }
125 //-->
126 </style>
127  </head>
128  <!-- Diffrent color for visited link doesn't make much sense here...
129       this page is autogenerated and it might be misleading after some
130       build log changes. -->
131  <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
132 <?php
133 }
134
135 function start_pre()
136 {
137         echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
138                 "<font color=\"#cccccc\"><pre>";
139 }
140
141 function end_pre()
142 {
143         echo "</pre></font></td></tr></table>\n";
144 }
145
146 function trailer()
147 {
148         echo "</body></html>";
149 }
150
151
152 function mydie($msg)
153 {
154         echo "Fatal error: $msg";
155 }
156
157 function open_ftp($pidx="", $pok="")
158 {
159         global $idx, $addr, $buildlogs_server, $ok;
160         global $ftp_conn, $big_url, $url, $ns;
161         global $off, $cnt;
162         
163         if ($pidx==="")$pidx=$idx;
164         if ($pok==="")$pok=$ok;
165
166         if (!isset($pidx) || !isset($addr[$pidx]))
167                 return false;
168
169         if ($pok != 1)
170                 $pok = 0;
171         if ($ns != 1)
172                 $ns = 0;
173
174         if ($pok == 1) {
175                 $a = "$addr[$pidx]/OK";
176         } else {
177                 $a = "$addr[$pidx]/FAIL";
178         }
179
180         if (!isset($off))
181                 $off = 0;
182         if (!isset($cnt))
183                 $cnt = 16;
184
185         $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
186
187         $ftp = ftp_connect($buildlogs_server);
188
189         if ($ftp == false) {
190                 mydie(_("cannot connect to")." $buildlogs_server");
191                 return false;
192         }
193
194         if (ftp_login($ftp, "anonymous", 
195                       "buildlogs-iface@pld-linux.org") == false) {
196                 ftp_quit($ftp);
197                 mydie(_("cannot ftp login to")." $buildlogs_server");
198                 return false;
199         }
200
201         $list = ftp_nlist($ftp, $a);
202         if ($list == false) {
203                 ftp_quit($ftp);
204                 mydie(_("cannot list")." $a");
205                 return false;
206         }
207
208         $ftp_conn = $ftp;
209
210         return $list;
211 }
212
213 function directory_list($pidx="",$pok="")
214 {
215         global $idx, $addr, $buildlogs_server, $ok;
216         global $root_directory, $big_url, $url, $ns;
217         global $off, $cnt;
218
219         if ($pidx==="")$pidx=$idx;
220         if ($pok==="")$pok=$ok;
221         if (!isset($pidx) || !isset($addr[$pidx]))
222                 return false;
223
224         if ($pok != 1)
225                 $pok = 0;
226         if ($ns != 1)
227                 $ns = 0;
228
229         if ($pok == 1) {
230                 $a = "$addr[$pidx]/OK";
231         } else {
232                 $a = "$addr[$pidx]/FAIL";
233         }
234
235         if (!isset($off))
236                 $off = 0;
237         if (!isset($cnt))
238                 $cnt = 16;
239
240         $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
241
242         $dir = opendir("$root_directory$a");
243         $i = 0;
244         $list = array ();
245         while ($file = readdir($dir)) {
246                 if (($file != ".") && ($file != "..")) {
247                         $list[$i] = "$a/$file";
248                         $i++;
249                 }
250         }
251         closedir($dir);
252         return $list;
253 }
254
255 function list_logs()
256 {
257         global $idx, $addr, $ok;
258         global $ftp_conn, $big_url, $ns, $qa_addr;
259         global $off, $cnt, $local, $root_directory;
260
261         if ($local) {
262                 $list = directory_list();
263         } else {
264                 $list = open_ftp();
265         }
266         if ($list == false)
267                 return;
268
269         if ($ok == 1) {
270                 echo "<h1>"._("Listing of")." $addr[$idx]/OK "
271                         ."(<a href=\"$big_url&amp;ok=0\">"._("fail")."</a>)</h1>\n";
272         } else {
273                 echo "<h1>"._("Listing of")." $addr[$idx]/FAIL "
274                         ."(<a href=\"$big_url&amp;ok=1\">"._("ok")."</a>)</h1>\n";
275         }
276
277         echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
278                 "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
279         echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
280                  "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File").
281                         "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
282                  "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
283                  "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
284                          "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
285                  "</tr>";
286
287         function cmp($f1, $f2) {
288                 global $ftp_conn, $root_directory, $local;
289                 if ($local)
290                         return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
291                 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
292         }
293
294         if ($ns != 1) {
295                 $ns = 0;
296                 usort($list, "cmp");
297         } else {
298                 sort($list);
299         }
300
301         $now = time();
302         for ($i = $off; $i < $cnt + $off; $i++) {
303                 if (!isset($list[$i]))
304                         continue;
305                 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
306                 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
307                 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
308                 if ($local) {
309                         $s = filesize("$root_directory$list[$i]");
310                         $t = $now - filemtime("$root_directory$list[$i]");
311                 } else {
312                         $s = ftp_size($ftp_conn, $list[$i]);
313                         $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
314                 }
315                 $t /= 60;
316                 if ($t >= 60) {
317                         $t /= 60;
318                         if ($t >= 24) {
319                                 $t /= 24;
320                                 $t = round($t);
321                                 $t = $t . "&nbsp;" . ngettext("day","days",$t);
322                         } else {
323                                 $t = round($t);
324                                 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
325                         }
326                 } else {
327                         $t = round($t);
328                         $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
329                 }
330                 $u = "$big_url&amp;off=$off&amp;id=$h";
331                 echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
332                      "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
333                      "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
334                       "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
335                      "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
336                      "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
337         }
338         echo "</table></div>\n";
339
340         $backarr = "&lt;&lt;&lt;&nbsp;";
341         $back = _("Page back");
342         $forward = _("Page forward");
343         $forwardarr = "&nbsp;&gt;&gt;&gt;";
344
345         echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">";
346
347         if ($off > 0) {
348                 $noff = $off - $cnt;
349                 if ($noff < 0)  
350                         $noff = 0;
351                 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
352                 echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
353         } else {
354                 echo "$backarr</td><td align=\"left\">$back";
355         }
356
357         echo "</td>\n<td align=\"center\">";
358
359         if ($qa_addr[$idx] != "") {
360                 echo "[<a href=\"$big_url&amp;action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
361         } else {
362                 echo "&nbsp;";
363         }
364
365         echo "</td>\n<td align=right>";
366         if ($off + $cnt < count($list)) {
367                 $noff = $off + $cnt;
368                 if ($noff < 0)  
369                         $noff = 0;
370                 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
371                 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
372         } else {
373                 echo "$forward</td><td align=right width=1%>$forwardarr";
374         }
375         echo "</td>\n</tr></table></p>";
376         if ($local == 0) {
377                 ftp_quit($ftp_conn);
378                 $ftp_conn = 0;
379         }
380 }
381
382 function file_name()
383 {
384         global $idx, $addr, $ok;
385         global $ftp_conn, $root_directory, $big_url, $ns, $id;
386         global $buildlogs_server, $local;
387
388         if (!isset($id))
389                 return false;
390         if ($local) {
391                 $list = directory_list();
392         } else {
393                 $list = open_ftp();
394         }
395         if ($list == false)
396                 return false;
397
398         $f = false;
399         for ($i = 0; $i < count($list); $i++) {
400                 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
401                 if ($h == $id) {
402                         $f = $list[$i];
403                 }
404         }
405
406         if ($f == false) {
407                 mydie(_("cannot find specified file:")." $id");
408                 if ($local == 0)
409                         ftp_quit($ftp_conn);
410                 return false;
411         }
412
413         return $f;
414 }
415
416 function dump_log($tail)
417 {
418         global $idx, $addr, $ok, $url;
419         global $ftp_conn, $root_directory, $big_url, $ns, $id, $cnt, $off;
420         global $buildlogs_server, $local, $qa_addr;
421
422         $f = file_name();
423
424         if ($f == false)
425                 return;
426
427         $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
428         $df = preg_replace("/\.(bz2|gz)$/", "", $df);
429
430         echo "<h1>$df</h1>";
431
432         echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">";
433
434         function one_item($h, $t) {
435                 echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
436                          "<td bgcolor=\"#cccccc\">$t</td></tr>";
437         }
438
439         function href($h, $c) {
440                 return "<a href=\"$h\">$c</a>";
441         }
442
443         one_item(_("Status"), ($ok == 1 ?  
444                                 "<font color=green><b>"._("OK")."</b></font>" : 
445                                 "<font color=red><b>"._("Failed")."</b></a>"));
446         one_item(_("Source URL"), 
447                  href("ftp://$buildlogs_server$f", 
448                       "ftp://$buildlogs_server$f"));
449
450         $bu = "$big_url&amp;off=$off";
451
452         one_item(_("text/plain URL"), 
453                  href("$bu&amp;id=$id&amp;action=text",
454                       _("View!")));
455         if ($tail) {
456                 one_item(_("full text"), 
457                          href("$bu&amp;id=$id",
458                               "View!"));
459         }
460
461         if ($qa_addr[$idx] != "") {
462                 one_item(_("rpm -qa of builder"), href("$bu&amp;action=qa", _("View!")));
463         } else {
464                 one_item(_("rpm -qa of builder"), _("Not available"));
465         }
466         if ($local) {
467                 one_item("Data", date("Y/m/d H:i:s", filemtime("$root_directory$f")));
468         } else {
469                 one_item("Data", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)));
470         }
471         /*
472         echo "<tr><td>Here:</td><td>" . 
473                 "<a href=\"$url?idx=$idx&amp;ok=$ok&amp;id=$id\">".
474                 "http://" . getenv("SERVER_NAME") .
475                 getenv("SCRIPT_NAME") . "?idx=$idx&amp;ok=$ok&amp;id=$id</a>" .
476              "</td></tr>"; */
477
478         echo "</table><h2>"._("Content:")."</h2>";
479
480         if ($local == 0) {
481                 ftp_quit($ftp_conn);
482                 $ftp_conn = 0;
483         }
484
485
486         # what can I say beside PHP suxx? how the fuck should I create
487         # bidirectional pipe? gotta use wget
488
489         if (preg_match("/\.bz2$/", $f)) {
490                 $filter = "bzcat";
491         } elseif (preg_match("/\.gz$/", $f)) {
492                 $filter = "zcat";
493         } else {
494                 $filter = "cat";
495         }
496
497         if ($local) {
498                 $cmd = "$filter $root_directory$f";
499         } else {
500                 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 | $filter 2>&1";
501         }
502         if ($tail)
503                 $cmd = "$cmd | tail -n 100";
504         $fd = popen($cmd, "r");
505         start_pre();
506         while (($s = fgets($fd, 1000)) != false) {
507                 $s = htmlspecialchars($s);
508                 echo $s;
509         }
510         end_pre();
511         pclose($fd);
512
513 ?>
514         <table width="100%">
515          <tr>
516           <td align=left>
517            [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
518           </td>
519           <td align=right>
520            [<a href="<?php echo "$bu&amp;action=qa" 
521                 ?>"><?=_("View rpm -qa of builder")?></a>]
522           </td>
523          </tr>
524         </table>
525 <?php
526
527 }
528
529 function dump_text()
530 {
531         global $ftp_conn, $root_directory;
532         global $buildlogs_server, $local;
533
534         header("Content-type: text/plain");
535
536         $f = file_name();
537
538         if ($f == false)
539                 return;
540
541         echo "# src  : ftp://$buildlogs_server$f\n";
542         if ($local) {
543                 echo "# date   : " .  
544                         date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n";
545         } else {
546                 echo "# date   : " .  
547                         date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)) . "\n";
548                 ftp_quit($ftp_conn);
549                 $ftp_conn = 0;
550         }
551
552         if (preg_match("/\.bz2$/", $f)) {
553                 $filter = "bzcat";
554         } elseif (preg_match("/\.gz$/", $f)) {
555                 $filter = "zcat";
556         } else {
557                 $filter = "cat";
558         }
559
560         if ($local) {
561                 $cmd = "$filter $root_directory$f";
562         } else {
563                 $cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 | $filter 2>&1";
564         }
565         $fd = popen($cmd, "r");
566         while (($s = fgets($fd, 1000)) != false) {
567                 echo $s;
568         }
569         pclose($fd);
570 }
571
572 function list_archs()
573 {
574         global $addr, $url, $idx, $cnt,$ok,$ns;
575
576         if (!isset($cnt))
577                 $cnt = 16;
578
579         $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
580
581         echo "<table width=\"100%\" border=\"0\">\n";
582         echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
583         for ($i = 0; $i < count($addr); $i++)
584                 echo "<tr><td nowrap=\"nowrap\">".
585                      "<a href=\"$url?idx=$i&amp;ok=0&amp;cnt=$cnt\">$addr[$i]</a></td><td nowrap=\"nowrap\">".
586                      "[<a href=\"$url?idx=$i&amp;ok=1&amp;cnt=$cnt\">OK</a>]</td>".
587                      #"<td>[<a href=\"$url?idx=$i&amp;action=qa\">qa</a>]</td>".
588                      "</tr>\n";
589         echo "</table><hr />\n";
590         
591         echo "<div align=\"center\">";
592         echo "<a href=\"$big_url&amp;action=adv_search\">"._("Advanced Search")."</a><br />\n";
593         
594         echo "<a href=\"$url\">main()</a><hr />\n";
595         echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ".
596                 "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
597              "<small>(c) 2002 ".
598              "<a href=\"mailto:feedback@pld-linux.org\">PLD&nbsp;Team</a>\n".
599              "</small></div>\n";
600
601         # smile ;)
602         echo "<div align=\"center\"><small>";
603         $pow = array("vim", "php", "brain", "power", "electricity",
604                      "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
605                      "voodoo magic", "Linux", "x-files", "X", "foobar",
606                      "/dev/null", "/dev/zero", "/dev/drzewo", 
607                      "Leppe'", "matrix", "Neo", "PDP-11",
608                      "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
609                      "foobarbaz", "ed", "Joe", "Unix conspiracy", 
610                      "overclock", "The Right Thing",
611                      "The Bad Thing", "Star Treck", "NSA", "NASA",
612                      "achelon", "VAX", "Real Programmer",
613                      "Real Operating System", "Real Computer",
614                      "computron", "bogon", "quantum bogodynamics",
615                      "BOFH", "/dev/ill", "nasi tu byli",
616                      "Paranoid Android", "Lunatic Corp", "Parallel thinking",
617                      "sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
618                      "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003"
619                      # feel free to add sth if you change this file ;)
620                      );
621         echo _("Powered by")." ";
622         $max = 1;
623         for ($i = 0; $i < $max; $i++) {
624                 $x = rand(0, count($pow) - 1);
625                 if ($pow[$x] == "") $i--;
626                 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
627                 $pow[$x] = "";
628         }
629         echo "</small></div>";
630
631         global $qa_addr;
632
633         if (isset($qa_addr[$idx]) && $qa_addr[$idx] != "") {
634         echo "<form action=\"index.php\" method=\"post\">";
635         echo "<input type=hidden name=idx value=$idx />";
636         echo "<input type=hidden name=action value=sqa />";
637         echo "<input type=text size=14 name=str /><br />";
638         echo "<input type=submit name=submit value=\""._("Search rpmqa!")."\" />";
639         echo "</form>";
640         }
641 }
642
643 function get_qa()
644 {
645         global $idx, $qa_addr;
646
647         if (!isset($idx) || !isset($qa_addr[$idx]))
648                 return false;
649
650         $a = $qa_addr[$idx];
651
652         if ($qa_addr[$idx] == "")
653                 return false;
654         else
655                 return fopen("$qa_addr[$idx]", "r");
656 }
657
658 function search_qa()
659 {
660         global $url, $idx, $qa_addr, $str;
661
662         $f = get_qa();
663         echo "<h1>"._("Search results for")." '$str' "._("in")." $qa_addr[$idx]</h1>";
664
665         start_pre();
666
667         if ($f == 0) {
668                 echo _("Sorry, cannot open.");
669         } else {
670                 while (($s = fgets($f, 1000)) != false) {
671                         if (stristr($s, $str))
672                                 echo $s;
673                 }
674                 echo "/* EOF */";
675         }
676         end_pre();
677 }
678
679 function dump_qa($plain)
680 {
681         global $url, $idx, $qa_addr;
682
683         $a = $qa_addr[$idx];
684
685         $f = get_qa();
686
687         if ($plain) {
688                 header("Content-type: text/plain"); 
689                 echo _("# rpm -qa of")." $a\n";
690         } else {
691                 echo "<h1>"._("rpm -qa of")." $a</h1>";
692                 echo "<a href=\"$url?idx=$idx&amp;action=qatxt\">"._("text/plain version")."</a>";
693                 start_pre();
694         }
695
696         if ($f == 0) {
697                 echo _("Sorry, cannot open.");
698         } else {
699                 while (($s = fgets($f, 1000)) != false) {
700                         echo $s;
701                 }
702         }
703
704         if (!$plain)
705                 end_pre();
706 }
707
708
709 function adv_search()
710 {
711   global $addr, $url, $local, $_POST, $off, $cnt, $root_directory;
712
713   $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
714
715   echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
716
717   echo "<div align=\"center\">";
718   echo "<table border=\"0\">\n";
719   echo "<tr>\n";
720   echo "<td>"._("Package name")."</td>\n";
721   echo "<td><input type=\"text\" size=\"20\" name=\"name\" value=\"".$_POST[name]."\"/></td>\n";
722   echo "</tr>\n";
723
724   echo "<tr>\n";
725   echo "<td>"._("Days")."</td>\n";
726   echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"".$_POST["age1"]."\" /></td>\n";
727   echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"".$_POST["age2"]."\" /></td>\n";
728   echo "</tr>\n";
729
730   echo "<tr>\n";
731   echo "<td>"._("Size")."</td>\n";
732   echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"".$_POST["size1"]."\" /></td>\n";
733   echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"".$_POST["size2"]."\" /></td>\n";
734   echo "</tr>\n";
735
736   echo "<tr>\n";
737   echo "<td>"._("Search logs:")."</td>\n";
738   echo "</tr>\n";
739
740   echo "<tr>\n";
741   echo "<td>"._("Failed")."</td>\n";
742   echo "<td>"._("OK")."</td>\n";
743   echo "</tr>\n";
744
745   for ($i = 0; $i < count($addr); $i++)
746   {
747     echo "<tr>\n";
748     $name="as0_".$i;
749     $check=" checked=\"on\"";
750     echo "<td><input name=$name type=\"checkbox\"$check>".$addr[$i]."</input></td>\n";
751     $name="as1_".$i;
752     $check=" checked=\"on\"";
753     echo "<td><input name=$name type=\"checkbox\"$check>".$addr[$i]."</input></td>\n";
754     echo "</tr>\n";
755   }
756         
757   echo "<tr>\n";
758   echo "<td><input type=submit name=submit value=\""._("Search!")."\" /></td>";
759   echo "</tr>\n";
760
761   echo "</table>\n";
762
763 //      if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
764 //        isset($_POST["size1"]) || isset($_POST["size2"]))
765   if (($_POST["name"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
766     ($_POST["size1"]!="") || ($_POST["size2"]!=""))
767   {
768     unset($list);
769     $now = time();
770     for ($i = 0; $i < count($addr); $i++)
771     
772       for ($j=0;$j<2;$j++)
773         {
774           unset($tmp_list);
775           if (isset($_POST["as".$j."_".$i]))
776           {
777             if ($local) {
778                 $tmp_list = directory_list($i,$j);
779             } else {
780                 $tmp_list = open_ftp($i,$j);
781             }
782             if (is_array($tmp_list))
783             {
784               while (list($k,$name)=each($tmp_list))
785               {
786                 $s = filesize("$root_directory$name");
787                 $t = $now - filemtime("$root_directory$name");
788                 $t/=(24*3600);
789                 if (($_POST["name"]!="") && (!preg_match("/".$_POST["name"]."/i",$name)))continue;
790                 if (($_POST["age1"]) && ($_POST["age1"]>$t))continue;
791                 if (($_POST["age2"]) && ($_POST["age2"]<$t))continue;
792
793                 if (($_POST["size1"]) && ($_POST["size1"]>$s))continue;
794                 if (($_POST["size2"]) && ($_POST["size2"]<$s))continue;
795
796                 $list[$i."_".$j."_".$k]=$name;
797               }
798             }
799           }
800         }
801         
802         if (sizeof($list)==0)
803         {
804           echo _("Nothing found");
805         } else
806         {
807
808         echo "<table border=\"0\" cellspacing=\"1\" ".
809                 "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
810         echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
811              "[<a href=\"$big_url&amp;ns=2\">"._("sort")."</a>]</th>";
812         echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
813                         "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
814                  "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
815                  "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
816                          "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
817                  "</th></tr>";
818
819         function cmp1($f1, $f2) {
820                 global $ftp_conn, $root_directory, $local;
821                 if ($local)
822                         return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
823                 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
824         }
825
826         function cmp2($f1, $f2) {
827           list($p11,$p12,$p13)=explode("_",$f1);
828           list($p21,$p22,$p23)=explode("_",$f2);
829           return strcmp($f2,$f1);
830         }
831
832         if ($ns == 1)
833         {
834           usort($list, "cmp1");
835 //      } else if ($ns == 2)
836 //      {
837 //        uksort($list, "cmp2");
838         } else
839         {
840           asort($list);
841         }
842
843         $counter=0;
844         while (list($k,$name)=each($list))
845         {
846         if (($counter<$off) || ($counter>$off+$cnt-1))
847         {
848           $counter++;
849           continue;
850         }
851
852           $counter++;
853           list($i,$j,$k)=explode("_",$k);
854
855                 $h = bin2hex(mhash(MHASH_MD5, $name));
856                 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $name);
857                 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
858                 if ($local) {
859                         $s = filesize("$root_directory$name");
860                         $t = $now - filemtime("$root_directory$name");
861                 } else {
862                         $s = ftp_size($ftp_conn, $list[$i]);
863                         $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
864                 }
865                 $t /= 60;
866                 if ($t >= 60) {
867                         $t /= 60;
868                         if ($t >= 24) {
869                                 $t /= 24;
870                                 $t = round($t);
871                                 $t = $t . "&nbsp;" . ngettext("day","days",$t);
872                         } else {
873                                 $t = round($t);
874                                 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
875                         }
876                 } else {
877                         $t = round($t);
878                         $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
879                 }
880                 $big_url = "$url?idx=$i&amp;ok=$j&amp;ns=$ns&amp;cnt=$cnt";
881                 $u = "$big_url&amp;off=$off&amp;id=$h";
882
883                 $builder=$addr[$i]."/".(($j=="1")?"OK":"FAIL");
884                 echo "<tr>";
885                 echo "<td bgcolor=#CCCCCC><a href=\"$u\">$builder</a></td>";
886                 echo "<td bgcolor=#CCCCCC><a href=\"$u\">$f</a> ".
887                      "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
888                       "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
889                      "</td><td bgcolor=#CCCCCC align=right>".
890                      "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
891         }
892         echo "</table></div>\n";
893
894         $backarr = "&lt;&lt;&lt;&nbsp;";
895         $back = _("Page back");
896         $forward = _("Page forward");
897         $forwardarr = "&nbsp;&gt;&gt;&gt;";
898
899 // FIXME
900 /*
901         echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
902
903         if ($off > 0) {
904                 $noff = $off - $cnt;
905                 if ($noff < 0)  
906                         $noff = 0;
907                 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
908                 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
909         } else {
910                 echo "$backarr</td><td align=left>$back";
911         }
912
913     echo "</td>\n<td align=\"center\">";
914     echo "</td>\n<td align=\"right\">";
915
916     if ($off + $cnt < count($list))
917     {
918       $noff = $off + $cnt;
919       if ($noff < 0)    
920         $noff = 0;
921       $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
922       echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>";
923     }
924     else
925     {
926       echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr";
927     }
928
929     echo "</td>\n</tr></table></p>";
930 */
931     }
932     if ($local == 0)
933     {
934       ftp_quit($ftp_conn);
935       $ftp_conn = 0;
936     }
937   } else
938   {
939     echo _("Enter something!");
940   }
941   echo "</form>\n";
942 }
943
944 function welcome()
945 {
946 ?>
947 <table border="0" width="100%"><tr><td width="20%">&nbsp;</td><td>
948 <h1><?=_("Welcome!")?></h1>
949 <p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
950 <?=_("Feel free to email bug reports, complaints and feature requests ")?>
951 <!-- ech... niech strace... -->
952 <a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?> 
953 <a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a> ;)</p>
954 <p>Version: $Id: index.php,v 1.73 2004/05/16 08:06:45 ankry Exp $</p>
955 </td><td width="20%">&nbsp;</td></tr>
956 </table>
957 <?php
958 }
959
960 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
961 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
962 header("Cache-Control: no-cache, must-revalidate");
963 header("Pragma: no-cache");
964
965 //phpinfo();
966 if ($local) {
967         if ($action == "text") {
968                 dump_text();
969         } else if ($action == "adv_search") {
970                 myheader();
971                 adv_search();
972                 trailer();
973         } else if ($action == "qatxt") {
974                 dump_qa(1);
975         } else {
976                 myheader();
977                 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
978                 list_archs();
979                 echo "</td><td valign=\"top\">";
980                 flush();
981                 if ($action == "qa")
982                         dump_qa(0);
983                 else if ($action == "sqa")
984                         search_qa();
985                 else if (isset($id))
986                         dump_log($action == "tail");
987                 else if (isset($idx))
988                         list_logs();
989                 else 
990                         welcome();
991                 echo "</td></tr></table>";
992                 trailer();
993         }
994 }
995 else {
996
997         if ($action == "text") {
998                 dump_text();
999         } else if ($action == "qatxt") {
1000                 dump_qa(1);
1001         } else {
1002                 myheader();
1003                 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=top width=\"10%\">";
1004                 list_archs();
1005                 echo "</td><td valign=\"top\">";
1006                 flush();
1007                 if ($action == "qa")
1008                         dump_qa(0);
1009                 else if (isset($id))
1010                         dump_log($action == "tail");
1011                 else if (isset($idx))
1012                         list_logs();
1013                 else 
1014                         welcome();
1015                 echo "</td></tr></table>";
1016                 trailer();
1017         }
1018 }
1019 ?>
This page took 0.172683 seconds and 3 git commands to generate.