<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';

if (!isset($user) && !isset($_GET['id'])){header("Location: /index.php?".SID);exit;}
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `user` WHERE `id` = '$ank[id]' LIMIT 1"),0)==0){header("Location: /index.php?".SID);exit;}
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $ank[id] LIMIT 1"));



if ((!isset($_SESSION['refer']) || $_SESSION['refer']==NULL)
&& isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']!=NULL &&
!strpos('gifts\.php',$_SERVER['HTTP_REFERER']))

$_SESSION['refer']=str_replace('&','&amp;',strstr('^http://[^/]*/','/', $_SERVER['HTTP_REFERER']));

if (isset($user))
{
$p = (isset($_GET['p'])) ? htmlspecialchars($_GET['p']) : null;



switch($p){

case 'send_rank':


include_once '../sys/inc/thead.php';
$set['title']='Наградить'; // заголовок страницы
title();
aut();


if ($user['level']==10){
$pid = intval($_GET['pid']);

if (isset($_GET['go'])){
$curr=date("d.m.y / H:i");
$balls = 0;
$msg=$_POST['msg'];
$ank['id'];
if($ank==0){
msg ('Пользователь не найден :(');
}else{if (isset($user) & $user['balls']<=$balls){
msg ('У Вас не достаточно денег :(');}else{
////////////////////
mysql_query("UPDATE `user` SET `balls` = '".($user['balls']-$balls)."' WHERE `id` = '$user[id]' LIMIT 1",$db);
mysql_query("UPDATE `user` SET `balls` = '".($ank['balls']+1000)."' WHERE `id` = '$ank[id]' LIMIT 1");
////////////////////
mysql_query("INSERT INTO `fin_oper` (`user`, `oper`, `time`, `cena`) values('$user[id]', 'Отправлен подарок $balls KM для $ank[nick]', '$time', '$balls')",$db);
////////////////////
mysql_query("INSERT INTO `rank` (`id_user`, `ot_id`, `text`, `time`, `id_rank`) values('$ank[id]', '$user[id]', '$msg', '$time', '$pid')",$db);
////////////////////
$msgrat="Вас наградил админ!Зайдите на страничку!";
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', '$ank[id]', '$msgrat', '$time')");
msg ('Награда произведина:)');
}}
include_once '../sys/inc/tfoot.php';}

echo"<img src='/rank/".$pid.".gif' alt='' class='icon'/>";

echo "<form method=\"post\" action=\"rank.php?p=send_rank&id=$ank[id]&pid=".$_GET['pid']."&go\">";
echo "Награждаем:<b> $ank[nick]</b><br/><br />\n";
echo "Ваше сообщение:<br/>";
echo "<input type=\"text\" name=\"msg\" value=\"\"/><br />\r\n";
echo "<input type=\"submit\" value=\"Наградить\" />";
echo "</form>\n";

}
include_once '../sys/inc/tfoot.php';

break;
}
$pod = (isset($_GET['pod'])) ? htmlspecialchars($_GET['pod']) : null;

$set['title']='Награды';
include_once '../sys/inc/thead.php';
title();
aut();



////////////

if ($user['level']==10){ 

switch($pod) {
case '1':
echo "<img src='/rank/1.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=1\">наградить</a><br/>";
echo "<img src='/rank/24.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=24\">наградить</a><br/>";
echo "<img src='/rank/25.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=25\">наградить</a><br/>";
echo "<img src='/rank/26.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=26\">наградить</a><br/>";
echo "<img src='/rank/5.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=5\">наградить</a><br/>";
echo "<img src='/rank/6.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=6\">наградить</a><br/>";
echo "<img src='/rank/7.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=7\">наградить</a><br/>";
echo "<img src='/rank/9.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=9\">наградить</a><br/>";
echo "<img src='/rank/10.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=10\">наградить</a><br/>";
echo "<img src='/rank/30.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=30\">наградить</a><br/>";
echo "<img src='/rank/11.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=11\">наградить</a><br/>";
echo "<br /><a href=\"rank.php?id=$ank[id]&pod=2\">Дальше</a>\n";
break;
case '2':

echo "<img src='/rank/12.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=12\">наградить</a><br/>";
echo "<img src='/rank/13.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=13\">наградить</a><br/>";
echo "<img src='/rank/14.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=14\">наградить</a><br/>";
echo "<img src='/rank/15.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=15\">наградить</a><br/>";
echo "<img src='/rank/16.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=16\">наградить</a><br/>";
echo "<img src='/rank/17.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=17\">наградить</a><br/>";
echo "<img src='/rank/18.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=18\">наградить</a><br/>";
echo "<img src='/rank/19.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=19\">наградить</a><br/>";
echo "<img src='/rank/20.gif' < width='20' height='20' alt=''> <a href=\"rank.php?p=send_rank&id=$ank[id]&pid=20\">наградить</a><br/>";
echo "<br /><a href=\"gifts.php?id=$ank[id]&pod=1\">Назад |</a>\n";



break;

}
}
else{
echo "Иди на а,хакер.Нах трогать сайт нормального чела??";
}



}else{
include_once '../sys/inc/thead.php';
$set['title']='Наградить'; // заголовок страницы
title();
aut();
echo'А тебе это и не нужно :) ';}
include_once '../sys/inc/tfoot.php';
?>