Просмотр файла profile_view_user.php

Размер файла: 4.71Kb
<?php
/***************************************************************************
 *                           �  KaspeR
 *                            -------------------
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);


$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);

$page_title = $lang['Views'];

include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$user_id = (isset($HTTP_POST_VARS[POST_USERS_URL])) ? intval($HTTP_POST_VARS[POST_USERS_URL]) : intval($HTTP_GET_VARS[POST_USERS_URL]);
$page_start = (isset($HTTP_POST_VARS['start'])) ? intval($HTTP_POST_VARS['start']) : intval($HTTP_GET_VARS['start']);

$template->set_filenames(array(
	'body' => 'profile_view_user_body.tpl')
);

$sql = "SELECT username FROM ".USERS_TABLE."
		WHERE user_id = ".$user_id;
	if ( !($result = $db->sql_query($sql)) )
	{
	   message_die(GENERAL_ERROR, "Could not read userdata.", '', __LINE__, __FILE__, $sql);
	}
	$profile=$db->sql_fetchrow($result);
	if (!is_array($profile))
	{
	   message_die(GENERAL_ERROR, "Unknown User-ID!!!", '', __LINE__, __FILE__, $sql);
	}


$per_page = ($userdata['user_posts_per_page'] == '') ? $board_config['posts_per_page'] : $userdata['user_posts_per_page'];

$sql = "SELECT p.*, u.user_avatar_type, u.user_allowavatar, u.user_avatar 
        FROM " . PROFILE_VIEW_TABLE . " p, " . USERS_TABLE . " u
	WHERE p.viewer_id = u.user_id
	AND p.user_id = " . $user_id;
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Could not read profile views.", '', __LINE__, __FILE__, $sql);
}
$total = $db->sql_numrows($result);
$db->sql_freeresult($result);

$pagination = generate_pagination("profile_view_user.$phpEx?".POST_USERS_URL."=".$user_id, $total, $per_page, $page_start);

$sql = "SELECT p.*, u.user_avatar_type, u.user_allowavatar, u.user_avatar 
        FROM " . PROFILE_VIEW_TABLE . " p, " . USERS_TABLE . " u
	WHERE p.viewer_id = u.user_id
	AND p.user_id = " . $user_id . "
	ORDER BY p.view_stamp DESC
	LIMIT " . $page_start . ", " . $per_page;
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Could not read profile views.", '', __LINE__, __FILE__, $sql);
}

$userrow = array();
while( $row = $db->sql_fetchrow($result) )
{
	$userrow[] = $row;
}
for ($i = 0; $i < count($userrow); $i += 5)      
{
        $template->assign_block_vars('visit', array());
		
	for ($j = $i; $j < ($i + 5); $j++)
	{ 
		if( $j >= count($userrow) )
		{
			break;
		}
	        $viewer = $userrow[$j]['viewer_id'];

		$avatar_img = '<img src="' . $board_config['avatar_path'] . '/noava.png" alt=""/>'; 
                if ( $userrow[$j]['user_avatar_type'] && $userrow[$j]['user_allowavatar'] ) 
                { 
                         switch( $userrow[$j]['user_avatar_type'] ) 
                         { 
                                case USER_AVATAR_UPLOAD: 
                                     $avatar_img = '<img src="' . $board_config['avatar_path'] . '/' . $userrow[$j]['user_avatar'] . '" alt=""/>'; 
                                break; 
                                case USER_AVATAR_REMOTE: 
                                     $avatar_img = '<img src="' . $userrow[$j]['user_avatar'] . '" alt=""/>'; 
                                break; 
                                case USER_AVATAR_GALLERY: 
                                     $avatar_img = '<img src="' . $board_config['avatar_gallery_path'] . '/' . $userrow[$j]['user_avatar'] . '" alt=""/>'; 
                                break; 
                         } 
                } 
                $row_class = ( !($j % 2) ) ? 'row_easy' : 'row_hard';
	        $template->assign_block_vars('visit.userrow', array(
	                'ROW_CLASS' => $row_class,
		        'AVATAR' => $avatar_img,
		        'VIEW_BY' => '<a href="'.append_sid("profile.$phpEx?mode=viewprofile&amp;".POST_USERS_URL."=$viewer").'">'.$userrow[$j]['viewername'].'</a>',
		        'NUMBER' => $userrow[$j]['counter'],
		        'STAMP' => create_date($userdata['user_dateformat'], $userrow[$j]['view_stamp'], $userdata['user_timezone']))
	        );
	}        
}

$template->assign_vars(array(
	'PAGINATION' => $pagination,
	'PROFILE' => '<a href="'.append_sid("profile.$phpEx?mode=viewprofile&amp;".POST_USERS_URL."=$user_id").'">'.$profile['username'].'</a>',
	'L_VIEW_TITLE' => $page_title,
	'L_VIEWER' => $lang['Username'],
	'L_NUMBER' => $lang['Views'],
	'L_STAMP' => $lang['Last_updated']));

$template->pparse('body');
include ($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>