Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/video_comment_vote.plugin.php
Строк: 53
<?php
defined
('_VALID') or die('Restricted Access!');
function 
ajax_plugin_video_comment_vote()
{
    
$data = array('status' => 0'code' => '''msg' => '''debug' => '');
    if (isset(
$_POST['comment_id']) && isset($_POST['rating'])) {
        
VLanguage::load('frontend.video');
        
        if (!
VAuth::loggedin()) {
            
$data['msg'] = __('comment-login', array('<a href="'.BASE_URL.'/user/login/">'.__('login').'</a>'));
            return 
json_encode($data);
        }
        
        
$rating        trim($_POST['rating']);
        
$rating        = ($rating == 'up') ? 0;
        
$comment_id    = (int) trim($_POST['comment_id']);
        
$user_id    = (int) $_SESSION['user_id'];
        
        
$db        VF::factory('database');
        
$db->query("SELECT likes
                    FROM #__video_comments
                    WHERE comment_id = "
.$comment_id."
                    LIMIT 1"
);
        if (!
$db->affected_rows()) {
            return;
        }
        
        
$likes    = (int) $db->fetch_field('likes');
        
        
$db->query("SELECT comment_id
                    FROM #__video_comments_votes
                    WHERE comment_id = "
.$comment_id."
                    AND user_id = "
.$user_id."
                    LIMIT 1"
);
        if (
$db->affected_rows()) {
            
$data['code']    = '<small><span class="text-success">'.$likes.'</span> '.__('vote-already').'</small>';
        } else {
            
$db->query("UPDATE #__video_comments
                        SET likes = "
.($likes+$rating).",
                            rated_by = rated_by+1
                        WHERE comment_id = "
.$comment_id."
                        LIMIT 1"
);
            
$db->query("INSERT INTO #__video_comments_votes
                        SET comment_id = "
.$comment_id.",
                            user_id = "
.$user_id.",
                            vote_time = "
.time());
            
$data['code']    = '<small><span class="text-success">'.($likes+$rating).'</span> '.__('vote-thanks').'</small>';
        }
        
        
$data['status'] = 1;
    } else {
        
$data['msg'] = 'Invalid ajax request!';
    }
    
    return 
json_encode($data);
}
?>
Онлайн: 0
Реклама