$wwwhome = dirname($_SERVER[SCRIPT_FILENAME]); $wwwlogs = "$wwwhome/logs"; $filename = $_GET[file]; $file = "$wwwhome/$filename"; if (file_exists($file)) { // find out file mime-type $type = 'application/x-octet-stream'; $ext = substr($file, -4); if ($ext == '.zip') $type = 'application/x-zip'; // if ($ext == '.png') $type = 'image/png'; //if ($ext == '.jpg') $type = 'image/jpeg'; // headers to trigger download action header("Content-type: $type"); header("Content-disposition: attachment; filename=\"$filename\""); // serve file $FILE = fopen($file, "r"); while ($chunk = fread($FILE, 1048576)) { echo $chunk; } fclose($FILE); // inc counter 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(); } $count[$filename] += 1; $serialized = serialize($count); $FILE = fopen("$wwwlogs/texture_count.dat", "w"); fwrite($FILE, $serialized); fclose($FILE); } else { include ("header.inc"); print "