getDirName($dir); $name = preg_replace("%[^a-zA-Z0-9_\-]++%", "", $name); $path = OPENVK_ROOT . "/storage/$dir/$name.$format"; if(!file_exists($path)) { $this->notFound(); } else { if(isset($_SERVER["HTTP_IF_NONE_MATCH"])) exit(header("HTTP/1.1 304 Not Modified")); header("Content-Type: " . mime_content_type($path)); header("Content-Size: " . filesize($path)); header("ETag: W/\"" . hash_file("snefru", $path) . "\""); readfile($path); exit; } } }