<?
include_once("./_common.php");

$g4[title] = "昵称检查";
include_once("$g4[path]/head.sub.php");

$mb_nick = trim($mb_nick);

// 昵称只能使用中文, 英文, 数字
if (!check_string($mb_nick, _G4_CHN_ + _G4_ALPHABETIC_ + _G4_NUMERIC_)) {
    echo "<script type='text/javascript'>";
    echo "alert(\"昵称只能使用中文、英文、数字！\");";
    echo "parent.document.getElementById('mb_nick_enabled').value = '';";
    echo "window.close();";
    echo "</script>";
    exit;
}

$mb = sql_fetch(" select mb_nick from $g4[member_table] where mb_nick = '$mb_nick' ");
if ($mb[mb_nick]) {
    echo "<script type='text/javascript'>";
    echo "alert(\"'{$mb_nick}'已被其他用户注册使用\");";
    echo "parent.document.getElementById('mb_nick_enabled').value = -1;";
    echo "window.close();";
    echo "</script>";
} else {
    if (preg_match("/[\,]?{$mb_nick}/i", $config[cf_prohibit_id])) {
        echo "<script type='text/javascript'>";
        echo "alert(\"'{$mb_nick}'已被禁止注册！\");";
        echo "parent.document.getElementById('mb_nick_enabled').value = -2;";
        echo "window.close();";
        echo "</script>";
    } else {
        echo "<script type='text/javascript'>";
        echo "alert(\"'{$mb_nick}'可以注册使用！\");";
        echo "parent.document.getElementById('mb_nick_enabled').value = 1;";
        echo "window.close();";
        echo "</script>";
    }
}

include_once("$g4[path]/tail.sub.php");
?>