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