]> git.pld-linux.org Git - projects/buildlogs.git/commitdiff
- new versions of buildlogs scripts, not tested at all
authorwitekfl <witekfl@pld-linux.org>
Wed, 22 Oct 2008 09:22:15 +0000 (09:22 +0000)
committerwitekfl <witekfl@pld-linux.org>
Wed, 22 Oct 2008 09:22:15 +0000 (09:22 +0000)
buildlogs.inc [new file with mode: 0644]
index.php [new file with mode: 0644]
pld-buildlogs/scripts/addlog.php [new file with mode: 0644]
pld-buildlogs/scripts/migration.php [new file with mode: 0644]

diff --git a/buildlogs.inc b/buildlogs.inc
new file mode 100644 (file)
index 0000000..074c8d7
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+$database_file = "/home/services/httpd/html/pld-buildlogs/db/buildlogs.db";
+$database = "sqlite:$database_file";
+$root_directory = "/home/services/ftp/pub/pld-buildlogs";
+$addr = array(
+       array("dist" => "", "arch" => ""),/* must be first */
+       array("dist" => "th, "arch" => "SRPMS"),
+       array("dist" => "th", "arch" => "i486"),
+       array("dist" => "th", "arch" => "i686"),
+       array("dist" => "th", "arch" => "athlon"),
+       array("dist" => "th", "arch" => "x86_64"),
+       array("dist" => "th", "arch" => "alpha"),       
+       array("dist" => "th", "arch" => "ppc"),
+       array("dist" => "ac", "arch" => "SRPMS"),
+       array("dist" => "ac", "arch" => "i386"),
+       array("dist" => "ac", "arch" => "i586"),
+       array("dist" => "ac", "arch" => "i686"),
+       array("dist" => "ac", "arch" => "athlon"),
+       array("dist" => "ac", "arch" => "amd64"),
+       array("dist" => "ac", "arch" => "alpha"),       
+       array("dist" => "ac", "arch" => "ppc"),
+       array("dist" => "ac", "arch" => "sparc"),
+  array("dist" => "ac", "arch" => "sparc64")
+);
+
+?>
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..5fb3bdc
--- /dev/null
+++ b/index.php
@@ -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&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
+
+       if ($ok == 1) {
+               echo "<h1>"._("Listing of")." $dist/$arch/OK "
+                       ."(<a href=\"$big_url&amp;ok=0\">"._("fail")."</a>)</h1>\n";
+       } else {
+               echo "<h1>"._("Listing of")." $dist/$arch/FAIL "
+                       ."(<a href=\"$big_url&amp;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&amp;ns=1\">"._("sort")."</a>]</th>".
+                "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
+                "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
+                        "[<a href=\"$big_url&amp;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 . "&nbsp;" . ngettext("day","days",$t);
+                       } else {
+                               $t = round($t);
+                               $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
+                       }
+               } else {
+                       $t = round($t);
+                       $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
+               }
+               $u = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;name=$name&amp;id=$id";
+               echo "<tr><td bgcolor=\"#CCCCCC\" align=\"right\">".($i+1).".</td>".
+                    "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
+                    "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
+                     "<a href=\"$u&amp;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 = "&lt;&lt;&lt;&nbsp;";
+       $back = _("Page back");
+       $forward = _("Page forward");
+       $forwardarr = "&nbsp;&gt;&gt;&gt;";
+
+       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&amp;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&amp;action=qa\">"._("View <quot>rpm&nbsp;-qa</quot> of builder")."</a>]";
+       } else {
+               echo "&nbsp;";
+       }
+
+       echo "</td>\n<td align=right>";
+       if ($cnt == $count) {
+               $noff = $off + $cnt;
+               if ($noff < 0)  
+                       $noff = 0;
+               $hrefurl = "<a href=\"$big_url&amp;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&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;cnt=$cnt";
+       $bu = "$big_url&amp;off=$off";
+
+       one_item(_("text/plain URL"), 
+                href("$bu&amp;id=$id&amp;action=text",
+                     _("View!")));
+       if ($tail) {
+               one_item(_("full text"), 
+                        href("$bu&amp;id=$id",
+                             _("View!")));
+       }
+
+       if (isset($dist) && isset($arch)) {
+               one_item(_("rpm -qa of builder"), href("$bu&amp;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&amp;ok=$ok&amp;id=$id\">".
+               "http://" . getenv("SERVER_NAME") .
+               getenv("SCRIPT_NAME") . "?idx=$idx&amp;ok=$ok&amp;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&amp;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&amp;ns=$ns&amp;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&amp;arch=$arch&amp;ok=0&amp;cnt=$cnt\">$addr[$i]</a></td><td nowrap=\"nowrap\">".
+                    "[<a href=\"$url?dist=$dist&amp;arch=$arch&amp;ok=1&amp;cnt=$cnt\">OK</a>]</td>".
+                    #"<td>[<a href=\"$url?idx=$i&amp;action=qa\">qa</a>]</td>".
+                    "</tr>\n";
+  }
+       echo "</table><hr />\n";
+       
+       echo "<div align=\"center\">";
+       echo "<a href=\"$big_url&amp;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@pld-linux.org\">PLD&nbsp;Team</a><br />\n".
+            '$Revision: 1.7 $'.
+            "</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&amp;arch=$arch&amp;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&amp;ns=$ns&amp;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\"";
+    }
+    echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">".$dist/$arch."</label></td>\n";
+    $name="as1_".$i;
+    if (!isset($_POST["$name"])) {
+       $check = " ";
+    } else {
+       $check=" checked=\"on\"";
+    }
+    echo "<td><input name=\"$name\" id=\"$name\" type=\"checkbox\"$check /><label for=\"$name\">".$dist/$arch."</label></td>\n";
+    echo "</tr>\n";
+  }
+       
+  echo "<tr>\n";
+  echo "<td><input name=\"all\" type=\"checkbox\" checked=\"on\" onClick=\"checkboxToggle()\">"._("Toggle checkboxes")."&nbsp;<input type=\"submit\" name=\"submit\" value=\""._("Search!")."\" /></td>";
+  echo "</tr>\n";
+
+  echo "</table>\n";
+
+//     if (isset($_POST["name"]) || isset($_POST["age1"]) || isset($_POST["age2"]) ||
+//       isset($_POST["size1"]) || isset($_POST["size2"])
+  if (($_POST["name"]!="") || ($_POST["age1"]!="") || ($_POST["age2"]!="") ||
+    ($_POST["size1"]!="") || ($_POST["size2"]!=""))
+  {
+       $query = "SELECT log_id, dist, arch, ok, name, size, mtime, id FROM logs WHERE 1 ";
+       if ($_POST["name"] != "") {
+               $n = addslashes($_POST["name"]);
+               $query .= "AND name LIKE '$n%' ";
+       }
+       $now = time();
+
+       if ($_POST["age1"] != "") {
+               $age = $now - (int)$_POST["age1"] * 24 * 3600;
+               $query .= "AND mtime > $age ";
+       }
+
+       if ($_POST["age2"] != "") {
+               $age = $now - (int)$_POST["age2"] * 24 * 3600;
+               $query .= "AND mtime < $age ";
+       }
+
+       if ($_POST["size1"] != "") {
+               $size = (int)$_POST["size1"];
+               $query .= "AND size > $size ";
+       }
+
+       if ($_POST["size2"] != "") {
+               $size = (int)$_POST["size2"];
+               $query .= "AND size < $size ";
+       }
+
+       $or = "AND (";
+       for ($i = 1; $i < count($addr); $i++) {
+               for ($j = 0; $j < 2; $j++) {
+                       if (isset($_POST["as" . $j . "_" .$i])) {
+                               $query .= "$or (dist = $addr[$i]['dist'] AND arch = $addr[$i]['arch'] AND ok = $j)";
+                               $or = " OR ";
+                       }
+               }
+       }
+       if ($or == " OR ") $query .= ")";
+//     if (!isset($cnt)) $cnt = 50;
+//     if (!isset($off)) $off = 0;
+       if (!isset($ns)) $ns = 0;
+       switch ($ns) {
+               case 0:
+                       $query .= " ORDER BY mtime DESC";
+                       break;
+               case 1:
+                       $query .= " ORDER BY name";
+                       break;
+               case 2:
+                       $query .= " ORDER BY dist, arch, name";
+                       break;
+       }
+       $query .= " LIMIT $cnt OFFSET $off ";
+
+       try {
+               $dbh = new PDO("$database");
+       } catch (PDOException $e) {
+               mydie("new PDO: " . $e->getMessage());
+       }
+       $result = $dbh->query("$query")->fetchAll();
+
+       if ($result == FALSE) {
+               echo _("Nothing found");
+       } else {
+               echo "<table border=\"0\" cellspacing=\"1\" ".
+                       "cellpadding=3 bgcolor=\"#000000\" width=\"90%\">\n";
+               echo "<tr><th bgcolor=\"#CCCCFF\" align=\"left\" width=\"10%\">"._("Builder").
+                       "[<a href=\"$big_url&amp;ns=2\">"._("sort")."</a>]</th>";
+               echo "<th bgcolor=\"#CCCCFF\" align=\"left\" width=\"60%\">"._("Log File").
+                       "[<a href=\"$big_url&amp;ns=1\">"._("sort")."</a>]</th>".
+                       "<th bgcolor=\"#CCCCFF\" align=\"right\" width=\"15%\">"._("Size")."</th> ".
+                        "<th bgcolor=\"#CCCCFF\" align=\"left\">"._("Age").
+                        "[<a href=\"$big_url&amp;ns=0\">"._("sort")."</a>]</th>".
+                        "</th></tr>";
+               $i = $off;
+//             for ($i = $off; $i < $off + $count; $i++) {
+               foreach ($result as $row) {
+      $dist = $row["dist"];
+      $arch = $row["arch"];
+      $name = $row["name"];
+      $id = $row["id"];
+                       $f = $name;
+      if ($id != '') $f .= ",$id";
+                       $t = $now - $row["mtime"];
+                       $s = $row["size"];
+                       $t /= 60;
+                       if ($t >= 60) {
+                               $t /= 60;
+                               if ($t >= 24) {
+                                       $t /= 24;
+                                       $t = round($t);
+                                       $t = $t . "&nbsp;" . ngettext("day","days",$t);
+                               } else {
+                                       $t = round($t);
+                                       $t = $t . "&nbsp;" . ngettext("hour","hours",$t);
+                               }
+                       } else {
+                               $t = round($t);
+                               $t = $t . "&nbsp;" . ngettext("minute","minutes",$t);
+                       }
+                       
+//                $big_url = "$url?idx=$i&amp;ok=$j&amp;ns=$ns&amp;cnt=$cnt";
+      $ok = $row["ok"];
+                       $u = "$url?dist=$dist&amp;arch=$arch&amp;name=$name&amp;ok=$ok;&amp;id=$id";
+                       $b = "$url?dist=$dist&amp;arch=$arch&amp;ok=$ok&amp;ns=$ns&amp;off=$off&amp;cnt=$cnt";
+
+                       $builder = "$dist/$arch/". $fail_or_ok[$ok];
+                       echo "<tr>";
+                       echo "<td bgcolor=\"#CCCCCC\"><a href=\"$b\">$builder</a></td>";
+                       echo "<td bgcolor=\"#CCCCCC\"><a href=\"$u\">$f</a> ".
+                       "[<a href=\"$u&amp;action=text\">"._("text")."</a> | ".
+                       "<a href=\"$u&amp;action=tail\">"._("tail")."</a>]".
+                       "</td><td bgcolor=\"#CCCCCC\" align=\"right\">".
+                       "$s</td><td bgcolor=\"#CCCCCC\">$t</td></tr>\n";
+                       $i++;
+               }
+               echo "</table></div>\n";
+
+               $backarr = "&lt;&lt;&lt;&nbsp;";
+               $back = _("Page back");
+               $forward = _("Page forward");
+               $forwardarr = "&nbsp;&gt;&gt;&gt;";
+
+       }
+// FIXME
+/*
+       echo "<p><table width=\"90%\" align=\"center\"><tr><td align=left width=1%>";
+
+       if ($off > 0) {
+               $noff = $off - $cnt;
+               if ($noff < 0)  
+                       $noff = 0;
+               $hrefurl = "<a href=\"$big_url&amp;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\">";
+    echo "</td>\n<td align=\"right\">";
+
+    if ($off + $cnt < count($list))
+    {
+      $noff = $off + $cnt;
+      if ($noff < 0)   
+        $noff = 0;
+      $hrefurl = "<a href=\"$big_url&amp;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>";
+*/
+  } else
+  {
+    echo _("Enter something!");
+  }
+  echo "</form>\n";
+}
+
+function welcome()
+{
+?>
+<table border="0" width="100%"><tr><td width="20%">&nbsp;</td><td>
+<h1><?=_("Welcome!")?></h1>
+<p><?=_("Welcome to PLD Build Logs WWW interface.")?></p><p>
+<?=_("Feel free to email bug reports, complaints and feature requests ")?>
+<!-- ech... niech strace... -->
+<a href="mailto:feedback@pld-linux.org"><?=_("to us")?></a>. <?=_("Positive opinions are also")?> 
+<a href="mailto:feedback@pld-linux.org"><?=_("welcome")?></a> ;)</p>
+<p>Version: $Id: index.php,v 1.7 2007/11/28 12:42:52 witekfl Exp $</p>
+</td><td width="20%">&nbsp;</td></tr>
+</table>
+<?php
+}
+
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+//phpinfo();
+if ($action == "text") {
+       dump_text();
+} else if ($action == "adv_search") {
+       myheader();
+       adv_search();
+       trailer();
+} else if ($action == "qatxt") {
+       dump_qa(1);
+} else {
+       myheader();
+       echo "<table cellpadding=\"10\" width=\"100%\"><tr><td valign=\"top\" width=\"10%\">";
+       list_archs();
+       echo "</td><td valign=\"top\">";
+       flush();
+       if ($action == "qa")
+               dump_qa(0);
+       else if ($action == "sqa")
+               search_qa();
+       else if (isset($id) || isset($name))
+               dump_log($action == "tail");
+       else if (isset($dist))
+               list_logs();
+       else
+               welcome();
+       echo "</td></tr></table>";
+       trailer();
+}
+?>
diff --git a/pld-buildlogs/scripts/addlog.php b/pld-buildlogs/scripts/addlog.php
new file mode 100644 (file)
index 0000000..319767c
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/php.cli
+<?php
+// $Revision: 1.8 $, $Date: 2008/03/12 15:59:00 $
+/*
+$database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs.db';
+$root_directory = '/home/services/ftp/pub/pld-buildlogs';
+// $database and $root_directory are taken from buildlogs.inc .
+// parameter: argv[1] - full path to the log file.
+*/
+
+$result = array("FAIL" => 0, "OK" => 1);
+include('buildlogs.inc');
+
+if (!isset($argv[1])) {
+       die("Usage: $argv[0] full_path_to_the_log\n");
+}
+if (!preg_match("|^$root_directory/(.*)/(.*)/(.*)/(.*),?(.*)?\.bz2$|", $argv[1], $matches))
+       exit(0);
+
+$dist = $matches[1];
+$arch = $matches[2];
+$ok = $result[$matches[3]];
+$name = $matches[4];
+if (isset($matches[5]) {
+       $id = $matches[5];
+} else {
+       $id = '';
+}
+$size = filesize($argv[1]);
+$mtime = filemtime($argv[1]);
+
+try {
+       $dbh = new PDO("$database");
+} catch (PDOException $e) {
+       die ($e->getMessage());
+}
+$result = $dbh->query("SELECT log_id FROM logs WHERE dist = '$dist' AND arch = '$arch' AND name = '$name'"
+." AND id = '$id' LIMIT 1")->fetchAll();
+if (count($result) == 1) {
+       foreach ($result as $row) {
+               $query = "UPDATE logs SET ok = $ok, size = $size, mtime = $mtime WHERE log_id = $row[log_id]";
+               break;
+       }
+} else {
+       $query = "INSERT INTO logs(dist, arch, ok, name, size, mtime, id) "
+       . "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id')";
+}
+$ile = $dbh->exec("$query");
+if ($ile != 1) {
+       print_r($dbh->errorInfo());
+}
+?>
diff --git a/pld-buildlogs/scripts/migration.php b/pld-buildlogs/scripts/migration.php
new file mode 100644 (file)
index 0000000..2276ac8
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/php.cli
+<?php
+// $Revision: 1.6 $, $Date: 2007/12/02 15:49:42 $
+/*
+$root_directory = '/home/services/ftp/pub/pld-buildlogs';
+$database = 'sqlite:/home/services/httpd/html/pld-buildlogs/db/buildlogs.db';
+// $root_directory and $database are taken from buildlogs.inc
+$reverse_addr = array(
+       "th/SRPMS" => 1,
+       "th/i486" => 2,
+       "th/i686" => 3,
+       "th/athlon" => 4,
+       "th/x86_64" => 5,
+       "th/ia64" => 6,
+       "th/alpha" => 7,
+       "th/ppc" => 8,
+       "th/sparc" => 9,
+       "ac/SRPMS" => 10,
+       "ac/i386" => 11,
+       "ac/i586" => 12,
+       "ac/i686" => 13,
+       "ac/athlon" => 14,
+       "ac/amd64" => 15,
+       "ac/alpha" => 16,
+       "ac/ppc" => 17,
+       "ac/sparc" => 18,
+       "ac/sparc64" => 19
+);
+*/
+include('buildlogs.inc');
+
+if (file_exists($database_file)) {
+       unlink($database_file);
+}
+
+$query = " CREATE TABLE LOGS(log_id INTEGER PRIMARY KEY, dist TEXT, arch TEXT, ok INTEGER, name TEXT, "
+. "size INTEGER, mtime INTEGER, id TEXT DEFAULT '');";
+try {
+       $dbhandle = new PDO("$database");
+} catch (PDOException $e) {
+       die("new PDO: ". $e->getMessage());
+}
+
+$result = array("FAIL", "OK");
+
+$dh = opendir($root_directory);
+if ($dh) {
+       die("opendir $root_directory");
+}
+while ($dist = readdir($dh)) {
+       if ($dist[0] == '.') continue;
+       if (!is_dir("$root_directory/$dist")) continue;
+       $ah = opendir("$root_directory/$dist");
+       if (!ah) die("opendir $dist");
+       while ($arch = readdir($ah)) {
+               if ($arch[0] == '.') continue;
+               if (!is_dir("$root_directory/$dist/$arch")) continue;
+               for ($ok = 0; $ok < 2; $ok++) {
+                       $directory = "$root_directory/$dist/$arch/" . $result[$ok]
+                       $sh = opendir($directory);
+                       if (!$sh) continue;
+                       while ($file = readdir($sh)) {
+                               if (preg_match("/^(.*),?(.*)?\.bz2$/", $file, $match)) {
+                                       $f = "$directory/" . $match[0];
+                                       $size = filesize($f);
+                                       $mtime = filemtime($f);
+                                       $name = $match[1];
+                                       if (isset($match[2])) {
+                                               $id = $match[2];
+                                       } else {
+                                               $id = "";
+                                       }
+$query .= " INSERT INTO logs(dist, arch, ok, name, size, mtime, id) "
+. "VALUES('$dist', '$arch', $ok, '$name', $size, $mtime, '$id');";
+                               }
+                               
+                       }
+                       closedir($sh);
+               }
+       }
+       closedir($ah);
+}
+closedir($dh);
+
+$dbhandle->beginTransaction();
+$dbhandle->exec("$query");
+$dbhandle->commit();
+?>
This page took 0.14507 seconds and 4 git commands to generate.