]>
Commit | Line | Data |
---|---|---|
a7f1713c | 1 | <?php |
2 | ob_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 | |
12 | include('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"; | |
20 | if (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 | ||
33 | if (isset($lang_detected) && isset($langs[$lang_detected])) | |
34 | { | |
35 | $lang=$lang_detected; | |
36 | } | |
37 | ||
38 | if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"]; | |
39 | if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"]; | |
40 | ||
41 | putenv("LANG=$lang"); | |
42 | setlocale(LC_ALL,$lang); | |
43 | bindtextdomain("messages","locale"); | |
44 | textdomain("messages"); | |
45 | ||
46 | if (isset($_GET["dist"]) && isset($_GET["arch"])) | |
47 | { | |
48 | $dist = basename($_GET["dist"]); | |
49 | $arch = basename($_GET["arch"]); | |
50 | } | |
51 | ||
52 | if (isset($_POST["dist"])) $dist = basename($_POST["dist"]); | |
53 | if (isset($_POST["arch"])) $arch = basename($_POST["arch"]); | |
54 | ||
55 | if (isset($_GET["name"])) { | |
56 | $name = basename($_GET["name"]); | |
57 | } | |
58 | if (isset($_GET["ok"]))$ok=(int)$_GET["ok"]; | |
59 | else $ok=""; | |
60 | if (isset($_GET["ns"]))$ns=(int)$_GET["ns"]; | |
61 | else $ns=""; | |
62 | if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"]; | |
63 | else $cnt = 50; | |
64 | if (isset($_GET["action"]))$action=$_GET["action"]; | |
65 | else $action=""; | |
66 | if (isset($_GET["off"]))$off=(int)$_GET["off"]; | |
67 | else $off = 0; | |
68 | if (isset($_GET["id"]))$id=$_GET["id"]; | |
69 | ||
70 | if (isset($_POST["str"]))$str=$_POST["str"]; | |
71 | if (isset($_POST["action"]))$action=$_POST["action"]; | |
72 | ||
73 | function myheader() | |
74 | { | |
75 | echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n"; | |
76 | echo '<' . '?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"><!-- | |
85 | A { text-decoration: none; } | |
86 | A:hover { text-decoration: underline; } | |
87 | H1 { font-family: arial,helvetica,sans-serif; | |
88 | font-size: 20pt; | |
89 | font-weight: bold;} | |
90 | H2 { font-family: arial,helvetica,sans-serif; | |
91 | font-size: 18pt; | |
92 | font-weight: bold;} | |
93 | BODY,TD { font-family: arial,helvetica,sans-serif; | |
94 | font-size: 13pt; } | |
95 | TH { 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 | ||
108 | function start_pre() | |
109 | { | |
110 | echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">". | |
111 | "<font color=\"#cccccc\"><pre style=\"width: 2048px;overflow: scroll\">"; | |
112 | } | |
113 | ||
114 | function end_pre() | |
115 | { | |
116 | echo "</pre></font></td></tr></table>\n"; | |
117 | } | |
118 | ||
119 | function trailer() | |
120 | { | |
121 | echo "</body></html>"; | |
122 | } | |
123 | ||
124 | ||
125 | function mydie($msg) | |
126 | { | |
127 | echo "Fatal error: $msg"; | |
128 | } | |
129 | ||
130 | ||
131 | ||
132 | function 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&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt"; | |
140 | ||
141 | if ($ok == 1) { | |
142 | echo "<h1>"._("Listing of")." $dist/$arch/OK " | |
143 | ."(<a href=\"$big_url&ok=0\">"._("fail")."</a>)</h1>\n"; | |
144 | } else { | |
145 | echo "<h1>"._("Listing of")." $dist/$arch/FAIL " | |
146 | ."(<a href=\"$big_url&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&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&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 . " " . ngettext("day","days",$t); | |
189 | } else { | |
190 | $t = round($t); | |
191 | $t = $t . " " . ngettext("hour","hours",$t); | |
192 | } | |
193 | } else { | |
194 | $t = round($t); | |
195 | $t = $t . " " . ngettext("minute","minutes",$t); | |
196 | } | |
197 | $u = "$url?dist=$dist&arch=$arch&ok=$ok&name=$name&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&action=text\">"._("text")."</a> | ". | |
201 | "<a href=\"$u&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 = "<<< "; | |
210 | $back = _("Page back"); | |
211 | $forward = _("Page forward"); | |
212 | $forwardarr = " >>>"; | |
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&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&action=qa\">"._("View <quot>rpm -qa</quot> of builder")."</a>]"; | |
230 | } else { | |
231 | echo " "; | |
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&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 | ||
247 | function 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 | ||
260 | function 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&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt"; | |
295 | $bu = "$big_url&off=$off"; | |
296 | ||
297 | one_item(_("text/plain URL"), | |
298 | href("$bu&id=$id&action=text", | |
299 | _("View!"))); | |
300 | if ($tail) { | |
301 | one_item(_("full text"), | |
302 | href("$bu&id=$id", | |
303 | _("View!"))); | |
304 | } | |
305 | ||
306 | if (isset($dist) && isset($arch)) { | |
307 | one_item(_("rpm -qa of builder"), href("$bu&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&ok=$ok&id=$id\">". | |
315 | "http://" . getenv("SERVER_NAME") . | |
316 | getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&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&action=qa" | |
357 | ?>"><?=_("View rpm -qa of builder")?></a>] | |
358 | </td> | |
359 | </tr> | |
360 | </table> | |
361 | <?php | |
362 | ||
363 | } | |
364 | ||
365 | function 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 | ||
396 | function 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&ns=$ns&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&arch=$arch&ok=0&cnt=$cnt\"> |
412 | $dist/$arch</a></td><td nowrap=\"nowrap\">". | |
a7f1713c | 413 | "[<a href=\"$url?dist=$dist&arch=$arch&ok=1&cnt=$cnt\">OK</a>]</td>". |
414 | #"<td>[<a href=\"$url?idx=$i&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&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 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 | ||
473 | function 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 | ||
484 | function 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 | ||
505 | function 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&arch=$arch&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 | ||
533 | function 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&ns=$ns&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")." <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&ns=2\">"._("sort")."</a>]</th>"; | |
691 | echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File"). | |
692 | "[<a href=\"$big_url&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&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 . " " . ngettext("day","days",$t); | |
715 | } else { | |
716 | $t = round($t); | |
717 | $t = $t . " " . ngettext("hour","hours",$t); | |
718 | } | |
719 | } else { | |
720 | $t = round($t); | |
721 | $t = $t . " " . ngettext("minute","minutes",$t); | |
722 | } | |
723 | ||
724 | // $big_url = "$url?idx=$i&ok=$j&ns=$ns&cnt=$cnt"; | |
725 | $ok = $row["ok"]; | |
726 | $u = "$url?dist=$dist&arch=$arch&name=$name&ok=$ok;&id=$id"; | |
727 | $b = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&off=$off&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&action=text\">"._("text")."</a> | ". | |
734 | "<a href=\"$u&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 = "<<< "; | |
742 | $back = _("Page back"); | |
743 | $forward = _("Page forward"); | |
744 | $forwardarr = " >>>"; | |
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&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&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 | ||
786 | function welcome() | |
787 | { | |
788 | ?> | |
789 | <table border="0" width="100%"><tr><td width="20%"> </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%"> </td></tr> | |
798 | </table> | |
799 | <?php | |
800 | } | |
801 | ||
802 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); | |
803 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); | |
804 | header("Cache-Control: no-cache, must-revalidate"); | |
805 | header("Pragma: no-cache"); | |
806 | ||
807 | //phpinfo(); | |
808 | if ($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 | ?> |