$serverroot = dirname($SCRIPT_FILENAME);
$wwwhome = dirname($SCRIPT_FILENAME);
$TITLE = "CGI-download";
include("header.inc");
#
# get parameters (DXT support?, card memory?)
#
$maxmem = $_POST[ram];
$dds = $_POST[dxt];
$mem = array( '8', '16', '32', '64', '128' );
$res = array( '2k', '4k', '8k', '16k' );
$resol = array( '2048 x 1024','4096 x 2048','8192 x 4096','16384 x 8192' );
?>

Texture Download
Readme 1st
$i = 0;
while ( $mem[$i] <= $maxmem ) {
$texdir ="textures/".$res[$i];
$previewdir=$texdir."/preview";
if ($dds) {
$texaltdir = $texdir."/jpg-png";
$texdir = $texdir."/dds";
} else {
$texdir = $texdir."/jpg-png";
}
chdir($wwwhome."/".$texdir);
$DIR = opendir('.');
$allfiles = array();
while (false !== ($file = readdir($DIR))) {
if ($file[0] != ".") array_push($allfiles, $file);
}
closedir($DIR);
#
# If - in case of DXT-support - there exist textures NOT in dds format,
# we list these, too
#
if ($dds){
chdir($wwwhome."/".$texaltdir);
$DIRALT = opendir('.');
$allaltfiles = array();
while (false !== ($file = readdir($DIRALT))) {
if ($file[0] != ".") array_push($allaltfiles, $file);
}
closedir($DIRALT);
foreach($allaltfiles as $fa) {
list($namealt,$format) = split("\.", $fa);
$filealt = "$wwwhome$texdir/$namealt.dds.zip";
if(!file_exists($filealt)){
array_push($allfiles, $fa);
}
}
}
#
# print table only if there are files in a given directory
#
$num = count($allfiles);
if ($num != 0) {
print "$resol[$i]";
print "";
print " | Texture | Size [bytes] |
Preview | Help |
\n";
foreach ($allfiles as $f) {
list($name,$format) = split("\.", $f);
if ($dds && ($format == "jpg" | $format == "png")) {
$stat = stat("$wwwhome/$texaltdir/".$f);
$size = $stat[7];
$filepath = "$texaltdir/".$f;
} else {
$stat = stat("$wwwhome/$texdir/".$f);
$size = $stat[7] ;
$filepath = "$texdir/".$f;
}
print "
| $f |
$size | ";
$file ="$wwwhome/$previewdir/$name.jpg";
if(file_exists($file)){
print "
 |
|
";
} else {
print " | | ";
}
}
}
$i++;
print "\n
";
}
echo "
";
include("footer.inc");
?>