]> git.pld-linux.org Git - projects/buildlogs.git/blame - index.php
Catch errors like: make[2]: *** No rule to make target '/usr/lib64/libhdf5.so.1.8...
[projects/buildlogs.git] / index.php
CommitLineData
a7f1713c 1<?php
aa0c7f70
AM
2if (!function_exists("ob_gzhandler"))
3 die("ob_gzhandler function is missing - install php zlib module");
4
a7f1713c 5ob_start("ob_gzhandler", 1);
6$buildlogs_server = "buildlogs.pld-linux.org";
a6cc6dd6 7$url = "index.php";
a7f1713c 8$fail_or_ok = array( "FAIL", "OK" );
9/*
9dcdc6b4 10$database = 'sqlite:/home/services/ftp/buildlogs2.db';
a7f1713c 11$root_directory = "/home/services/ftp/pub/pld-buildlogs";
12*/
13
14// $database, $root_directory and others are taken from buildlogs.inc
f27dac56 15include('buildlogs.inc');
a7f1713c 16
17/* It should be set */
18
19$langs["en_US"]["charset"]="ISO-8859-1";
20$langs["pl_PL"]["charset"]="ISO-8859-2";
21
22$lang="en_US";
aa0c7f70 23$lang_detected="";
a7f1713c 24if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
25{
26 $rows=explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
27 $rows=explode(",",$rows[0]);
28 $lang_detected=rtrim($rows[0]);
29} else if (preg_match("/opera/i",$_SERVER["HTTP_USER_AGENT"]))
30{
31 $lang_detected=preg_replace("/.*\[(.*)\].*/i","\\1",$_SERVER["HTTP_USER_AGENT"]);
32}
33
34// FIXME - some array
35$lang_detected=preg_replace("/^pl$/i","pl_PL",$lang_detected);
36
37if (isset($lang_detected) && isset($langs[$lang_detected]))
38{
39 $lang=$lang_detected;
40}
41
42if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"];
43if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"];
44
45putenv("LANG=$lang");
46setlocale(LC_ALL,$lang);
47bindtextdomain("messages","locale");
48textdomain("messages");
49
50if (isset($_GET["dist"]) && isset($_GET["arch"]))
51{
52 $dist = basename($_GET["dist"]);
53 $arch = basename($_GET["arch"]);
54}
55
56if (isset($_POST["dist"])) $dist = basename($_POST["dist"]);
57if (isset($_POST["arch"])) $arch = basename($_POST["arch"]);
58
59if (isset($_GET["name"])) {
8f0e31ba 60 $name_url = urlencode($_GET["name"]);
a7f1713c 61 $name = basename($_GET["name"]);
62}
63if (isset($_GET["ok"]))$ok=(int)$_GET["ok"];
64else $ok="";
65if (isset($_GET["ns"]))$ns=(int)$_GET["ns"];
66else $ns="";
67if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"];
68else $cnt = 50;
69if (isset($_GET["action"]))$action=$_GET["action"];
70else $action="";
71if (isset($_GET["off"]))$off=(int)$_GET["off"];
72else $off = 0;
73if (isset($_GET["id"]))$id=$_GET["id"];
74
75if (isset($_POST["str"]))$str=$_POST["str"];
76if (isset($_POST["action"]))$action=$_POST["action"];
77
48071668 78if (isset($arch) && $arch == "src")
dbb4d4ae
AM
79 $arch = "SRPMS";
80
a7f1713c 81function myheader()
82{
83echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
84echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
85?>
86<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
87 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88<html xmlns="http://www.w3.org/1999/xhtml">
89 <head>
90 <title>PLD Build Logs</title>
91 <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
92 <style type="text/css"><!--
93A { text-decoration: none; }
94A:hover { text-decoration: underline; }
2ba2cc91
ER
95H1 { font-family: arial,helvetica,sans-serif;
96 font-size: 20pt;
a7f1713c 97 font-weight: bold;}
2ba2cc91
ER
98H2 { font-family: arial,helvetica,sans-serif;
99 font-size: 18pt;
a7f1713c 100 font-weight: bold;}
2ba2cc91 101BODY,TD { font-family: arial,helvetica,sans-serif;
a7f1713c 102 font-size: 13pt; }
2ba2cc91
ER
103TH { font-family: arial,helvetica,sans-serif;
104 font-size: 13pt;
a7f1713c 105 font-weight: bold; }
2ba2cc91
ER
106/* error lines from build logs */
107.error {
108 background-color: #b00;
109}
e926de50
ER
110.verbose {
111 color: #886;
112}
113.section {
114 color: #111;
115 background-color: #161;
116}
d9365f95
ER
117.changelog a {
118 color: #fff;
119}
a7f1713c 120//-->
121</style>
122 </head>
123 <!-- Diffrent color for visited link doesn't make much sense here...
124 this page is autogenerated and it might be misleading after some
125 build log changes. -->
126 <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
127<?php
128}
129
130function start_pre()
131{
132 echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
05eb5093 133 "<font color=\"#cccccc\"><pre style=\"white-space: pre-line; word-break: break-all;\">";
a7f1713c 134}
135
136function end_pre()
137{
138 echo "</pre></font></td></tr></table>\n";
139}
140
141function trailer()
142{
143 echo "</body></html>";
144}
145
146
147function mydie($msg)
148{
149 echo "Fatal error: $msg";
150}
151
152
153
154function list_logs()
155{
156 global $database;
157 global $arch, $dist, $ok;
158 global $big_url, $ns;
159 global $off, $cnt, $root_directory, $url;
160
161 $big_url = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
162
163 if ($ok == 1) {
164 echo "<h1>"._("Listing of")." $dist/$arch/OK "
165 ."(<a href=\"$big_url&amp;ok=0\">"._("fail")."</a>)</h1>\n";
166 } else {
167 echo "<h1>"._("Listing of")." $dist/$arch/FAIL "
168 ."(<a href=\"$big_url&amp;ok=1\">"._("ok")."</a>)</h1>\n";
169 }
170
171 echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
172 "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
173 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
174 "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File").
175 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
176 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
177 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
178 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
179 "</tr>";
180
181 if ($ns != 1) $ns = 0;
182 if (!isset($ok)) $ok = 0;
183// if (!isset($off)) $off = 0;
184// if (!isset($cnt)) $cnt = 50;
185 if ($ns == 0) $order = "mtime DESC";
186 else $order = "name";
187
188 $query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE "
189 . "dist = '$dist' AND arch = '$arch' AND ok = $ok ORDER BY $order LIMIT $cnt OFFSET $off";
190
191 try {
192 $dbh = new PDO("$database");
193 } catch (PDOException $e) {
194 mydie("new PDO: " . $e->getMessage());
195 }
196 $now = time();
197 $i = $off;
198 foreach ($dbh->query("$query") as $row) {
8f0e31ba 199 $name = $row["name"];
200 $id = $row["id"];
201 $dist = $row["dist"];
202 $arch = $row["arch"];
203 $f = $name;
204 $name_url = urlencode($name);
a7f1713c 205 $t = $now - $row["mtime"];
206 $s = $row["size"];
207 $h = $row["log_id"];
208
209 $t /= 60;
210 if ($t >= 60) {
211 $t /= 60;
212 if ($t >= 24) {
213 $t /= 24;
214 $t = round($t);
215 $t = $t . "&nbsp;" . ngettext("day","days",$t);
216 } else {
217 $t = round($t);
218 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
219 }
220 } else {
221 $t = round($t);
222 $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
223 }
8f0e31ba 224 $u = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;name=$name_url&amp;id=$id";
a7f1713c 225 echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
226 "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
227 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
228 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
229 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
230 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
231 $i++;
232 }
233 $count = $i - $off;
234 echo "</table></div>\n";
235
236 $backarr = "&lt;&lt;&lt;&nbsp;";
237 $back = _("Page back");
238 $forward = _("Page forward");
239 $forwardarr = "&nbsp;&gt;&gt;&gt;";
240
241 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">";
242
243 if ($off > 0) {
244 $noff = $off - $count;
245 if ($noff < 0)
246 $noff = 0;
247 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
248 echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
249 } else {
250 echo "$backarr</td><td align=\"left\">$back";
251 }
252
253 echo "</td>\n<td align=\"center\">";
254
255 if (isset($dist) && isset($arch)) {
256 echo "[<a href=\"$big_url&amp;action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
257 } else {
258 echo "&nbsp;";
259 }
260
261 echo "</td>\n<td align=right>";
262 if ($cnt == $count) {
263 $noff = $off + $cnt;
264 if ($noff < 0)
265 $noff = 0;
266 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
267 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
268 } else {
269 echo "$forward</td><td align=right width=1%>$forwardarr";
270 }
271 echo "</td>\n</tr></table></p>";
272}
273
274function file_name()
275{
8f0e31ba 276 global $ok, $dist, $arch, $name, $name_url, $id;
a7f1713c 277
278 if (isset($name) && isset($ok) && isset($arch) && isset($dist)) {
279 if (isset($id) && $id != '') {
280 $name = $name . ",$id";
281 }
282 $w = $ok ? "OK" : "FAIL";
283 return "$dist/$arch/$w/$name.bz2";
284 }
285}
286
2454d41c
AM
287function get_filter($f)
288{
289 if (preg_match("/\.bz2$/", $f)) {
290 if (is_executable("/usr/bin/lbzcat"))
291 $filter = "lbzcat";
292 else
293 $filter = "bzcat";
294 } elseif (preg_match("/\.gz$/", $f)) {
295 $filter = "zcat";
296 } else {
297 $filter = "cat";
298 }
299 return $filter;
300}
301
a7f1713c 302function dump_log($tail)
303{
8f0e31ba 304 global $ok, $url, $dist, $arch, $name, $name_url;
a7f1713c 305 global $root_directory, $big_url, $ns, $id, $cnt, $off;
306 global $buildlogs_server;
307
308 $f = file_name();
309
310 if ($f == false)
311 return;
312
313 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
314 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
2865efbd 315 list($name, $id) = explode(',', $df);
a7f1713c 316
2865efbd
ER
317 if ($name != 'command') {
318 $gitweb_url = "http://git.pld-linux.org/?p=packages/$name.git;a=summary";
319 $name = "<a href=\"$gitweb_url\">$name</a>";
320 }
321 echo "<h1>$name <small>$id</small></h1>";
a7f1713c 322
d9365f95 323 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\" width=\"100%\">";
a7f1713c 324
325 function one_item($h, $t) {
326 echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
327 "<td bgcolor=\"#cccccc\">$t</td></tr>";
328 }
329
330 function href($h, $c) {
331 return "<a href=\"$h\">$c</a>";
332 }
333
2ba2cc91
ER
334 one_item(_("Status"), ($ok == 1 ?
335 "<font color=\"green\"><b>"._("OK")."</b></font>" :
a7f1713c 336 "<font color=\"red\"><b>"._("Failed")."</b></a>"));
2ba2cc91
ER
337 one_item(_("Source URL"),
338 href("ftp://$buildlogs_server/$f",
a7f1713c 339 "ftp://$buildlogs_server/$f"));
340
341 $big_url = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
342 $bu = "$big_url&amp;off=$off";
343
2ba2cc91 344 one_item(_("text/plain URL"),
8f0e31ba 345 href("$bu&amp;name=$name_url&amp;id=$id&amp;action=text",
a7f1713c 346 _("View!")));
347 if ($tail) {
2ba2cc91 348 one_item(_("full text"),
8f0e31ba 349 href("$bu&amp;name=$name_url&amp;id=$id",
a7f1713c 350 _("View!")));
351 }
352
353 if (isset($dist) && isset($arch)) {
354 one_item(_("rpm -qa of builder"), href("$bu&amp;action=qa", _("View!")));
355 } else {
356 one_item(_("rpm -qa of builder"), _("Not available"));
357 }
35a4c15e 358 one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory/$f")));
a7f1713c 359 /*
2ba2cc91 360 echo "<tr><td>Here:</td><td>" .
a7f1713c 361 "<a href=\"$url?idx=$idx&amp;ok=$ok&amp;id=$id\">".
362 "http://" . getenv("SERVER_NAME") .
363 getenv("SCRIPT_NAME") . "?idx=$idx&amp;ok=$ok&amp;id=$id</a>" .
364 "</td></tr>"; */
365
a7f1713c 366
367
368 # what can I say beside PHP suxx? how the fuck should I create
369 # bidirectional pipe? gotta use wget
370
2454d41c 371 $filter = get_filter($f);
a7f1713c 372
8f0e31ba 373 $cmd = "$filter '$root_directory/$f'";
a7f1713c 374 $fd = popen($cmd, "r");
e926de50 375 $toc = array();
e69f53b7 376 $err = array();
4a2b3f54
AM
377 $first_cut = false;
378 $first_cut_done = false;
b530f30e 379 $time = "";
e69f53b7 380 $out_buf = array();
77aded7c 381 $out_buf_size = 0;
aa0c7f70 382 $err_count = 0;
a7f1713c 383 while (($s = fgets($fd, 102400)) != false) {
015d7b6a 384
e69f53b7
AM
385 $toc_elem = false;
386 $err_elem = false;
387
a7f1713c 388 $s = htmlspecialchars($s);
2ba2cc91 389 // highlight errors
1c26089b 390 if (preg_match("/(?:fail|error(s|\sCS\d+)?):/i", $s)) {
4a2b3f54 391 $first_cut = true;
283f4590 392 $err_count++;
e69f53b7
AM
393 $toc_elem = "error $err_count";
394 $err_elem = $s;
395 $s = "<span class=error id=error-$err_count>$s</span>";
a79bc71c 396 } elseif (preg_match("/(?:undefined reference to|recipe for target '.*?' failed|make\[.*:.* Stop\.$)/i", $s)) {
4a2b3f54 397 $first_cut = true;
e69f53b7
AM
398 $err_count++;
399 $toc_elem = "error $err_count";
400 $err_elem = $s;
98e99288 401 $s = "<span class=error id=error-$err_count>$s</span>";
1c26089b
ER
402 } elseif (preg_match("#^\+ /usr/bin/make\b.*\b(?P<target>check)\b#", $s, $m)) {
403 // rpm build section
e69f53b7
AM
404 $toc_elem = "make {$m['target']}";
405 $err_elem = $s;
1c26089b 406 $s = "<span class=line id=make-{$m['target']}>$s</span>";
d9365f95
ER
407 } elseif (preg_match('/^(?P<line>- For complete changelog see:) (?P<link>.+)$/', $s, $m)) {
408 // rpm changelog link
409 $link = "<a href=\"{$m['link']}\">{$m['link']}</a>";
410 $s = "<span class=changelog>{$m['line']} $link<br/></span>";
411 } elseif (preg_match('/^(?P<line>\* \w{3} \w{3} [ \d]{2} \d{4} .*?) (?P<hash>[a-z0-9]{7})$/', $s, $m)) {
412 // rpm changelogs
413 $url = "http://git.pld-linux.org/?p=packages/{$name_url}.git;a=commitdiff;h={$m['hash']}";
414 $link = "<a href=\"$url\">{$m['hash']}</a>";
415 $s = "<span class=changelog>{$m['line']} $link<br/></span>";
e926de50
ER
416 } elseif (substr($s, 0, 2) == "+ ") {
417 // shell verbose
418 $s = "<span class=verbose>$s</span>";
419 } elseif (preg_match("/^Executing\(%(?P<section>\w+)\)/", $s, $m)) {
420 // rpm build section
e69f53b7
AM
421 $toc_elem = $m['section'];
422 $err_elem = $s;
98e99288 423 $s = "<span class=section id={$m['section']}>$s</span>";
901abf2c 424 } elseif (preg_match("/^Processing files: (?P<pkg>(?P<name>.+)-[^-]+-[^-]+)/", $s, $m)) {
4a2b3f54 425 $first_cut = true;
901abf2c 426 // processing files
e69f53b7
AM
427 $toc_elem = "files ".$m['name'];
428 $err_elem = $s;
98e99288 429 $s = "<span class=section id=files-{$m['name']}>$s</span>";
b530f30e
ER
430 } elseif (preg_match("/^ended at: (?P<date>.+), done in (?P<time>[\d:.]+)/", $s, $m)) {
431 $time = $m['time'];
2ba2cc91 432 }
e69f53b7 433
4a2b3f54 434 $out_buf[] = $s;
77aded7c 435 $out_buf_size++;
015d7b6a
AM
436
437 // if error/processing found truncate early but keep last 100 lines before error
4a2b3f54 438 if ($tail && $first_cut && !$first_cut_done && $out_buf_size > 100) {
015d7b6a
AM
439 array_splice($out_buf, 0, $out_buf_size - 100);
440 $out_buf_size = 100;
4a2b3f54 441 $first_cut_done = true;
015d7b6a
AM
442 }
443
e69f53b7 444 // if (not in tail mode) or (in tail mode but we have an error)
4a2b3f54 445 if (!$tail || $first_cut) {
e69f53b7
AM
446 if ($toc_elem)
447 $toc[] = $toc_elem;
448 if ($err_elem)
449 $err[] = $err_elem;
e69f53b7 450 }
a7f1713c 451 }
a7f1713c 452 pclose($fd);
e69f53b7 453
015d7b6a 454 // no errors found, no processing found but we are in tail mode
4a2b3f54 455 if ($tail && !$first_cut_done && $out_buf_size > 100) {
015d7b6a
AM
456 array_splice($out_buf, 0, $out_buf_size - 100);
457 $out_buf_size = 100;
458 }
459
77aded7c 460 $code = join('', $out_buf);
e926de50 461
b530f30e
ER
462 if ($time) {
463 one_item(_("Runtime"), $time);
464 }
465
f43fc7b7
ER
466 echo "</table>";
467
e926de50
ER
468 if (!empty($toc)) {
469 echo "<h2>"._("Toc:")."</h2>";
470 echo "<ul class=toc>";
98e99288 471 foreach ($toc as $i => $section) {
901abf2c
ER
472 $id = str_replace(" ", "-", $section);
473 echo "<li><a href=#{$id}>{$section}</a></li>";
98e99288 474 echo "<code>{$err[$i]}</code>";
e926de50
ER
475 }
476 echo "</ul>";
477 }
478
479 echo "<h2>"._("Content:")."</h2>";
480
481 start_pre();
482 echo $code;
483 end_pre();
a7f1713c 484
485?>
486 <table width="100%">
487 <tr>
488 <td align=left>
489 [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
490 </td>
491 <td align=right>
2ba2cc91 492 [<a href="<?php echo "$bu&amp;action=qa"
a7f1713c 493 ?>"><?=_("View rpm -qa of builder")?></a>]
494 </td>
495 </tr>
496 </table>
497<?php
498
499}
500
501function dump_text()
502{
503 global $root_directory;
504 global $buildlogs_server;
505
506 header("Content-type: text/plain");
507
508 $f = file_name();
509 if ($f == false)
510 return;
511
512 echo "# src : ftp://$buildlogs_server/$f\n";
2ba2cc91 513 echo "# date : " .
a7f1713c 514 date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
515
2454d41c 516 $filter = get_filter($f);
a7f1713c 517
2454d41c 518 $cmd = "$filter '$root_directory/$f'";
a7f1713c 519 $fd = popen($cmd, "r");
2454d41c 520 fpassthru($fd);
a7f1713c 521 pclose($fd);
522}
523
524function list_archs()
525{
526 global $addr, $url, $cnt,$ok,$ns;
527
528 if (!isset($cnt))
529 $cnt = 50;
530
531 $big_url = "$url?ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
532
533 echo "<table width=\"100%\" border=\"0\">\n";
534 echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
a918ff2f
AM
535 foreach ($addr as $dist => $ddist) {
536 echo "<tr><td colspan=2 nowrap=\"nowrap\"><hr/></td></tr>\n";
537 foreach ($ddist as $arch) {
538 echo "<tr><td nowrap=\"nowrap\">".
539 "<a href=\"$url?dist=$dist&amp;arch=$arch&amp;ok=0&amp;cnt=$cnt\">
540 $dist/$arch</a></td><td nowrap=\"nowrap\">".
541 "[<a href=\"$url?dist=$dist&amp;arch=$arch&amp;ok=1&amp;cnt=$cnt\">OK</a>]</td>".
542 #"<td>[<a href=\"$url?idx=$i&amp;action=qa\">qa</a>]</td>".
543 "</tr>\n";
544 }
545 }
a7f1713c 546 echo "</table><hr />\n";
547
548 echo "<div align=\"center\">";
549 echo "<a href=\"$big_url&amp;action=adv_search\">"._("Advanced Search")."</a><br />\n";
550
551 echo "<a href=\"$url\">main()</a><hr />\n";
552 echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ".
4a2b3f54 553 "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
60845d0a 554 "<small>(c) 2002-". date("Y") . " ".
a7f1713c 555 "<a href=\"mailto:feedback@pld-linux.org\">PLD&nbsp;Team</a><br />\n".
82d6f6b1 556 '$Revision: 1.37 $'.
a7f1713c 557 "</small></div>\n";
558
559 # smile ;)
560 echo "<div align=\"center\"><small>";
561 $pow = array("vim", "php", "brain", "power", "electricity",
562 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
563 "voodoo magic", "Linux", "x-files", "X", "foobar",
2ba2cc91 564 "/dev/null", "/dev/zero", "/dev/drzewo",
a7f1713c 565 "Leppe'", "matrix", "Neo", "PDP-11",
566 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
2ba2cc91 567 "foobarbaz", "ed", "Joe", "Unix conspiracy",
a7f1713c 568 "overclock", "The Right Thing",
569 "The Bad Thing", "Star Treck", "NSA", "NASA",
570 "achelon", "VAX", "Real Programmer",
571 "Real Operating System", "Real Computer",
572 "computron", "bogon", "quantum bogodynamics",
573 "BOFH", "/dev/ill", "nasi tu byli",
574 "Paranoid Android", "Lunatic Corp", "Parallel thinking",
575 "sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
576 "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3",
3cf4f3e8 577 "synergy", "six Cray XMT Supercomputers"
a7f1713c 578 # feel free to add sth if you change this file ;)
579 );
580 echo _("Powered by")." ";
581 $max = 1;
582 for ($i = 0; $i < $max; $i++) {
583 $x = rand(0, count($pow) - 1);
584 if ($pow[$x] == "") $i--;
585 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
586 $pow[$x] = "";
587 }
588 echo "</small></div>";
589
774eb927
AM
590 echo "<div align=\"center\"><small>";
591 echo "Your IP: " . $_SERVER['REMOTE_ADDR'];
592 echo "</small></div>";
593
a7f1713c 594 if (isset($dist) && isset($arch)) {
a6cc6dd6 595 echo "<form action=\"index.php\" method=\"post\">";
a7f1713c 596 echo "<input type=\"hidden\" name=\"dist\" value=\"$dist\" />";
597 echo "<input type=\"hidden\" name=\"arch\" value=\"$arch\" />";
598 echo "<input type=\"hidden\" name=\"action\" value=\"sqa\" />";
599 echo "<input type=\"text\" size=\"14\" name=\"str\" /><br />";
600 echo "<input type=\"submit\" name=\"submit\" value=\""._("Search rpmqa!")."\" />";
601 echo "</form>";
602 }
603}
604
605function get_qa()
606{
607 global $dist, $arch;
608
609 if (!isset($dist) || !isset($arch))
610 return false;
f0694a44 611 $addr = "http://ftp1.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt";
a7f1713c 612 return fopen("$addr", "r");
613}
614
615function search_qa()
616{
617 global $url, $str, $dist, $arch;
618
619 $f = get_qa();
620 echo "<h1>"._("Search results for")." '$str' "._("in")." $dist/$arch</h1>";
621
622 start_pre();
623
624 if ($f == 0) {
625 echo _("Sorry, cannot open.");
626 } else {
627 while (($s = fgets($f, 1000)) != false) {
ea35dacf
AM
628 if (stristr($s, "Query done at:")) {
629 echo "rpmqa database from " . strstr($s, ":") . "\n";
4a2b3f54 630 continue;
ea35dacf
AM
631 }
632
a7f1713c 633 if (stristr($s, $str))
634 echo $s;
635 }
ea35dacf 636 echo "\n/* EOF */";
a7f1713c 637 }
638 end_pre();
639}
640
641function dump_qa($plain)
642{
643 global $url, $dist, $arch;
644
645 $f = get_qa();
646
647 if ($plain) {
2ba2cc91 648 header("Content-type: text/plain");
a7f1713c 649 echo _("# rpm -qa of")." $dist/$arch\n";
650 } else {
651 echo "<h1>"._("rpm -qa of")." $a</h1>";
652 echo "<a href=\"$url?dist=$dist&amp;arch=$arch&amp;action=qatxt\">"._("text/plain version")."</a>";
653 start_pre();
654 }
655
656 if ($f == 0) {
657 echo _("Sorry, cannot open.");
658 } else {
659 while (($s = fgets($f, 1000)) != false) {
660 echo $s;
661 }
662 }
663
664 if (!$plain)
665 end_pre();
666}
667
668
669function adv_search()
670{
671 global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns;
672
673 $big_url = "$url?ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
674
675 echo "<script><!--\n".
676 "function checkboxToggle() {\n".
677 "for (var i=0;i<document.forms[0].elements.length;i++) {\n".
678 "var e = document.forms[0].elements[i];\n".
679 "if ((e.name != 'all') && (e.type=='checkbox'))\n".
680 "e.checked = document.forms[0].all.checked;\n".
681 "}\n }\n -->\n </script>\n";
682
683/* Shut up warnings */
8f0e31ba 684 if (!isset($_POST["n2"])) $_POST["n2"] = "";
a7f1713c 685 if (!isset($_POST["age1"])) $_POST["age1"] = "";
686 if (!isset($_POST["age2"])) $_POST["age2"] = "";
687 if (!isset($_POST["size1"])) $_POST["size1"] = "";
688 if (!isset($_POST["size2"])) $_POST["size2"] = "";
689
a6cc6dd6 690 echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
a7f1713c 691
692 echo "<div align=\"center\">";
693 echo "<table border=\"0\">\n";
694 echo "<tr>\n";
695 echo "<td>"._("Package name")."</td>\n";
8f0e31ba 696 echo "<td><input type=\"text\" size=\"20\" name=\"n2\" value=\"". $_POST["name"] ."\"/></td>\n";
a7f1713c 697 echo "</tr>\n";
698
699 echo "<tr>\n";
700 echo "<td>"._("Days")."</td>\n";
701 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"". $_POST["age1"] ."\" /></td>\n";
702 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"". $_POST["age2"] ."\" /></td>\n";
703 echo "</tr>\n";
704
705 echo "<tr>\n";
706 echo "<td>"._("Size")."</td>\n";
707 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"". $_POST["size1"] ."\" /></td>\n";
708 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"". $_POST["size2"] ."\" /></td>\n";
709 echo "</tr>\n";
710
711 echo "<tr>\n";
712 echo "<td>"._("Search logs:")."</td>\n";
713 echo "</tr>\n";
714
715 echo "<tr>\n";
716 echo "<td>"._("Failed")."</td>\n";
717 echo "<td>"._("OK")."</td>\n";
718 echo "</tr>\n";
719
506bb488 720 $i = 1;
8f0e31ba 721 foreach ($addr as $dist => $ddist) {
506bb488 722 foreach ($ddist as $arch) {
a7f1713c 723 echo "<tr>\n";
724 $name="as0_".$i;
a7f1713c 725 if (!isset($_POST["$name"])) {
726 $check = " ";
727 } else {
1b44998a 728 $check=" checked='checked'";
a7f1713c 729 }
8f0e31ba 730 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n";
a7f1713c 731 $name="as1_".$i;
8f0e31ba 732 if (!isset($_POST["$n2"])) {
a7f1713c 733 $check = " ";
734 } else {
1b44998a 735 $check=" checked='checked'";
a7f1713c 736 }
8f0e31ba 737 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n";
a7f1713c 738 echo "</tr>\n";
506bb488 739 $i++;
740 }
a7f1713c 741 }
742
743 echo "<tr>\n";
8f0e31ba 744 echo "<td><label><input name=\"all\" type=\"checkbox\" checked=\"on\" onClick=\"checkboxToggle()\">"._("Toggle checkboxes")."</label>&nbsp;<input type=\"submit\" name=\"submit\" value=\""._("Search!")."\" /></td>";
a7f1713c 745 echo "</tr>\n";
746
747 echo "</table>\n";
748
749// if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
750// isset($_POST["size1"]) || isset($_POST["size2"])
8f0e31ba 751 if (($_POST["n2"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
a7f1713c 752 ($_POST["size1"]!="") || ($_POST["size2"]!=""))
753 {
754 $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 ";
8f0e31ba 755 if ($_POST["n2"] != "") {
756 $n = addslashes($_POST["n2"]);
a7f1713c 757 $query .= "AND name LIKE '$n%' ";
758 }
759 $now = time();
760
761 if ($_POST["age1"] != "") {
762 $age = $now - (int)$_POST["age1"] * 24 * 3600;
763 $query .= "AND mtime > $age ";
764 }
765
766 if ($_POST["age2"] != "") {
767 $age = $now - (int)$_POST["age2"] * 24 * 3600;
768 $query .= "AND mtime < $age ";
769 }
770
771 if ($_POST["size1"] != "") {
772 $size = (int)$_POST["size1"];
773 $query .= "AND size > $size ";
774 }
775
776 if ($_POST["size2"] != "") {
777 $size = (int)$_POST["size2"];
778 $query .= "AND size < $size ";
779 }
780
781 $or = "AND (";
506bb488 782 $i = 1;
8f0e31ba 783 foreach ($addr as $dist => $ddist) {
506bb488 784 foreach ($ddist as $arch) {
785 for ($j = 0; $j < 2; $j++) {
786 if (isset($_POST["as" . $j . "_" .$i])) {
8f0e31ba 787 $query .= "$or (dist = '$dist' AND arch = '$arch' AND ok = $j)";
a7f1713c 788 $or = " OR ";
789 }
790 }
506bb488 791 $i++;
792 }
a7f1713c 793 }
794 if ($or == " OR ") $query .= ")";
795// if (!isset($cnt)) $cnt = 50;
796// if (!isset($off)) $off = 0;
797 if (!isset($ns)) $ns = 0;
798 switch ($ns) {
799 case 0:
800 $query .= " ORDER BY mtime DESC";
801 break;
802 case 1:
803 $query .= " ORDER BY name";
804 break;
805 case 2:
806 $query .= " ORDER BY dist, arch, name";
807 break;
808 }
809 $query .= " LIMIT $cnt OFFSET $off ";
2ba2cc91 810
a7f1713c 811 try {
812 $dbh = new PDO("$database");
813 } catch (PDOException $e) {
814 mydie("new PDO: " . $e->getMessage());
815 }
816 $result = $dbh->query("$query")->fetchAll();
817
818 if ($result == FALSE) {
819 echo _("Nothing found");
820 } else {
821 echo "<table border=\"0\" cellspacing=\"1\" ".
822 "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
823 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
824 "[<a href=\"$big_url&amp;ns=2\">"._("sort")."</a>]</th>";
825 echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
826 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
827 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
828 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
829 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
830 "</th></tr>";
831 $i = $off;
832// for ($i = $off; $i < $off + $count; $i++) {
833 foreach ($result as $row) {
834 $dist = $row["dist"];
835 $arch = $row["arch"];
836 $name = $row["name"];
8f0e31ba 837 $name_url = urlencode($name);
a7f1713c 838 $id = $row["id"];
839 $f = $name;
a7f1713c 840 $t = $now - $row["mtime"];
841 $s = $row["size"];
842 $t /= 60;
843 if ($t >= 60) {
844 $t /= 60;
845 if ($t >= 24) {
846 $t /= 24;
847 $t = round($t);
848 $t = $t . "&nbsp;" . ngettext("day","days",$t);
849 } else {
850 $t = round($t);
851 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
852 }
853 } else {
854 $t = round($t);
855 $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
856 }
857
858// $big_url = "$url?idx=$i&amp;ok=$j&amp;ns=$ns&amp;cnt=$cnt";
859 $ok = $row["ok"];
8f0e31ba 860 $u = "$url?dist=$dist&amp;arch=$arch&amp;name=$name_url&amp;ok=$ok&amp;id=$id";
a7f1713c 861 $b = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;off=$off&amp;cnt=$cnt";
862
863 $builder = "$dist/$arch/". $fail_or_ok[$ok];
864 echo "<tr>";
865 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$b\">$builder</a></td>";
866 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
867 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
868 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
869 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
870 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
871 $i++;
872 }
873 echo "</table></div>\n";
874
875 $backarr = "&lt;&lt;&lt;&nbsp;";
876 $back = _("Page back");
877 $forward = _("Page forward");
878 $forwardarr = "&nbsp;&gt;&gt;&gt;";
879
880 }
881// FIXME
882/*
883 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
884
885 if ($off > 0) {
886 $noff = $off - $cnt;
887 if ($noff < 0)
888 $noff = 0;
889 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
890 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
891 } else {
892 echo "$backarr</td><td align=left>$back";
893 }
894
895 echo "</td>\n<td align=\"center\">";
896 echo "</td>\n<td align=\"right\">";
897
898 if ($off + $cnt < count($list))
899 {
900 $noff = $off + $cnt;
901 if ($noff < 0)
902 $noff = 0;
903 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
904 echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>";
905 }
906 else
907 {
908 echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr";
909 }
910
911 echo "</td>\n</tr></table></p>";
912*/
913 } else
914 {
915 echo _("Enter something!");
916 }
4086dafb 917 echo "</div></form>\n";
a7f1713c 918}
919
920function welcome()
921{
922?>
923<table border="0" width="100%"><tr><td width="20%">&nbsp;</td><td>
924<h1><?=_("Welcome!")?></h1>
925<p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
926<?=_("Feel free to email bug reports, complaints and feature requests ")?>
927<!-- ech... niech strace... -->
2ba2cc91 928<a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?>
ac853124 929 <a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a>.</p>
a7f1713c 930</td><td width="20%">&nbsp;</td></tr>
931</table>
932<?php
933}
934
935header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
936header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
937header("Cache-Control: no-cache, must-revalidate");
938header("Pragma: no-cache");
939
940//phpinfo();
941if ($action == "text") {
942 dump_text();
943} else if ($action == "adv_search") {
944 myheader();
945 adv_search();
946 trailer();
947} else if ($action == "qatxt") {
948 dump_qa(1);
949} else {
950 myheader();
951 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
952 list_archs();
953 echo "</td><td valign=\"top\">";
954 flush();
955 if ($action == "qa")
956 dump_qa(0);
957 else if ($action == "sqa")
958 search_qa();
959 else if (isset($id) || isset($name))
960 dump_log($action == "tail");
961 else if (isset($dist))
962 list_logs();
963 else
964 welcome();
965 echo "</td></tr></table>";
966 trailer();
967}
968?>
This page took 0.562668 seconds and 4 git commands to generate.