private function streamDownloads($file_path, $ext)
 {
     $parts = explode('/', $file_path);
     $file = end($parts);
     switch ($ext) {
         case "asf":
             $type = "video/x-ms-asf";
             break;
         case "avi":
             $type = "video/x-msvideo";
             break;
         case "exe":
             $type = "application/octet-stream";
             break;
         case "cab":
             $type = "application/octet-stream";
             break;
         case "doc":
             $type = "application/msword";
             break;
         case "docx":
             $type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
             break;
         case "jar":
             $type = "application/octet-stream";
             break;
         case "mov":
             $type = "video/quicktime";
             break;
         case "mp3":
             $type = "audio/mpeg";
             break;
         case "mpg":
             $type = "video/mpeg";
             break;
         case "mpeg":
             $type = "video/mpeg";
             break;
         case "pdf":
             $type = "application/pdf";
             break;
         case "ppt":
             $type = "application/vnd.ms-powerpoint";
             break;
         case "pptx":
             $type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
             break;
         case "rar":
             $type = "encoding/x-compress";
             break;
         case "swf":
             $type = "application/x-shockwave-flash";
             break;
         case "txt":
             $type = "text/plain";
             break;
         case "wav":
             $type = "audio/wav";
             break;
         case "wma":
             $type = "audio/x-ms-wma";
             break;
         case "wmv":
             $type = "video/x-ms-wmv";
             break;
         case "zip":
             $type = "application/x-zip-compressed";
             break;
         default:
             $type = "application/force-download";
             break;
     }
     $header_file = strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? preg_replace('/\\./', '%2e', $file, substr_count($file, '.') - 1) : $file;
     if ($stream = fopen($file_path, 'rb')) {
         $this->doStatistics(filesize($file_path));
         header("Pragma: public");
         header("Expires: 0");
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header("Cache-Control: public", false);
         header("Content-Description: File Transfer");
         header("Content-Type: " . $type);
         header("Accept-Ranges: bytes");
         header("Content-Disposition: attachment; filename=\"" . $header_file . "\";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . filesize($file_path));
         header('HTTP/1.1 200 OK');
         while (!feof($stream) && connection_status() == 0) {
             set_time_limit(0);
             print fread($stream, 1024 * 8);
         }
         fclose($stream);
         flush();
         return true;
     } else {
         flush();
         self::$last_error = __(F_STR_ERROR);
         return false;
     }
 }
<?php

$file_path = 'web/images/blank.gif';
$download_manager = new PADownloadManager($file_path);
if (!$download_manager->getFile()) {
    out_error404($download_manager->lastError(), $file_path);
}
 /**
  * Determines the request type (php, or file) and dispatches control to the appropriate
  * classes and functions 
  */
 public function dispatch()
 {
     $res_script = null;
     list($file_type, $file_path, $success) = $this->parseRequestURL();
     if ($success) {
         switch ($file_type) {
             case 'php':
                 self::$request_type = 'script';
                 if (!($script = getShadowedPath($file_path))) {
                     out_error404(F_NOT_FOUND, $file_path);
                 }
                 if (!$this->current_route) {
                     $this->current_route = $_SERVER['PHP_SELF'];
                     $this->route_query_str = $_SERVER['QUERY_STRING'];
                 } else {
                     $this->route_query_str = $this->org_query_str;
                 }
                 $res_script = $this->bootApp($file_path);
                 break;
             default:
                 self::$request_type = 'file';
                 $download_manager = new PADownloadManager($file_path);
                 if (!$download_manager->getFile()) {
                     out_error404($download_manager->lastError(), $file_path);
                 }
                 exit;
         }
     } else {
         out_error404(F_NO_ROUTE);
     }
     return $res_script;
 }