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