diff --git a/.gitignore b/.gitignore index f3d7e52..47b8471 100644 --- a/.gitignore +++ b/.gitignore @@ -1,73 +1,75 @@ #ignore pling-music and pling-books */pling-books-html5/* */pling-music-html5/* #ignore store specific images */images_sys/store_*/ #ignore eclipse files .buildpath .project .settings/* #ignore PHPStorm Files .idea/* #ignore local Vagrant dir .vagrant/* #ignore local tmp dir */.tmb/* #ignore local dir local/* +public/config.php + phing/* *.local* --.htaccess* .htaccess* .htpasswd* *.orig *.tsm *.ova */.well-known loadstorm-41440.html mu-2cc5c638-f7c471ad-be42f5c0-99b8cf30.txt mu-9ff52416-7b5ae544-c8bac39d-dc810a54 #ignore thumbnails created by windows Thumbs.db #Ignore files build by Visual Studio *.obj *.exe *.pdb *.user *.aps *.pch *.vspscc *_i.c *_p.c *.ncb *.suo *.tlb *.tlh *.bak *.cache *.ilk *.log [Bb]in [Dd]ebug*/ *.lib *.sbr obj/ [Rr]elease*/ _ReSharper*/ [Tt]est[Rr]esult* httpdocs/src/status.jsx .idea/ /nbproject/private/ \ No newline at end of file diff --git a/delete.php b/delete.php new file mode 100644 index 0000000..3e0ba1a --- /dev/null +++ b/delete.php @@ -0,0 +1,105 @@ +. + **/ + +//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']; + + +$privKey = urldecode($_GET['key']); + +if (!$privKey || $privKey != $configKey) { + header("HTTP/1.0 500 Server Error"); + echo "Error" . PHP_EOL; + return; +} + +$imgurl = urldecode($_GET['path']); + +$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; +} + +echo "Deleting file: ".$imgurl.PHP_EOL; + +$fileExists = file_exists($CN_APTH.'/img/' . $imgurl); + +if($fileExists) { + echo("File exists" . PHP_EOL); +} else { + echo("File did not exists" . PHP_EOL); +} + +if($fileExists) { + echo("Rename file..." . PHP_EOL); + $last_line = system('mv '.$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("Rename File done: ".$CN_APTH.'/img/' . $imgurl . $delete_post_name . PHP_EOL); + } else { + header("HTTP/1.0 500 Server Error"); + echo("Rename File did not work!" . 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); + +$numFiles = count($resultArray); +if($numFiles == 0) { + echo "No cached files found." . PHP_EOL; +} else { + echo "Found $numFiles files." . PHP_EOL; +} + +foreach ($resultArray as $value) { + if(strpos($value, '/cache/') !== false) { + echo "Command: rm $value" . PHP_EOL; + $last_line = system("rm $value 2>&1"); + echo $last_line . PHP_EOL; + } +} \ No newline at end of file