Просмотр файла modules/user/profile.php

Размер файла: 6.31Kb
<?
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua	  *
**********************************/
if ($db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->rowCount() == 0)
{
    header('Location: /');
	exit();
}

$nick = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->fetch();
if(isset($_GET['user_id']))
	{
		$title = $lang->word('pr_of') . $nick['nick'].'';
	} else {
		$title = $lang->word('pr_of') . $user['nick'].'';
	}

if (isset($_GET['user_id']))
{
    if ($db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->rowCount() == 1)
    {
        $usr = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->fetch();
        $susr = $db->query("SELECT * FROM `settings` WHERE `user_id` = '". abs(intval($_GET['user_id'])) ."' LIMIT 1")->fetch();
    }
    else
    {
        $usr = $db->query("SELECT * FROM `users` WHERE `id` = '$user[id]' LIMIT 1")->fetch();
		$susr = $db->query("SELECT * FROM `settings` WHERE `user_id` = '". abs(intval($user['id'])) ."' LIMIT 1")->fetch();
    }
}
else
{
	$usr = $db->query("SELECT * FROM `users` WHERE `id` = '$user[id]' LIMIT 1")->fetch();
	$susr = $db->query("SELECT * FROM `settings` WHERE `user_id` = '". abs(intval($user['id'])) ."' LIMIT 1")->fetch();
}
$locate = 'in_profile';
require_once(SYS.'/view/header.php');
$tpl->div('title', '<b>'.$lang->word('pr_of') . $usr['nick'].'</b> ('.user_level(abs(intval($usr['id']))).')');
echo '<div class="menu">';
	echo avatar($usr['nick']);
	if (empty($usr['name']) && empty($usr['surname']) && empty($usr['device']) && empty($usr['gender']) && empty($usr['year']) && empty($usr['info']) && empty($usr['interests']) && empty($usr['site']) && empty($usr['city']) && empty($usr['icq']) && empty($usr['country'])) {
		echo $lang->word('e_pr');
	}
	else if ($susr['view_profile'] == 'self' && abs(intval($usr['id'])) != $user['id']) {
		echo $lang->word('h_pr');
	}
	else if (!isset($user) && $susr['view_profile'] == 'regs') {
		echo $lang->word('h_pr') .'<a href="/sign_up/"> '.$lang->word('sign_up').'</a> | <a href="/sign_in/">'.$lang->word('sign_in').'</a>';
	}
	else {
		if(!empty($usr['year']) || $usr['year'] !=0)
			{
				$sec = 0; 
				$min = 0; 
				$hour = 0; 
				$day = $usr['day'];
				$month = $usr['month']; 
				$year = $usr['year'];
				$birthdate_unix = mktime($hour, $min, $sec, $month, $day, $year);
				$current_unix = time();
				$period_unix = $current_unix - $birthdate_unix; 
				$age = floor($period_unix / (365*24*60*60)); 
			}	
		echo (!empty($usr['name'])?'<b>'.$lang->word('name').':</b> '. $usr['name'] .'<br />':NULL) .'
		'. (!empty($usr['surname'])?'<b>'.$lang->word('surname').':</b> '. $usr['surname'] .'<br />':NULL) .'
		'. (!empty($usr['device'])?'<b>'.$lang->word('device').':</b> '. $usr['device'] .'<br />':NULL) .'
		'. (!empty($usr['gender'])?'<b>'.$lang->word('gender').':</b> '. ($usr['gender'] == 1?''.$lang->word('male').'':''.$lang->word('female').'') .'<br />':NULL) .'
		'. (!empty($usr['year'])?'<b>'.$lang->word('birth').':</b> '. output($usr['day']) .'.'. output($usr['month']) .'.'. output($usr['year']) .' (<span style="color: gray;"><b>'.$age.'</b></span>)<br />':NULL) .'';
		echo ''. (!empty($usr['city'])?'<b>'.$lang->word('city').':</b> '.$usr['city'] .'</a><br />':NULL) .'
		'. (!empty($usr['country'])?'<b>'.$lang->word('country').':</b> '. $usr['country'] .'<br />':NULL) .'
		'. (!empty($usr['icq'])?'<b>ICQ:</b> '. output($usr['icq']) .'<br />':NULL) .'
		'. (!empty($usr['site']) ? '<b>'.$lang->word('site').':</b> <a target="_blank" href="http://'. $usr['site'] .'">'. $usr['site'] .'</a><br />':NULL).'
		'.($susr['show_email'] == 'yes' ? '<b>E-Mail</b>: <a href="mailto:'. $usr['email'] .'">'. $usr['email'] .'</a><br/>' : NULL) .'
		'. (!empty($usr['info'])?'<b>'.$lang->word('about_me').':</b> '. $usr['info'] .'<br />':NULL);
		
	}
echo '</div>';
$user_comments = $db->query("SELECT * FROM `share_comms` WHERE `user_id` = '". abs(intval($usr['id'])) ."'")->rowCount() + $db->query("SELECT * FROM `news_comms` WHERE `user_id` = '". abs(intval($usr['id'])) ."'")->rowCount();
$user_posts	= $db->query("SELECT * FROM `forum_pt` WHERE `user_id` = '". abs(intval($usr['id'])) ."'")->rowCount();
$user_topics = $db->query("SELECT * FROM `forum_pt` WHERE `cat_id` != '0' AND `user_id` = '". abs(intval($usr['id'])) ."'")->rowCount();
$user_files	= $db->query("SELECT * FROM `share_files` WHERE `user_id` = '". abs(intval($usr['id'])) ."'")->rowCount();
echo '<div class="post"><a href="/user/'.abs(intval($usr['id'])).'?'.(!isset($_GET['activity']) ? 'activity' : NULL).'">'.$lang->word('user_activity').'</a><br/>
			'.(isset($_GET['activity']) ? '
			'. $lang->word('user_posts') .': '.$user_posts.'<br/>
			'. $lang->word('user_topics') .': '.$user_topics.'<br/>
			'. $lang->word('user_comments') .': '. $user_comments .'<br/>
			'. $lang->word('user_files') .': '. $user_files .'<br/>'
			: NULL).'
		</div>';
$tpl->div('block', (isset($user) && $user['id'] != abs(intval($usr['id'])) ? img('mail-send.png') .'<a href="/mail/write/?user_id='. abs(intval($usr['id'])).'">'. $lang->word('w_mail') .'</a><br/>' : NULL) 
				  . (isset($user) && abs(intval($usr['id'])) != $user['id'] && $db->query("SELECT * FROM `friends` WHERE `user_id` = '".$user['id']."' AND `friend_id` = '".abs(intval($usr['id']))."'")->rowCount() == 0 && $db->query("SELECT * FROM `friends` WHERE `friend_id` = '".$user['id']."' AND `user_id` = '".abs(intval($usr['id']))."'")->rowCount() == 0 ? NAV .' <a href="/friends/add/'. abs(intval($usr['id'])) .'">'. $lang->word('friends_add') .'</a><br />':NULL)
				  .(isset($user) && $user['id'] != abs(intval($usr['id'])) && $user['level'] >=6 && $usr['level'] < 7 ? img('nav.png') .'<a href="/padmin/ban/'. abs(intval($usr['id'])).'/">'. $lang->word('to_ban') .'</a><br/>' : NULL) 
				  .(isset($user) && $user['id'] != abs(intval($usr['id'])) && $user['level'] >=6 && $usr['level'] < 7 ? img('nav.png') .'<a href="/padmin/change-dest/'. abs(intval($usr['id'])).'/">'. $lang->word('change_dest') .'</a><br/>' : NULL) 
				  .HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');

?>