]> git.pld-linux.org Git - projects/buildlogs.git/commitdiff
- added locale files handling
authorjuandon <witekfl@pld-linux.org>
Mon, 25 Mar 2002 22:08:34 +0000 (22:08 +0000)
committerjuandon <witekfl@pld-linux.org>
Mon, 25 Mar 2002 22:08:34 +0000 (22:08 +0000)
- \$root_directory should be set, point to root directory of buildlogs
- php-mhash, php-pcre must be installed on server (and php-ftp for ftp support)

obsolete/buildlogs/index.php

index 4d7d88fea0ca96561993f5c823bb5ef98e774d70..0abd10460a13255b7c3350007555532f206cddb0 100644 (file)
@@ -6,12 +6,18 @@ $addr = array(
        "/nest/i386",
        "/nest/i586",
        "/nest/i686",
+       "/nest/ppc",
+       "/nest/ppc-ralike",
        "/ra/i386",
        "/ra/i586",
        "/ra/i686",
        "/ra/alpha",
        "/ra/sparc"
 );
+$local = 1; /* $local=0 for FTP */ 
+$root_directory = "";
+/* It should be set */
+
 
 function myheader()
 {
@@ -120,6 +126,45 @@ function open_ftp()
        return $list;
 }
 
+function directory_list()
+{
+       global $idx, $addr, $buildlogs_server, $ok;
+       global $root_directory, $big_url, $url, $ns;
+       global $off, $cnt;
+       
+       if (!isset($idx) || !isset($addr[$idx]))
+               return false;
+       
+       if ($ok != 1)
+               $ok = 0;
+       if ($ns != 1)
+               $ns = 0;
+               
+       if ($ok == 1) {
+               $a = "$addr[$idx]/OK";
+       } else {
+               $a = "$addr[$idx]/FAIL";
+       }
+       
+       if (!isset($off))
+               $off = 0;
+       if (!isset($cnt))
+               $cnt = 16;
+               
+       $big_url = "$url?idx=$idx&ok=$ok&ns=$ns";
+       
+       $dir = opendir("$root_directory$a");
+       $i = 0;
+       while ($file = readdir($dir)) {
+               if (($file != ".") && ($file != "..")) {
+                       $list[$i] = "$a/$file";
+                       $i++;
+               }
+       }
+       closedir($dir);
+       return $list;
+}
+
 function list_logs()
 {
        global $idx, $addr, $ok;
@@ -227,6 +272,110 @@ function list_logs()
        $ftp_conn = 0;
 }
 
+function local_list_logs()
+{
+       global $idx, $addr, $ok;
+       global $root_directory, $big_url, $ns;
+       global $off, $cnt;
+
+       $list = directory_list();
+
+       if ($list == false)
+               return;
+       
+       if ($ok == 1) {
+               echo "<h1>Listing of $addr[$idx]/OK "
+                       ."(<a href=\"$big_url&ok=0\">fail</a>)</h1>";
+       } else {
+               echo "<h1>Listing of $addr[$idx]/FAIL "
+                       ."(<a href=\"$big_url&ok=1\">ok</a>)</h1>";
+       }
+       
+       echo "<div align=center><table border=0 cellspacing=1 ".
+               "cellpadding=3 bgcolor=#000000 width=90%>\n";
+       echo "<tr><th bgcolor=#CCCCFF align=left width=60%>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>".
+                "</th></tr>";
+       
+       function cmp($f1, $f2) {
+               global $root_directory;
+               
+       return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
+       }
+
+       if ($ns != 1) {
+               $ns = 0;
+               usort($list, cmp);
+       } else {
+               sort($list);
+       }
+       
+       $now = time();
+       for ($i = $off; $i < $cnt + $off; $i++) {
+               if (!isset($list[$i]))
+                       continue;
+               $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
+               $f = preg_replace("/.*\/([^\/]*)$/", "\\1", $list[$i]);
+               $f = preg_replace("/\.(bz2|gz)$/", "", $f);
+               $s = filesize("$root_directory$list[$i]");
+               $t = $now - filemtime("$root_directory$list[$i]");
+               $t /= 60;
+               if ($t >= 60) {
+                       $t /= 60;
+                       if ($t >= 24) {
+                               $t /= 24;
+                               $t = round($t) . " days";
+                       } else {
+                               $t = round($t) . " hour";
+                       }
+               } else {
+                       $t = round($t) . " minutes";
+               }
+               $u = "$big_url&cnt=$cnt&off=$off&id=$h";
+               echo "<tr><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";
+       }
+       echo "</table></div>\n";
+
+       $back = "&lt;&lt;&lt; Page back";
+       $forward = "Page forward &gt;&gt;&gt;";
+
+       echo "<p align=center><table width=90%><tr><td align=left width=25%>";
+
+       if ($off > 0) {
+               $noff = $off - $cnt;
+               if ($noff < 0)  
+                       $noff = 0;
+               echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$back</a>\n";
+       } else {
+               echo "$back\n";
+       }
+       
+       echo "</td><td width=50% align=center>";
+       
+       echo "[<a href=\"$big_url&action=qa\">View rpm -qa of ".
+               "builder</a>]\n";
+               
+       echo "</td><td align=right width=25%>";
+       if ($off + $cnt < count($list)) {
+               $noff = $off + $cnt;
+               if ($noff < 0)  
+                       $noff = 0;
+               echo "<a href=\"$big_url&cnt=$cnt&off=$noff\">$forward</a>\n";
+       } else {
+               echo "$forward\n";
+       }
+       echo "</td></tr></table></p>";
+}
+
 function file_name()
 {
        global $idx, $addr, $ok;
@@ -258,6 +407,38 @@ function file_name()
        return $f;
 }
 
+
+function local_file_name()
+{
+       global $idx, $addr, $ok;
+       global $root_directory, $big_url, $ns, $id;
+       global $buildlogs_server;
+
+       if (!isset($id))
+               return false;
+               
+       $list = directory_list();
+
+       if ($list == false)
+               return false;
+
+       $f = false;
+       for ($i = 0; $i < count($list); $i++) {
+               $h = bin2hex(mhash(MHASH_MD5, $list[$i]));
+               if ($h == $id) {
+                       $f = $list[$i];
+               }
+       }
+
+       if ($f == false) {
+               mydie("cannot find specified file: $id");
+               return false;
+       }
+
+       return $f;
+}
+
+
 function dump_log($tail)
 {
        global $idx, $addr, $ok, $url;
@@ -356,6 +537,100 @@ function dump_log($tail)
 
 }
 
+
+function local_dump_log($tail)
+{
+       global $idx, $addr, $ok, $url;
+       global $root_directory, $big_url, $ns, $id, $cnt, $off;
+       global $buildlogs_server;
+
+       $f = local_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"));
+
+       $bu = "$big_url&cnt=$cnt&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!"));
+       }
+       
+       one_item("rpm -qa of builder", href("$bu&action=qa", "View!"));
+       one_item("Date", 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)) {
+               $cmd = "bzcat $root_directory$f";
+       } elseif (preg_match("/\.gz$/", $f)) {
+               $cmd = "zcat $root_directory$f";
+       } else {
+               $cmd = "cat $root_directory$f";
+       }
+
+       if ($tail)
+               $cmd = "$cmd | tail -n 100";
+       $fd = popen($cmd, "r");
+       start_pre();
+       while (($s = fgets($fd, 1000)) != false) {
+               $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>
+<?php
+
+}
+
 function dump_text()
 {
        global $ftp_conn;
@@ -391,6 +666,39 @@ function dump_text()
        pclose($fd);
 }
 
+
+function local_dump_text()
+{
+       global $root_directory;
+       global $buildlogs_server;
+       
+       header("Content-type: text/plain");
+
+       $f = local_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)) {
+               $cmd = "bzcat";
+       } elseif (preg_match("/\.gz$/", $f)) {
+               $cmd = "zcat";
+       } else {
+               $cmd = "cat";
+       }
+
+       $fd = popen("$cmd $root_directory$f", "r");
+       while (($s = fgets($fd, 1000)) != false) {
+               echo $s;
+       }
+       pclose($fd);
+}
+
+
 function list_archs()
 {
        global $addr, $url;
@@ -425,7 +733,8 @@ function list_archs()
                     "achelon", "VAX", "Real Programmer",
                     "Real Operating System", "Real Computer",
                     "computron", "bogon", "quantum bogodynamics",
-                    "BOFH"
+                    "BOFH", "/dev/ill", "nasi tu byli",
+                    "Paranoid Android", "Lunatic Corp"
                     # feel free to add sth if you change this file ;)
                     );
        echo "Powered by ";
@@ -481,7 +790,7 @@ Feel free to email bug reports, complaints and feature requests
 <!-- ech... niech strace... -->
 <a href="mailto:malekith (at) pld org pl">to us</a>. Positive opinions are also 
 <a href="mailto:malekith (at) pld org pl">welcome</a> ;)</p>
-<p>Version: $Id: index.php,v 1.1 2002/01/14 17:16:48 malekith Exp $</p>
+<p>Version: $Id: index.php,v 1.2 2002/01/16 13:02:24 malekith Exp $</p>
 </td><td width=20%>&nbsp;</td></tr>
 </table>
 <?php
@@ -493,27 +802,51 @@ header("Cache-Control: no-cache, must-revalidate");
 header("Pragma: no-cache");
 
 //phpinfo();
+if ($local) {
+       if ($action == "text") {
+               local_dump_text();
+       } 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 (isset($id))
+                       local_dump_log($action == "tail");
+               else if (isset($idx))
+                       local_list_logs();
+               else 
+                       welcome();
+               echo "</tr></table>";
+               trailer();
+       }
+}
+else {
 
-
-if ($action == "text") {
-       dump_text();
-} 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 (isset($id))
-               dump_log($action == "tail");
-       else if (isset($idx))
-               list_logs();
-       else 
-               welcome();
-       echo "</tr></table>";
-       trailer();
+       if ($action == "text") {
+               dump_text();
+       } 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 (isset($id))
+                       dump_log($action == "tail");
+               else if (isset($idx))
+                       list_logs();
+               else 
+                       welcome();
+               echo "</tr></table>";
+               trailer();
+       }
 }
 ?>
This page took 0.127529 seconds and 4 git commands to generate.