2016-02-10 00:02:51 +01:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
2019-04-23 23:12:38 +02:00
|
|
|
/*
|
|
|
|
| Delete an image from a particular page
|
|
|
|
|
|
|
|
|
| @_POST['filename'] string Name of the file to delete
|
|
|
|
| @_POST['uuid'] string Page uuid
|
|
|
|
|
|
|
|
|
| @return array
|
|
|
|
*/
|
|
|
|
|
2017-10-06 18:28:06 +02:00
|
|
|
// $_POST
|
2018-04-13 23:32:29 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
$filename = isset($_POST['filename']) ? $_POST['filename'] : false;
|
2018-10-07 23:11:49 +02:00
|
|
|
$uuid = empty($_POST['uuid']) ? false : $_POST['uuid'];
|
2018-04-13 23:32:29 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2016-02-10 00:02:51 +01:00
|
|
|
|
2019-03-10 18:27:24 +01:00
|
|
|
if ($filename===false) {
|
2019-01-30 23:15:36 +01:00
|
|
|
ajaxResponse(1, 'The filename is empty.');
|
2016-02-10 00:02:51 +01:00
|
|
|
}
|
|
|
|
|
2018-10-07 23:11:49 +02:00
|
|
|
if ($uuid && IMAGE_RESTRICT) {
|
|
|
|
$imagePath = PATH_UPLOADS_PAGES.$uuid.DS;
|
|
|
|
$thumbnailPath = PATH_UPLOADS_PAGES.$uuid.DS.'thumbnails'.DS;
|
|
|
|
} else {
|
|
|
|
$imagePath = PATH_UPLOADS;
|
|
|
|
$thumbnailPath = PATH_UPLOADS_THUMBNAILS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete image
|
|
|
|
if (Sanitize::pathFile($imagePath.$filename)) {
|
|
|
|
Filesystem::rmfile($imagePath.$filename);
|
2017-10-06 18:28:06 +02:00
|
|
|
}
|
2016-02-10 00:02:51 +01:00
|
|
|
|
2018-10-07 23:11:49 +02:00
|
|
|
// Delete thumbnail
|
|
|
|
if (Sanitize::pathFile($thumbnailPath.$filename)) {
|
|
|
|
Filesystem::rmfile($thumbnailPath.$filename);
|
2016-02-10 00:02:51 +01:00
|
|
|
}
|
|
|
|
|
2019-01-30 23:15:36 +01:00
|
|
|
ajaxResponse(0, 'Image deleted.');
|
2016-02-10 00:02:51 +01:00
|
|
|
|
|
|
|
?>
|