Файл: modules/user/profile.php
Строк: 217
<?php
/**
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) 2013, Taras Chornyi, Sergiy Mazurenko, Ivan Kotliar
* @link http://perf-engine.net
* @package PerfEngine
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
if ($db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->rowCount() == 0)
{
header('Location: /pages/not_found');
exit();
}
$nick = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->fetch();
if(isset($_GET['id']))
{
$title = _t('pr_of') . $nick['nick'].'';
} else {
$title = _t('pr_of') . $user['nick'].'';
}
if (isset($_GET['id']))
{
if ($db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->rowCount() == 1)
{
$usr = $db->query("SELECT * FROM `users` WHERE `id` = '". abs(intval($_GET['id'])) ."' LIMIT 1")->fetch();
$susr = $db->query("SELECT * FROM `settings` WHERE `user_id` = '". abs(intval($_GET['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';
include_header($title);
$tpl->div('title', '<b>'._t('pr_of') . $usr['nick'].'</b> ('.user_level(abs(intval($usr['id']))).')');
///////////
if ($usr['ban_time'] > time())
{
Template::div('error', _t('user_banned').'!<br /><b>'._t('end_ban').'</b>: '.rtime($usr['ban_time']).'<br />'. (!empty($usr['ban_text'])? '<b>'._t('ban_text').'</b>: '.$usr['ban_text'].'':NULL));
}
//////////
echo '<div class="post">';
echo avatar($usr['id']).'<br/>';
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 _t('e_pr');
}
else if ($susr['view_profile'] == 'self' && abs(intval($usr['id'])) != $user['id'])
{
echo _t('h_pr');
}
else if (!isset($user) && $susr['view_profile'] == 'regs')
{
echo _t('h_pr') .'<a href="/user/sign_up"> '._t('sign_up').'</a> | <a href="/user/sign_in">'._t('sign_in').'</a>';
}
else
{
echo (!empty($usr['name'])? img('u_info.png') .'<u>'._t('name').':</u> '. $usr['name'] .'<br />':NULL) .'
'. (!empty($usr['surname'])? img('u_info.png') .'<u>'._t('surname').':</u> '. $usr['surname'] .'<br />':NULL) .'
'. (!empty($usr['device'])? img('u_device.png') .'<u>'._t('device').':</u> '. $usr['device'] .'<br />':NULL) .'
'. (!empty($usr['gender'])? img('u_gender.png') .'<u>'._t('gender').':</u> '. ($usr['gender'] == 1?''._t('male').'':''._t('female').'') .'<br />':NULL) .'
'. (!empty($usr['year'])? img('u_year.png') .'<u>'._t('birth').':</u> '. output($usr['day']) .'.'. output($usr['month']) .'.'. output($usr['year']) .' (<span style="color: gray;"><b>'.birthday($usr['year'].'-'.$usr['month'].'-'.$usr['day']).'</b></span>)<br />':NULL) .'';
echo (!empty($usr['city'])? img('u_life.png') .'<u>'._t('city').':</u> '.$usr['city'] .'</a><br />':NULL) .'
'. (!empty($usr['country'])? img('u_life.png') .'<u>'._t('country').':</u> '. $usr['country'] .'<br />':NULL) .'
'. (!empty($usr['icq'])? img('u_icq.png') .'<u>ICQ:</u> '. output($usr['icq']) .'<br />':NULL) .'
'. (!empty($usr['site']) ? img('u_site.png') .'<u>'._t('site').':</u> <a target="_blank" href="http://'. $usr['site'] .'">'. $usr['site'] .'</a><br />':NULL).'
'. ($susr['show_email'] == 'yes' ? img('u_e-mail.png') .'<u>E-Mail</u>: <a href="mailto:'. $usr['email'] .'">'. $usr['email'] .'</a><br/>' : NULL) .'
'. (!empty($usr['info'])? img('u_info.png') .'<u>'._t('about_me').':</u> '. $usr['info'] .'<br />':NULL);
}
echo '</div>';
echo '<div class="post">';
# user rating
$rating_plus = $db->query("SELECT * FROM `users_rating` WHERE `plus` != '0' AND `user_id` = '". $usr['id'] ."'")->rowCount();
$rating_minus = $db->query("SELECT * FROM `users_rating` WHERE `minus` != '0' AND `user_id` = '". $usr['id'] ."'")->rowCount();
$rating = $rating_plus - $rating_minus;
echo img('rating.png').'<u>'._t('rating').':</u> <b>'.($rating > 0 ? '<span class="green">+'.$rating.'</span>' : ($rating < 0 ? '<span class="red">'.$rating.'</span>' : $rating)).'</b>'
. ($rating > 0 ? ' (<span class="green">'.$rating_plus.'</span>/<span class="red">'.$rating_minus.'</span>)' : null);
$cou = $db->query("SELECT * FROM `users_rating` WHERE `user_id` = '".$usr['id']."'")->rowCount();
$count = $cou ? round(100 / $cou * $rating_plus, 1) : 0;
echo '<div class="rating"><span style="width: '.($cou == 0 ? '50' : $count).'%"></span>
</div>
<a href="/user/rating/'.$usr['id'].'">'._t('view').' >></a></div>
';
# /user rating
echo '<div class="post">'.img('coins.png').'<u>'._t('user_balance').':</u> <b>'.$usr['balance'].'</b>'. (User::logged() && $usr['id'] != User::Id() ? ' (<a href="/user/send_balance/'.$usr['id'].'">'._t('balance_transfer').'</a>)' : null).'<br/>';
$friends_r = $db->query("SELECT * FROM `friends` WHERE (`friend_id` = '". $usr['id'] ."' OR `user_id` = '". $usr['id'] ."') AND `active` = '1'")->rowCount();
$user_notes = $db->query("SELECT * FROM `blogs` WHERE `user_id` = '". $usr['id'] ."'")->rowCount();
$albums = $db->query("SELECT * FROM `albums` WHERE `user_id` = '{$usr['id']}'")->rowCount();
echo img('users.png').' <a href="/user/friends/'.$usr['id'].'">'._t('friends').'</a> ('.$friends_r.')<br/>'
. img('albums.png').' <a href="/albums/user/'.$usr['id'].'">'._t('album_of_user').'</a> ('. $albums .')<br/>'
. img('blog.png').' <a href="/blog/user/'.$usr['id'].'">'._t('blog_of_user').'</a> ('.$user_notes.')<br/>';
echo '</div>';
echo '<div class="post"><a href="/user/activity/'.abs(intval($usr['id'])).'">'._t('user_activity').'</a></div>';
echo '<div class="post">
'. img('u_reg.png') .' '. _t('registration_time') .': '. rtime($usr['reg_time']).'<br/>
'. img('u_go.png') .' '. _t('last_visit_time') .': '. rtime($usr['time']).'<br/>
</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'])).'">'. _t('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 ? img('user_add.png') .' <a href="/friends/add/'. abs(intval($usr['id'])) .'">'. _t('friends_add') .'</a><br />':NULL)
.(isset($user) && $user['id'] != abs(intval($usr['id'])) && $user['level'] >=6 && $usr['level'] < 7 ? ' '.($usr['ban_time'] > time() ? ''.img('user-ban.png') .'<a href="/padmin/ban/'. abs(intval($usr['id'])).'/?act=upban">'. _t('upban') .'</a><br/>' : ''.img('user-ban.png') .'<a href="/padmin/ban/'. abs(intval($usr['id'])).'/">'. _t('to_ban') .'</a><br/>' ) .' ' : NULL)
.(isset($user) && $user['id'] != abs(intval($usr['id'])) && $user['level'] >=6 && $usr['level'] < 7 ? img('privacy.png') .'<a href="/padmin/change-dest/'. abs(intval($usr['id'])).'/">'. _t('change_dest') .'</a><br/>' : NULL)
.HICO .'<a href="/">'. _t('home').'</a>');
include_footer();
?>