$serverroot = dirname($_SERVER[SCRIPT_FILENAME]);
$wwwhome = dirname($_SERVER[SCRIPT_FILENAME]);
$wwwlogs = "$wwwhome/logs";
// Handle sessions.
$current = $_COOKIE[current];
if (time() - $current > 15 * 60) { // If last access > 15min -> new session
$last = $current;
setcookie('last', $last, time() + 365 * 86400);
} else {
$last = $_COOKIE[last];
}
setcookie('current', time(), time() + 365 * 86400);
// $last is the date of the last visit.
$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' );
$stat = stat("readme.php4");
$new = ( $stat[9] > $last );
$new = $new?'[ NEW ] ':'';
?>

Texture Download
print "$new";
?>
Readme 1st
$i = 0;
if (file_exists("$wwwlogs/texture_count.dat")) {
$FILE = fopen("$wwwlogs/texture_count.dat", "r");
while( $line = fgets($FILE) ) {
$serialized .= $line;
}
fclose($FILE);
$count = unserialize($serialized);
if (!is_array($count)) $count = array();
} else {
$count = array();
}
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] | Downloads |
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];
$new = ( $stat[9] > $last );
$filepath = "$texaltdir/".$f;
} else {
$stat = stat("$wwwhome/$texdir/".$f);
$size = $stat[7] ;
$new = ( $stat[9] > $last );
$filepath = "$texdir/".$f;
}
$new = $new?'[ NEW ] ':'';
if ($count[$filepath]=='') $count[$filepath] = 0;
print "
| $new
$f |
$size | $count[$filepath] | ";
$file ="$wwwhome/$previewdir/$name.jpg";
if(file_exists($file)){
print "
 |
|
";
} else {
print " | | ";
}
}
}
$i++;
print "\n
";
}
echo "
";
include("footer.inc");
?>