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