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