View file wu-engine/wu-actions/acc_message_del_all.php

File size: 1.28Kb
<?php
require_once('../wu_init.php');
if (!wu_token()) { exit('wu-error'); }
if (!USER_LOGGED) { exit('wu-error'); }

if(isset($_POST['id'])){
if(!empty($_POST['id'])){
$id = intval($_POST['id']);

$fromu = mysqli_fetch_assoc(mysqli_query($connect_db, "SELECT uid,log FROM `".DB_PREFIX."_users` WHERE uid='$id' LIMIT 1"));

$qin = mysqli_query($connect_db, "SELECT id,files FROM `".DB_PREFIX."_messages` WHERE (`fr` = '$u_id' AND `tou` = '$id') OR (`fr` = '$id' AND `tou` = '$u_id')");
while($row = mysqli_fetch_assoc($qin)) {

//Удаление прикреплений
if (!empty($row['files'])) {
$images = array('gif','jpg', 'png', 'jpeg');
$files = explode('|', $row['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."_messages` WHERE (`fr` = '$u_id' AND `tou` = '$id') OR (`fr` = '$id' AND `tou` = '$u_id')");
}

wu_log_act(1, "Удалил переписку с пользователем $fromu[log]");

exit('1');
} else { exit('wu-error'); }
} else { exit('wu-error'); }
?>