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