mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-15 04:28:01 +00:00
streamlined hash detection
This commit is contained in:
@@ -16,8 +16,6 @@ $hash = $_REQUEST['hash'];
|
|||||||
|
|
||||||
if(!isExistingHash($hash))
|
if(!isExistingHash($hash))
|
||||||
{
|
{
|
||||||
//check storage controllers
|
|
||||||
|
|
||||||
exit(json_encode(array('status'=>'err','reason'=>'File not found')));
|
exit(json_encode(array('status'=>'err','reason'=>'File not found')));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -31,10 +29,12 @@ else
|
|||||||
function getInfoAboutHash($hash)
|
function getInfoAboutHash($hash)
|
||||||
{
|
{
|
||||||
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
|
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
|
||||||
|
if(!$file_exists($file))
|
||||||
|
return array('status'=>'err','reason'=>'File not found');
|
||||||
$size = filesize($file);
|
$size = filesize($file);
|
||||||
$size_hr = renderSize($size);
|
$size_hr = renderSize($size);
|
||||||
$content_type = exec("file -bi " . escapeshellarg($file));
|
$content_type = exec("file -bi " . escapeshellarg($file));
|
||||||
if($content_type && $content_type!=$type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
|
if($content_type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
|
||||||
{
|
{
|
||||||
$type = $content_type;
|
$type = $content_type;
|
||||||
$c = explode(';',$type);
|
$c = explode(';',$type);
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ function getNewHash($type,$length=10)
|
|||||||
|
|
||||||
function isExistingHash($hash)
|
function isExistingHash($hash)
|
||||||
{
|
{
|
||||||
|
if(!trim($hash)) return false;
|
||||||
return is_dir(ROOT.DS.'data'.DS.$hash);
|
return is_dir(ROOT.DS.'data'.DS.$hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user