<?
$auth=array();
include 'begin.php';
if (IsSet($_POST['auth']))
{
do
{
$auth=$_POST['auth'];
if (!IsSet($auth['name']) || !IsSet($auth['password']))
{
$msg='Ошибка';
break;
}
if (!preg_match('/^[a-zA-Z0-9]{1,16}$/',$auth['name']))
{
$msg='Имя персонажа введено неверно';
break;
}
if (!preg_match('/^[a-zA-Z0-9]{8,12}$/',$auth['password']))
{
$msg='Пароль введен неверно';
break;
}
$res=sql_query('SELECT char_name, builder, account_id FROM [lin2world].[dbo].[user_data] WHERE char_name=?',$auth['name']);
if (mssql_num_rows($res)!=1)
{
$msg='Персонаж не найден';
break;
}
$row=mssql_fetch_array($res);
$auth['name']=$row['char_name'];
$builder=$row['builder'];
if ($builder==0 || $builder>5)
{
$msg='Доступ запрещен';
break;
}
$res=sql_query('SELECT * FROM [lin2db].[dbo].[user_account] WHERE uid=?',$row['account_id']);
if (mssql_num_rows($res)!=1)
{
$msg='Аккаунт не найден';
break;
}
$row=mssql_fetch_array($res);
if ($row['pay_stat']==0 || $row['block_flag']==1 || $row['block_flag2']==1)
{
$msg='Учетная запись заблокирована';
break;
}
$res=sql_query('SELECT password FROM [lin2db].[dbo].[user_auth] WHERE account=?',$row['account']);
if (mssql_num_rows($res)!=1)
{
$msg='Пароль не найден';
break;
}
$row=mssql_fetch_array($res);
$password='0x'.bin2hex($row['password']);
if (encrypt($auth['password'])!=$password)
{
$msg='Пароль введен неверно';
break;
}
$_SESSION['name']=$auth['name'];
$_SESSION['builder']=$builder;
header('Location: index.php');
}
while (false);
}
if (!IsSet($auth['name'])) $auth['name']='';
if (IsSet($msg)) $msg='<b>'.p($msg).'</b><br><br>'; else $msg='';
?>
<div class="form">
<h1>Вход в панель управления</h1>
<?=$msg?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">
Имя:<br>
<input type="text" name="auth[name]" value="<?=p($auth['name'])?>" class="mar"><br>
Пароль:<br>
<input type="password" name="auth[password]" class="mar"><br>
<input type="submit" value="Отправить">
</form>
</div>
<?
include 'end.php';
?>