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