<?php
define("IN_MYMPS",true);
define('CURSCRIPT','javascript');

require dirname(__FILE__)."/include/global.php";
require MYMPS_DATA."/config.php";

$part 		= $part 	 ? 	$part : 'jswizard';
$id	 		= $id 	 ?	intval($id) : '';
$inajax		= $inajax ?	intval($inajax) : '';
$getvalue	= $value ? 	$value : '';
$timestamp	= time();
$cityid	 	= $cityid ?	intval($cityid) : '';
$customtype = $customtype ? $customtype : 'info';
$url 		= isset($url) ? urlencode($url) : '';

if(empty($part) || !in_array($part,array('gg','advertisement','information','news','member','jswizard','mayilogin','chk_remember','chk_remobile','chk_remail','chk_wxlogin','upload'))){
	$part = 'advertisement';
}

if($part == 'chk_remember'){

	require MYMPS_DATA."/config.db.php";
	@header("Content-type: text/html; charset=".$charset);
	
	require MYMPS_INC."/db.class.php";
	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 {
			$getvalue = $getvalue ? htmlspecialchars(addslashes($getvalue)) : '';
			$check = CheckUserID($getvalue,"用户名");
			if(strstr($getvalue,'admin') || strstr($getvalue,'管理员')){
				exit("该用户名已被保护，请换一个用户名！");	
			}
			if(strlen($getvalue) < 4 || strlen($getvalue) > 25){
				exit("请输入5-25个字符，可输入字母、数字、下划线。");
			}
			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;
	require MYMPS_DATA."/config.db.php";
	@header("Content-type: text/html; charset=".$charset);
	require MYMPS_INC."/db.class.php";
	if($db->getOne("SELECT id FROM {$db_mymps}member WHERE email = '$getvalue'")){
		echo empty($mod) ? '很抱歉！该电子邮箱地址已经被注册！' : 'success';
	} else {
		echo $mod == 1 ? '该电子邮箱帐号不存在，无法发送邮件！' : 'success';
	}

}elseif($part=='chk_wxlogin'){
	$actionkey = is_numeric($_GET['actionkey'])? htmlspecialchars($_GET['actionkey']) : '';
	require MYMPS_DATA."/config.db.php";
	require MYMPS_INC."/db.class.php";
	require MYMPS_INC."/member.class.php";
	if($row = $db->getRow("SELECT * FROM `{$db_mymps}member_wx` WHERE actionkey='$actionkey'")){
		$db->query("DELETE FROM `{$db_mymps}member_wx` WHERE actionkey = '$actionkey'");
		$member_log->in($row['userid'],$row['userpwd'],'on','noredirect');
		echo 1;
	}else{
		echo 0;
	}
}elseif($part == 'chk_remobile'){

	$mod = isset($_GET['mod']) 	 ?	intval($_GET['mod']) : 0;
	require MYMPS_DATA."/config.db.php";
	@header("Content-type: text/html; charset=".$charset);
	require MYMPS_INC."/db.class.php";
	if($db->getOne("SELECT id FROM {$db_mymps}member WHERE mobile = '$getvalue'")){
		echo empty($mod) ? '该号码已注册，可在忘记密码页找回密码登录' : 'success';
	} else {
		echo $mod == 1 ? '该手机号码未注册会员，无法发送验证码！' : 'success';
	}

} elseif($part == 'gg' || $part == 'advertisement') {

	empty($id) && exit(html2js('Invalid Id'));
	require MYMPS_ROOT."/data/config.db.php";
	require MYMPS_ROOT."/include/db.class.php";
	
	if($code = $db -> getOne("SELECT code FROM `{$db_mymps}advertisement` WHERE available > '0' AND starttime<='".$timestamp."' AND type = 'normalad' AND advid = '$id'")) echo html2js($code);

} elseif($part == 'mayilogin'){
	
	require MYMPS_DATA."/config.db.php";
	require MYMPS_INC."/db.class.php";
	require MYMPS_INC."/member.class.php";

	$qqlogin = read_static_cache('qqlogin');
	$wxlogin = read_static_cache('wxlogin');
	$return=array();
	if($qqlogin['open']==1){$return['qqlogin']='success';}else{$return['qqlogin']='error';}
	if($wxlogin['open']==1){$return['wxlogin']='success';}else{$return['wxlogin']='error';}
	if($member_log->chk_in()){$return['login']='success';$return['s_uid']=$charset=='gbk'?iconv('GB2312','UTF-8//IGNORE',$s_uid):$s_uid;}else{$return['login']='error';}
	$callback = mhtmlspecialchars($_GET['callback']);
	echo $callback.'('.json_encode($return).')';
	exit;

} elseif($part == 'jswizard') {
	
	require MYMPS_ROOT."/data/config.db.php";
	require MYMPS_ROOT."/include/db.class.php";
	echo custom($flag,'js');
	
} /*elseif($part=='upload'){
	require MYMPS_DATA."/config.db.php";
	require MYMPS_INC."/db.class.php";
	require MYMPS_INC."/upfile.fun.php";
	
	$name_file = "Filedata";
	$destination="/temp/".date('Ymd')."/";
	$status = check_upimage_return($name_file);
	if($status == '-1'){
		$arr=array('msg'=>0,"m"=>'您选择的图片尺寸太大，请更换一张小点的图片');
		echo json_encode($arr);
		exit;
	}elseif($status == '-2'){
		$arr=array('msg'=>0,"m"=>'您选择的图片格式不正确，请选择jpg，gif，png格式的图片');
		echo json_encode($arr);
		exit;
	}elseif($status == '-3'){
		$arr=array('msg'=>0,"m"=>'您选择的图片类型不正确，请选择jpg，gif，png格式的图片');
		echo json_encode($arr);
		exit;
	}
	
	$mymps_image=start_upload($name_file,$destination,$mymps_global['cfg_upimg_watermark'],$mymps_mymps['cfg_information_limit']['width'],$mymps_mymps['cfg_information_limit']['height']);
	
	if ($mymps_image[1] && $mymps_image[0]) {
		$arr=array('msg'=>1,"picid"=>rand(),'thumb'=>$mymps_global['SiteUrl'].$mymps_image[1],'file'=>$mymps_image[0]);
	} else {
		$arr=array('msg'=>0,"m"=>'上传出错');
	}
	echo json_encode($arr);
} */else{
	exit(html2js('Access Denied!'));
}
?>