]> git.pld-linux.org Git - projects/buildlogs.git/blame - obsolete/buildlogs/index.php
missing space
[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{
d0e7c65a
AF
80echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
81echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
2a73daad
MM
82?>
83<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
84 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
85<html xmlns="http://www.w3.org/1999/xhtml">
86 <head>
87 <title>PLD Build Logs</title>
f3eff925 88 <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
89 <style type="text/css"><!--
2a73daad
MM
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{
fca9b4c4 115 echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
2a73daad
MM
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
f3eff925 163 $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;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
f3eff925 218 $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;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 "
3fe241e6 248 ."(<a href=\"$big_url&amp;ok=0\">"._("fail")."</a>)</h1>\n";
2a73daad 249 } else {
d304116f 250 echo "<h1>"._("Listing of")." $addr[$idx]/FAIL "
3fe241e6 251 ."(<a href=\"$big_url&amp;ok=1\">"._("ok")."</a>)</h1>\n";
2a73daad 252 }
c8c26d5e 253
3048cac7 254 echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
fca9b4c4 255 "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
3fe241e6 256 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
9beed3cc 257 "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
f3eff925 258 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
9beed3cc 259 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
fca9b4c4 260 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
f3eff925 261 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
3048cac7 262 "</tr>";
2a73daad 263
c8c26d5e 264 function cmp($f1, $f2) {
265 global $ftp_conn, $root_directory, $local;
266 if ($local)
267 return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
2a73daad
MM
268 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
269 }
270
271 if ($ns != 1) {
272 $ns = 0;
273 usort($list, cmp);
ca0f7067
MM
274 } else {
275 sort($list);
2a73daad 276 }
c8c26d5e 277
2a73daad 278 $now = time();
ca0f7067
MM
279 for ($i = $off; $i < $cnt + $off; $i++) {
280 if (!isset($list[$i]))
281 continue;
2a73daad
MM
282 $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
283 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
284 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
c8c26d5e 285 if ($local) {
286 $s = filesize("$root_directory$list[$i]");
287 $t = $now - filemtime("$root_directory$list[$i]");
2a73daad 288 } else {
c8c26d5e 289 $s = ftp_size($ftp_conn, $list[$i]);
290 $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
2a73daad 291 }
e86d1be4 292 $t /= 60;
293 if ($t >= 60) {
294 $t /= 60;
295 if ($t >= 24) {
296 $t /= 24;
8abba06f 297 $t = round($t);
d304116f 298 $t = $t . ngettext(" day"," days",$t);
e86d1be4 299 } else {
8abba06f 300 $t = round($t);
d304116f 301 $t = $t . ngettext(" hour"," hours",$t);
e86d1be4 302 }
303 } else {
8abba06f 304 $t = round($t);
d304116f 305 $t = $t . ngettext(" minute"," minutes",$t);
e86d1be4 306 }
f3eff925 307 $u = "$big_url&amp;off=$off&amp;id=$h";
1ded5d5e 308 echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
9beed3cc 309 "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
f3eff925 310 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
311 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
fca9b4c4
AF
312 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
313 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
e86d1be4 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
fca9b4c4 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;
f3eff925 328 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
fca9b4c4 329 echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
e86d1be4 330 } else {
fca9b4c4 331 echo "$backarr</td><td align=\"left\">$back";
e86d1be4 332 }
f93aa6bf 333
fca9b4c4 334 echo "</td>\n<td align=\"center\">";
f93aa6bf 335
bb3ae015 336 if ($qa_addr[$idx] != "") {
f3eff925 337 echo "[<a href=\"$big_url&amp;action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
f93aa6bf 338 } else {
339 echo "&nbsp;";
c8c26d5e 340 }
341
f3eff925 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;
f3eff925 347 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
348 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
e86d1be4 349 } else {
f3eff925 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
fca9b4c4 409 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">";
2a73daad
MM
410
411 function one_item($h, $t) {
fca9b4c4
AF
412 echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
413 "<td bgcolor=\"#cccccc\">$t</td></tr>";
2a73daad
MM
414 }
415
416 function href($h, $c) {
417 return "<a href=\"$h\">$c</a>";
418 }
c8c26d5e 419
58c74097 420 one_item(_("Status"), ($ok == 1 ?
f3eff925 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
f3eff925 427 $bu = "$big_url&amp;off=$off";
c8c26d5e 428
58c74097 429 one_item(_("text/plain URL"),
f3eff925 430 href("$bu&amp;id=$id&amp;action=text",
58c74097 431 _("View!")));
ca0f7067 432 if ($tail) {
58c74097 433 one_item(_("full text"),
f3eff925 434 href("$bu&amp;id=$id",
ca0f7067
MM
435 "View!"));
436 }
f93aa6bf 437
d381dfdf 438 if ($qa_addr[$idx] != "") {
f3eff925 439 one_item(_("rpm -qa of builder"), href("$bu&amp;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>" .
f3eff925 450 "<a href=\"$url?idx=$idx&amp;ok=$ok&amp;id=$id\">".
2a73daad 451 "http://" . getenv("SERVER_NAME") .
f3eff925 452 getenv("SCRIPT_NAME") . "?idx=$idx&amp;ok=$ok&amp;id=$id</a>" .
2a73daad
MM
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?>
fca9b4c4 491 <table width="100%">
e86d1be4 492 <tr>
f3eff925 493 <td align=left>
d304116f 494 [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
e86d1be4 495 </td>
f3eff925 496 <td align=right>
497 [<a href="<?php echo "$bu&amp;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{
398665bf 551 global $addr, $url, $idx, $cnt;
552
553 if (!isset($cnt))
554 $cnt = 16;
2a73daad 555
f3eff925 556 $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
d304116f 557
fca9b4c4 558 echo "<table width=\"100%\" border=\"0\">\n";
6d9948a2 559 echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
2a73daad 560 for ($i = 0; $i < count($addr); $i++)
fca9b4c4 561 echo "<tr><td nowrap=\"nowrap\">".
43ab2a23 562 "<a href=\"$url?idx=$i&amp;ok=0&amp;cnt=$cnt\">$addr[$i]</a></td><td nowrap=\"nowrap\">".
563 "[<a href=\"$url?idx=$i&amp;ok=1&amp;cnt=$cnt\">OK</a>]</td>".
f3eff925 564 #"<td>[<a href=\"$url?idx=$i&amp;action=qa\">qa</a>]</td>".
2a73daad
MM
565 "</tr>\n";
566 echo "</table><hr />\n";
58c74097 567
568 echo "<div align=\"center\">";
f3eff925 569 echo "<a href=\"$big_url&amp;action=adv_search\">"._("Advanced Search")."</a><br />\n";
58c74097 570
571 echo "<a href=\"$url\">main()</a><hr />\n";
f3eff925 572 echo "<a href=\"http://www.pld.org.pl/\"><img src=\"powpld.png\" ".
573 "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
2a73daad
MM
574 "<small>(c) 2002 ".
575 "<a href=\"mailto:feedback@pld.org.pl\">PLD&nbsp;Team</a>\n".
576 "</small></div>\n";
c8c26d5e 577
2a73daad 578 # smile ;)
fca9b4c4 579 echo "<div align=\"center\"><small>";
2a73daad 580 $pow = array("vim", "php", "brain", "power", "electricity",
51aa6406 581 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
2a73daad
MM
582 "voodoo magic", "Linux", "x-files", "X", "foobar",
583 "/dev/null", "/dev/zero", "/dev/drzewo",
584 "Leppe'", "matrix", "Neo", "PDP-11",
585 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
51aa6406 586 "foobarbaz", "ed", "Joe", "Unix conspiracy",
2a73daad
MM
587 "overclock", "The Right Thing",
588 "The Bad Thing", "Star Treck", "NSA", "NASA",
589 "achelon", "VAX", "Real Programmer",
590 "Real Operating System", "Real Computer",
591 "computron", "bogon", "quantum bogodynamics",
e86d1be4 592 "BOFH", "/dev/ill", "nasi tu byli",
3048cac7 593 "Paranoid Android", "Lunatic Corp", "Parallel thinking"
2a73daad
MM
594 # feel free to add sth if you change this file ;)
595 );
d304116f 596 echo _("Powered by")." ";
2a73daad
MM
597 $max = 1;
598 for ($i = 0; $i < $max; $i++) {
599 $x = rand(0, count($pow) - 1);
600 if ($pow[$x] == "") $i--;
601 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
602 $pow[$x] = "";
603 }
2a73daad 604 echo "</small></div>";
c8c26d5e 605
38299f63
MM
606 global $qa_addr;
607
608 if ($qa_addr[$idx] != "") {
609 echo "<form action=\"index.php\" method=\"post\">";
f3eff925 610 echo "<input type=hidden name=idx value=$idx />";
611 echo "<input type=hidden name=action value=sqa />";
612 echo "<input type=text size=14 name=str /><br />";
613 echo "<input type=submit name=submit value=\""._("Search rpmqa!")."\" />";
38299f63
MM
614 echo "</form>";
615 }
2a73daad
MM
616}
617
38299f63 618function get_qa()
2a73daad 619{
38299f63 620 global $idx, $qa_addr, $qa_base;
c8c26d5e 621
b018fce6 622 if (!isset($idx) || !isset($qa_addr[$idx]))
2a73daad
MM
623 return false;
624
b018fce6 625 $a = $qa_addr[$idx];
c8c26d5e 626
38299f63
MM
627 if ($qa_addr[$idx] == "")
628 return false;
629 else
630 return fopen("$qa_base$qa_addr[$idx]", "r");
631}
632
633function search_qa()
634{
635 global $url, $idx, $qa_addr, $str;
636
637 $f = get_qa();
d304116f 638 echo "<h1>"._("Search results for")." '$str' "._("in")." $qa_addr[$idx]</h1>";
38299f63
MM
639
640 start_pre();
641
642 if ($f == 0) {
d304116f 643 echo _("Sorry, cannot open.");
38299f63
MM
644 } else {
645 while (($s = fgets($f, 1000)) != false) {
646 if (stristr($s, $str))
647 echo $s;
648 }
649 echo "/* EOF */";
650 }
651 end_pre();
652}
653
654function dump_qa($plain)
655{
656 global $url, $idx, $qa_addr;
c8c26d5e 657
38299f63
MM
658 $a = $qa_addr[$idx];
659
660 $f = get_qa();
c8c26d5e 661
2a73daad
MM
662 if ($plain) {
663 header("Content-type: text/plain");
d304116f 664 echo _("# rpm -qa of")." $a\n";
2a73daad 665 } else {
d304116f 666 echo "<h1>"._("rpm -qa of")." $a</h1>";
f3eff925 667 echo "<a href=\"$url?idx=$idx&amp;action=qatxt\">"._("text/plain version")."</a>";
2a73daad
MM
668 start_pre();
669 }
670
38299f63 671 if ($f == 0) {
d304116f 672 echo _("Sorry, cannot open.");
b018fce6 673 } else {
38299f63
MM
674 while (($s = fgets($f, 1000)) != false) {
675 echo $s;
676 }
2a73daad 677 }
c8c26d5e 678
2a73daad
MM
679 if (!$plain)
680 end_pre();
681}
682
58c74097 683
684function adv_search()
685{
e8aab146 686 global $addr, $url, $local, $_POST, $off, $cnt, $root_directory;
58c74097 687
f3eff925 688 $big_url = "$url?idx=$idx&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
58c74097 689
690 echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
691
fca9b4c4
AF
692 echo "<div align=\"center\">";
693 echo "<table border=\"0\">\n";
58c74097 694 echo "<tr>\n";
695 echo "<td>"._("Package name")."</td>\n";
696 echo "<td><input type=\"text\" size=\"20\" name=\"name\" value=\"".$_POST[name]."\"/></td>\n";
697 echo "</tr>\n";
698
699 echo "<tr>\n";
700 echo "<td>"._("Days")."</td>\n";
701 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"".$_POST["age1"]."\" /></td>\n";
702 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"".$_POST["age2"]."\" /></td>\n";
703 echo "</tr>\n";
704
705 echo "<tr>\n";
706 echo "<td>"._("Size")."</td>\n";
707 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"".$_POST["size1"]."\" /></td>\n";
708 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"".$_POST["size2"]."\" /></td>\n";
709 echo "</tr>\n";
710
711 echo "<tr>\n";
712 echo "<td>"._("Search logs:")."</td>\n";
713 echo "</tr>\n";
714
715 echo "<tr>\n";
58c74097 716 echo "<td>"._("Failed")."</td>\n";
0e70bcd4 717 echo "<td>"._("OK")."</td>\n";
58c74097 718 echo "</tr>\n";
719
720 for ($i = 0; $i < count($addr); $i++)
721 {
722 echo "<tr>\n";
723 $name="as0_".$i;
f3eff925 724 $check=" checked=\"on\"";
725 echo "<td><input name=$name type=\"checkbox\"$check>".$addr[$i]."</input></td>\n";
58c74097 726 $name="as1_".$i;
f3eff925 727 $check=" checked=\"on\"";
728 echo "<td><input name=$name type=\"checkbox\"$check>".$addr[$i]."</input></td>\n";
58c74097 729 echo "</tr>\n";
730 }
731
732 echo "<tr>\n";
f3eff925 733 echo "<td><input type=submit name=submit value=\""._("Search!")."\" /></td>";
58c74097 734 echo "</tr>\n";
735
736 echo "</table>\n";
737
738// if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
739// isset($_POST["size1"]) || isset($_POST["size2"]))
740 if (($_POST["name"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
741 ($_POST["size1"]!="") || ($_POST["size2"]!=""))
742 {
743 unset($list);
744 $now = time();
745 for ($i = 0; $i < count($addr); $i++)
746
747 for ($j=0;$j<2;$j++)
748 {
749 unset($tmp_list);
750 if (isset($_POST["as".$j."_".$i]))
751 {
752 if ($local) {
753 $tmp_list = directory_list($i,$j);
754 } else {
755 $tmp_list = open_ftp($i,$j);
756 }
757 if (is_array($tmp_list))
758 {
759 while (list($k,$name)=each($tmp_list))
760 {
761 $s = filesize("$root_directory$name");
762 $t = $now - filemtime("$root_directory$name");
763 $t/=(24*3600);
764 if (($_POST["name"]!="") && (!preg_match("/".$_POST["name"]."/i",$name)))continue;
765 if (($_POST["age1"]) && ($_POST["age1"]>$t))continue;
766 if (($_POST["age2"]) && ($_POST["age2"]<$t))continue;
767
768 if (($_POST["size1"]) && ($_POST["size1"]>$s))continue;
769 if (($_POST["size2"]) && ($_POST["size2"]<$s))continue;
770
771 $list[$i."_".$j."_".$k]=$name;
772 }
773 }
774 }
775 }
776
777 if (sizeof($list)==0)
778 {
779 echo _("Nothing found");
ecba143e 780 } else
781 {
58c74097 782
fca9b4c4 783 echo "<table border=\"0\" cellspacing=\"1\" ".
f3eff925 784 "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
fca9b4c4 785 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
f3eff925 786 "[<a href=\"$big_url&amp;ns=2\">"._("sort")."</a>]</th>";
fca9b4c4 787 echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
f3eff925 788 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
fca9b4c4
AF
789 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
790 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
f3eff925 791 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
58c74097 792 "</th></tr>";
793
794 function cmp1($f1, $f2) {
795 global $ftp_conn, $root_directory, $local;
796 if ($local)
797 return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
798 return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $f1);
799 }
800
801 function cmp2($f1, $f2) {
802 list($p11,$p12,$p13)=explode("_",$f1);
803 list($p21,$p22,$p23)=explode("_",$f2);
804 return strcmp($f2,$f1);
805 }
806
807 if ($ns == 1)
808 {
809 usort($list, "cmp1");
810// } else if ($ns == 2)
811// {
812// uksort($list, "cmp2");
813 } else
814 {
815 asort($list);
816 }
817
818 $counter=0;
819 while (list($k,$name)=each($list))
820 {
821 if (($counter<$off) || ($counter>$off+$cnt-1))
822 {
823 $counter++;
824 continue;
825 }
826
827 $counter++;
828 list($i,$j,$k)=explode("_",$k);
829
830 $h = bin2hex(mhash(MHASH_MD5, $name));
831 $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $name);
832 $f = preg_replace("/\.(bz2|gz)$/", "", $f);
833 if ($local) {
834 $s = filesize("$root_directory$name");
835 $t = $now - filemtime("$root_directory$name");
836 } else {
837 $s = ftp_size($ftp_conn, $list[$i]);
838 $t = $now - ftp_mdtm($ftp_conn, $list[$i]);
839 }
840 $t /= 60;
841 if ($t >= 60) {
842 $t /= 60;
843 if ($t >= 24) {
844 $t /= 24;
845 $t = round($t);
846 $t = $t . ngettext(" day"," days",$t);
847 } else {
848 $t = round($t);
849 $t = $t . ngettext(" hour"," hours",$t);
850 }
851 } else {
852 $t = round($t);
853 $t = $t . ngettext(" minute"," minutes",$t);
854 }
f3eff925 855 $big_url = "$url?idx=$i&amp;ok=$j&amp;ns=$ns&amp;cnt=$cnt";
856 $u = "$big_url&amp;off=$off&amp;id=$h";
ecba143e 857
f0f4086d 858 $builder=$addr[$i]."/".(($j=="1")?"OK":"FAIL");
58c74097 859 echo "<tr>";
f3eff925 860 echo "<td bgcolor=#CCCCCC><a href=\"$u\">$builder</a></td>";
861 echo "<td bgcolor=#CCCCCC><a href=\"$u\">$f</a> ".
862 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
863 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
864 "</td><td bgcolor=#CCCCCC align=right>".
865 "$s</td><td bgcolor=#CCCCCC>$t</td></tr>\n";
58c74097 866 }
867 echo "</table></div>\n";
868
869 $backarr = "&lt;&lt;&lt;&nbsp;";
870 $back = _("Page back");
871 $forward = _("Page forward");
872 $forwardarr = "&nbsp;&gt;&gt;&gt;";
873
874// FIXME
875/*
f3eff925 876 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
58c74097 877
878 if ($off > 0) {
879 $noff = $off - $cnt;
880 if ($noff < 0)
881 $noff = 0;
f3eff925 882 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
58c74097 883 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
884 } else {
885 echo "$backarr</td><td align=left>$back";
886 }
887
f3eff925 888 echo "</td>\n<td align=\"center\">";
889 echo "</td>\n<td align=\"right\">";
58c74097 890
891 if ($off + $cnt < count($list))
892 {
893 $noff = $off + $cnt;
894 if ($noff < 0)
895 $noff = 0;
f3eff925 896 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
897 echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>";
58c74097 898 }
899 else
900 {
f3eff925 901 echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr";
58c74097 902 }
903
904 echo "</td>\n</tr></table></p>";
905*/
ecba143e 906 }
58c74097 907 if ($local == 0)
908 {
909 ftp_quit($ftp_conn);
910 $ftp_conn = 0;
911 }
912 } else
913 {
914 echo _("Enter something!");
915 }
916 echo "</form>\n";
917}
918
2a73daad
MM
919function welcome()
920{
921?>
f3eff925 922<table border="0" width="100%"><tr><td width="20%">&nbsp;</td><td>
d304116f 923<h1><?=_("Welcome!")?></h1>
924<p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
925<?=_("Feel free to email bug reports, complaints and feature requests ")?>
ca0f7067 926<!-- ech... niech strace... -->
58c74097 927<a href="mailto:feedback@pld.org.pl"><?=_("to us")?></a>. <?=_("Positive opinions are also")?>
928<a href="mailto:feedback@pld.org.pl"><?=_("welcome")?></a> ;)</p>
3fe241e6 929<p>Version: $Id: index.php,v 1.48 2002/10/12 20:50:04 ankry Exp $</p>
f3eff925 930</td><td width="20%">&nbsp;</td></tr>
2a73daad
MM
931</table>
932<?php
933}
934
935header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
936header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
937header("Cache-Control: no-cache, must-revalidate");
938header("Pragma: no-cache");
939
940//phpinfo();
e86d1be4 941if ($local) {
942 if ($action == "text") {
c8c26d5e 943 dump_text();
58c74097 944 } else if ($action == "adv_search") {
945 myheader();
946 adv_search();
947 trailer();
e86d1be4 948 } else if ($action == "qatxt") {
949 dump_qa(1);
950 } else {
951 myheader();
fca9b4c4 952 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
e86d1be4 953 list_archs();
fca9b4c4 954 echo "</td><td valign=\"top\">";
e86d1be4 955 flush();
956 if ($action == "qa")
957 dump_qa(0);
38299f63
MM
958 else if ($action == "sqa")
959 search_qa();
e86d1be4 960 else if (isset($id))
c8c26d5e 961 dump_log($action == "tail");
e86d1be4 962 else if (isset($idx))
c8c26d5e 963 list_logs();
e86d1be4 964 else
965 welcome();
51aa6406 966 echo "</td></tr></table>";
e86d1be4 967 trailer();
968 }
969}
970else {
2a73daad 971
e86d1be4 972 if ($action == "text") {
973 dump_text();
974 } else if ($action == "qatxt") {
975 dump_qa(1);
976 } else {
977 myheader();
f3eff925 978 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=top width=\"10%\">";
e86d1be4 979 list_archs();
fca9b4c4 980 echo "</td><td valign=\"top\">";
e86d1be4 981 flush();
982 if ($action == "qa")
983 dump_qa(0);
984 else if (isset($id))
985 dump_log($action == "tail");
986 else if (isset($idx))
987 list_logs();
988 else
989 welcome();
51aa6406 990 echo "</td></tr></table>";
e86d1be4 991 trailer();
992 }
2a73daad
MM
993}
994?>
This page took 0.214433 seconds and 4 git commands to generate.