View file modules/user/profile.php

File size: 4.72Kb
<?
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.pp.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($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' && $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> '. output($usr['name']) .'<br />':NULL) .'
		'. (!empty($usr['surname'])?'<b>'.$lang->word('surname').':</b> '. output($usr['surname']) .'<br />':NULL) .'
		'. (!empty($usr['device'])?'<b>'.$lang->word('device').':</b> '. output($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> '.output($usr['city']) .'</a><br />':NULL) .'
		'. (!empty($usr['country'])?'<b>'.$lang->word('country').':</b> '. output($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="'. $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> '. output($usr['info']) .'<br />':NULL);
		
	}
echo '</div>';
$tpl->div('block', (isset($user) && $user['id'] != $usr['id'] ? img('mail-send.png') .'<a href="/mail/write/?user_id='. $usr['id'].'">'. $lang->word('w_mail') .'</a><br/>' : NULL) .(isset($user) && $user['id'] != $usr['id'] && $user['level'] >=6 && $usr['level'] < 7 ? img('nav.png') .'<a href="/padmin/ban/'. $usr['id'].'/">'. $lang->word('to_ban') .'</a><br/>' : NULL) . (isset($user) && $user['id'] != $usr['id'] && $user['level'] >=6 && $usr['level'] < 7 ? img('nav.png') .'<a href="/padmin/change-dest/'. $usr['id'].'/">'. $lang->word('change_dest') .'</a><br/>' : NULL) .  HICO .'<a href="/">'. $lang->word('home').'</a>');
require_once(SYS.'/view/footer.php');

?>