<?php
CURSCRIPT != 'wap' && exit('FORBIDDEN');

$getvalue	= isset($value)	? trim($value) : '';

if(empty($part) || !in_array($part,array('chk_remember','chk_remobile','chk_authcode','chk_smsauthcode','chk_remail','qr','chk_badwords'))){
	$part = 'chk_authcode';
}

if($part == 'chk_authcode'){
	
	exit(mymps_chk_randcode($getvalue) ? 'success' : '验证码不正确');
	$getvalue='';
	
}elseif($part == 'chk_badwords'){
	require_once MYMPS_ROOT."/include/cache.fun.php";
	$badwords   = read_static_cache('badwords');
	if(is_array($badwords)){
		if(empty($getvalue)){
			exit('请输入内容');
		}elseif($getvalue){
			$arr = explode(',',$badwords[0]);
			if(is_array($arr)){
				foreach($arr as $k){
					if(@strstr($getvalue,$k)){
						$bw .= ''.$k.' ';
					}
				}
			}
			if($bw){
				$bw = '违禁词：'.$bw;
				echo $bw;
				exit;
			}else{
				echo 'success';
			   exit();
			}
			
		}else{
			echo 'success';
			  exit();
		}
	}
	$result = $getvalue = $whenpost = $data = NULL;
}elseif($part == 'chk_smsauthcode'){

	exit(mymps_chk_smsrandcode($getvalue,$phonenum) ? 'success' : '手机验证码输入不正确');
	$getvalue='';
	
}elseif($part == 'chk_remember'){
	@header("Content-type: text/html; charset=".$charset);
	if(empty($getvalue)){
		echo "用户名不符合规范！";
	} else {
		if(PASSPORT_TYPE == 'phpwind'){
		
			include MYMPS_ROOT.'/pw_client/uc_client.php';
			exit(uc_user_get($getvalue) ? "很遗憾！该用户名已被注册！" : "success");
		
		} elseif(PASSPORT_TYPE == 'ucenter'){
		
			include MYMPS_ROOT.'/uc_client/client.php';
			exit(uc_get_user($getvalue) ? "很遗憾！该用户名已被注册！" : "success");
			
		} else {
		
			$check = CheckUserID($getvalue,"用户名");
			if(strstr($getvalue,'admin') || strstr($getvalue,'管理员')){
				exit("该用户名已被保护，请换一个用户名！");	
			}
			if(strlen($getvalue) < 4 || strlen($getvalue) > 30){
				exit("可填写字母、数字、下划线_，不得少于4字符");
			}
			if($check == 'ok'){
				exit((!$re = $db->getOne("SELECT * FROM {$db_mymps}member WHERE userid LIKE '$getvalue'")) ? "success" : "很抱歉！该用户名已经被注册！");
	
			}else{
				exit($check);
			}
		}
		
	}
	$getvalue = NULL;

}elseif($part == 'chk_remail'){

	$mod = isset($_GET['mod']) 	 ?	intval($_GET['mod']) : 0;
	@header("Content-type: text/html; charset=".$charset);
	if($db->getOne("SELECT id FROM {$db_mymps}member WHERE email = '$getvalue'")){
		echo empty($mod) ? '很抱歉！该电子邮箱地址已经被注册！' : 'success';
	} else {
		echo $mod == 1 ? '该电子邮箱帐号不存在，无法发送邮件！' : 'success';
	}

}elseif($part == 'chk_remobile'){
	$mod = isset($_GET['mod']) 	 ?	intval($_GET['mod']) : 0;
	@header("Content-type: text/html; charset=".$charset);
	
	if($db->getOne("SELECT id FROM {$db_mymps}member WHERE mobile = '$getvalue'")){
		echo empty($mod) ? '很抱歉！该手机号码已经被注册！' : 'success';
	} else {
		echo $mod == 1 ? '该手机号码未注册会员，无法发送验证码！' : 'success';
	}

}elseif($part=='qr'){
    require MYMPS_INC."/qrcode/phpqrcode.php";  
    $value = isset($value) ? $value : "";
	$url = isset($url) ? base64_decode($url) : '';
	$size = isset($size)? $size : "5";
    $errorCorrectionLevel = "L";
	ob_clean();
    QRcode::png($url?$url:$value, false, $errorCorrectionLevel, $size);
    exit;
}
?>