Файл: monst/core/pag/save.php
Строк: 67
<?
if ( $user['account_saved'] ) {
g('/main');
}
upd_loc('save character');
if ( !empty($_POST['name']) ) {
$name = null_html($_POST['name']);
$pass = null_html($_POST['pass']);
$error = '';
if ( empty($name) OR empty($pass) ) {
$error .= '- ' . $lang['save.php']['error']['empty'].'<br/>';
}
if ( mb_strlen($name) < 2 OR mb_strlen($name) > 25 ) {
$error .= '- ' . $lang['save.php']['error']['name_lens'].'<br/>';
}
$ru_preg = '/^[А-Яа-яЁё]* ?[А-Яа-яЁё]*$/u';
$en_preg = '/^[A-Za-z]* ?[A-Za-z]*$/';
$preg_ok = 0;
if ( (preg_match($ru_preg, $name ) AND !preg_match($en_preg, $name )) OR (preg_match($en_preg, $name ) AND !preg_match($ru_preg, $name )) ) {
$preg_ok = 1;
}
if ( !$preg_ok ) {
$error .= '- ' . $lang['save.php']['error']['name_preg'].'<br/>';
}
// if ( $pass != $pass2 ) {
// $error .= '- ' . $lang['save.php']['error']['pass'].'<br/>';
// }
$find = $_users -> findOne(
[
'name' => $name
]
);
if ( !empty($find) ) {
$error .= '- ' . $lang['save.php']['error']['name_exist'].'<br/>';
}
if ( $error != '' ) {
?>
<div class='error_box'>
<span class='error_col'>
<?=$lang['save.php']['error_title']?><br/>
</span>
<?=$error?><br/>
</div>
<br/><br/>
<?
} else {
foreach ( $quest as $q ) {
if ( $q['type'] == 'save' ) {
$quest_db[$q['id']]['count'] = 1;
}
}
$upd = $_users -> update(
[
'id' => $user['id']
],
[
'$set' =>
[
'account_saved' => 1,
'name' => $name,
'pass' => md5($pass),
'quest' => $quest_db
]
]
);
Cook_set('pass', md5($pass));
$name = Name($user['id'], 1);
g('/main?account_saved');
}
}
?>
<div style='text-align: center;'>
<form method='post' action='/save'>
<?=$lang['save.php']['name']?>:<br/>
<span style='color: #555;'><?=$lang['save.php']['name_info']?></span><br/>
<input name='name'/><br/>
<?=$lang['save.php']['pass']?>:<br/>
<input name='pass'/><br/>
<br/>
<span style='color: #555;'><?=$lang['save.php']['pass_info']?></span><br/>
<br/>
<input type='submit' value='<?=$lang['save.php']['submit']['save']?>'>
</form>
</div>