Файл: savepers.php
Строк: 79
<?php
require ('lib/core.php');
require ('theme/header.php');
require ('lib/zag.php');
if($user['newpers']=='0'){
header('Location: /main');
exit;
}
$race = htmlspecialchars(strip_tags($_GET['race']));
$pol = htmlspecialchars(strip_tags($_GET['pol']));
$spec = htmlspecialchars(strip_tags($_GET['spec']));
switch($sd){
default:
echo "<center>Выберите рассу:<br><br>";
echo "<a href='/savepers/step1?race=human'><img src='/pic/avatar/humanmanwar.gif'></a> ";
echo "<a href='/savepers/step1?race=elf'><img src='/pic/avatar/elfmanwar.gif'></a> ";
echo "<a href='/savepers/step1?race=darkelf'><img src='/pic/avatar/darkelfmanwar.gif'></a><hr>";
echo "<a href='/savepers/step1?race=ork'><img src='/pic/avatar/orkmanwar.gif'></a> ";
echo "<a href='/savepers/step1?race=gnom'><img src='/pic/avatar/gnommanwar.gif'></a>";
echo "<a href='/savepers/step1?race=kamael'><img src='/pic/avatar/kamaelmanwar.gif'></a>";
echo "</center>";
break;
case 'step1':
echo "<center>Выберите пол:<br><br>";
echo "<a href='/savepers/step2?race=$race&pol=man'><img src='/pic/avatar/".$race."manwar.gif'></a> <a href='/savepers/step2?race=$race&pol=woman'><img src='/pic/avatar/".$race."womanwar.gif'></a>";
echo "</center>";
echo "<br><br><a href='/savepers'>назад</a>";
break;
case 'step2':
echo "<center>Выберите класс:<br><br>";
if($race=='gnom' or $race=='kamael'){
echo "<font size=2 color=grey>Внимание! Гномы и Камаели не могут быть магами!</font><br><br>";
echo "<figure class='img'><a href='/savepers/step3?race=$race&pol=$pol&spec=warrior'><img src='/pic/avatar/".$race."".$pol."war.gif'><figcaption>Воин</figcaption></figure></a> ";
}else{
echo "<a href='/savepers/step3?race=$race&pol=$pol&spec=warrior'><figure class='img'><figcaption>← Воин</figure></figcaption><img src='/pic/avatar/".$race."".$pol."war.gif'></a> <a href='/savepers/step3?race=$race&pol=$pol&spec=wizard'><img src='/pic/avatar/".$race."".$pol."wizard.gif'><figure class='img'><figcaption>Маг →</figure></figcaption></a>";
}
echo "</center>";
echo "<br><br><a href='/savepers/step1?race=$race'>назад</a>";
break;
case 'step3':
if($race!=='human' and $race!=='elf' and $race!=='darkelf' and $race!=='ork' and $race!=='gnom' and $race!=='kamael'){
header('Location: /savepers');
exit;
}
if($spec!=='warrior' and $spec!=='wizard'){
header('Location: /savepers');
exit;
}
if($pol!=='man' and $pol!=='woman'){
header('Location: /savepers');
exit;
}
echo "<center>Вы выбрали:<br><br>";
if($race=='human'){$r="Человек";}
if($race=='elf'){$r="Эльф";}
if($race=='darkelf'){$r="Тёмный Эльф";}
if($race=='ork'){$r="Орк";}
if($race=='gnom'){$r="Гном";}
if($race=='kamael'){$r="Камаэль";}
if($spec=='warrior'){$s="Воин";}
if($spec=='wizard'){$s="Маг";}
echo "<figure class='img'><img src='/pic/avatar/".$race."".$pol."".$spec.".gif'><figcaption>$r, $s [<a href='/savepers'>изменить</a>]</figcaption></figure><br>";
echo viewsession('savepers');
clearsession('savepers');
if(empty($_POST['submit'])){
echo "<form action='/savepers/step3?race=$race&pol=$pol&spec=$spec' method='post'>
Никнейм:<br>
<input type='text' name='login'><br>
Пароль:<br>
<input type='password' name='password'><br>
<input type='submit' name='submit' value='Сохранить'></form>";
}else{
$login = htmlspecialchars(strip_tags($_POST['login']));
$password = htmlspecialchars(strip_tags($_POST['password']));
if($login=='' or $password==''){
header("Location: /savepers/step3?race=$race&pol=$pol&spec=$spec");
exit;
}
$q = mysql_query("SELECT * FROM `l2_user` WHERE `login`='$login'");
if(mysql_num_rows($q)>='1'){
setsession('savepers', '<hr><font color=red>Введённый вами логин занят</font><br><hr>');
header("Location: /savepers/step3?race=$race&pol=$pol&spec=$spec");
exit;
}
$hpass = md5(md5($password));
if($spec=='warrior'){$patt=6;$pdef=5;$matt=2;$mdef=3;}else{$patt=3;$pdef=4;$matt=6;$mdef=5;}
mysql_query("UPDATE `l2_user` SET `login`='$login',`password`='$hpass',`newpers`='0',`patt`='$patt',`pdef`='$pdef',`matt`='$mdef',`mdef`='$mdef',`profa`='$spec' WHERE `id`='$uid'");
header('Location: /main');
exit;
}
break;
}
require ('lib/down.php');
require ('theme/foot.php');
?>