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