Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/comment_delete.plugin.php
Строк: 41
<?php
defined('_VALID') or die('Restricted Access!');
function ajax_plugin_comment_delete()
{
$data = array('status' => 0, 'code' => '', 'msg' => '', 'debug' => '');
if (isset($_POST['comment_id'])) {
$user_id = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
if ($user_id) {
VLanguage::load('frontend.profile');
$comment_id = (int) trim($_POST['comment_id']);
$db = VF::factory('database');
$db->query("SELECT user_id, poster_id
FROM #__user_comments
WHERE comment_id = ".$comment_id."
LIMIT 1");
if ($db->affected_rows()) {
$comment = $db->fetch_assoc();
$owner_id = (int) $comment['user_id'];
$poster_id = (int) $comment['poster_id'];
if ($user_id == $owner_id or $user_id == $poster_id or VAuth::group('Moderator')) {
$db->query("UPDATE #__user_activity
SET total_profile_comments = CASE WHEN total_profile_comments > 0 THEN total_profile_comments-1 ELSE 0 END
WHERE user_id = ".$user_id."
LIMIT 1");
$db->query("DELETE FROM #__user_comments
WHERE comment_id = ".$comment_id."
LIMIT 1");
$data['msg'] = __('comment-delete-success');
$data['status'] = 1;
} else {
$data['msg'] = __('comment-delete-access');
}
} else {
$data['msg'] = __('comment-missing');
}
} else {
$data['msg'] = __('comment-login-delete');
}
} else {
$data['msg'] = 'Invalid ajax request!?';
}
return json_encode($data);
}