File size: 1.02Kb
<?php
require_once('../wu_init.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }
include('wu_checkadmin.php');
if(isset($_POST['id'])){
if(!empty($_POST['id'])){
$id = intval($_POST['id']);
$msg = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT id,msg,files FROM `".DB_PREFIX."_tickets_msg` WHERE id='$id' LIMIT 1"));
if (empty($msg['id'])) { exit('wu-error'); }
//Удаление прикреплений
if (!empty($msg['files'])) {
$images = array('gif','jpg', 'png', 'jpeg');
$files = explode('|', $msg['files']);
foreach ($files as $file) {
if (!empty($file)){
$expl = explode(':', $file);
$ifile = $expl[0];
$iname = $expl[1];
$exp = explode('.', $ifile);
$exp_e = strtolower($exp[1]);
unlink('../../wu-uploads/attach/full/'.$ifile);
if (in_array($exp_e, $images)) {
unlink('../../wu-uploads/attach/thumbs/'.$ifile);
}
}
}
}
mysqli_query($connect_db, "DELETE FROM `".DB_PREFIX."_tickets_msg` WHERE id='$id' LIMIT 1");
exit('1');
} else { exit('wu-error'); }
} else { exit('wu-error'); }
?>