mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-11 18:56:21 +00:00
added filetype to json response of duplicates
This commit is contained in:
@@ -33,14 +33,16 @@ if($_REQUEST['base64'])
|
||||
|
||||
base64ToFile($data, $tmpfile);
|
||||
|
||||
//get the file type
|
||||
$type = getTypeOfFile($tmpfile);
|
||||
|
||||
//check for duplicates
|
||||
$sha1 = sha1_file($tmpfile);
|
||||
$ehash = sha1Exists($sha1);
|
||||
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
|
||||
|
||||
//get the file type
|
||||
$type = getTypeOfFile($tmpfile);
|
||||
|
||||
|
||||
//cross check filetype for controllers
|
||||
//
|
||||
|
||||
@@ -35,13 +35,15 @@ $name = basename($url);
|
||||
$tmpfile = ROOT.DS.'tmp'.DS.$name;
|
||||
file_put_contents($tmpfile,file_get_contents($url));
|
||||
|
||||
$type = getTypeOfFile($tmpfile);
|
||||
|
||||
//check for duplicates
|
||||
$sha1 = sha1_file($tmpfile);
|
||||
$ehash = sha1Exists($sha1);
|
||||
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
|
||||
|
||||
|
||||
$type = getTypeOfFile($tmpfile);
|
||||
|
||||
//cross check filetype for controllers
|
||||
//
|
||||
|
||||
@@ -26,15 +26,14 @@ $hash = sanatizeString(trim($_REQUEST['hash']))?sanatizeString(trim($_REQUEST['h
|
||||
// check for POST upload
|
||||
if ($_FILES['file']["error"] == UPLOAD_ERR_OK)
|
||||
{
|
||||
//get the file type
|
||||
$type = getTypeOfFile($_FILES['file']["tmp_name"]);
|
||||
|
||||
//check for duplicates
|
||||
$sha1 = sha1_file($_FILES['file']["tmp_name"]);
|
||||
$ehash = sha1Exists($sha1);
|
||||
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'url'=>URL.$ehash)));
|
||||
|
||||
|
||||
//get the file type
|
||||
$type = getTypeOfFile($_FILES['file']["tmp_name"]);
|
||||
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
|
||||
|
||||
//cross check filetype for controllers
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user