<?php
    chdir
("../sessions.lqfm"); require ".htsession.php"chdir("../home.lqfm");
    if (
$validated) {
        
$pathrequest str_replace("..""", ($_GET['file']));
        
$pathrequest str_replace("/""/.ht"$pathrequest);
        
$path ".htfolders/.ht".$username."/.ht".$pathrequest;
        
clearstatcache();
        if (
file_exists($path)) {
            if (
is_dir($path))
                echo 
"Directories cannot be retrieved.";
            else {
                
$fileExtension strtolower(substr(strrchr($pathrequest"."), 1));
                switch (
$fileExtension) {
                    case 
"aif": case "aiff"$contentType "audio/x-aiff"; break;
                    case 
"avi"$contentType "video/avi"; break;
                    case 
"bmp"$contentType "image/bmp"; break;
                    case 
"c"$contentType "text/plain"; break;
                    case 
"c++"$contentType "text/plain"; break;
                    case 
"css"$contentType "text/css"; break;
                    case 
"doc"$contentType "application/msword"; break;
                    case 
"exe"$contentType "application/octet-stream"; break;
                    case 
"gif"$contentType "image/gif"; break;
                    case 
"htm": case "html"$contentType "text/html"; break;
                    case 
"ico"$contentType "image/x-icon"; break;
                    case 
"jpg": case "jpeg"$contentType "image/jpeg"; break;
                    case 
"m4a"$contentType "audio/x-m4a"; break;
                    case 
"mid"$contentType "audio/midi"; break;
                    case 
"mov"$contentType "video/quicktime"; break;
                    case 
"mp3"$contentType "audio/mpeg"; break;
                    case 
"mpg"$contentType "video/mpeg"; break;
                    case 
"pdf"$contentType "application/pdf"; break;
                    case 
"png"$contentType "image/png"; break;
                    case 
"wmv"$contentType "video/x-ms-wmv"; break;
                    case 
"zip"$contentType "application/zip"; break;
                    default: 
$contentType "text/plain"// Or application/octet-stream
                
}
            
                
$fp fopen($path'rb');

                
header("Content-Transfer-Encoding: binary");
                
header("Content-Type: $contentType");
                
header("Content-Length: " filesize($path));

                
fpassthru($fp);
                
fclose($fp);
            }
        }
        else
            echo 
"File $path does not exist.";
    }
?>