mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-11 18:56:21 +00:00
added delete codes and fixed various bugs related to custom hashes
This commit is contained in:
@@ -28,8 +28,6 @@ class ImageController implements ContentController
|
||||
$res = imagecreatefromjpeg($tmpfile);
|
||||
imagejpeg($res, $tmpfile, (defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
|
||||
$ext = 'jpg';
|
||||
|
||||
$newsha1 = sha1_file($tmpfile);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -42,26 +40,13 @@ class ImageController implements ContentController
|
||||
}
|
||||
else
|
||||
{
|
||||
$hash.='.'.$ext;
|
||||
if(!endswith($hash,'.'.$ext))
|
||||
$hash.='.'.$ext;
|
||||
if(isExistingHash($hash))
|
||||
return array('status'=>'err','reason'=>'Custom hash already exists');
|
||||
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
|
||||
}
|
||||
|
||||
if($newsha1)
|
||||
addSha1($hash,$newsha1);
|
||||
|
||||
mkdir(ROOT.DS.'data'.DS.$hash);
|
||||
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
|
||||
|
||||
copy($tmpfile, $file);
|
||||
unlink($tmpfile);
|
||||
|
||||
if(defined('LOG_UPLOADER') && LOG_UPLOADER)
|
||||
{
|
||||
$fh = fopen(ROOT.DS.'data'.DS.'uploads.txt', 'a');
|
||||
fwrite($fh, time().';'.$url.';'.$hash.';'.getUserIP()."\n");
|
||||
fclose($fh);
|
||||
}
|
||||
storeFile($tmpfile,$hash,true);
|
||||
|
||||
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
|
||||
}
|
||||
|
||||
@@ -43,21 +43,10 @@ class TextController implements ContentController
|
||||
if(!endswith($hash,'.txt'))
|
||||
$hash.='.txt';
|
||||
if(isExistingHash($hash))
|
||||
return array('status'=>'err','reason'=>'Custom hash already exists');
|
||||
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
|
||||
}
|
||||
|
||||
mkdir(ROOT.DS.'data'.DS.$hash);
|
||||
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
|
||||
|
||||
copy($tmpfile, $file);
|
||||
unlink($tmpfile);
|
||||
|
||||
if(defined('LOG_UPLOADER') && LOG_UPLOADER)
|
||||
{
|
||||
$fh = fopen(ROOT.DS.'data'.DS.'uploads.txt', 'a');
|
||||
fwrite($fh, time().';'.$url.';'.$hash.';'.getUserIP()."\n");
|
||||
fclose($fh);
|
||||
}
|
||||
storeFile($tmpfile,$hash,true);
|
||||
|
||||
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
|
||||
}
|
||||
|
||||
@@ -69,24 +69,13 @@ class VideoController implements ContentController
|
||||
{
|
||||
$hash.='.mp4';
|
||||
if(isExistingHash($hash))
|
||||
return array('status'=>'err','reason'=>'Custom hash already exists');
|
||||
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
|
||||
}
|
||||
|
||||
mkdir(ROOT.DS.'data'.DS.$hash);
|
||||
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
|
||||
|
||||
copy($tmpfile, $file);
|
||||
unlink($tmpfile);
|
||||
storeFile($tmpfile,$hash,true);
|
||||
|
||||
if(!$this->rightEncodedMP4($file))
|
||||
system("nohup php ".ROOT.DS.'tools'.DS.'re-encode_mp4.php force '.$hash." > /dev/null 2> /dev/null &");
|
||||
|
||||
if(defined('LOG_UPLOADER') && LOG_UPLOADER)
|
||||
{
|
||||
$fh = fopen(ROOT.DS.'data'.DS.'uploads.txt', 'a');
|
||||
fwrite($fh, time().';'.$url.';'.$hash.';'.getUserIP()."\n");
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user