added delete codes and fixed various bugs related to custom hashes

This commit is contained in:
Chris
2018-12-25 11:34:43 +01:00
parent bf13df48aa
commit b66a1f2a55
7 changed files with 106 additions and 56 deletions

View File

@@ -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);
}