Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/video_comment_delete.plugin.php
Строк: 42
<?php
defined('_VALID') or die('Restricted Access!');
function ajax_plugin_video_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.video');
$comment_id = (int) trim($_POST['comment_id']);
$db = VF::factory('database');
$db->query("SELECT user_id, video_id
FROM #__video_comments
WHERE comment_id = ".$comment_id."
LIMIT 1");
if ($db->affected_rows()) {
$comment = $db->fetch_assoc();
$owner_id = (int) $comment['user_id'];
$video_id = (int) $comment['video_id'];
if ($user_id == $owner_id OR VAuth::group('Moderator')) {
$db->query("UPDATE #__video
SET total_comments = total_comments-1
WHERE video_id = ".$video_id."
LIMIT 1");
$db->query("UPDATE #__user_activity
SET total_video_comments = total_video_comments-1
WHERE user_id = ".$user_id."
LIMIT 1");
$db->query("DELETE FROM #__video_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);
}