listdir($dir.'/'.$file);
}
else {if (strpos($dir.':'.$file,'/src:m3makefile,v') > 0)
{ $dire = substr($dir,$fcut,strlen($dir)-4-$fcut);
$name = substr($dire,strrpos($dire,'/')+1,strlen($dire)-strrpos($dire,'/')-1);
$flist[$dire] = strtolower($name);};
}
}
}
closedir($handle);
}
}
}
### Dateigroesse in KB umwandeln
function fsize($size)
{
$wert = (string) Floor($size / 102.4); if ($size<1024) {$wert="0".$wert;};
return substr($wert,0,strlen($wert)-1).",".$wert[strlen($wert)-1]." kB";
}
### Dateiliste aller Paketdateien erstellen
class filelist {
function listfiles($dir) {
global $fcut,$totsize,$totfiles,$mdir;
if (is_readable($dir))
{$handle=opendir($dir);
while ($file = readdir($handle)) {
if ($file != ".." && $file != ".")
{
if (is_dir($dir.'/'.$file))
{
$newins = new filelist;
$newins->listfiles($dir.'/'.$file);
}
else { $name = substr($dir."/".$file,$fcut,strlen($dir."/".$file)-$fcut);
if (is_readable($mdir."/".$name)) {echo"
".fsize(filesize($mdir."/".$name))." | ".$name." |
\n"; $totsize+=filesize($mdir."/".$name); $totfiles++;};};
}
}
closedir($handle);
}
}
}
### HTML-Header ausgeben
function head() {
global $HTTP_USER_AGENT;
if (preg_match("/Win|MSIE/", $HTTP_USER_AGENT)) {$size1="10"; }
else {$size1="12"; };
if (preg_match("/Opera/", $HTTP_USER_AGENT)) {$size1="12"; };
echo '
Download CM3 packages
'."\n";
$fn = BODYPATH."/right-top-body-en.php";
$alternativeback='Back to M3 download';
$title = "";
if (is_readable($fn)) { include($fn); };
}
### HTML-Header fuer Dateidownload ausgeben
function download($filename,$cont) {
global $HTTP_USER_AGENT;
header("Pragma: no-cache");// HTTP/1.0
header("Cache-Control: no-cache, must-revalidate");// HTTP/1.1
header("Content-Type: ".$cont);
if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
$header = "Content-Disposition: filename=".$filename;
}else {
$header = "Content-Disposition: attachment; filename=".$filename;
}
header($header);
header("Content-Transfer-Encoding: binary\n");
}
### Hinweis oder Fehlermeldung ausgeben
function msgout($message, $typ) {
if ($typ=="f") {
echo 'Error!
';};
echo ''.$message.'
';
}
### Sicherheit: Pruefen ob angeforderte Datei in der Liste vorhanden
function securitytest()
{
global $flist,$dl;
$dirli = new dirlist;
$dirli->listdir(MAINDIR);
$chkok=1;
for ($i=0; $i strlen($dl[$counter2]))&&(strpos($dl[$counter],$dl[$counter2])===0)) {if ($dl[$counter][strlen($dl[$counter2])]=="/") {$sout=1;};};
$counter2++;
}
if ($sout==1) {array_splice($dl,$counter,1);}
else {$counter++;};
}
}
### Ausgabefunktion zu fileconttotable
function filecontout()
{
global $clist;
for ($i=0; $i".$buf."\n";
}
else
{
$clist[]=$prestr.$buf.$afterstr;
};
};
};
fclose($fp);
}
##### Hauptprogramm #####
$atype="gz";
$opt="source";
$sort="";
$dl="";
$dlsubmit=0;
$rst=0;
$datumrev="";
$datum="";
$rev="";
$modula="CM3";
### Querystring-Verarbeitung
if (isset($QUERY_STRING))
{if ($QUERY_STRING=="dist=PM3") {$modula="PM3";};};
if (isset($HTTP_POST_VARS))
{for (reset($HTTP_POST_VARS); $key = key($HTTP_POST_VARS); next($HTTP_POST_VARS))
{
$valu=array($key,$HTTP_POST_VARS[$key]);
$val2=$key."=".$HTTP_POST_VARS[$key];
if ($val2=="atype=bz2") {$atype="bz2";}
elseif ($val2=="atype=zip") {$atype="zip";}
elseif ($val2=="option=cvs") {$opt="cvs";}
elseif ($val2=="sort=Name") {$sort="name";}
elseif ($val2=="dist=PM3") {$modula="PM3";}
elseif ($val2=="submit=Download selected packages") {$dlsubmit=1;}
elseif ($val2=="submit=File list of selected packages") {$dlsubmit=2;}
# elseif ($val2=="submit=List all revisions") {$dlsubmit=3; }
else
{
if (($valu[0]=="revi") or (($valu[0]=="revi2")&&($rev===""))) {$rev=$valu[1];};
if (($valu[0]=="date")&&(strlen(trim($valu[1]))>0)) {$datumrev.=" -D \"".EscapeShellCmd(trim($valu[1]))."\""; $datum=$valu[1];}
elseif ($valu[1]=="Reset selection")
{$rst=1;
if ($valu[0]=="resetname") {$sort="name";}}
elseif ($valu[0]=="Downld") {$dl=$valu[1];};
};
}
}
if ($rst==1) {$dl=""; $atype="gz"; $opt="source"; $datum=""; $rev="";};
if ($dlsubmit==3) {$opt="source";};
if (strlen(trim($rev))>0) {$datumrev.=" -r \"".EscapeShellCmd(trim($rev))."\"";}
###
$ch[$atype]="checked";
$che[$opt]="checked";
#### Verzeichnisdefinition
if ($modula=="CM3")
{
define("MAINDIR", "/usr/cvs/cm3");
define("MAINDIRCVS", "/usr/cvs");
define("SUBDIRCVS", "cm3");
$rfiles=array("cm3_tags");
}
else
{
define("MAINDIR", "/usr/cvs/pm3/m3/pm3");
define("MAINDIRCVS", "/usr/cvs/pm3");
define("SUBDIRCVS", "m3/pm3");
$rfiles=array("./pm3/pm3_tags");
};
define("BODYPATH", ".");
define("REVDIR", ".");
ini_set(max_execution_time,"36000"); #evtl. mehr Zeit
$fcut=1+strlen(MAINDIR);
#$rfiles2=array("all_tags_3", "all_tags_1", "all_tags_2", "all_tags_4");
#$rnames=array("devel", "release", "branch", "other");
if ($dlsubmit == 0) {
$dirli = new dirlist;
$dirli->listdir(MAINDIR);
# $rfiles=array("all_tags_1", "all_tags_2");
### Haupttabelle ausgeben
head();
echo "
".$modula." package download
\n";
include("pkg-download-txt-en.php");
echo '";
}
elseif ($dlsubmit<3) {
### Pruefen, Packen, Downloaden
if ($dl == "") {head(); msgout("Nothing selected.", "f"); $dlsubmit=0;}
else
{
if ($atype != "zip") {$atype="tar.".$atype;}
$cdl=0;
for ($i=0; $iOnly listed packages could be requested.", "f"); $dlsubmit=0;}
else
{$pathtopack=""; subdirfilter();
if ($opt!="cvs") {$j=SUBDIRCVS."/";} else {$j="";};
for ($i=0; $i".$error, "f"); $dlsubmit=0;}
else
{
if ($atype=="tar.gz") {$execstr='tar --gzip -cf - --block-size 1 -C '.$mdir.' '.$pathtopack; $mimet="x-gzip";}
if ($atype=="tar.bz2") {$execstr='tar --bzip2 -cf - --block-size 1 -C '.$mdir.' '.$pathtopack; $mimet="x-bzip2";}
if ($atype=="zip") {$execstr="zippack ".$mdir." ".$pathtopack; $mimet="x-zip-compressed";}
if ($dlsubmit==1)
{
### Downloaden
download($name.".".$atype,"application/".$mimet);
passthru($execstr);
}
else {
### Nur Liste ausgeben
head();
$fcut=1+strlen($mdir);
$totfilesall=0; $totsizeall=0;
for ($i=0; $iPackage: ".$dl[$i]."
";
echo "Size | File: |
\n";
$totsize=0; $totfiles=0;
$fileli = new filelist;
$fileli->listfiles($mdir."/".$dl[$i]);
echo "
\n";
echo $totfiles." files; ".fsize($totsize)." total (uncompressed).
\n";
$totfilesall+=$totfiles; $totsizeall+=$totsize;
};
echo "All selected packages: ".$totfilesall." files; ".fsize($totsizeall)." total (uncompressed).
\n";
}
};
#if ($opt!="cvs") {exec ("rm -dfr ".$tmpdir);};
if ($opt!="cvs")
{$fp = fopen($tmpdir."/.transfer-done", "w");
fclose($fp);};
}
}
}
}
}
else
{
### Anzeige aller Revisionen
echo "Not enabled yet.";
# head();
# $rev="";
# echo "\n";
# $clist="";
#for ($i=0; $i<4; $i++)
# {
# $clist[]="".$rnames[$i].":\n";
# $clist[]="\n";
# fileconttotable($rfiles2[$i],""," | \n");
# $clist[]=" \n";
# };
# $r=round((count($clist)/2))+1;
#for ($i=0; $i")===0)
# {$rnames=substr($clist[$i],7,strpos($clist[$i],"")-7);};
# if ($i==$r) {echo " |
\n
| ".$rnames."\n\n";};
# echo $clist[$i];
# };
# echo " \n";
}
if ($dlsubmit!=1) {
$fn = BODYPATH."/right-bottom-body.php";
if (is_readable($fn)) { find_pics_top($pics); include($fn); };
echo '';
};
?>
|