Beispiel #1
0
 /**
  * Send files using X-Sendfile server module
  *
  * @param string $filePath
  */
 public static function sendWithXSendfile($filePath)
 {
     if (stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== FALSE) {
         $fallback = true;
         $config =& QFinder_Connector_Core_Factory::getInstance("Core_Config");
         $XSendfileNginx = $config->getXSendfileNginx();
         foreach ($XSendfileNginx as $location => $root) {
             if (false !== stripos($filePath, $root)) {
                 $fallback = false;
                 $filePath = str_ireplace($root, $location, $filePath);
                 header("X-Accel-Redirect: " . $filePath);
                 // Nginx
                 break;
             }
         }
         // fallback to standar method
         if ($fallback) {
             QFinder_Connector_Utils_FileSystem::readfileChunked($filePath);
         }
     } elseif (stripos($_SERVER['SERVER_SOFTWARE'], 'lighttpd/1.4') !== FALSE) {
         header("X-LIGHTTPD-send-file: " . $filePath);
         // Lighttpd v1.4
     } else {
         header("X-Sendfile: " . $filePath);
         // Apache, Lighttpd v1.5, Cherokee
     }
 }