Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/video_comment_pagination.plugin.php
Строк: 139
<?php
defined
('_VALID') or die('Restricted Access!');
function 
ajax_plugin_video_comment_pagination()
{
    
$data = array('status' => 0'code' => '''msg' => '''debug' => '''end' => 0);
    if (isset(
$_POST['video_id']) && isset($_POST['page'])) {
        
$video_id    = (int) trim($_POST['video_id']);
        
$page        = (int) trim($_POST['page']);
        
        
VLanguage::load('frontend.video');
        
        
$db VF::factory('database');
        
$db->query("SELECT user_id, title, premium
                    FROM #__video
                    WHERE video_id = "
.$video_id."
                    AND status = 1
                    LIMIT 1"
);
        if (
$db->affected_rows()) {
            
$title        $db->fetch_field('title');
            
$url        BASE_URL.'/'.$video_id.'/'.prepare_string($titleTRUE).'/';
            
$user_id    = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
            
            if (
VCfg::get('video.view_comments')) {
                
$sql_count        "SELECT COUNT(*) AS total_comments
                                     FROM #__video_comments
                                   WHERE video_id = "
.$video_id."
                                   AND status = '1'"
;
                
$comments_total $db->get_field($sql_count'total_comments');
                
$pagination        VPagination::get($page$comments_totalVCfg::get('video.comments_per_page'));
                
$sql            "SELECT c.comment_id, c.parent_id, c.user_id,
                                          c.nickname, c.comment, c.add_time,
                                          c.likes, c.rated_by,
                                          u.username, u.gender, u.avatar
                                   FROM #__video_comments AS c
                                   LEFT JOIN #__user AS u ON (u.user_id = c.user_id)
                                   WHERE c.video_id = "
.$video_id."
                                   AND c.status = '1'
                                   ORDER BY c.comment_id DESC
                                   LIMIT "
.$pagination['limit'];
                
$db->query($sql);
                
$comments        $db->fetch_rows();
                
                
$output            = array();
                if (
$comments) {
                    foreach (
$comments as $comment) {
                          
$output[]       = '<div id="comment-'.$comment['comment_id'].'" class="media">';

                    
                          
$output[]    = '<div class="media-left">';
                          
                          if (
$comment['user_id']) {
                              
$avatar 'nopic-'.$comment['gender'].'.gif';
                              if (
$comment['avatar'] != '') {
                                  
$avatar     $user_id.'.'.$comment['avatar'];
                              }
                              
                              
$output[]   = '<a href="'.REL_URL.'/users/'.e($comment['username']).'/" class="media-left media-middle">';
                              
$output[]   = '<img src="'.USER_URL.'/'.$avatar.'" width="70" alt="'.__('alt-avatar', array(e($comment['username']))).'" class="img-rounded media-object" />';
                              
$output[]   = '</a>';
                          } else {
                              
$output[]    = '<img src="'.USER_URL.'/nopic-hidden.gif" width="70" alt="'.__('alt-avatar', array(e(__('anonymous')))).'" class="img-rounded media-object" />';
                          }
                          
                          
$output[]   = '</div>';

                          
$output[]   = '<div class="media-body">';
                          
$output[]   = '<div class="media-heading">';
                          
$output[]   = __('by').' <span>';
                          
                          if (
$comment['user_id']) {
                              
$output[]   = '<a href="'.REL_URL.'/users/'.e($comment['username']).'/">'.e($comment['username']).'</a>';
                          } else {
                              
$output[]    = __('anonymous');
                          }
                          
                          
$output[]   = '</span> '.VDate::nice($comment['add_time']);
                          
$output[]   = '<div class="buttons pull-right">';

                          if (
$comment['user_id'] == $user_id or VAuth::group('Moderator')) {
                              
$output[]   = '<button id="comment-delete-'.$comment['comment_id'].'" type="button" class="btn btn-default btn-xs">'.__('delete').'</button>';
                          }
                    
                          
$output[]   = '<span id="spam-video-'.$comment['comment_id'].'">';
                          
$output[]   = '<button id="spam-video-'.$comment['comment_id'].'-'.$user_id.'" type="button" class="btn btn-default btn-xs">'.__('spam').'</button>';
                          
$output[]   = '</span>';
                          
$output[]   = '</div>';
                          
$output[]       = '<p>'.nl2br(e($comment['comment'])).'</p>';

                          if (
$user_id) {
                              
$output[]       = '<div class="media-footer-'.$comment['comment_id'].'">';
                              
$output[]       = '<small class="text-success">'.$comment['likes'].'</small>';
                              
$output[]       = '<button id="vote-up-'.$comment['comment_id'].'" class="btn btn-link btn-xs btn-thumb" data-toggle="tooltip" data-placement="top" title="'.__('vote-up').'"><i class="fa fa-thumbs-up"></i></button>';
                              
$output[]       = '<button id="vote-down-'.$comment['comment_id'].'" class="btn btn-link btn-xs btn-thumb" data-toggle="tooltip" data-placement="top" title="'.__('vote-down').'"><i class="fa fa-thumbs-down"></i></button>';
                              
$output[]       = '</div>';
                          }
                    
                          
$output[]       = '</div></div></div>';
                    }
                    
                    
$data['code']    = implode("n"$output);
                    
$data['page']    = $page+1;
                    
                    if (
$comments_total < ($page*VCfg::get('video.comments_per_page'))) {
                        
$data['end']    = 1;
                    }
                    
                    
$data['status']    = 1;
                }
            } else {
                
$data['msg'] = __('comments-disabled');
            }
        } else {
            
$data['msg'] = __('comment-missing');
        }
    } else {
        
$data['msg'] = 'Invalid ajax request!';
    }
    
    return 
json_encode($data);
}
?>
Онлайн: 0
Реклама