diff --git a/public/delete.php b/public/delete.php index e187520..8d2e9dd 100644 --- a/public/delete.php +++ b/public/delete.php @@ -1,101 +1,103 @@ . **/ //Constants //$CN_APTH = "/mnt/volume-fra1-11/var/www/cdn/pling-cdn"; $CN_APTH = "."; if (file_exists('config.php')) { require_once('config.php'); +} else { + header("HTTP/1.0 500 Server Error"); + echo "Error" . PHP_EOL; + return; } $configKey = $config['privateKey']; -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); - +echo "Deleting file: ".$imgurl.PHP_EOL; +$fileExists = file_exists($CN_APTH.'/img/' . $imgurl); if($fileExists) { - echo("File exists" . PHP_EOL);
- echo '' . PHP_EOL;
+ echo("File exists" . PHP_EOL);
} else {
- echo("
File did not exists" . PHP_EOL); + 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); +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;
+ echo("Rename File done" . PHP_EOL);
} else {
- echo("
File did not exists" . PHP_EOL); + header("HTTP/1.0 500 Server Error"); + echo("Rename File did not work!" . PHP_EOL); } //TODO -echo("
Search for cached files:" . PHP_EOL); -echo('
Command: locate -i "' . $imgurl.'"' . PHP_EOL); +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); + +if(count($resultArray) == 0) { + echo "No cached files found." . PHP_EOL; +} foreach ($resultArray as $value) { if(strpos($value, '/cache/') !== false) { - echo "
Command: rm $value" . PHP_EOL; + echo "Command: rm $value" . PHP_EOL; } } \ No newline at end of file