<?php
define('CURSCRIPT', 'ajax');
$response='213';
require_once './engine/common.inc.php';
if($action=='checkuser'){

		$qmember=isset($qmember)?strtolower($qmember):'';
		$q=$db->query("SELECT uid FROM g_members WHERE userid='$qmember'");
		$memberformat=preg_match("/(^[a-z0-9_]+$)/", $qmember);// \W表示只要匹配到 下划线,字母,数字就为真.
		if(strlen($qmember)>16 || strlen($qmember)<4){
			$memberformat=false;
		}
		if(!$memberformat){
		$response="&nbsp;<img src=\"images/common/check_error.gif\" class=\"absmiddle\" />&nbsp;用户账号只能是字母、数字或下划线,且字符数大于3位小于16位";
		}elseif(in_array($qmember,$registerkeyword)){
		$response="&nbsp;<img src=\"images/common/check_error.gif\" class=\"absmiddle\" />&nbsp;该用户账号被管理员设为禁用账号";
		}elseif($db->num_rows($q)){
		$response="&nbsp;<img src=\"images/common/check_error.gif\" class=\"absmiddle\" />&nbsp;用户已经存在";
		}else{
		$response="&nbsp;<img src=\"images/common/check_right.gif\"  class=\"absmiddle\" />&nbsp;恭喜! 该用户名可以注册";
		}
}

if($action=='checkemail'){
		if (!isemail($qemail)){
			$response="&nbsp;<img src=\"images/common/check_error.gif\" class=\"absmiddle\" />&nbsp;email格式不正确";
		}elseif(!$soleemail && $db->result($db->query("select count(*) from g_members where email='$qemail'"),0)){
			$response="&nbsp;<img src=\"images/common/check_error.gif\" class=\"absmiddle\" />&nbsp;该email地址已经被注册，请选择其他email地址注册";
		}else{
			$response="&nbsp;<img src=\"images/common/check_right.gif\" class=\"absmiddle\" />";
		}
}


echo $response;
?>