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