'err','reason'=>'File not found'))); } else { $answer = getInfoAboutHash($hash); $answer['status'] = 'ok'; exit(json_encode($answer)); } function getInfoAboutHash($hash) { $file = ROOT.DS.'data'.DS.$hash.DS.$hash; $size = filesize($file); $size_hr = renderSize($size); $content_type = exec("file -bi " . escapeshellarg($file)); if($content_type && $content_type!=$type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false) { $type = $content_type; $c = explode(';',$type); $type = $c[0]; } return array('hash'=>$hash,'size_bytes'=>$size,'size_interpreted'=>$size_hr,'type'=>$type,'type_interpreted'=>getTypeOfFile($file)); }