Вход Регистрация
Файл: monst/core/pag/setting/name.php
Строк: 93
<?
if ( !empty($_POST['save']) ) {
    
$name null_html($_POST['name']);

    
$error '';

    if ( empty(
$name) ) {
        
$error .= $lang['setting.php']['name']['error']['empty'].'<br/>';
    }

    if ( 
$name == $user['name'] ) {
        
$error .= $lang['setting.php']['name']['error']['double'].'<br/>';
    }

    if ( 
mb_strlen($name) < OR mb_strlen($name) > 25 ) {
        
$error .= $lang['setting.php']['name']['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['setting.php']['name']['error']['name_preg'].'<br/>';
    }

    
$find $_users -> findOne(
        [
            
'name' => $name,
            
'id' => [
                
'$ne' => $user['id']
            ]
        ]
    );

    if ( !empty(
$find) ) {
        
$error .= $lang['setting.php']['name']['error']['name_exist'].'<br/>';
    }


    if ( 
$user['gold'] < 2000 ) {
        
$error .= $lang['setting.php']['name']['error']['no_gold'].'<br/>';
    }

    if ( 
$error != '' ) {
        
?>
        <div class='error_box'>
            <?=$error?>
        </div>
        <?
    
} else {
        
$_users -> update(
            [
                
'id' => $user['id']
            ],

            [
                
'$set' => [
                    
'name' => $name,
                    
'gold' => $user['gold'] - 2000
                
]
            ]
        );

        
$upd_name Name($user['id'], 1);

        
g('/setting/name?save_ok');
    }

}


if ( isset(
$_GET['save_ok']) ) {
    
?>
    <div class='ok_box'>
        <?=$lang['setting.php']['name']['save_ok']?><br/>
    </div>
    <?
}

?>
<form method='post' action='/setting/name'>
    <input type='hidden' name='save' value='1'/>


    <div style='text-align: center;'>
        <?=$lang['setting.php']['name']['char_name']?>:<br/>
        <span style='color: #777;'><?=$lang['setting.php']['name']['name_desc']?></span><br/>

        <input name='name' value='<?=$user['name']?>' style='text-align: center;'/><br/>

        <br/>
        <?=$lang['setting.php']['name']['cost']?><br/>
        <img src='<?=$gold_icon?>' alt='' width='40'/><span class='gold_color'>2000</span><br/>

        <input type='submit' value='<?=$lang['setting.php']['name']['submit']['save']?>'/>
    </div>
</form>

    <br/>
    <div>
        <a href='/setting'><?=$lang['setting.php']['back']?></a>
    </div>

<?
Онлайн: 1
Реклама