diff --git a/public/delete.php b/public/delete.php index 21080eb..e187520 100644 --- a/public/delete.php +++ b/public/delete.php @@ -1,96 +1,101 @@ . **/ //Constants //$CN_APTH = "/mnt/volume-fra1-11/var/www/cdn/pling-cdn"; $CN_APTH = "."; if (file_exists('config.php')) { require_once('config.php'); } -var_dump($config); +$configKey = $config['privateKey']; -if(!isset($config['privateKey'])){ - $configKey = md5(rand()).md5(rand()); -} echo $configKey; +$privKey = urldecode($_GET['key']); + +if (!$privKey || $privKey != $configKey) { + header("HTTP/1.0 500 Server Error"); + echo "Error" . PHP_EOL; + return; +} + $imgurl = urldecode($_GET['path']); echo "

Deleting file: ".$imgurl.'

' . PHP_EOL; $delete_post_name = $_GET['post']; $imagename = basename($imgurl); if (!$imgurl || !$imagename) { header("HTTP/1.0 500 Server Error"); echo "Error, param: path missing" . PHP_EOL; return; } if (!$delete_post_name) { header("HTTP/1.0 500 Server Error"); echo "Error, param: post missing" . PHP_EOL; return; } $fileExists = file_exists($CN_APTH.'/img/' . $imgurl); if($fileExists) { echo("

File exists" . PHP_EOL); echo '' . PHP_EOL; } else { echo("

File did not exists" . PHP_EOL); } echo("

Rename file..." . PHP_EOL); echo('

Command: cp '.$CN_APTH.'/img/' . $imgurl . ' ' . $CN_APTH.'/img/' . $imgurl . $delete_post_name . PHP_EOL); //TODO //$last_line = system('mv '.$imgurl . ' ' . $imgurl . $delete_post_name, $retval); $last_line = system('cp '.$CN_APTH.'/img/' . $imgurl . ' ' . $CN_APTH.'/img/' . $imgurl . $delete_post_name.' 2>&1'); echo $last_line . PHP_EOL; $fileExists = file_exists($CN_APTH.'/img/' . $imgurl . $delete_post_name); if($fileExists) { echo("

File exists" . PHP_EOL); echo '' . PHP_EOL; } else { echo("

File did not exists" . PHP_EOL); } //TODO echo("

Search for cached files:" . PHP_EOL); echo('

Command: locate -i "' . $imgurl.'"' . PHP_EOL); $last_line = exec('locate -i "' . $imgurl.'" 2>&1', $resultArray, $result); //var_dump($resultArray); foreach ($resultArray as $value) { if(strpos($value, '/cache/') !== false) { echo "

Command: rm $value" . PHP_EOL; } } \ No newline at end of file