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