<?php
require("config.php");
$locations=array();
$locations[]="$_SESSION[root_folder]/$_SESSION[domain_name]$_SERVER[REQUEST_URI]";
$locations[]="$_SESSION[root_folder]$_SERVER[REQUEST_URI]";
$fileExtension=array_pop(explode('.',$_SERVER['REQUEST_URI']));
foreach($locations as $location){
if(file_exists($location)){
$mimeCachePath="$_SESSION[root_folder]/.mimetype";
$mimeMasterPath="$_SESSION[root_folder]/../.cpanel/datastore/SYSTEMMIME";
$mimeTypeData=@unserialize(file_get_contents($mimeCachePath));
if($mimeTypeData===false)
$mimeTypeData=array();
if(@$mimeTypeData['masterTimestamp']!=filemtime($mimeMasterPath)){
$mimeTypeData['masterTimestamp']=filemtime($mimeMasterPath);
$masterRaw=unpack('C*', file_get_contents($mimeMasterPath));
$magic=chr(array_shift($masterRaw)).chr(array_shift($masterRaw)).chr(array_shift($masterRaw)).chr(array_shift($masterRaw));
if($magic!='pst0')
throw new Exception("e1308282055 - mime list is not a perl stored file");
$version=array_shift($masterRaw).'.'.array_shift($masterRaw).'.'.array_shift($masterRaw); $dataCount=array_shift($masterRaw)<<24|array_shift($masterRaw)<<16|array_shift($masterRaw)<<8|array_shift($masterRaw);
while(@$dataCount){
if(array_shift($masterRaw)!=10)
throw new Exception("e1308282103 - expected LF at end of line");
$keyLength=array_shift($masterRaw);
$key='';
while(@$keyLength){
$key.=chr(array_shift($masterRaw));
$keyLength--;
}
$valueLength=array_shift($masterRaw)<<24|array_shift($masterRaw)<<16|array_shift($masterRaw)<<8|array_shift($masterRaw);
$value='';
while(@$valueLength){
$value.=chr(array_shift($masterRaw));
$valueLength--;
}
foreach(explode(' ',$key)as $extension)
$mimeTypeData['extensions'][$extension]=$value;
$dataCount--;
}
file_put_contents($mimeCachePath,serialize($mimeTypeData));
}
$mimeType=@$mimeTypeData['extensions'][$fileExtension];
if(!$mimeType)$mimeType='application/octet-stream';
header("Content-Type: $mimeType");
@readfile($location);
echo(1);
die;
}
}?>