AvocadoAmber/AvocadoEdition_Light/plugin/editor/cheditor5/imageUpload/delete.php

52 lines
1.2 KiB
PHP
Raw Normal View History

2022-09-17 20:50:50 +09:00
<?php
require_once("config.php");
if(!function_exists('ft_nonce_is_valid')){
2024-09-23 11:07:19 +09:00
include_once "../editor.lib.php";
2022-09-17 20:50:50 +09:00
}
2024-09-19 20:37:21 +09:00
$filesrc = isset($_POST["filesrc"]) ? preg_replace("/[ #\&\+\-%@=\/\\\:;,\'\"\^`~|\!\?\*$#<>()\[\]\{\}]/", "", $_POST["filesrc"]) : '';
2022-09-17 20:50:50 +09:00
2024-09-19 20:37:21 +09:00
if( !$filesrc || ! preg_match('=^[^/?*;:{}\\\\]+\.[^/?*;:{}\\\\]+$=', $filesrc) || ! preg_match('/\.(gif|jpe?g|bmp|png)$/i', $filesrc) ){
2022-09-17 20:50:50 +09:00
die( false );
}
$is_editor_upload = false;
$get_nonce = get_session('nonce_'.FT_NONCE_SESSION_KEY);
if( $get_nonce && ft_nonce_is_valid( $get_nonce, 'cheditor' ) ){
$is_editor_upload = true;
}
if( !$is_editor_upload ){
die( false );
}
// ---------------------------------------------------------------------------
$file_arr = explode('_', $filesrc );
if( $file_arr[1] !== che_get_file_passname() ){
die( false );
}
$filepath = SAVE_DIR . '/' . $filesrc;
$r = false;
2024-09-19 20:37:21 +09:00
if( function_exists('run_event') ){
run_event('delete_editor_file', $filepath, $r);
}
2022-09-17 20:50:50 +09:00
if (file_exists($filepath)) {
$r = unlink($filepath);
if ($r) {
$thumbPath = dirname($filepath) . DIRECTORY_SEPARATOR . "thumb_" . basename($filepath);
if (file_exists($thumbPath)) {
unlink($thumbPath);
}
}
}
2024-09-26 08:55:13 +09:00
echo $r ? true : false;