$hash,'content'=>htmlentities(file_get_contents($path)))); } public function handleUpload($tmpfile,$hash=false) { if($hash===false) { $hash = getNewHash('txt',6); } else { if(!endswith($hash,'.txt')) $hash.='.txt'; if(isExistingHash($hash)) return array('status'=>'err','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); } return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash); } function getTypeOfText($hash) { return file_get_contents(ROOT.DS.'data'.DS.$hash.DS.'type'); } }