2 if (!function_exists("ob_gzhandler"))
3 die("ob_gzhandler function is missing - install php zlib module");
5 ob_start("ob_gzhandler", 1);
6 $buildlogs_server = "buildlogs.pld-linux.org";
8 $fail_or_ok = array( "FAIL", "OK" );
10 $database = 'sqlite:/home/services/ftp/buildlogs2.db';
11 $root_directory = "/home/services/ftp/pub/pld-buildlogs";
14 // $database, $root_directory and others are taken from buildlogs.inc
15 include('buildlogs.inc');
17 /* It should be set */
19 $langs["en_US"]["charset"]="ISO-8859-1";
20 $langs["pl_PL"]["charset"]="ISO-8859-2";
24 if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
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"]))
31 $lang_detected=preg_replace("/.*\[(.*)\].*/i","\\1",$_SERVER["HTTP_USER_AGENT"]);
35 $lang_detected=preg_replace("/^pl$/i","pl_PL",$lang_detected);
37 if (isset($lang_detected) && isset($langs[$lang_detected]))
42 if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"];
43 if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"];
46 setlocale(LC_ALL,$lang);
47 bindtextdomain("messages","locale");
48 textdomain("messages");
50 if (isset($_GET["dist"]) && isset($_GET["arch"]))
52 $dist = $_GET["dist"];
53 $dist = basename(htmlspecialchars($dist, ENT_QUOTES, 'UTF-8'));
54 $arch = $_GET["arch"];
55 $arch = basename(htmlspecialchars($arch, ENT_QUOTES, 'UTF-8'));
58 if (isset($_POST["dist"])) {
59 $dist = $_POST["dist"];
60 $dist = basename(htmlspecialchars($dist, ENT_QUOTES, 'UTF-8'));
63 if (isset($_POST["arch"])) {
64 $arch = $_POST["arch"];
65 $arch = basename(htmlspecialchars($arch, ENT_QUOTES, 'UTF-8'));
68 if (isset($_GET["name"])) {
69 $name_url = urlencode($_GET["name"]);
70 $name = $_GET["name"];
71 $name = basename(htmlspecialchars($name, ENT_QUOTES, 'UTF-8'));
74 if (isset($_GET["ok"]))$ok=(int)$_GET["ok"];
76 if (isset($_GET["ns"]))$ns=(int)$_GET["ns"];
78 if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"];
80 if (isset($_GET["action"])) {
81 $action = $_GET["action"];
82 $action = htmlspecialchars($action, ENT_QUOTES, 'UTF-8');
85 if (isset($_GET["off"]))$off=(int)$_GET["off"];
87 if (isset($_GET["id"])) {
89 $id = htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
92 if (isset($_POST["str"])) {
94 $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
96 if (isset($_POST["action"])) {
97 $action = $_POST["action"];
98 $action = htmlspecialchars($action, ENT_QUOTES, 'UTF-8');
101 if (isset($arch) && $arch == "src")
106 echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
107 echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
109 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
110 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
111 <html xmlns="http://www.w3.org/1999/xhtml">
113 <title>PLD Build Logs</title>
114 <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
115 <style type="text/css"><!--
116 A { text-decoration: none; }
117 A:hover { text-decoration: underline; }
118 H1 { font-family: arial,helvetica,sans-serif;
121 H2 { font-family: arial,helvetica,sans-serif;
124 BODY,TD { font-family: arial,helvetica,sans-serif;
126 TH { font-family: arial,helvetica,sans-serif;
129 /* error lines from build logs */
131 background-color: #b00;
138 background-color: #161;
146 <!-- Diffrent color for visited link doesn't make much sense here...
147 this page is autogenerated and it might be misleading after some
148 build log changes. -->
149 <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
155 echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
156 "<font color=\"#cccccc\"><pre style=\"white-space: pre-line; word-break: break-all;\">";
161 echo "</pre></font></td></tr></table>\n";
166 echo "</body></html>";
172 echo "Fatal error: $msg";
180 global $arch, $dist, $ok;
181 global $big_url, $ns;
182 global $off, $cnt, $root_directory, $url;
190 $big_url = $url . '?' . http_build_query($query_data);
193 echo "<h1>"._("Listing of")." $dist/$arch/OK "
194 ."(<a href=\"$big_url&ok=0\">"._("fail")."</a>)</h1>\n";
196 echo "<h1>"._("Listing of")." $dist/$arch/FAIL "
197 ."(<a href=\"$big_url&ok=1\">"._("ok")."</a>)</h1>\n";
200 echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
201 "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
202 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
203 "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File").
204 "[<a href=\"$big_url&ns=1\">"._("sort")."</a>]</th>".
205 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
206 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
207 "[<a href=\"$big_url&ns=0\">"._("sort")."</a>]</th>".
210 if ($ns != 1) $ns = 0;
211 if (!isset($ok)) $ok = 0;
212 // if (!isset($off)) $off = 0;
213 // if (!isset($cnt)) $cnt = 50;
214 if ($ns == 0) $order = "mtime DESC";
215 else $order = "name";
217 $query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE
218 dist = :dist AND arch = :arch AND ok = :ok ORDER BY $order LIMIT :limitnr OFFSET :offset ";
221 $dbh = new PDO("$database");
222 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
223 $dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
224 } catch (PDOException $e) {
225 mydie("new PDO: " . $e->getMessage());
229 $stmt = $dbh->prepare($query);
230 $stmt->bindParam(':dist', $dist, PDO::PARAM_STR);
231 $stmt->bindParam(':arch', $arch, PDO::PARAM_STR);
232 $stmt->bindParam(':ok', $ok, PDO::PARAM_INT);
233 $stmt->bindParam(':limitnr', $cnt, PDO::PARAM_INT);
234 $stmt->bindParam(':offset', $off, PDO::PARAM_INT);
235 $stmt->execute([$dist, $arch, $ok, $cnt, $off]);
236 while ($row = $stmt->fetch()) {
237 $name = $row["name"];
239 $dist = $row["dist"];
240 $arch = $row["arch"];
242 $name_url = urlencode($name);
243 $t = $now - $row["mtime"];
253 $t = $t . " " . ngettext("day","days",$t);
256 $t = $t . " " . ngettext("hour","hours",$t);
260 $t = $t . " " . ngettext("minute","minutes",$t);
268 $u = $url . '?' . http_build_query($url_data);
269 echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
270 "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">".htmlspecialchars($f, ENT_QUOTES, 'UTF-8')."</a> ".
271 "[<a href=\"$u&action=text\">"._("text")."</a> | ".
272 "<a href=\"$u&action=tail\">"._("tail")."</a>]".
273 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
274 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
278 echo "</table></div>\n";
280 $backarr = "<<< ";
281 $back = _("Page back");
282 $forward = _("Page forward");
283 $forwardarr = " >>>";
285 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">";
288 $noff = $off - $count;
291 $hrefurl = "<a href=\"$big_url&off=$noff\">";
292 echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
294 echo "$backarr</td><td align=\"left\">$back";
297 echo "</td>\n<td align=\"center\">";
299 if (isset($dist) && isset($arch)) {
300 echo "[<a href=\"$big_url&action=qa\">"._("View <quot>rpm -qa</quot> of builder")."</a>]";
305 echo "</td>\n<td align=right>";
306 if ($cnt == $count) {
310 $hrefurl = "<a href=\"$big_url&off=$noff\">";
311 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
313 echo "$forward</td><td align=right width=1%>$forwardarr";
315 echo "</td>\n</tr></table></p>";
320 global $ok, $dist, $arch, $name, $name_url, $id;
322 if (isset($name) && isset($ok) && isset($arch) && isset($dist)) {
323 if (isset($id) && $id != '') {
324 $name = $name . ",$id";
326 $w = $ok ? "OK" : "FAIL";
327 return "$dist/$arch/$w/$name.bz2";
331 function get_filter($f)
333 if (preg_match("/\.bz2$/", $f)) {
334 if (is_executable("/usr/bin/lbzcat"))
338 } elseif (preg_match("/\.gz$/", $f)) {
346 function dump_log($tail)
348 global $ok, $url, $dist, $arch, $name, $name_url;
349 global $root_directory, $big_url, $ns, $id, $cnt, $off;
350 global $buildlogs_server;
357 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
358 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
359 list($name, $id) = explode(',', $df);
361 if ($name != 'command') {
362 $gitweb_url = "http://git.pld-linux.org/?p=packages/$name.git;a=summary";
363 $name = "<a href=\"$gitweb_url\">$name</a>";
365 echo "<h1>$name <small>$id</small></h1>";
367 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\" width=\"100%\">";
369 function one_item($h, $t) {
370 echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
371 "<td bgcolor=\"#cccccc\">$t</td></tr>";
374 function href($h, $c) {
375 return "<a href=\"$h\">$c</a>";
378 one_item(_("Status"), ($ok == 1 ?
379 "<font color=\"green\"><b>"._("OK")."</b></font>" :
380 "<font color=\"red\"><b>"._("Failed")."</b></a>"));
381 one_item(_("Source URL"),
382 href("https://$buildlogs_server/pld/$f",
383 "https://$buildlogs_server/pld/$f"));
385 $big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt";
386 $bu = "$big_url&off=$off";
388 one_item(_("text/plain URL"),
389 href("$bu&name=$name_url&id=$id&action=text",
392 one_item(_("full text"),
393 href("$bu&name=$name_url&id=$id",
397 if (isset($dist) && isset($arch)) {
398 one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!")));
400 one_item(_("rpm -qa of builder"), _("Not available"));
402 one_item("Date", date("Y/m/d H:i:s", filemtime("$root_directory/$f")));
404 echo "<tr><td>Here:</td><td>" .
405 "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
406 "http://" . getenv("SERVER_NAME") .
407 getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
412 # what can I say beside PHP suxx? how the fuck should I create
413 # bidirectional pipe? gotta use wget
415 $filter = get_filter($f);
417 $cmd = "$filter '$root_directory/$f'";
418 $fd = popen($cmd, "r");
422 $first_cut_done = false;
427 while (($s = fgets($fd, 102400)) != false) {
432 $s = htmlspecialchars($s);
434 if (preg_match("/(?:fail|error(s|\sCS\d+)?):/i", $s)) {
437 $toc_elem = "error $err_count";
439 $s = "<span class=error id=error-$err_count>$s</span>";
440 } elseif (preg_match("/(?:undefined reference to|recipe for target '.*?' failed|compilation terminated|make\[.*:.* (Stop\.$|Error))/i", $s)) {
443 $toc_elem = "error $err_count";
445 $s = "<span class=error id=error-$err_count>$s</span>";
446 } elseif (preg_match("#^\+ /usr/bin/make\b.*\b(?P<target>check)\b#", $s, $m)) {
448 $toc_elem = "make {$m['target']}";
450 $s = "<span class=line id=make-{$m['target']}>$s</span>";
451 } elseif (preg_match('/^(?P<line>- For complete changelog see:) (?P<link>.+)$/', $s, $m)) {
452 // rpm changelog link
453 $link = "<a href=\"{$m['link']}\">{$m['link']}</a>";
454 $s = "<span class=changelog>{$m['line']} $link<br/></span>";
455 } elseif (preg_match('/^(?P<line>\* \w{3} \w{3} [ \d]{2} \d{4} .*?) (?P<hash>[a-z0-9]{7})$/', $s, $m)) {
457 $url = "http://git.pld-linux.org/?p=packages/{$name_url}.git;a=commitdiff;h={$m['hash']}";
458 $link = "<a href=\"$url\">{$m['hash']}</a>";
459 $s = "<span class=changelog>{$m['line']} $link<br/></span>";
460 } elseif (substr($s, 0, 2) == "+ ") {
462 $s = "<span class=verbose>$s</span>";
463 } elseif (preg_match("/^Executing\(%(?P<section>\w+)\)/", $s, $m)) {
465 $toc_elem = $m['section'];
467 $s = "<span class=section id={$m['section']}>$s</span>";
468 } elseif (preg_match("/^Processing files: (?P<pkg>(?P<name>.+)-[^-]+-[^-]+)/", $s, $m)) {
471 $toc_elem = "files ".$m['name'];
473 $s = "<span class=section id=files-{$m['name']}>$s</span>";
474 } elseif (preg_match("/^ended at: (?P<date>.+), done in (?P<time>[\d:.]+)/", $s, $m)) {
481 // if error/processing found truncate early but keep last 100 lines before error
482 if ($tail && $first_cut && !$first_cut_done && $out_buf_size > 100) {
483 array_splice($out_buf, 0, $out_buf_size - 100);
485 $first_cut_done = true;
488 // if (not in tail mode) or (in tail mode but we have an error)
489 if (!$tail || $first_cut) {
498 // no errors found, no processing found but we are in tail mode
499 if ($tail && !$first_cut_done && $out_buf_size > 100) {
500 array_splice($out_buf, 0, $out_buf_size - 100);
504 $code = join('', $out_buf);
507 one_item(_("Runtime"), $time);
513 echo "<h2>"._("Toc:")."</h2>";
514 echo "<ul class=toc>";
515 foreach ($toc as $i => $section) {
516 $id = str_replace(" ", "-", $section);
517 echo "<li><a href=#{$id}>{$section}</a></li>";
518 echo "<code>{$err[$i]}</code>";
523 echo "<h2>"._("Content:")."</h2>";
533 [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
536 [<a href="<?php echo "$bu&action=qa"
537 ?>"><?=_("View rpm -qa of builder")?></a>]
547 global $root_directory;
548 global $buildlogs_server;
550 header("Content-type: text/plain");
556 echo "# src : https://$buildlogs_server/pld/$f\n";
558 date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
560 $filter = get_filter($f);
562 $cmd = "$filter '$root_directory/$f'";
563 $fd = popen($cmd, "r");
568 function list_archs()
570 global $addr, $url, $cnt,$ok,$ns;
575 $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt";
577 echo "<table width=\"100%\" border=\"0\">\n";
578 echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
579 foreach ($addr as $dist => $ddist) {
580 echo "<tr><td colspan=2 nowrap=\"nowrap\"><hr/></td></tr>\n";
581 foreach ($ddist as $arch) {
582 echo "<tr><td nowrap=\"nowrap\">".
583 "<a href=\"$url?dist=$dist&arch=$arch&ok=0&cnt=$cnt\">
584 $dist/$arch</a></td><td nowrap=\"nowrap\">".
585 "[<a href=\"$url?dist=$dist&arch=$arch&ok=1&cnt=$cnt\">OK</a>]</td>".
586 #"<td>[<a href=\"$url?idx=$i&action=qa\">qa</a>]</td>".
590 echo "</table><hr />\n";
592 echo "<div align=\"center\">";
593 echo "<a href=\"$big_url&action=adv_search\">"._("Advanced Search")."</a><br />\n";
595 echo "<a href=\"$url\">main()</a><hr />\n";
596 echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ".
597 "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
598 "<small>(c) 2002-". date("Y") . " ".
599 "<a href=\"mailto:feedback@pld-linux.org\">PLD Team</a><br />\n".
604 echo "<div align=\"center\"><small>";
605 $pow = array("vim", "php", "brain", "power", "electricity",
606 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
607 "voodoo magic", "Linux", "x-files", "X", "foobar",
608 "/dev/null", "/dev/zero", "/dev/drzewo",
609 "Leppe'", "matrix", "Neo", "PDP-11",
610 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
611 "foobarbaz", "ed", "Joe", "Unix conspiracy",
612 "overclock", "The Right Thing",
613 "The Bad Thing", "Star Treck", "NSA", "NASA",
614 "achelon", "VAX", "Real Programmer",
615 "Real Operating System", "Real Computer",
616 "computron", "bogon", "quantum bogodynamics",
617 "BOFH", "/dev/ill", "nasi tu byli",
618 "Paranoid Android", "Lunatic Corp", "Parallel thinking",
619 "sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
620 "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3",
621 "synergy", "six Cray XMT Supercomputers"
622 # feel free to add sth if you change this file ;)
624 echo _("Powered by")." ";
626 for ($i = 0; $i < $max; $i++) {
627 $x = rand(0, count($pow) - 1);
628 if ($pow[$x] == "") $i--;
629 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
632 echo "</small></div>";
634 echo "<div align=\"center\"><small>";
635 echo "Your IP: " . $_SERVER['REMOTE_ADDR'];
636 echo "</small></div>";
638 if (isset($dist) && isset($arch)) {
639 echo "<form action=\"index.php\" method=\"post\">";
640 echo "<input type=\"hidden\" name=\"dist\" value=\"$dist\" />";
641 echo "<input type=\"hidden\" name=\"arch\" value=\"$arch\" />";
642 echo "<input type=\"hidden\" name=\"action\" value=\"sqa\" />";
643 echo "<input type=\"text\" size=\"14\" name=\"str\" /><br />";
644 echo "<input type=\"submit\" name=\"submit\" value=\""._("Search rpmqa!")."\" />";
653 if (!isset($dist) || !isset($arch))
655 $addr = "http://ftp1.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt";
656 return fopen("$addr", "r");
661 global $url, $str, $dist, $arch;
664 echo "<h1>"._("Search results for")." '$str' "._("in")." $dist/$arch</h1>";
669 echo _("Sorry, cannot open.");
671 while (($s = fgets($f, 1000)) != false) {
672 if (stristr($s, "Query done at:")) {
673 echo "rpmqa database from " . strstr($s, ":") . "\n";
677 if (stristr($s, $str))
685 function dump_qa($plain)
687 global $url, $dist, $arch;
692 header("Content-type: text/plain");
693 echo _("# rpm -qa of")." $dist/$arch\n";
695 echo "<h1>"._("rpm -qa of")." $a</h1>";
696 echo "<a href=\"$url?dist=$dist&arch=$arch&action=qatxt\">"._("text/plain version")."</a>";
701 echo _("Sorry, cannot open.");
703 while (($s = fgets($f, 1000)) != false) {
713 function adv_search()
715 global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns;
717 $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt";
719 echo "<script><!--\n".
720 "function checkboxToggle() {\n".
721 "for (var i=0;i<document.forms[0].elements.length;i++) {\n".
722 "var e = document.forms[0].elements[i];\n".
723 "if ((e.name != 'all') && (e.type=='checkbox'))\n".
724 "e.checked = document.forms[0].all.checked;\n".
725 "}\n }\n -->\n </script>\n";
727 /* Shut up warnings */
728 if (!isset($_POST["n2"])) $_POST["n2"] = "";
729 if (!isset($_POST["age1"])) $_POST["age1"] = "";
730 if (!isset($_POST["age2"])) $_POST["age2"] = "";
731 if (!isset($_POST["size1"])) $_POST["size1"] = "";
732 if (!isset($_POST["size2"])) $_POST["size2"] = "";
734 echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
736 echo "<div align=\"center\">";
737 echo "<table border=\"0\">\n";
739 echo "<td>"._("Package name")."</td>\n";
740 echo "<td><input type=\"text\" size=\"20\" name=\"n2\" value=\"". $_POST["name"] ."\"/></td>\n";
744 echo "<td>"._("Days")."</td>\n";
745 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"". $_POST["age1"] ."\" /></td>\n";
746 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"". $_POST["age2"] ."\" /></td>\n";
750 echo "<td>"._("Size")."</td>\n";
751 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"". $_POST["size1"] ."\" /></td>\n";
752 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"". $_POST["size2"] ."\" /></td>\n";
756 echo "<td>"._("Search logs:")."</td>\n";
760 echo "<td>"._("Failed")."</td>\n";
761 echo "<td>"._("OK")."</td>\n";
765 foreach ($addr as $dist => $ddist) {
766 foreach ($ddist as $arch) {
769 if (!isset($_POST["$name"])) {
772 $check=" checked='checked'";
774 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n";
776 if (!isset($_POST["$n2"])) {
779 $check=" checked='checked'";
781 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">". "$dist/$arch" ."</label></td>\n";
788 echo "<td><label><input name=\"all\" type=\"checkbox\" checked=\"on\" onClick=\"checkboxToggle()\">"._("Toggle checkboxes")."</label> <input type=\"submit\" name=\"submit\" value=\""._("Search!")."\" /></td>";
793 // if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
794 // isset($_POST["size1"]) || isset($_POST["size2"])
795 if (($_POST["n2"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
796 ($_POST["size1"]!="") || ($_POST["size2"]!=""))
798 $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 ";
799 if ($_POST["n2"] != "") {
800 $n = addslashes($_POST["n2"]);
801 $query .= "AND name LIKE '$n%' ";
805 if ($_POST["age1"] != "") {
806 $age = $now - (int)$_POST["age1"] * 24 * 3600;
807 $query .= "AND mtime > $age ";
810 if ($_POST["age2"] != "") {
811 $age = $now - (int)$_POST["age2"] * 24 * 3600;
812 $query .= "AND mtime < $age ";
815 if ($_POST["size1"] != "") {
816 $size = (int)$_POST["size1"];
817 $query .= "AND size > $size ";
820 if ($_POST["size2"] != "") {
821 $size = (int)$_POST["size2"];
822 $query .= "AND size < $size ";
827 foreach ($addr as $dist => $ddist) {
828 foreach ($ddist as $arch) {
829 for ($j = 0; $j < 2; $j++) {
830 if (isset($_POST["as" . $j . "_" .$i])) {
831 $query .= "$or (dist = '$dist' AND arch = '$arch' AND ok = $j)";
838 if ($or == " OR ") $query .= ")";
839 // if (!isset($cnt)) $cnt = 50;
840 // if (!isset($off)) $off = 0;
841 if (!isset($ns)) $ns = 0;
844 $query .= " ORDER BY mtime DESC";
847 $query .= " ORDER BY name";
850 $query .= " ORDER BY dist, arch, name";
853 $query .= " LIMIT $cnt OFFSET $off ";
856 $dbh = new PDO("$database");
857 } catch (PDOException $e) {
858 mydie("new PDO: " . $e->getMessage());
860 $result = $dbh->query("$query")->fetchAll();
862 if ($result == FALSE) {
863 echo _("Nothing found");
865 echo "<table border=\"0\" cellspacing=\"1\" ".
866 "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
867 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
868 "[<a href=\"$big_url&ns=2\">"._("sort")."</a>]</th>";
869 echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
870 "[<a href=\"$big_url&ns=1\">"._("sort")."</a>]</th>".
871 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
872 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
873 "[<a href=\"$big_url&ns=0\">"._("sort")."</a>]</th>".
876 // for ($i = $off; $i < $off + $count; $i++) {
877 foreach ($result as $row) {
878 $dist = $row["dist"];
879 $arch = $row["arch"];
880 $name = $row["name"];
881 $name_url = urlencode($name);
884 $t = $now - $row["mtime"];
892 $t = $t . " " . ngettext("day","days",$t);
895 $t = $t . " " . ngettext("hour","hours",$t);
899 $t = $t . " " . ngettext("minute","minutes",$t);
902 // $big_url = "$url?idx=$i&ok=$j&ns=$ns&cnt=$cnt";
904 $u = "$url?dist=$dist&arch=$arch&name=$name_url&ok=$ok&id=$id";
905 $b = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&off=$off&cnt=$cnt";
907 $builder = "$dist/$arch/". $fail_or_ok[$ok];
909 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$b\">$builder</a></td>";
910 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
911 "[<a href=\"$u&action=text\">"._("text")."</a> | ".
912 "<a href=\"$u&action=tail\">"._("tail")."</a>]".
913 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
914 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
917 echo "</table></div>\n";
919 $backarr = "<<< ";
920 $back = _("Page back");
921 $forward = _("Page forward");
922 $forwardarr = " >>>";
927 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
933 $hrefurl = "<a href=\"$big_url&off=$noff\">";
934 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
936 echo "$backarr</td><td align=left>$back";
939 echo "</td>\n<td align=\"center\">";
940 echo "</td>\n<td align=\"right\">";
942 if ($off + $cnt < count($list))
947 $hrefurl = "<a href=\"$big_url&off=$noff\">";
948 echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>";
952 echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr";
955 echo "</td>\n</tr></table></p>";
959 echo _("Enter something!");
961 echo "</div></form>\n";
967 <table border="0" width="100%"><tr><td width="20%"> </td><td>
968 <h1><?=_("Welcome!")?></h1>
969 <p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
970 <?=_("Feel free to email bug reports, complaints and feature requests ")?>
971 <!-- ech... niech strace... -->
972 <a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?>
973 <a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a>.</p>
974 </td><td width="20%"> </td></tr>
979 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
980 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
981 header("Cache-Control: no-cache, must-revalidate");
982 header("Pragma: no-cache");
985 if ($action == "text") {
987 } else if ($action == "adv_search") {
991 } else if ($action == "qatxt") {
995 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
997 echo "</td><td valign=\"top\">";
1001 else if ($action == "sqa")
1003 else if (isset($id) || isset($name))
1004 dump_log($action == "tail");
1005 else if (isset($dist))
1009 echo "</td></tr></table>";