<?php

define('_IN_JOHNCMS', 1);
$headmod = 'award';
$textl = 'Sovrinlar';
require('../incfiles/core.php');
require('../incfiles/head.php');

$error = '';
if (!$user_id)
    $error = $lng['access_guest_forbidden'];
if ($error) {
    require_once ("../incfiles/head.php");
    echo '<div class="rmenu"><p>' . $error . '</p></div>';
    require_once ("../incfiles/end.php");
    exit;
}
switch ($act) {
    default:
		$id = isset($_GET['id']) ? abs(intval($_GET['id'])) : 0;
		if ($id) {
			if ($id == $user_id)
				mysql_query("UPDATE `users` SET
								`award`='" . time() . "'");


			echo '<div class="phdr">Foydalanuvchi sovrinlari</div>';
			$count = mysql_result(mysql_query("select count(*) from `award_users` where `id_user` = '".$id."'"),0);
				if	($count	> 0) {
							$req = mysql_query("select `awards`.*,`award_users`.`id_who`,`award_users`.`time` as `givetime`, `users`.`name` as `nick` from `awards` left join `users` on `awards`.`user_id` = `users`.`id` left join `award_users` on `award_users`.`id_award` = `awards`.`id`  where `award_users`.`id_user` = '".$id."'  order by `award_users`.`time` desc limit $start, $kmess");
							while ($res = mysql_fetch_array($req)) {
$name=html_entity_decode($res[name]);

$info = html_entity_decode($res[desc]);

								echo '<div class="menu">';
								echo '<img src="img/' .functions::checkout($res['img']). '.jpg" alt="Sovrin"/> <br /><span style="font-size: 15px;">'.$name.'</span>';
								if ($res['desc'] != '')echo  '<br /><span style="font-size: 15px;">'.$info.'</span>';
								$dan = mysql_fetch_array(mysql_query("SELECT `name` from `users` WHERE `id` = '" . abs(intval($res['id_who'])) . "' LIMIT 1"));
								echo '<br />Taqdirladi: <a href="../users/profile.php?user=' .abs(intval($res['id_who'])). '">' . functions::checkout($dan['name']) .'</a><br />' . functions::display_date(abs(intval($res['givetime'])));
								if ($rights >= 7) echo '<br /> <a href="panel.php?act=take&amp;user='.$id.'&amp;id='.abs(intval($res['id'])).'">O\'chirish</a>';
								echo '</div>';
							}
					}
				else echo '<div class="menu">Sovrinlar yo\'q!</div>';	
			if ($count > $kmess) echo '<div class="topmenu">' . functions::display_pagination('index.php?id='.$id.'&amp;', $start, $count, $kmess) . '</div>';
				
		}
		else header("location: index.php?id=$user_id");
		echo '<div class="phdr"><a href="../users/profile.php?id='.$id.'">'.$lng['profile'].'</a></div>';
	break;
	
}
require('../incfiles/end.php');
?>