Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/comment_pagination.plugin.php
Строк: 153
<?php
defined
('_VALID') or die('Restricted Access!');
function 
ajax_plugin_comment_pagination()
{
    
$data = array('status' => 0'code' => '''msg' => '''debug' => '''end' => 0);
    if (isset(
$_POST['user_id']) && isset($_POST['page'])) {
        
$user_id    = (int) trim($_POST['user_id']);
        
$page        = (int) trim($_POST['page']);
        
$browser_id    = (VAuth::loggedin()) ? (int) $_SESSION['user_id'] : 0;
        
        
VLanguage::load('frontend.video');
        
        
$db VF::factory('database');
        
$db->query("SELECT u.user_id, p.profile_comments
                    FROM #__user AS u
                    LEFT JOIN #__user_preferences AS p ON (p.user_id = u.user_id)
                    WHERE u.user_id = "
.$user_id."
                    AND u.status = '1'
                    LIMIT 1"
);
        if (
$db->affected_rows()) {
            
$data            $db->fetch_assoc();
            if (
$data['profile_comments'] == 'no') {
                
$data['msg'] = 'Comments disabled!';
                return 
json_encode($data);
            } else if (
$data['profile_comments'] == 'friends') {
                if (!
$browser_id) {
                    
$data['msg'] = 'Please login to view these comments!';
                    return 
json_encode($data);
                }
                
                
$db->query("SELECT status
                            FROM #__user_friends
                            WHERE user_id = "
.$user_id."
                            AND friend_id = "
.$browser_id."
                            LIMIT 1"
);
                
$db->debug();
                if (
$db->affected_rows()) {
                      if (
$db->fetch_field('status') != 'approved') {
                          
$data['msg']    = 'Friendship not approved!';
                          return 
json_encode($data);
                      }                      
                } else {
                      
$data['msg']    = 'Not friends!';
                      return 
json_encode($data);
                }
                
            }
        
            
$sql_count        "SELECT COUNT(*) AS total_comments
                                 FROM #__user_comments
                               WHERE user_id = "
.$user_id."
                               AND status = '1'"
;
            
$comments_total $db->get_field($sql_count'total_comments');
            
$pagination        VPagination::get($page$comments_total10);
            
$sql            "SELECT uc.comment_id, uc.parent_id, uc.user_id, uc.poster_id, uc.comment,
                                      uc.add_time, uc.likes, uc.rated_by, u.username, u.gender, u.avatar
                                 FROM #__user_comments AS uc
                                 LEFT JOIN #__user AS u ON (u.user_id = uc.poster_id)
                                 WHERE uc.user_id = "
.$user_id."
                                 AND uc.status = '1'
                               ORDER BY uc.comment_id DESC
                               LIMIT "
.$pagination['limit'];
            
$comments        $db->get_rows($sql);
                
            
$output            = array();
            if (
$comments) {
                foreach (
$comments as $comment) {
                    
$output[]       = '<div id="comment-'.$comment['comment_id'].'" class="media">';
                      
                      
$avatar 'nopic-'.$comment['gender'].'.gif';
                      if (
$comment['avatar'] != '') {
                            
$avatar     $user_id.'.'.$comment['avatar'];
                      }
                      
                      
$output[]    = '<div class="media-left">';
                      
$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>';
                    
$output[]    = '</div>';
                    
                      
$output[]   = '<div class="media-body">';
                      
$output[]   = '<div class="media-heading">';
                      
$output[]   = __('by').' <span>';
                    
$output[]   = '<a href="'.REL_URL.'/users/'.e($comment['username']).'/">'.e($comment['username']).'</a>';
                    
$output[]   = '</span> '.VDate::nice($comment['add_time']);
                    
$output[]   = '<div class="buttons pull-right" style="display: none;">';
                    
                    if (
$comment['user_id'] == $browser_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[]    = '</div>';                                  
                      
$output[]       = '<p>'.nl2br(e($comment['comment'])).'</p>';
                      
                      if (
$browser_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>';
                }
                    
                
$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
Реклама