buildlogs: buildlogs.sql/index2.php (NEW), buildlogs.sql/addlog2.php (NEW), ...
witekfl
witekfl at pld-linux.org
Wed Oct 22 11:22:20 CEST 2008
Author: witekfl Date: Wed Oct 22 09:22:20 2008 GMT
Module: buildlogs Tag: HEAD
---- Log message:
- new versions of buildlogs scripts, not tested at all
---- Files affected:
buildlogs/buildlogs.sql:
index2.php (NONE -> 1.1) (NEW), addlog2.php (NONE -> 1.1) (NEW), buildlogs2.inc (NONE -> 1.1) (NEW), migration2.php (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: buildlogs/buildlogs.sql/index2.php
diff -u /dev/null buildlogs/buildlogs.sql/index2.php:1.1
--- /dev/null Wed Oct 22 11:22:20 2008
+++ buildlogs/buildlogs.sql/index2.php Wed Oct 22 11:22:15 2008
@@ -0,0 +1,826 @@
+<?php
+ob_start("ob_gzhandler", 1);
+$buildlogs_server = "buildlogs.pld-linux.org";
+$url = "index2.php";
+$fail_or_ok = array( "FAIL", "OK" );
+/*
+$database = 'sqlite:/home/services/ftp/buildlogs.db';
+$root_directory = "/home/services/ftp/pub/pld-buildlogs";
+*/
+
+// $database, $root_directory and others are taken from buildlogs.inc
+include('buildlogs2.inc');
+
+/* It should be set */
+
+$langs["en_US"]["charset"]="ISO-8859-1";
+$langs["pl_PL"]["charset"]="ISO-8859-2";
+
+$lang="en_US";
+if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]))
+{
+ $rows=explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
+ $rows=explode(",",$rows[0]);
+ $lang_detected=rtrim($rows[0]);
+} else if (preg_match("/opera/i",$_SERVER["HTTP_USER_AGENT"]))
+{
+ $lang_detected=preg_replace("/.*\[(.*)\].*/i","\\1",$_SERVER["HTTP_USER_AGENT"]);
+}
+
+// FIXME - some array
+$lang_detected=preg_replace("/^pl$/i","pl_PL",$lang_detected);
+
+if (isset($lang_detected) && isset($langs[$lang_detected]))
+{
+ $lang=$lang_detected;
+}
+
+if (isset($_GET["lang"]))$_SESSION["lang"]=$_GET["lang"];
+if (isset($_SESSION["lang"]))$lang=$_SESSION["lang"];
+
+putenv("LANG=$lang");
+setlocale(LC_ALL,$lang);
+bindtextdomain("messages","locale");
+textdomain("messages");
+
+if (isset($_GET["dist"]) && isset($_GET["arch"]))
+{
+ $dist = basename($_GET["dist"]);
+ $arch = basename($_GET["arch"]);
+}
+
+if (isset($_POST["dist"])) $dist = basename($_POST["dist"]);
+if (isset($_POST["arch"])) $arch = basename($_POST["arch"]);
+
+if (isset($_GET["name"])) {
+ $name = basename($_GET["name"]);
+}
+if (isset($_GET["ok"]))$ok=(int)$_GET["ok"];
+else $ok="";
+if (isset($_GET["ns"]))$ns=(int)$_GET["ns"];
+else $ns="";
+if (isset($_GET["cnt"]))$cnt=(int)$_GET["cnt"];
+else $cnt = 50;
+if (isset($_GET["action"]))$action=$_GET["action"];
+else $action="";
+if (isset($_GET["off"]))$off=(int)$_GET["off"];
+else $off = 0;
+if (isset($_GET["id"]))$id=$_GET["id"];
+
+if (isset($_POST["str"]))$str=$_POST["str"];
+if (isset($_POST["action"]))$action=$_POST["action"];
+
+function myheader()
+{
+echo '<' . '?xml version="1.0" encoding="' . _("ISO-8859-1") .'"?' . ">\n";
+echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>PLD Build Logs</title>
+ <?php echo '<meta http-equiv="Content-type" content="text/html; charset=' . _("ISO-8859-1") .'"/>' ."\n";?>
+ <style type="text/css"><!--
+A { text-decoration: none; }
+A:hover { text-decoration: underline; }
+H1 { font-family: arial,helvetica,sans-serif;
+ font-size: 20pt;
+ font-weight: bold;}
+H2 { font-family: arial,helvetica,sans-serif;
+ font-size: 18pt;
+ font-weight: bold;}
+BODY,TD { font-family: arial,helvetica,sans-serif;
+ font-size: 13pt; }
+TH { font-family: arial,helvetica,sans-serif;
+ font-size: 13pt;
+ font-weight: bold; }
+//-->
+</style>
+ </head>
+ <!-- Diffrent color for visited link doesn't make much sense here...
+ this page is autogenerated and it might be misleading after some
+ build log changes. -->
+ <body bgcolor="#ffffff" text="#000000" link="#5f26cd" vlink="#5f26cd">
+<?php
+}
+
+function start_pre()
+{
+ echo "<table cellpadding=\"10\"><tr><td bgcolor=\"#000000\">".
+ "<font color=\"#cccccc\"><pre style=\"width: 2048px;overflow: scroll\">";
+}
+
+function end_pre()
+{
+ echo "</pre></font></td></tr></table>\n";
+}
+
+function trailer()
+{
+ echo "</body></html>";
+}
+
+
+function mydie($msg)
+{
+ echo "Fatal error: $msg";
+}
+
+
+
+function list_logs()
+{
+ global $database;
+ global $arch, $dist, $ok;
+ global $big_url, $ns;
+ global $off, $cnt, $root_directory, $url;
+
+ $big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt";
+
+ if ($ok == 1) {
+ echo "<h1>"._("Listing of")." $dist/$arch/OK "
+ ."(<a href=\"$big_url&ok=0\">"._("fail")."</a>)</h1>\n";
+ } else {
+ echo "<h1>"._("Listing of")." $dist/$arch/FAIL "
+ ."(<a href=\"$big_url&ok=1\">"._("ok")."</a>)</h1>\n";
+ }
+
+ echo "<div align=\"center\"><table cols=\"4\" border=\"0\" cellspacing=\"1\" ".
+ "cellpadding=\"3\" bgcolor=\"#000000\" width=\"90%\">\n";
+ echo "<tr><th bgcolor=\"#CCCCFF\" align=\"right\" width=\"1%\">"._("No.")."</th>".
+ "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"80%\">"._("Log File").
+ "[<a href=\"$big_url&ns=1\">"._("sort")."</a>]</th>".
+ "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
+ "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
+ "[<a href=\"$big_url&ns=0\">"._("sort")."</a>]</th>".
+ "</tr>";
+
+ if ($ns != 1) $ns = 0;
+ if (!isset($ok)) $ok = 0;
+// if (!isset($off)) $off = 0;
+// if (!isset($cnt)) $cnt = 50;
+ if ($ns == 0) $order = "mtime DESC";
+ else $order = "name";
+
+ $query = "SELECT log_id, dist, arch, ok, name, mtime, size, id FROM logs WHERE "
+ . "dist = '$dist' AND arch = '$arch' AND ok = $ok ORDER BY $order LIMIT $cnt OFFSET $off";
+
+ try {
+ $dbh = new PDO("$database");
+ } catch (PDOException $e) {
+ mydie("new PDO: " . $e->getMessage());
+ }
+ $now = time();
+ $i = $off;
+ foreach ($dbh->query("$query") as $row) {
+ $f = $row["name"];
+ $t = $now - $row["mtime"];
+ $s = $row["size"];
+ $h = $row["log_id"];
+
+ $t /= 60;
+ if ($t >= 60) {
+ $t /= 60;
+ if ($t >= 24) {
+ $t /= 24;
+ $t = round($t);
+ $t = $t . " " . ngettext("day","days",$t);
+ } else {
+ $t = round($t);
+ $t = $t . " " . ngettext("hour","hours",$t);
+ }
+ } else {
+ $t = round($t);
+ $t = $t . " " . ngettext("minute","minutes",$t);
+ }
+ $u = "$url?dist=$dist&arch=$arch&ok=$ok&name=$name&id=$id";
+ echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
+ "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
+ "[<a href=\"$u&action=text\">"._("text")."</a> | ".
+ "<a href=\"$u&action=tail\">"._("tail")."</a>]".
+ "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
+ "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
+ $i++;
+ }
+ $count = $i - $off;
+ echo "</table></div>\n";
+
+ $backarr = "<<< ";
+ $back = _("Page back");
+ $forward = _("Page forward");
+ $forwardarr = " >>>";
+
+ echo "<p><table width=\"90%\" align=\"center\"><tr><td align=\"left\" width=\"1%\">";
+
+ if ($off > 0) {
+ $noff = $off - $count;
+ if ($noff < 0)
+ $noff = 0;
+ $hrefurl = "<a href=\"$big_url&off=$noff\">";
+ echo "$hrefurl$backarr</a></td><td align=\"left\">$hrefurl$back</a>";
+ } else {
+ echo "$backarr</td><td align=\"left\">$back";
+ }
+
+ echo "</td>\n<td align=\"center\">";
+
+ if (isset($dist) && isset($arch)) {
+ echo "[<a href=\"$big_url&action=qa\">"._("View <quot>rpm -qa</quot> of builder")."</a>]";
+ } else {
+ echo " ";
+ }
+
+ echo "</td>\n<td align=right>";
+ if ($cnt == $count) {
+ $noff = $off + $cnt;
+ if ($noff < 0)
+ $noff = 0;
+ $hrefurl = "<a href=\"$big_url&off=$noff\">";
+ echo "$hrefurl$forward</a></td><td align=right width=1%>$hrefurl$forwardarr</a>";
+ } else {
+ echo "$forward</td><td align=right width=1%>$forwardarr";
+ }
+ echo "</td>\n</tr></table></p>";
+}
+
+function file_name()
+{
+ global $ok, $dist, $arch, $name, $id;
+
+ if (isset($name) && isset($ok) && isset($arch) && isset($dist)) {
+ if (isset($id) && $id != '') {
+ $name = $name . ",$id";
+ }
+ $w = $ok ? "OK" : "FAIL";
+ return "$dist/$arch/$w/$name.bz2";
+ }
+}
+
+function dump_log($tail)
+{
+ global $ok, $url, $dist, $arch;
+ global $root_directory, $big_url, $ns, $id, $cnt, $off;
+ global $buildlogs_server;
+
+ $f = file_name();
+
+ if ($f == false)
+ return;
+
+ $df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
+ $df = preg_replace("/\.(bz2|gz)$/", "", $df);
+
+ echo "<h1>$df</h1>";
+
+ echo "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#000000\">";
+
+ function one_item($h, $t) {
+ echo "<tr><td bgcolor=\"#ccccff\">$h:</td>".
+ "<td bgcolor=\"#cccccc\">$t</td></tr>";
+ }
+
+ function href($h, $c) {
+ return "<a href=\"$h\">$c</a>";
+ }
+
+ one_item(_("Status"), ($ok == 1 ?
+ "<font color=\"green\"><b>"._("OK")."</b></font>" :
+ "<font color=\"red\"><b>"._("Failed")."</b></a>"));
+ one_item(_("Source URL"),
+ href("ftp://$buildlogs_server/$f",
+ "ftp://$buildlogs_server/$f"));
+
+ $big_url = "$url?dist=$dist&arch=$arch&ok=$ok&ns=$ns&cnt=$cnt";
+ $bu = "$big_url&off=$off";
+
+ one_item(_("text/plain URL"),
+ href("$bu&id=$id&action=text",
+ _("View!")));
+ if ($tail) {
+ one_item(_("full text"),
+ href("$bu&id=$id",
+ _("View!")));
+ }
+
+ if (isset($dist) && isset($arch)) {
+ one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!")));
+ } else {
+ one_item(_("rpm -qa of builder"), _("Not available"));
+ }
+ one_item("Data", date("Y/m/d H:i:s", filemtime("$root_directory/$f")));
+ /*
+ echo "<tr><td>Here:</td><td>" .
+ "<a href=\"$url?idx=$idx&ok=$ok&id=$id\">".
+ "http://" . getenv("SERVER_NAME") .
+ getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id</a>" .
+ "</td></tr>"; */
+
+ echo "</table><h2>"._("Content:")."</h2>";
+
+
+ # what can I say beside PHP suxx? how the fuck should I create
+ # bidirectional pipe? gotta use wget
+
+ if (preg_match("/\.bz2$/", $f)) {
+ $filter = "bzcat";
+ } elseif (preg_match("/\.gz$/", $f)) {
+ $filter = "zcat";
+ } else {
+ $filter = "cat";
+ }
+
+ $cmd = "$filter $root_directory/$f";
+ if ($tail)
+ $cmd = "$cmd | tail -n 100";
+ $fd = popen($cmd, "r");
+ start_pre();
+ while (($s = fgets($fd, 102400)) != false) {
+ if (strlen($s) > 800) {
+ $s = chunk_split($s, 800, "\n ");
+ $s = trim($s);
+ }
+ $s = htmlspecialchars($s);
+ echo $s;
+ }
+ end_pre();
+ pclose($fd);
+
+?>
+ <table width="100%">
+ <tr>
+ <td align=left>
+ [<a href="<?php echo $bu; ?>"><?=_("Back to list of logs")?></a>]
+ </td>
+ <td align=right>
+ [<a href="<?php echo "$bu&action=qa"
+ ?>"><?=_("View rpm -qa of builder")?></a>]
+ </td>
+ </tr>
+ </table>
+<?php
+
+}
+
+function dump_text()
+{
+ global $root_directory;
+ global $buildlogs_server;
+
+ header("Content-type: text/plain");
+
+ $f = file_name();
+ if ($f == false)
+ return;
+
+ echo "# src : ftp://$buildlogs_server/$f\n";
+ echo "# date : " .
+ date("Y/m/d H:i:s", filemtime("$root_directory/$f")) . "\n";
+
+ if (preg_match("/\.bz2$/", $f)) {
+ $filter = "bzcat";
+ } elseif (preg_match("/\.gz$/", $f)) {
+ $filter = "zcat";
+ } else {
+ $filter = "cat";
+ }
+
+ $cmd = "$filter $root_directory/$f";
+ $fd = popen($cmd, "r");
+ while (($s = fgets($fd, 1000)) != false) {
+ echo $s;
+ }
+ pclose($fd);
+}
+
+function list_archs()
+{
+ global $addr, $url, $cnt,$ok,$ns;
+
+ if (!isset($cnt))
+ $cnt = 50;
+
+ $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt";
+
+ echo "<table width=\"100%\" border=\"0\">\n";
+ echo "<tr><td bgcolor=\"#cccccc\" nowrap=\"nowrap\">"._("Failed")."</td><td bgcolor=\"#cccccc\">"._("Ok")."</td></tr>\n";
+ for ($i = 1; $i < count($addr); $i++) {
+ $dist = $addr[$i]['dist'];
+ $arch = $addr[$i]['arch'];
+ echo "<tr><td nowrap=\"nowrap\">".
+ "<a href=\"$url?dist=$dist&arch=$arch&ok=0&cnt=$cnt\">$addr[$i]</a></td><td nowrap=\"nowrap\">".
+ "[<a href=\"$url?dist=$dist&arch=$arch&ok=1&cnt=$cnt\">OK</a>]</td>".
+ #"<td>[<a href=\"$url?idx=$i&action=qa\">qa</a>]</td>".
+ "</tr>\n";
+ }
+ echo "</table><hr />\n";
+
+ echo "<div align=\"center\">";
+ echo "<a href=\"$big_url&action=adv_search\">"._("Advanced Search")."</a><br />\n";
+
+ echo "<a href=\"$url\">main()</a><hr />\n";
+ echo "<a href=\"http://www.pld-linux.org/\"><img src=\"powpld.png\" ".
+ "alt=\""._("Powered by PLD Linux")."\" border=\"0\" /></a><br />\n" .
+ "<small>(c) 2002 ".
+ "<a href=\"mailto:feedback at pld-linux.org\">PLD Team</a><br />\n".
+ '$Revision$'.
+ "</small></div>\n";
+
+ # smile ;)
+ echo "<div align=\"center\"><small>";
+ $pow = array("vim", "php", "brain", "power", "electricity",
+ "coffee", "ufo", "penguin", "GNOME", "ELF", "DWARF",
+ "voodoo magic", "Linux", "x-files", "X", "foobar",
+ "/dev/null", "/dev/zero", "/dev/drzewo",
+ "Leppe'", "matrix", "Neo", "PDP-11",
+ "Ken", "GNU antilope", "PDP-7", "ITS", "Multics",
+ "foobarbaz", "ed", "Joe", "Unix conspiracy",
+ "overclock", "The Right Thing",
+ "The Bad Thing", "Star Treck", "NSA", "NASA",
+ "achelon", "VAX", "Real Programmer",
+ "Real Operating System", "Real Computer",
+ "computron", "bogon", "quantum bogodynamics",
+ "BOFH", "/dev/ill", "nasi tu byli",
+ "Paranoid Android", "Lunatic Corp", "Parallel thinking",
+ "sfistak", "Linus", "The Golden Path", "Dark Side of the Force",
+ "Przewodniczacego Lepper-a", "KDE", "Microsoft Windows 2003", "sqlite3",
+ "synergy"
+ # feel free to add sth if you change this file ;)
+ );
+ echo _("Powered by")." ";
+ $max = 1;
+ for ($i = 0; $i < $max; $i++) {
+ $x = rand(0, count($pow) - 1);
+ if ($pow[$x] == "") $i--;
+ else echo $pow[$x] . ($i == $max - 1 ? "." : ", ");
+ $pow[$x] = "";
+ }
+ echo "</small></div>";
+
+ if (isset($dist) && isset($arch)) {
+ echo "<form action=\"index.php\" method=\"post\">";
+ echo "<input type=\"hidden\" name=\"dist\" value=\"$dist\" />";
+ echo "<input type=\"hidden\" name=\"arch\" value=\"$arch\" />";
+ echo "<input type=\"hidden\" name=\"action\" value=\"sqa\" />";
+ echo "<input type=\"text\" size=\"14\" name=\"str\" /><br />";
+ echo "<input type=\"submit\" name=\"submit\" value=\""._("Search rpmqa!")."\" />";
+ echo "</form>";
+ }
+}
+
+function get_qa()
+{
+ global $dist, $arch;
+
+ if (!isset($dist) || !isset($arch))
+ return false;
+
+$addr = "http://ftp.pld-linux.org/dists/$dist/.stat/builder/$dist/rpmqa-$arch.txt";
+ return fopen("$addr", "r");
+}
+
+function search_qa()
+{
+ global $url, $str, $dist, $arch;
+
+ $f = get_qa();
+ echo "<h1>"._("Search results for")." '$str' "._("in")." $dist/$arch</h1>";
+
+ start_pre();
+
+ if ($f == 0) {
+ echo _("Sorry, cannot open.");
+ } else {
+ while (($s = fgets($f, 1000)) != false) {
+ if (stristr($s, $str))
+ echo $s;
+ }
+ echo "/* EOF */";
+ }
+ end_pre();
+}
+
+function dump_qa($plain)
+{
+ global $url, $dist, $arch;
+
+ $f = get_qa();
+
+ if ($plain) {
+ header("Content-type: text/plain");
+ echo _("# rpm -qa of")." $dist/$arch\n";
+ } else {
+ echo "<h1>"._("rpm -qa of")." $a</h1>";
+ echo "<a href=\"$url?dist=$dist&arch=$arch&action=qatxt\">"._("text/plain version")."</a>";
+ start_pre();
+ }
+
+ if ($f == 0) {
+ echo _("Sorry, cannot open.");
+ } else {
+ while (($s = fgets($f, 1000)) != false) {
+ echo $s;
+ }
+ }
+
+ if (!$plain)
+ end_pre();
+}
+
+
+function adv_search()
+{
+ global $database, $addr, $fail_or_ok, $url, $_POST, $off, $cnt, $root_directory, $ok, $ns;
+
+ $big_url = "$url?ok=$ok&ns=$ns&cnt=$cnt";
+
+ echo "<script><!--\n".
+ "function checkboxToggle() {\n".
+ "for (var i=0;i<document.forms[0].elements.length;i++) {\n".
+ "var e = document.forms[0].elements[i];\n".
+ "if ((e.name != 'all') && (e.type=='checkbox'))\n".
+ "e.checked = document.forms[0].all.checked;\n".
+ "}\n }\n -->\n </script>\n";
+
+/* Shut up warnings */
+ if (!isset($_POST["name"])) $_POST["name"] = "";
+ if (!isset($_POST["age1"])) $_POST["age1"] = "";
+ if (!isset($_POST["age2"])) $_POST["age2"] = "";
+ if (!isset($_POST["size1"])) $_POST["size1"] = "";
+ if (!isset($_POST["size2"])) $_POST["size2"] = "";
+
+ echo "<form action=\"index.php?action=adv_search\" method=\"post\">";
+
+ echo "<div align=\"center\">";
+ echo "<table border=\"0\">\n";
+ echo "<tr>\n";
+ echo "<td>"._("Package name")."</td>\n";
+ echo "<td><input type=\"text\" size=\"20\" name=\"name\" value=\"". $_POST["name"] ."\"/></td>\n";
+ echo "</tr>\n";
+
+ echo "<tr>\n";
+ echo "<td>"._("Days")."</td>\n";
+ echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"age1\" value=\"". $_POST["age1"] ."\" /></td>\n";
+ echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"age2\" value=\"". $_POST["age2"] ."\" /></td>\n";
+ echo "</tr>\n";
+
+ echo "<tr>\n";
+ echo "<td>"._("Size")."</td>\n";
+ echo "<td>"._("From").": <input type=\"text\" size=\"20\" name=\"size1\" value=\"". $_POST["size1"] ."\" /></td>\n";
+ echo "<td>"._("To").": <input type=\"text\" size=\"20\" name=\"size2\" value=\"". $_POST["size2"] ."\" /></td>\n";
+ echo "</tr>\n";
+
+ echo "<tr>\n";
+ echo "<td>"._("Search logs:")."</td>\n";
+ echo "</tr>\n";
+
+ echo "<tr>\n";
+ echo "<td>"._("Failed")."</td>\n";
+ echo "<td>"._("OK")."</td>\n";
+ echo "</tr>\n";
+
+ for ($i = 1; $i < count($addr); $i++)
+ {
+ echo "<tr>\n";
+ $name="as0_".$i;
+ $dist = $addr[$i]['dist'];
+ $arch = $addr[$i]['arch'];
+ if (!isset($_POST["$name"])) {
+ $check = " ";
+ } else {
+ $check=" checked=\"on\"";
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list