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