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