diff --git a/api/base64.php b/api/base64.php index c569951..4aeb9be 100644 --- a/api/base64.php +++ b/api/base64.php @@ -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 // diff --git a/api/geturl.php b/api/geturl.php index 1465307..9ea75ed 100644 --- a/api/geturl.php +++ b/api/geturl.php @@ -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 // diff --git a/api/upload.php b/api/upload.php index b5ea9f6..7d6828f 100644 --- a/api/upload.php +++ b/api/upload.php @@ -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 //