]> git.pld-linux.org Git - projects/buildlogs.git/blame - index.php
- simpification. Not tested yet.
[projects/buildlogs.git] / index.php
CommitLineData
a7f1713c 1<?php
2ob_start("ob_gzhandler", 1);
3$buildlogs_server = "buildlogs.pld-linux.org";
4$url = "index2.php";
5$fail_or_ok = array( "FAIL", "OK" );
6/*
7$database = 'sqlite:/home/services/ftp/buildlogs.db';
8$root_directory = "/home/services/ftp/pub/pld-buildlogs";
9*/
10
11// $database, $root_directory and others are taken from buildlogs.inc
12include('buildlogs2.inc');
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"])) {
56 $name = basename($_GET["name"]);
57}
58if (isset($_GET["ok"]))$ok=(int)$_GET["ok"];
59else $ok="";
60if (isset($_GET["ns"]))$ns=(int)$_GET["ns"];
61else $ns="";
62if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"];
63else $cnt = 50;
64if (isset($_GET["action"]))$action=$_GET["action"];
65else $action="";
66if (isset($_GET["off"]))$off=(int)$_GET["off"];
67else $off = 0;
68if (isset($_GET["id"]))$id=$_GET["id"];
69
70if (isset($_POST["str"]))$str=$_POST["str"];
71if (isset($_POST["action"]))$action=$_POST["action"];
72
73function myheader()
74{
75echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
76echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
77?>
78<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
79 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
80<html xmlns="http://www.w3.org/1999/xhtml">
81 <head>
82 <title>PLD Build Logs</title>
83 <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
84 <style type="text/css"><!--
85A { text-decoration: none; }
86A:hover { text-decoration: underline; }
87H1 { font-family: arial,helvetica,sans-serif;
88 font-size: 20pt;
89 font-weight: bold;}
90H2 { font-family: arial,helvetica,sans-serif;
91 font-size: 18pt;
92 font-weight: bold;}
93BODY,TD { font-family: arial,helvetica,sans-serif;
94 font-size: 13pt; }
95TH { font-family: arial,helvetica,sans-serif;
96 font-size: 13pt;
97 font-weight: bold; }
98//-->
99</style>
100 </head>
101 <!-- Diffrent color for visited link doesn't make much sense here...
102 this page is autogenerated and it might be misleading after some
103 build log changes. -->
104 <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
105<?php
106}
107
108function start_pre()
109{
110 echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
111 "<font color=\"#cccccc\"><pre style=\"width: 2048px;overflow: scroll\">";
112}
113
114function end_pre()
115{
116 echo "</pre></font></td></tr></table>\n";
117}
118
119function trailer()
120{
121 echo "</body></html>";
122}
123
124
125function mydie($msg)
126{
127 echo "Fatal error: $msg";
128}
129
130
131
132function list_logs()
133{
134 global $database;
135 global $arch, $dist, $ok;
136 global $big_url, $ns;
137 global $off, $cnt, $root_directory, $url;
138
139 $big_url = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
140
141 if ($ok == 1) {
142 echo "<h1>"._("Listing of")." $dist/$arch/OK "
143 ."(<a href=\"$big_url&amp;ok=0\">"._("fail")."</a>)</h1>\n";
144 } else {
145 echo "<h1>"._("Listing of")." $dist/$arch/FAIL "
146 ."(<a href=\"$big_url&amp;ok=1\">"._("ok")."</a>)</h1>\n";
147 }
148
149 echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
150 "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
151 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
152 "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File").
153 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
154 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
155 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
156 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
157 "</tr>";
158
159 if ($ns != 1) $ns = 0;
160 if (!isset($ok)) $ok = 0;
161// if (!isset($off)) $off = 0;
162// if (!isset($cnt)) $cnt = 50;
163 if ($ns == 0) $order = "mtime DESC";
164 else $order = "name";
165
166 $query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE "
167 . "dist = '$dist' AND arch = '$arch' AND ok = $ok ORDER BY $order LIMIT $cnt OFFSET $off";
168
169 try {
170 $dbh = new PDO("$database");
171 } catch (PDOException $e) {
172 mydie("new PDO: " . $e->getMessage());
173 }
174 $now = time();
175 $i = $off;
176 foreach ($dbh->query("$query") as $row) {
177 $f = $row["name"];
178 $t = $now - $row["mtime"];
179 $s = $row["size"];
180 $h = $row["log_id"];
181
182 $t /= 60;
183 if ($t >= 60) {
184 $t /= 60;
185 if ($t >= 24) {
186 $t /= 24;
187 $t = round($t);
188 $t = $t . "&nbsp;" . ngettext("day","days",$t);
189 } else {
190 $t = round($t);
191 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
192 }
193 } else {
194 $t = round($t);
195 $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
196 }
197 $u = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;name=$name&amp;id=$id";
198 echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
199 "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
200 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
201 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
202 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
203 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
204 $i++;
205 }
206 $count = $i - $off;
207 echo "</table></div>\n";
208
209 $backarr = "&lt;&lt;&lt;&nbsp;";
210 $back = _("Page back");
211 $forward = _("Page forward");
212 $forwardarr = "&nbsp;&gt;&gt;&gt;";
213
214 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">";
215
216 if ($off > 0) {
217 $noff = $off - $count;
218 if ($noff < 0)
219 $noff = 0;
220 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
221 echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
222 } else {
223 echo "$backarr</td><td align=\"left\">$back";
224 }
225
226 echo "</td>\n<td align=\"center\">";
227
228 if (isset($dist) && isset($arch)) {
229 echo "[<a href=\"$big_url&amp;action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
230 } else {
231 echo "&nbsp;";
232 }
233
234 echo "</td>\n<td align=right>";
235 if ($cnt == $count) {
236 $noff = $off + $cnt;
237 if ($noff < 0)
238 $noff = 0;
239 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
240 echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
241 } else {
242 echo "$forward</td><td align=right width=1%>$forwardarr";
243 }
244 echo "</td>\n</tr></table></p>";
245}
246
247function file_name()
248{
249 global $ok, $dist, $arch, $name, $id;
250
251 if (isset($name) && isset($ok) && isset($arch) && isset($dist)) {
252 if (isset($id) && $id != '') {
253 $name = $name . ",$id";
254 }
255 $w = $ok ? "OK" : "FAIL";
256 return "$dist/$arch/$w/$name.bz2";
257 }
258}
259
260function dump_log($tail)
261{
262 global $ok, $url, $dist, $arch;
263 global $root_directory, $big_url, $ns, $id, $cnt, $off;
264 global $buildlogs_server;
265
266 $f = file_name();
267
268 if ($f == false)
269 return;
270
271 $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
272 $df = preg_replace("/\.(bz2|gz)$/", "", $df);
273
274 echo "<h1>$df</h1>";
275
276 echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">";
277
278 function one_item($h, $t) {
279 echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
280 "<td bgcolor=\"#cccccc\">$t</td></tr>";
281 }
282
283 function href($h, $c) {
284 return "<a href=\"$h\">$c</a>";
285 }
286
287 one_item(_("Status"), ($ok == 1 ?
288 "<font color=\"green\"><b>"._("OK")."</b></font>" :
289 "<font color=\"red\"><b>"._("Failed")."</b></a>"));
290 one_item(_("Source URL"),
291 href("ftp://$buildlogs_server/$f",
292 "ftp://$buildlogs_server/$f"));
293
294 $big_url = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
295 $bu = "$big_url&amp;off=$off";
296
297 one_item(_("text/plain URL"),
298 href("$bu&amp;id=$id&amp;action=text",
299 _("View!")));
300 if ($tail) {
301 one_item(_("full text"),
302 href("$bu&amp;id=$id",
303 _("View!")));
304 }
305
306 if (isset($dist) && isset($arch)) {
307 one_item(_("rpm -qa of builder"), href("$bu&amp;action=qa", _("View!")));
308 } else {
309 one_item(_("rpm -qa of builder"), _("Not available"));
310 }
311 one_item("Data", date("Y/m/d H:i:s", filemtime("$root_directory/$f")));
312 /*
313 echo "<tr><td>Here:</td><td>" .
314 "<a href=\"$url?idx=$idx&amp;ok=$ok&amp;id=$id\">".
315 "http://" . getenv("SERVER_NAME") .
316 getenv("SCRIPT_NAME") . "?idx=$idx&amp;ok=$ok&amp;id=$id</a>" .
317 "</td></tr>"; */
318
319 echo "</table><h2>"._("Content:")."</h2>";
320
321
322 # what can I say beside PHP suxx? how the fuck should I create
323 # bidirectional pipe? gotta use wget
324
325 if (preg_match("/\.bz2$/", $f)) {
326 $filter = "bzcat";
327 } elseif (preg_match("/\.gz$/", $f)) {
328 $filter = "zcat";
329 } else {
330 $filter = "cat";
331 }
332
333 $cmd = "$filter $root_directory/$f";
334 if ($tail)
335 $cmd = "$cmd | tail -n 100";
336 $fd = popen($cmd, "r");
337 start_pre();
338 while (($s = fgets($fd, 102400)) != false) {
339 if (strlen($s) > 800) {
340 $s = chunk_split($s, 800, "\n ");
341 $s = trim($s);
342 }
343 $s = htmlspecialchars($s);
344 echo $s;
345 }
346 end_pre();
347 pclose($fd);
348
349?>
350 <table width="100%">
351 <tr>
352 <td align=left>
353 [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
354 </td>
355 <td align=right>
356 [<a href="<?php echo "$bu&amp;action=qa"
357 ?>"><?=_("View rpm -qa of builder")?></a>]
358 </td>
359 </tr>
360 </table>
361<?php
362
363}
364
365function dump_text()
366{
367 global $root_directory;
368 global $buildlogs_server;
369
370 header("Content-type: text/plain");
371
372 $f = file_name();
373 if ($f == false)
374 return;
375
376 echo "# src : ftp://$buildlogs_server/$f\n";
377 echo "# date : " .
378 date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
379
380 if (preg_match("/\.bz2$/", $f)) {
381 $filter = "bzcat";
382 } elseif (preg_match("/\.gz$/", $f)) {
383 $filter = "zcat";
384 } else {
385 $filter = "cat";
386 }
387
388 $cmd = "$filter $root_directory/$f";
389 $fd = popen($cmd, "r");
390 while (($s = fgets($fd, 1000)) != false) {
391 echo $s;
392 }
393 pclose($fd);
394}
395
396function list_archs()
397{
398 global $addr, $url, $cnt,$ok,$ns;
399
400 if (!isset($cnt))
401 $cnt = 50;
402
403 $big_url = "$url?ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
404
405 echo "<table width=\"100%\" border=\"0\">\n";
406 echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
506bb488 407 foreach ($addr as $ddist) {
408 $dist = key($addr);
409 foreach ($ddist as $arch) {
a7f1713c 410 echo "<tr><td nowrap=\"nowrap\">".
506bb488 411 "<a href=\"$url?dist=$dist&amp;arch=$arch&amp;ok=0&amp;cnt=$cnt\">
412 $dist/$arch</a></td><td nowrap=\"nowrap\">".
a7f1713c 413 "[<a href=\"$url?dist=$dist&amp;arch=$arch&amp;ok=1&amp;cnt=$cnt\">OK</a>]</td>".
414 #"<td>[<a href=\"$url?idx=$i&amp;action=qa\">qa</a>]</td>".
415 "</tr>\n";
506bb488 416 }
a7f1713c 417 }
418 echo "</table><hr />\n";
419
420 echo "<div align=\"center\">";
421 echo "<a href=\"$big_url&amp;action=adv_search\">"._("Advanced Search")."</a><br />\n";
422
423 echo "<a href=\"$url\">main()</a><hr />\n";
424 echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ".
425 "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
426 "<small>(c) 2002 ".
427 "<a href=\"mailto:feedback@pld-linux.org\">PLD&nbsp;Team</a><br />\n".
428 '$Revision: 1.7 $'.
429 "</small></div>\n";
430
431 # smile ;)
432 echo "<div align=\"center\"><small>";
433 $pow = array("vim", "php", "brain", "power", "electricity",
434 "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
435 "voodoo magic", "Linux", "x-files", "X", "foobar",
436 "/dev/null", "/dev/zero", "/dev/drzewo",
437 "Leppe'", "matrix", "Neo", "PDP-11",
438 "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
439 "foobarbaz", "ed", "Joe", "Unix conspiracy",
440 "overclock", "The Right Thing",
441 "The Bad Thing", "Star Treck", "NSA", "NASA",
442 "achelon", "VAX", "Real Programmer",
443 "Real Operating System", "Real Computer",
444 "computron", "bogon", "quantum bogodynamics",
445 "BOFH", "/dev/ill", "nasi tu byli",
446 "Paranoid Android", "Lunatic Corp", "Parallel thinking",
447 "sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
448 "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3",
449 "synergy"
450 # feel free to add sth if you change this file ;)
451 );
452 echo _("Powered by")." ";
453 $max = 1;
454 for ($i = 0; $i < $max; $i++) {
455 $x = rand(0, count($pow) - 1);
456 if ($pow[$x] == "") $i--;
457 else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
458 $pow[$x] = "";
459 }
460 echo "</small></div>";
461
462 if (isset($dist) && isset($arch)) {
463 echo "<form action=\"index.php\" method=\"post\">";
464 echo "<input type=\"hidden\" name=\"dist\" value=\"$dist\" />";
465 echo "<input type=\"hidden\" name=\"arch\" value=\"$arch\" />";
466 echo "<input type=\"hidden\" name=\"action\" value=\"sqa\" />";
467 echo "<input type=\"text\" size=\"14\" name=\"str\" /><br />";
468 echo "<input type=\"submit\" name=\"submit\" value=\""._("Search rpmqa!")."\" />";
469 echo "</form>";
470 }
471}
472
473function get_qa()
474{
475 global $dist, $arch;
476
477 if (!isset($dist) || !isset($arch))
478 return false;
479
480$addr = "http://ftp.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt";
481 return fopen("$addr", "r");
482}
483
484function search_qa()
485{
486 global $url, $str, $dist, $arch;
487
488 $f = get_qa();
489 echo "<h1>"._("Search results for")." '$str' "._("in")." $dist/$arch</h1>";
490
491 start_pre();
492
493 if ($f == 0) {
494 echo _("Sorry, cannot open.");
495 } else {
496 while (($s = fgets($f, 1000)) != false) {
497 if (stristr($s, $str))
498 echo $s;
499 }
500 echo "/* EOF */";
501 }
502 end_pre();
503}
504
505function dump_qa($plain)
506{
507 global $url, $dist, $arch;
508
509 $f = get_qa();
510
511 if ($plain) {
512 header("Content-type: text/plain");
513 echo _("# rpm -qa of")." $dist/$arch\n";
514 } else {
515 echo "<h1>"._("rpm -qa of")." $a</h1>";
516 echo "<a href=\"$url?dist=$dist&amp;arch=$arch&amp;action=qatxt\">"._("text/plain version")."</a>";
517 start_pre();
518 }
519
520 if ($f == 0) {
521 echo _("Sorry, cannot open.");
522 } else {
523 while (($s = fgets($f, 1000)) != false) {
524 echo $s;
525 }
526 }
527
528 if (!$plain)
529 end_pre();
530}
531
532
533function adv_search()
534{
535 global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns;
536
537 $big_url = "$url?ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
538
539 echo "<script><!--\n".
540 "function checkboxToggle() {\n".
541 "for (var i=0;i<document.forms[0].elements.length;i++) {\n".
542 "var e = document.forms[0].elements[i];\n".
543 "if ((e.name != 'all') && (e.type=='checkbox'))\n".
544 "e.checked = document.forms[0].all.checked;\n".
545 "}\n }\n -->\n </script>\n";
546
547/* Shut up warnings */
548 if (!isset($_POST["name"])) $_POST["name"] = "";
549 if (!isset($_POST["age1"])) $_POST["age1"] = "";
550 if (!isset($_POST["age2"])) $_POST["age2"] = "";
551 if (!isset($_POST["size1"])) $_POST["size1"] = "";
552 if (!isset($_POST["size2"])) $_POST["size2"] = "";
553
554 echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
555
556 echo "<div align=\"center\">";
557 echo "<table border=\"0\">\n";
558 echo "<tr>\n";
559 echo "<td>"._("Package name")."</td>\n";
560 echo "<td><input type=\"text\" size=\"20\" name=\"name\" value=\"". $_POST["name"] ."\"/></td>\n";
561 echo "</tr>\n";
562
563 echo "<tr>\n";
564 echo "<td>"._("Days")."</td>\n";
565 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"". $_POST["age1"] ."\" /></td>\n";
566 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"". $_POST["age2"] ."\" /></td>\n";
567 echo "</tr>\n";
568
569 echo "<tr>\n";
570 echo "<td>"._("Size")."</td>\n";
571 echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"". $_POST["size1"] ."\" /></td>\n";
572 echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"". $_POST["size2"] ."\" /></td>\n";
573 echo "</tr>\n";
574
575 echo "<tr>\n";
576 echo "<td>"._("Search logs:")."</td>\n";
577 echo "</tr>\n";
578
579 echo "<tr>\n";
580 echo "<td>"._("Failed")."</td>\n";
581 echo "<td>"._("OK")."</td>\n";
582 echo "</tr>\n";
583
506bb488 584 $i = 1;
585 foreach ($addr as $ddist) {
586 $dist = key($addr);
587 foreach ($ddist as $arch) {
a7f1713c 588 echo "<tr>\n";
589 $name="as0_".$i;
a7f1713c 590 if (!isset($_POST["$name"])) {
591 $check = " ";
592 } else {
593 $check=" checked=\"on\"";
594 }
595 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">".$dist/$arch."</label></td>\n";
596 $name="as1_".$i;
597 if (!isset($_POST["$name"])) {
598 $check = " ";
599 } else {
600 $check=" checked=\"on\"";
601 }
602 echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">".$dist/$arch."</label></td>\n";
603 echo "</tr>\n";
506bb488 604 $i++;
605 }
a7f1713c 606 }
607
608 echo "<tr>\n";
609 echo "<td><input name=\"all\" type=\"checkbox\" checked=\"on\" onClick=\"checkboxToggle()\">"._("Toggle checkboxes")."&nbsp;<input type=\"submit\" name=\"submit\" value=\""._("Search!")."\" /></td>";
610 echo "</tr>\n";
611
612 echo "</table>\n";
613
614// if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
615// isset($_POST["size1"]) || isset($_POST["size2"])
616 if (($_POST["name"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
617 ($_POST["size1"]!="") || ($_POST["size2"]!=""))
618 {
619 $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 ";
620 if ($_POST["name"] != "") {
621 $n = addslashes($_POST["name"]);
622 $query .= "AND name LIKE '$n%' ";
623 }
624 $now = time();
625
626 if ($_POST["age1"] != "") {
627 $age = $now - (int)$_POST["age1"] * 24 * 3600;
628 $query .= "AND mtime > $age ";
629 }
630
631 if ($_POST["age2"] != "") {
632 $age = $now - (int)$_POST["age2"] * 24 * 3600;
633 $query .= "AND mtime < $age ";
634 }
635
636 if ($_POST["size1"] != "") {
637 $size = (int)$_POST["size1"];
638 $query .= "AND size > $size ";
639 }
640
641 if ($_POST["size2"] != "") {
642 $size = (int)$_POST["size2"];
643 $query .= "AND size < $size ";
644 }
645
646 $or = "AND (";
506bb488 647 $i = 1;
648 foreach ($addr as $ddist) {
649 $dist = key($addr);
650 foreach ($ddist as $arch) {
651 for ($j = 0; $j < 2; $j++) {
652 if (isset($_POST["as" . $j . "_" .$i])) {
653 $query .= "$or (dist = $dist AND arch = $arch AND ok = $j)";
a7f1713c 654 $or = " OR ";
655 }
656 }
506bb488 657 $i++;
658 }
a7f1713c 659 }
660 if ($or == " OR ") $query .= ")";
661// if (!isset($cnt)) $cnt = 50;
662// if (!isset($off)) $off = 0;
663 if (!isset($ns)) $ns = 0;
664 switch ($ns) {
665 case 0:
666 $query .= " ORDER BY mtime DESC";
667 break;
668 case 1:
669 $query .= " ORDER BY name";
670 break;
671 case 2:
672 $query .= " ORDER BY dist, arch, name";
673 break;
674 }
675 $query .= " LIMIT $cnt OFFSET $off ";
676
677 try {
678 $dbh = new PDO("$database");
679 } catch (PDOException $e) {
680 mydie("new PDO: " . $e->getMessage());
681 }
682 $result = $dbh->query("$query")->fetchAll();
683
684 if ($result == FALSE) {
685 echo _("Nothing found");
686 } else {
687 echo "<table border=\"0\" cellspacing=\"1\" ".
688 "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
689 echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
690 "[<a href=\"$big_url&amp;ns=2\">"._("sort")."</a>]</th>";
691 echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
692 "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
693 "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
694 "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
695 "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
696 "</th></tr>";
697 $i = $off;
698// for ($i = $off; $i < $off + $count; $i++) {
699 foreach ($result as $row) {
700 $dist = $row["dist"];
701 $arch = $row["arch"];
702 $name = $row["name"];
703 $id = $row["id"];
704 $f = $name;
705 if ($id != '') $f .= ",$id";
706 $t = $now - $row["mtime"];
707 $s = $row["size"];
708 $t /= 60;
709 if ($t >= 60) {
710 $t /= 60;
711 if ($t >= 24) {
712 $t /= 24;
713 $t = round($t);
714 $t = $t . "&nbsp;" . ngettext("day","days",$t);
715 } else {
716 $t = round($t);
717 $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
718 }
719 } else {
720 $t = round($t);
721 $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
722 }
723
724// $big_url = "$url?idx=$i&amp;ok=$j&amp;ns=$ns&amp;cnt=$cnt";
725 $ok = $row["ok"];
726 $u = "$url?dist=$dist&amp;arch=$arch&amp;name=$name&amp;ok=$ok;&amp;id=$id";
727 $b = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;off=$off&amp;cnt=$cnt";
728
729 $builder = "$dist/$arch/". $fail_or_ok[$ok];
730 echo "<tr>";
731 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$b\">$builder</a></td>";
732 echo "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
733 "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
734 "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
735 "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
736 "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
737 $i++;
738 }
739 echo "</table></div>\n";
740
741 $backarr = "&lt;&lt;&lt;&nbsp;";
742 $back = _("Page back");
743 $forward = _("Page forward");
744 $forwardarr = "&nbsp;&gt;&gt;&gt;";
745
746 }
747// FIXME
748/*
749 echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
750
751 if ($off > 0) {
752 $noff = $off - $cnt;
753 if ($noff < 0)
754 $noff = 0;
755 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
756 echo "$hrefurl$backarr</a></td><td align=left>$hrefurl$back</a>";
757 } else {
758 echo "$backarr</td><td align=left>$back";
759 }
760
761 echo "</td>\n<td align=\"center\">";
762 echo "</td>\n<td align=\"right\">";
763
764 if ($off + $cnt < count($list))
765 {
766 $noff = $off + $cnt;
767 if ($noff < 0)
768 $noff = 0;
769 $hrefurl = "<a href=\"$big_url&amp;off=$noff\">";
770 echo "$hrefurl$forward</a></td><td align=\"right\" width=\"1%\">$hrefurl$forwardarr</a>";
771 }
772 else
773 {
774 echo "$forward</td><td align=\"right\" width=\"1%\">$forwardarr";
775 }
776
777 echo "</td>\n</tr></table></p>";
778*/
779 } else
780 {
781 echo _("Enter something!");
782 }
783 echo "</form>\n";
784}
785
786function welcome()
787{
788?>
789<table border="0" width="100%"><tr><td width="20%">&nbsp;</td><td>
790<h1><?=_("Welcome!")?></h1>
791<p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
792<?=_("Feel free to email bug reports, complaints and feature requests ")?>
793<!-- ech... niech strace... -->
794<a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?>
795<a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a> ;)</p>
796<p>Version: $Id: index.php,v 1.7 2007/11/28 12:42:52 witekfl Exp $</p>
797</td><td width="20%">&nbsp;</td></tr>
798</table>
799<?php
800}
801
802header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
803header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
804header("Cache-Control: no-cache, must-revalidate");
805header("Pragma: no-cache");
806
807//phpinfo();
808if ($action == "text") {
809 dump_text();
810} else if ($action == "adv_search") {
811 myheader();
812 adv_search();
813 trailer();
814} else if ($action == "qatxt") {
815 dump_qa(1);
816} else {
817 myheader();
818 echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
819 list_archs();
820 echo "</td><td valign=\"top\">";
821 flush();
822 if ($action == "qa")
823 dump_qa(0);
824 else if ($action == "sqa")
825 search_qa();
826 else if (isset($id) || isset($name))
827 dump_log($action == "tail");
828 else if (isset($dist))
829 list_logs();
830 else
831 welcome();
832 echo "</td></tr></table>";
833 trailer();
834}
835?>
This page took 0.224856 seconds and 4 git commands to generate.