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