[cvs] / gkbweb / htdocs / shared / inc / global.inc  

cvs: gkbweb/htdocs/shared/inc/global.inc

File: [cvs] / gkbweb / htdocs / shared / inc / global.inc (download)
Revision: 1.9, Wed Mar 21 22:12:41 2007 UTC (6 years, 2 months ago) by tobias
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
lots of updates

<?php
    $home 
"/var/www/www.ppckernel.org";
    
$html "$home/htdocs";
    
//$ftp = "$home/www/source";
    
    
$layout_top "$html/shared/inc/layout-top.inc";
    
$layout_tail "$html/shared/inc/layout-tail.inc";
    
$enableAds true;

    
error_reporting(E_ALL);
    
    include(
"$html/shared/inc/config.php");

    function 
dbconnect() {
        global 
$mysql_host$mysql_db$mysql_user$mysql_pass;
        
$dbh mysql_pconnect($mysql_host$mysql_user$mysql_pass);
        
mysql_select_db($mysql_db$dbh);
        return 
$dbh;
    }
    
    function 
hostname() {
        return 
"www.ppckernel.org";
    }
    
    function 
kernelfile($kernel$file) {
        global 
$html;
        
        if (
file_exists("$html/download/$kernel/.$file"))
            return 
trim(join("",file("$html/download/$kernel/.$file")));
        else
            return 
"";
    }
    
    function 
formatdate($indate) {
        
$inudate strtotime(str_replace(" at","",$indate));
        if ((
date("U") - date("U",$inudate)) < 60*60*24*30)
            
$outdate "<em>$indate</em>";
        else
            
$outdate $indate;
        return 
$outdate;
    }
    
    function 
binarylink($kernel$version) {
        global 
$html;
        
        if (
file_exists("$html/download/$kernel/linux-$kernel-$version.tar.bz2"))
            return 
"<a href=\"/download/$kernel/linux-$kernel-$version.tar.bz2\">linux-$kernel-$version.tar.bz2</a> (" 
                
number_format(filesize("$html/download/$kernel/linux-$kernel-$version.tar.bz2")/1024) . " kb)";
        else
            return 
"None";
    }
    
    function 
sourcelink($kernel) {
        global 
$html;
        return 
"<code>$kernel</code> (available via rsync from <a href='http://rsync.ppckernel.org'>rsync.ppckernel.org</a>)";
        
$lfile "$html/download/source/src-$kernel.tar.bz2";
        if (
file_exists($lfile)) {
            
$size number_format(filesize($lfile)/1024/1024,1);
            
$date filemtime($lfile);
            
$date date("n/j/y",$date);
            
$date formatdate($date);
            return 
"<a href=\"http://www.ppckernel.org/download/source/src-$kernel.tar.bz2\">src-$kernel.tar.bz2</a> ($size mb; updated $date)";
        } else
            return 
"None";
    }
    
    function 
configlink($name,$configname) {
        global 
$html;
        
        if (
file_exists("$html/build/configs/$name/$configname"))
            return 
"<a href='/build/configs/$name/$configname'>$configname</a> (" 
                
number_format(filesize("$html/build/configs/$name/$configname")/1024) . " kb)";
        else
            return 
"None";
    }
    
    function 
patchlink($name,$patchname) {
        global 
$html;
        
$patches=explode(';',$patchname);

        for(
$i=0$i<count($patches); $i++) {
            
$pname $patches[$i];
            if (
file_exists("$html/build/patches/$name/$pname"))
                
$output.= "<a href=\"/build/patches/$name/$pname\">$pname</a> (" 
                    
number_format(filesize("$html/build/patches/$name/$pname")/1024) . " kb)&nbsp;&nbsp; ";
            else
                
$output.= "None";

            if (
$i< (count($patches)-1))
                
$output.= " | ";
        }
    }
    
    class 
buildinfo {
        var 
$version$date$failed$failed_date;
        
        function 
buildinfo($kernel) {
            global 
$html;
            
$this->version kernelfile($kernel,"version");
        
            if (empty(
$this->version))
                
$this->version "None";
            else
                
$this->date kernelfile($kernel,"date");
            
            
$this->failed kernelfile($kernel,"failed");
        
$failed_file "$html/download/$kernel/.failed";        
if (
file_exists($failed_file)) {
$mdate filemtime($failed_file);
$mmdate date("F jS, Y"$mdate);
                                
$mmtime date("g:i A T"$mdate);
$this->failed_date "$mmdate at $mmtime";
}    
            
        }
    }
    
    function 
dlstart($left$right$name) {
        echo 
"<tr><td class=\"dlheader\"><a name='$name'></a>$left</td><td align=\"right\">$right</td></tr>\n";
        echo 
"<tr><td colspan=\"2\" class=\"dldesc\">\n";
    }
    
    function 
dlend() {
        echo 
"</td></tr>\n";
    }
    
    function 
showkernel($name$safename$fullname$description$patchfile$configfile$configpath) {
        
$title $fullname;
        
//        echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
        
$info = new buildinfo($safename);
        
        
dlstart($fullname$info->version,$safename);
        
        echo 
"<p>$description</p>\n";
        echo 
"<p><b>Latest build:</b> $info->version<br>\n";
        if (
$info->version != "None") {
            echo 
"<b>Built on:</b> ".formatdate($info->date)."<br><br>\n";
            
            echo 
"<b>Download:</b> " binarylink($safename$info->version) . "<br>\n";
            
            echo 
"<b>Source tree:</b> " sourcelink($name);
            
            if (!empty(
$patchfile))
                echo 
"<br>\n<b>Patch:</b> " patchlink($safename,$patchfile) . "\n";
            if (!empty(
$configfile))
                echo 
"<br>\n<b>Config:</b> " configlink($safename,$configfile) . "\n";
            elseif (!empty(
$configpath))
                echo 
"<br>\n<b>Config:</b> May be found within the source tree at <code><a href='http://rsync.ppckernel.org/modules/$name/$configpath'>$configpath</a></code>\n";
            
            if(empty(
$info->failed)) {
                echo 
"<br><br>\n";
                
$host kernelfile($safename,"host");
                if (
$q mysql_query("select hostname, logspath, infopath from buildhosts where name='$host'")) {
                    if (
$r mysql_fetch_object($q)) {
                        echo 
"This kernel was built by <a href='http://".$r->hostname."/".$r->infopath."'>".$host."</a>.  \n";
                        echo 
"<b>Build logs</b> are available at <a href='http://".$r->hostname."/".$r->logspath."/".$safename."'>".$r->hostname."/".$r->logspath."/$safename</a>.\n";
                    }
                }
            }
            echo 
"</p>\n";
        } else {
            echo 
"</p>\n";
            echo 
"<p>There are currently no builds of this kernel available.  This is, most likely, a relatively new kernel that is present in the database but hasn't reached the build scripts yet.";
            if (empty(
$info->failed))
                echo 
"<br><br>Furthermore, I am not aware of any previous errors building this kernel, so it should be available soon.";
            if (!empty(
$patchfile))
                echo 
"<br>\n<b>Patch:</b> " patchlink($safename,$patchfile) . "\n";
            if (!empty(
$configfile))
                echo 
"<br>\n<b>Config:</b> " configlink($safename,$configfile) . "\n";
            elseif (!empty(
$configpath))
                echo 
"<br>\n<b>Config:</b> May be found within the source tree at <code><a href='http://rsync.ppckernel.org/modules/$name/$configpath'>$configpath</a></code>\n";
            echo 
"</p>\n";
        }

        if (!empty(
$info->failed)) {
            echo 
"<p><b>Note:</b> the source code for 
$info->failed is available but could not be built. Last build 
attempted "
.formatdate($info->failed_date).".\n";
        
            echo 
"<br><br>\n";
            
$host kernelfile($safename,"host");
            if (
$q mysql_query("select hostname, logspath, infopath from buildhosts where name='$host'")) {
                if (
$r mysql_fetch_object($q)) {
                    echo 
"This build was attempted by <a href='http://".$r->hostname."/".$r->infopath."'>".$host."</a>.  \n";
                    echo 
"<b>Build logs</b> are available at <a href='http://".$r->hostname."/".$r->logspath."/".$safename."'>".$r->hostname."/".$r->logspath."/$safename</a>.\n";
                }
            }

            echo 
"</p>\n";
        
//echo "<p><b>Build logs:</b> <a href=\"http://dev.build.ppckernel.org/logs/log-$safename/\">dev.build.ppckernel.org/logs/log-$safename</a>.</p>\n";
        
}
        
dlend();
        
//        echo "</table>\n";
    
}    
?>

Tobias McNulty

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help