\n";
echo '<' . '?xml-stylesheet href="#internalStyle" type="text/css"?' . ">\n";
?>
PLD Build Logs
' ."\n";?>
".
"";
}
function end_pre()
{
echo " |
\n";
}
function trailer()
{
echo "";
}
function mydie($msg)
{
echo "Fatal error: $msg";
}
function open_ftp($pidx="", $pok="")
{
global $idx, $addr, $buildlogs_server, $ok;
global $ftp_conn, $big_url, $url, $ns;
global $off, $cnt;
if ($pidx==="")$pidx=$idx;
if ($pok==="")$pok=$ok;
if (!isset($pidx) || !isset($addr[$pidx]))
return false;
if ($pok != 1)
$pok = 0;
if ($ns != 1)
$ns = 0;
if ($pok == 1) {
$a = "$addr[$pidx]/OK";
} else {
$a = "$addr[$pidx]/FAIL";
}
if (!isset($off))
$off = 0;
if (!isset($cnt))
$cnt = 16;
$big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
$ftp = ftp_connect($buildlogs_server);
if ($ftp == false) {
mydie(_("cannot connect to")." $buildlogs_server");
return false;
}
if (ftp_login($ftp, "anonymous",
"buildlogs-iface@pld.org.pl") == false) {
ftp_quit($ftp);
mydie(_("cannot ftp login to")." $buildlogs_server");
return false;
}
$list = ftp_nlist($ftp, $a);
if ($list == false) {
ftp_quit($ftp);
mydie(_("cannot list")." $a");
return false;
}
$ftp_conn = $ftp;
return $list;
}
function directory_list($pidx="",$pok="")
{
global $idx, $addr, $buildlogs_server, $ok;
global $root_directory, $big_url, $url, $ns;
global $off, $cnt;
if ($pidx==="")$pidx=$idx;
if ($pok==="")$pok=$ok;
if (!isset($pidx) || !isset($addr[$pidx]))
return false;
if ($pok != 1)
$pok = 0;
if ($ns != 1)
$ns = 0;
if ($pok == 1) {
$a = "$addr[$pidx]/OK";
} else {
$a = "$addr[$pidx]/FAIL";
}
if (!isset($off))
$off = 0;
if (!isset($cnt))
$cnt = 16;
$big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
$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;
global $ftp_conn, $big_url, $ns, $qa_addr;
global $off, $cnt, $local, $root_directory;
if ($local) {
$list = directory_list();
} else {
$list = open_ftp();
}
if ($list == false)
return;
if ($ok == 1) {
echo ""._("Listing of")." $addr[$idx]/OK "
."("._("fail").")
\n";
} else {
echo ""._("Listing of")." $addr[$idx]/FAIL "
."("._("ok").")
\n";
}
echo "\n";
echo ""._("No.")." | ".
""._("Log File").
"["._("sort")."] | ".
""._("Size")." | ".
""._("Age").
"["._("sort")."] | ".
"
";
function cmp($f1, $f2) {
global $ftp_conn, $root_directory, $local;
if ($local)
return filemtime("$root_directory$f2") - filemtime("$root_directory$f1");
return ftp_mdtm($ftp_conn, $f2) - ftp_mdtm($ftp_conn, $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);
if ($local) {
$s = filesize("$root_directory$list[$i]");
$t = $now - filemtime("$root_directory$list[$i]");
} else {
$s = ftp_size($ftp_conn, $list[$i]);
$t = $now - ftp_mdtm($ftp_conn, $list[$i]);
}
$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 = "$big_url&off=$off&id=$h";
echo "".($i+1).". | ".
"$f ".
"["._("text")." | ".
""._("tail")."]".
" | ".
"$s | $t |
\n";
}
echo "
\n";
$backarr = "<<< ";
$back = _("Page back");
$forward = _("Page forward");
$forwardarr = " >>>";
echo "";
if ($off > 0) {
$noff = $off - $cnt;
if ($noff < 0)
$noff = 0;
$hrefurl = "";
echo "$hrefurl$backarr | $hrefurl$back";
} else {
echo "$backarr | $back";
}
echo " | \n";
if ($qa_addr[$idx] != "") {
echo "["._("View rpm -qa of builder")."]";
} else {
echo " ";
}
echo " | \n";
if ($off + $cnt < count($list)) {
$noff = $off + $cnt;
if ($noff < 0)
$noff = 0;
$hrefurl = "";
echo "$hrefurl$forward | $hrefurl$forwardarr";
} else {
echo "$forward | $forwardarr";
}
echo " | \n
";
if ($local == 0) {
ftp_quit($ftp_conn);
$ftp_conn = 0;
}
}
function file_name()
{
global $idx, $addr, $ok;
global $ftp_conn, $root_directory, $big_url, $ns, $id;
global $buildlogs_server, $local;
if (!isset($id))
return false;
if ($local) {
$list = directory_list();
} else {
$list = open_ftp();
}
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");
if ($local == 0)
ftp_quit($ftp_conn);
return false;
}
return $f;
}
function dump_log($tail)
{
global $idx, $addr, $ok, $url;
global $ftp_conn, $root_directory, $big_url, $ns, $id, $cnt, $off;
global $buildlogs_server, $local, $qa_addr;
$f = file_name();
if ($f == false)
return;
$df = preg_replace("/.*\/([^\/]*)$/", "\\1", $f);
$df = preg_replace("/\.(bz2|gz)$/", "", $df);
echo "$df
";
echo "";
function one_item($h, $t) {
echo "$h: | ".
"$t |
";
}
function href($h, $c) {
return "$c";
}
one_item(_("Status"), ($ok == 1 ?
""._("OK")."" :
""._("Failed").""));
one_item(_("Source URL"),
href("ftp://$buildlogs_server$f",
"ftp://$buildlogs_server$f"));
$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 ($qa_addr[$idx] != "") {
one_item(_("rpm -qa of builder"), href("$bu&action=qa", _("View!")));
} else {
one_item(_("rpm -qa of builder"), _("Not available"));
}
if ($local) {
one_item("Data", date("Y/m/d H:i:s", filemtime("$root_directory$f")));
} else {
one_item("Data", date("Y/m/d H:i:s", ftp_mdtm($ftp_conn, $f)));
}
/*
echo "Here: | " .
"".
"http://" . getenv("SERVER_NAME") .
getenv("SCRIPT_NAME") . "?idx=$idx&ok=$ok&id=$id" .
" |
"; */
echo "
"._("Content:")."
";
if ($local == 0) {
ftp_quit($ftp_conn);
$ftp_conn = 0;
}
# 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";
}
if ($local) {
$cmd = "$filter $root_directory$f";
} else {
$cmd = "wget -q -O - ftp://$buildlogs_server$f 2>&1 | $filter 2>&1";
}
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);
?>
&1 | $filter 2>&1";
}
$fd = popen($cmd, "r");
while (($s = fgets($fd, 1000)) != false) {
echo $s;
}
pclose($fd);
}
function list_archs()
{
global $addr, $url, $idx, $cnt;
if (!isset($cnt))
$cnt = 16;
$big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
echo "\n";
echo ""._("Failed")." | "._("Ok")." |
\n";
for ($i = 0; $i < count($addr); $i++)
echo "".
"$addr[$i] | ".
"[OK] | ".
#"[qa] | ".
"
\n";
echo "
\n";
echo "\n";
# smile ;)
echo "";
$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"
# 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 "
";
global $qa_addr;
if ($qa_addr[$idx] != "") {
echo "";
}
}
function get_qa()
{
global $idx, $qa_addr, $qa_base;
if (!isset($idx) || !isset($qa_addr[$idx]))
return false;
$a = $qa_addr[$idx];
if ($qa_addr[$idx] == "")
return false;
else
return fopen("$qa_base$qa_addr[$idx]", "r");
}
function search_qa()
{
global $url, $idx, $qa_addr, $str;
$f = get_qa();
echo ""._("Search results for")." '$str' "._("in")." $qa_addr[$idx]
";
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, $idx, $qa_addr;
$a = $qa_addr[$idx];
$f = get_qa();
if ($plain) {
header("Content-type: text/plain");
echo _("# rpm -qa of")." $a\n";
} else {
echo ""._("rpm -qa of")." $a
";
echo ""._("text/plain version")."";
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 $addr, $url, $local, $_POST, $off, $cnt, $root_directory;
$big_url = "$url?idx=$idx&ok=$ok&ns=$ns&cnt=$cnt";
echo "\n";
}
function welcome()
{
?>
|
=_("Welcome!")?>
=_("Welcome to PLD Build Logs WWW interface.")?>
=_("Feel free to email bug reports, complaints and feature requests ")?>
=_("to us")?>. =_("Positive opinions are also")?>
=_("welcome")?> ;)
Version: $Id: index.php,v 1.48 2002/10/12 20:50:04 ankry Exp $
| |
";
list_archs();
echo " | ";
flush();
if ($action == "qa")
dump_qa(0);
else if ($action == "sqa")
search_qa();
else if (isset($id))
dump_log($action == "tail");
else if (isset($idx))
list_logs();
else
welcome();
echo " |
";
trailer();
}
}
else {
if ($action == "text") {
dump_text();
} else if ($action == "qatxt") {
dump_qa(1);
} else {
myheader();
echo "";
list_archs();
echo " | ";
flush();
if ($action == "qa")
dump_qa(0);
else if (isset($id))
dump_log($action == "tail");
else if (isset($idx))
list_logs();
else
welcome();
echo " |
";
trailer();
}
}
?>