Файл: mentor.php
Строк: 51
<?php
session_start();
include ('private/mysql.php');
include ('tmp/head.php');
switch($sd){
default:
if($user['refer']==''){
echo "<font color=orange>Наставник</font> - человек, который будет помогать тебе основаться в игре, назначить наставником можно любого игрока.<br><br>";
echo "<form action='mentor.php?sd=mymentor' method='post'>
Ник <font color=orange>Наставника</font>:<br>
<input type='text' name='nick' class='enter'><br>
<input type='submit' name='submit' value='Назначить' class='enter'></form>";
}else{
$nast = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id`='$user[refer]'"));
echo "Ваш наставник: <a href='pers.php?id=$user[refer]'>$nast[login]</a><br>";
}
echo "Ваши очки Наставника: $user[mentor]<br>";
echo "<br><br><ul class='list_page'><div class='linem'></div><li><a href='mentor.php?sd=stu'>Мои ученики</a></li></ul><div class='linem2'></div>";
break;
case 'stu':
$q = mysql_query("SELECT * FROM `users` WHERE `refer`='$uid'");
$e = mysql_num_rows($q);
if($e=='0'){
echo "У вас нет учеников.<br>← <a href='mentor.php'>назад</a>";
include ('tmp/foot.php');
exit;
}
While($w = mysql_fetch_assoc($q)){
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id`='$w[id]'"));
$i++;
echo "$i. <a href='pers.php?id=$us[id]'>$us[login]</a> <small>$us[level] ур.</small><div class='linem2'></div>";
}
break;
case 'mymentor':
if($user['refer']!==''){
header('Location: mentor.php');
exit;
}
$nick = mysql_real_escape_string(htmlspecialchars(strip_tags($_POST['nick'])));
if($nick==''){
header('Location: mentor.php');
exit;
}
$us = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `login`='$nick'"));
if($nick==$log){
header('Location: mentor.php');
exit;
}
if($us['id']==$uid){
header('Location: mentor.php');
exit;
}
mysql_query("UPDATE `users` SET `refer`='$us[id]' WHERE `id`='$uid'");
header('Location: mentor.php');
exit;
break;
}
include ('tmp/foot.php');
?>