<?php
define('IN_PHPMPS', true);
require dirname(__FILE__) . '/include/common.inc.php';
if(is_weixin()===false){
	header("Location:com.php");
}else{
	if(empty($_userid)){
		if(empty($_COOKIE['useropenid'])){
			$url = urlencode('http://'.$CFG['wx_redirect_uri'].'/oauth.php');
			header("Location:https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$CFG['wx_appid']."&redirect_uri=".$url."&scope=snsapi_userinfo&response_type=code&state=STATE&connect_redirect=1#wechat_redirect");
		}else{
			$opens = $db->getRow("SELECT userid,password FROM {$table}member where wx_openid='".$_COOKIE['useropenid']."'");
			setcookie('userid', $opens['userid'], time()+86400*24);
			setcookie('password', $opens['password'], time()+86400*24);
			header("Location:com.php");
		}
	}else{
			header("Location:com.php");
	}
}
$seo['title'] = $CFG['webname'];
include tpl('index');
?>