]> git.pld-linux.org Git - projects/buildlogs.git/blame - obsolete/buildlogs/index.php
- advanced search added
[projects/buildlogs.git] / obsolete / buildlogs / index.php
CommitLineData
2a73daad
MM
1<?php
2$buildlogs_server = "buildlogs.pld.org.pl";
2a73daad
MM
3$url = "index.php";
4$addr = array(
a8cafede 5 "/nest/athlon",
2a73daad
MM
6 "/nest/i386",
7 "/nest/i586",
8 "/nest/i686",
e86d1be4 9 "/nest/ppc",
2a73daad
MM
10 "/ra/i386",
11 "/ra/i586",
12 "/ra/i686",
13 "/ra/alpha",
8fdf8843
AM
14 "/ra/sparc",
15 "/ra/ppc"
2a73daad 16);
58c74097 17$addr = array(
18 "aaa","bbb"
19);
b018fce6
MM
20$qa_base = "http://ftp.pld.org.pl/.stat/builder";
21$qa_addr = array(
a8cafede 22 "",
b018fce6
MM
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",
861fb048 30 "/mifgate/rpmqa-ra-alpha.txt",
f93aa6bf 31 "/team/rpmqa-ra-sparc.txt",
b018fce6
MM
32 ""
33);
e86d1be4 34$local = 1; /* $local=0 for FTP */
8154e1aa 35$root_directory = "/home/services/ftp/pub/logs";
58c74097 36$root_directory = "./";
c8c26d5e 37$ftp_conn = 0;
e86d1be4 38/* It should be set */
39
d304116f 40$langs["en_US"]["charset"]="ISO-8859-1";
41$langs["pl_PL"]["charset"]="ISO-8859-2";
42
43$lang="en_US";
44if (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
57if (isset($lang_detected) && isset($langs[$lang_detected]))
58{
59 $lang=$lang_detected;
60}
61
62if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"];
63if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"];
64
65putenv("LANG=$lang");
66setlocale(LC_ALL,$lang);
67bindtextdomain("messages","locale");
68textdomain("messages");
69
23f2f6e7 70if (isset($_GET["idx"]))$idx=$_GET["idx"];
71if (isset($_GET["ok"]))$ok=$_GET["ok"];
72if (isset($_GET["ns"]))$ns=$_GET["ns"];
73if (isset($_GET["cnt"]))$cnt=$_GET["cnt"];
74if (isset($_GET["action"]))$action=$_GET["action"];
58c74097 75if (isset($_GET["off"]))$cnt=$_GET["off"];
23f2f6e7 76
f47b2a29 77if (isset($_POST["str"]))$str=$_POST["str"];
78if (isset($_POST["idx"]))$idx=$_POST["idx"];
23f2f6e7 79if (isset($_POST["action"]))$action=$_POST["action"];
2a73daad
MM
80
81function 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"><!--
90A { text-decoration: none; }
91A:hover { text-decoration: underline; }
92H1 { font-family: arial,helvetica,sans-serif;
93 font-size: 20pt;
94 font-weight: bold;}
95H2 { font-family: arial,helvetica,sans-serif;
96 font-size: 18pt;
97 font-weight: bold;}
98BODY,TD { font-family: arial,helvetica,sans-serif;
99 font-size: 13pt; }
100TH { 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
113function start_pre()
114{
115 echo "<table cellpadding=10><tr><td bgcolor=\"#000000\">".
116 "<font color=\"#cccccc\"><pre>";
117}
118
119function end_pre()
120{
121 echo "</pre></font></td></tr></table>\n";
122}
123
124function trailer()
125{
126 echo "</body></html>";
127}
128
129
130function mydie($msg)
131{
132 echo "Fatal error: $msg";
133}
134
58c74097 135function open_ftp($pidx="", $pok="")
2a73daad
MM
136{
137 global $idx, $addr, $buildlogs_server, $ok;
138 global $ftp_conn, $big_url, $url, $ns;
ca0f7067 139 global $off, $cnt;
58c74097 140
141 if ($pidx==="")$pidx=$idx;
142 if ($pok==="")$pok=$ok;
c8c26d5e 143
58c74097 144 if (!isset($pidx) || !isset($addr[$pidx]))
2a73daad 145 return false;
c8c26d5e 146
58c74097 147 if ($pok != 1)
148 $pok = 0;
2a73daad
MM
149 if ($ns != 1)
150 $ns = 0;
c8c26d5e 151
58c74097 152 if ($pok == 1) {
153 $a = "$addr[$pidx]/OK";
2a73daad 154 } else {
58c74097 155 $a = "$addr[$pidx]/FAIL";
2a73daad 156 }
c8c26d5e 157
ca0f7067
MM
158 if (!isset($off))
159 $off = 0;
160 if (!isset($cnt))
161 $cnt = 16;
c8c26d5e 162
29209fb4 163 $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
c8c26d5e 164
2a73daad 165 $ftp = ftp_connect($buildlogs_server);
c8c26d5e 166
2a73daad 167 if ($ftp == false) {
d304116f 168 mydie(_("cannot connect to")." $buildlogs_server");
2a73daad
MM
169 return false;
170 }
171
172 if (ftp_login($ftp, "anonymous",
2050e923 173 "buildlogs-iface@pld.org.pl") == false) {
2a73daad 174 ftp_quit($ftp);
d304116f 175 mydie(_("cannot ftp login to")." $buildlogs_server");
2a73daad
MM
176 return false;
177 }
178
179 $list = ftp_nlist($ftp, $a);
180 if ($list == false) {
181 ftp_quit($ftp);
d304116f 182 mydie(_("cannot list")." $a");
2a73daad
MM
183 return false;
184 }
185
186 $ftp_conn = $ftp;
c8c26d5e 187
2a73daad
MM
188 return $list;
189}
190
58c74097 191function directory_list($pidx="",$pok="")
e86d1be4 192{
193 global $idx, $addr, $buildlogs_server, $ok;
194 global $root_directory, $big_url, $url, $ns;
195 global $off, $cnt;
c8c26d5e 196
58c74097 197 if ($pidx==="")$pidx=$idx;
198 if ($pok==="")$pok=$ok;
199 if (!isset($pidx) || !isset($addr[$pidx]))
e86d1be4 200 return false;
c8c26d5e 201
58c74097 202 if ($pok != 1)
203 $pok = 0;
e86d1be4 204 if ($ns != 1)
205 $ns = 0;
c8c26d5e 206
58c74097 207 if ($pok == 1) {
208 $a = "$addr[$pidx]/OK";
e86d1be4 209 } else {
58c74097 210 $a = "$addr[$pidx]/FAIL";
e86d1be4 211 }
c8c26d5e 212
e86d1be4 213 if (!isset($off))
214 $off = 0;
215 if (!isset($cnt))
216 $cnt = 16;
c8c26d5e 217
29209fb4 218 $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
c8c26d5e 219
e86d1be4 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
2a73daad
MM
232function list_logs()
233{
234 global $idx, $addr, $ok;
c8c26d5e 235 global $ftp_conn, $big_url, $ns, $qa_addr;
236 global $off, $cnt, $local, $root_directory;
2a73daad 237
c8c26d5e 238 if ($local) {
239 $list = directory_list();
240 } else {
241 $list = open_ftp();
242 }
2a73daad
MM
243 if ($list == false)
244 return;
c8c26d5e 245
2a73daad 246 if ($ok == 1) {
d304116f 247 echo "<h1>"._("Listing of")." $addr[$idx]/OK "
248 ."(<a href=\"$big_url&ok=0\">"._("fail")."</a>)</h1>";
2a73daad 249 } else {
d304116f 250 echo "<h1>"._("Listing of")." $addr[$idx]/FAIL "
251 ."(<a href=\"$big_url&ok=1\">"._("ok")."</a>)</h1>";
2a73daad 252 }
c8c26d5e 253
2a73daad
MM
254 echo "<div align=center><table border=0 cellspacing=1 ".
255 "cellpadding=3 bgcolor=#000000 width=90%>\n";
d304116f 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>".
2a73daad 261 "</th></tr>";
2a73daad 262
c8c26d5e 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");
2a73daad
MM
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);
ca0f7067
MM
273 } else {
274 sort($list);
2a73daad 275 }
c8c26d5e 276
2a73daad 277 $now = time();
ca0f7067
MM
278 for ($i = $off; $i < $cnt + $off; $i++) {
279 if (!isset($list[$i]))
280 continue;
2a73daad
MM
281 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
282 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
283 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
c8c26d5e 284 if ($local) {
285 $s = filesize("$root_directory$list[$i]");
286 $t = $now - filemtime("$root_directory$list[$i]");
2a73daad 287 } else {
c8c26d5e 288 $s = ftp_size($ftp_conn, $list[$i]);
289 $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
2a73daad 290 }
e86d1be4 291 $t /= 60;
292 if ($t >= 60) {
293 $t /= 60;
294 if ($t >= 24) {
295 $t /= 24;
8abba06f 296 $t = round($t);
d304116f 297 $t = $t . ngettext(" day"," days",$t);
e86d1be4 298 } else {
8abba06f 299 $t = round($t);
d304116f 300 $t = $t . ngettext(" hour"," hours",$t);
e86d1be4 301 }
302 } else {
8abba06f 303 $t = round($t);
d304116f 304 $t = $t . ngettext(" minute"," minutes",$t);
e86d1be4 305 }
29209fb4 306 $u = "$big_url&off=$off&id=$h";
e86d1be4 307 echo "<tr><td bgcolor=#CCCCCC><a ".
308 "href=\"$u\">".
309 "$f</a> ".
d304116f 310 "[<a href=\"$u&action=text\">"._("text")."</a> | ".
311 "<a href=\"$u&action=tail\">"._("tail")."</a>]".
e86d1be4 312 "</td><td bgcolor=#CCCCCC align=right>".
313 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
314 }
315 echo "</table></div>\n";
316
d326cd64 317 $backarr = "&lt;&lt;&lt;&nbsp;";
d304116f 318 $back = _("Page back");
319 $forward = _("Page forward");
d326cd64 320 $forwardarr = "&nbsp;&gt;&gt;&gt;";
e86d1be4 321
d326cd64 322 echo "<p><table width=90% align=center><tr><td align=left width=1%>";
e86d1be4 323
324 if ($off > 0) {
325 $noff = $off - $cnt;
326 if ($noff < 0)
327 $noff = 0;
d326cd64 328 $hrefurl = "<a href=\"$big_url&off=$noff\">";
329 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
e86d1be4 330 } else {
d326cd64 331 echo "$backarr</td><td align=left>$back";
e86d1be4 332 }
f93aa6bf 333
d326cd64 334 echo "</td>\n<td align=center>";
f93aa6bf 335
bb3ae015 336 if ($qa_addr[$idx] != "") {
d304116f 337 echo "[<a href=\"$big_url&action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
f93aa6bf 338 } else {
339 echo "&nbsp;";
c8c26d5e 340 }
341
d326cd64 342 echo "</td>\n<td align=right>";
e86d1be4 343 if ($off + $cnt < count($list)) {
344 $noff = $off + $cnt;
345 if ($noff < 0)
346 $noff = 0;
d326cd64 347 $hrefurl = "<a href=\"$big_url&off=$noff\">";
348 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
e86d1be4 349 } else {
d326cd64 350 echo "$forward</td><td align=right width=1%>$forwardarr";
e86d1be4 351 }
d326cd64 352 echo "</td>\n</tr></table></p>";
c8c26d5e 353 if ($local == 0) {
2a73daad 354 ftp_quit($ftp_conn);
c8c26d5e 355 $ftp_conn = 0;
2a73daad 356 }
2a73daad
MM
357}
358
c8c26d5e 359function file_name()
e86d1be4 360{
361 global $idx, $addr, $ok;
c8c26d5e 362 global $ftp_conn, $root_directory, $big_url, $ns, $id;
363 global $buildlogs_server, $local;
e86d1be4 364
365 if (!isset($id))
366 return false;
c8c26d5e 367 if ($local) {
368 $list = directory_list();
369 } else {
370 $list = open_ftp();
371 }
e86d1be4 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) {
d304116f 384 mydie(_("cannot find specified file:")." $id");
c8c26d5e 385 if ($local == 0)
386 ftp_quit($ftp_conn);
e86d1be4 387 return false;
388 }
389
390 return $f;
391}
392
ca0f7067 393function dump_log($tail)
2a73daad
MM
394{
395 global $idx, $addr, $ok, $url;
c8c26d5e 396 global $ftp_conn, $root_directory, $big_url, $ns, $id, $cnt, $off;
397 global $buildlogs_server, $local, $qa_addr;
2a73daad
MM
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);
c8c26d5e 406
2a73daad
MM
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 }
c8c26d5e 419
58c74097 420 one_item(_("Status"), ($ok == 1 ?
d304116f 421 "<font color=green><b>"._("OK")."</b></font>" :
422 "<font color=red><b>"._("Failed")."</b></a>"));
58c74097 423 one_item(_("Source URL"),
2a73daad
MM
424 href("ftp://$buildlogs_server$f",
425 "ftp://$buildlogs_server$f"));
ca0f7067 426
29209fb4 427 $bu = "$big_url&off=$off";
c8c26d5e 428
58c74097 429 one_item(_("text/plain URL"),
ca0f7067 430 href("$bu&id=$id&action=text",
58c74097 431 _("View!")));
ca0f7067 432 if ($tail) {
58c74097 433 one_item(_("full text"),
ca0f7067
MM
434 href("$bu&&id=$id",
435 "View!"));
436 }
f93aa6bf 437
d381dfdf 438 if ($qa_addr[$idx] != "") {
d304116f 439 one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!")));
f93aa6bf 440 } else {
d304116f 441 one_item(_("rpm -qa of builder"), _("Not available"));
f93aa6bf 442 }
c8c26d5e 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 }
2a73daad
MM
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
d304116f 455 echo "</table><h2>"._("Content:")."</h2>";
2a73daad 456
c8c26d5e 457 if ($local == 0) {
458 ftp_quit($ftp_conn);
459 $ftp_conn = 0;
e86d1be4 460 }
e86d1be4 461
e86d1be4 462
e86d1be4 463 # what can I say beside PHP suxx? how the fuck should I create
464 # bidirectional pipe? gotta use wget
c8c26d5e 465
e86d1be4 466 if (preg_match("/\.bz2$/", $f)) {
c8c26d5e 467 $filter = "bzcat";
e86d1be4 468 } elseif (preg_match("/\.gz$/", $f)) {
c8c26d5e 469 $filter = "zcat";
e86d1be4 470 } else {
c8c26d5e 471 $filter = "cat";
e86d1be4 472 }
473
c8c26d5e 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 }
e86d1be4 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>
d304116f 494 [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
e86d1be4 495 </td>
496 <td align=right>
497 [<a href="<?php echo "$bu&action=qa"
d304116f 498 ?>"><?=_("View rpm -qa of builder")?></a>]
e86d1be4 499 </td>
500 </tr>
51aa6406 501 </table>
e86d1be4 502<?php
503
504}
505
2a73daad
MM
506function dump_text()
507{
c8c26d5e 508 global $ftp_conn, $root_directory;
509 global $buildlogs_server, $local;
510
2a73daad
MM
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";
c8c26d5e 519 if ($local) {
520 echo "# date : " .
521 date("Y/m/d H:i:s", filemtime("$root_directory$f")) . "\n";
2a73daad 522 } else {
c8c26d5e 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;
2a73daad 527 }
e86d1be4 528
529 if (preg_match("/\.bz2$/", $f)) {
c8c26d5e 530 $filter = "bzcat";
e86d1be4 531 } elseif (preg_match("/\.gz$/", $f)) {
c8c26d5e 532 $filter = "zcat";
e86d1be4 533 } else {
c8c26d5e 534 $filter = "cat";
e86d1be4 535 }
536
c8c26d5e 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");
e86d1be4 543 while (($s = fgets($fd, 1000)) != false) {
544 echo $s;
545 }
546 pclose($fd);
547}
548
2a73daad
MM
549function list_archs()
550{
38299f63 551 global $addr, $url, $idx;
2a73daad 552
d304116f 553 $big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
554
2a73daad 555 echo "<table width=100% border=0>\n";
d304116f 556 echo "<tr><td bgcolor=#cccccc nowrap=1>"._("Failed")."</td><td bgcolor=#cccccc>"._("Ok")."</td></tr>\n";
2a73daad
MM
557 for ($i = 0; $i < count($addr); $i++)
558 echo "<tr><td nowrap=1>".
e2dff542 559 "<a href=\"$url?idx=$i&ok=0\">$addr[$i]</a></td><td nowrap=1>".
2a73daad
MM
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";
58c74097 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";
2050e923 569 echo "<a href=\"http://www.pld.org.pl/\"><img src=powpld.png ".
d304116f 570 "alt=\""._("Powered by PLD Linux")."\" border=0></a><br />\n" .
2a73daad
MM
571 "<small>(c) 2002 ".
572 "<a href=\"mailto:feedback@pld.org.pl\">PLD&nbsp;Team</a>\n".
573 "</small></div>\n";
c8c26d5e 574
2a73daad
MM
575 # smile ;)
576 echo "<div align=center><small>";
577 $pow = array("vim", "php", "brain", "power", "electricity",
51aa6406 578 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
2a73daad
MM
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",
51aa6406 583 "foobarbaz", "ed", "Joe", "Unix conspiracy",
2a73daad
MM
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",
e86d1be4 589 "BOFH", "/dev/ill", "nasi tu byli",
590 "Paranoid Android", "Lunatic Corp"
2a73daad
MM
591 # feel free to add sth if you change this file ;)
592 );
d304116f 593 echo _("Powered by")." ";
2a73daad
MM
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 }
2a73daad 601 echo "</small></div>";
c8c26d5e 602
38299f63
MM
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/>";
d304116f 610 echo "<input type=submit name=submit value=\""._("Search rpmqa!")."\" />";
38299f63
MM
611 echo "</form>";
612 }
2a73daad
MM
613}
614
38299f63 615function get_qa()
2a73daad 616{
38299f63 617 global $idx, $qa_addr, $qa_base;
c8c26d5e 618
b018fce6 619 if (!isset($idx) || !isset($qa_addr[$idx]))
2a73daad
MM
620 return false;
621
b018fce6 622 $a = $qa_addr[$idx];
c8c26d5e 623
38299f63
MM
624 if ($qa_addr[$idx] == "")
625 return false;
626 else
627 return fopen("$qa_base$qa_addr[$idx]", "r");
628}
629
630function search_qa()
631{
632 global $url, $idx, $qa_addr, $str;
633
634 $f = get_qa();
d304116f 635 echo "<h1>"._("Search results for")." '$str' "._("in")." $qa_addr[$idx]</h1>";
38299f63
MM
636
637 start_pre();
638
639 if ($f == 0) {
d304116f 640 echo _("Sorry, cannot open.");
38299f63
MM
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
651function dump_qa($plain)
652{
653 global $url, $idx, $qa_addr;
c8c26d5e 654
38299f63
MM
655 $a = $qa_addr[$idx];
656
657 $f = get_qa();
c8c26d5e 658
2a73daad
MM
659 if ($plain) {
660 header("Content-type: text/plain");
d304116f 661 echo _("# rpm -qa of")." $a\n";
2a73daad 662 } else {
d304116f 663 echo "<h1>"._("rpm -qa of")." $a</h1>";
664 echo "<a href=\"$url?idx=$idx&action=qatxt\">"._("text/plain version")."</a>";
2a73daad
MM
665 start_pre();
666 }
667
38299f63 668 if ($f == 0) {
d304116f 669 echo _("Sorry, cannot open.");
b018fce6 670 } else {
38299f63
MM
671 while (($s = fgets($f, 1000)) != false) {
672 echo $s;
673 }
2a73daad 674 }
c8c26d5e 675
2a73daad
MM
676 if (!$plain)
677 end_pre();
678}
679
58c74097 680
681function 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
2a73daad
MM
913function welcome()
914{
915?>
916<table border=0 width=100%><tr><td width=20%>&nbsp;</td><td>
d304116f 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 ")?>
ca0f7067 920<!-- ech... niech strace... -->
58c74097 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>
d304116f 923<p>Version: $Id: index.php,v 1.24 2002/10/07 11:04:22 ggodlewski Exp $</p>
2a73daad
MM
924</td><td width=20%>&nbsp;</td></tr>
925</table>
926<?php
927}
928
929header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
930header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
931header("Cache-Control: no-cache, must-revalidate");
932header("Pragma: no-cache");
933
934//phpinfo();
e86d1be4 935if ($local) {
936 if ($action == "text") {
c8c26d5e 937 dump_text();
58c74097 938 } else if ($action == "adv_search") {
939 myheader();
940 adv_search();
941 trailer();
e86d1be4 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);
38299f63
MM
952 else if ($action == "sqa")
953 search_qa();
e86d1be4 954 else if (isset($id))
c8c26d5e 955 dump_log($action == "tail");
e86d1be4 956 else if (isset($idx))
c8c26d5e 957 list_logs();
e86d1be4 958 else
959 welcome();
51aa6406 960 echo "</td></tr></table>";
e86d1be4 961 trailer();
962 }
963}
964else {
2a73daad 965
e86d1be4 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();
51aa6406 984 echo "</td></tr></table>";
e86d1be4 985 trailer();
986 }
2a73daad
MM
987}
988?>
This page took 0.311758 seconds and 4 git commands to generate.