<?php
/*
 * this is not a freeware, use is subject to license terms
 * ============================================================================
 * 系统官网: https://www.mayicms.com
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！不允许对程序代码以任何形式任何目的的再发布。
 * 此系统限制为仅授权用户，任何的侵权、盗版行为终将追究其法律责任。
 * ============================================================================
`*/
define('IN_SMT', true);
define('IN_MYMPS', true);

require dirname(__FILE__)."/include/global.php";
!is_file(MYMPS_ROOT.'/data/install.lock') && write_msg('','install/index.php');
require MYMPS_DATA."/config.php";
require MYMPS_DATA."/config.db.php";
require MYMPS_INC."/db.class.php";

runcron();

ifsiteopen();
$fcityid = mgetcookie('fcityid');

if($cityid) {
	$city = $db->getRow("SELECT * FROM `{$db_mymps}city` WHERE cityid = '$cityid'");
}

if($ifmobile){
	if(!is_robot() && $fcityid > 0 && !$cityid && empty($mod)){
		$fcity = get_city_caches($fcityid);
		if($fcity['mdomain']){
			write_msg("",defined('WAP')?$fcity['mdomain']:$fcity['domain']);
		}
		exit;
	}
	define('CURSCRIPT','wap');
	$mayimobile = get_mobile_settings();
	$mayimobile['mobiledomain'] = $mayimobile['mobiledomain']?$mayimobile['mobiledomain']:$mymps_global['SiteUrl'].'/m';
	if($mayimobile['allowmobile'] != 1){
		exit('本站手机版暂停访问！');
	}
	
	if($invite && $mymps_global['partner_open']==1){
		$invite = intval($invite);
		msetcookie('invite',$invite,3600*24);
	}
	
	if($mayimobile['post']!=1 && $mod == 'post'){
		redirectmsg('本站暂不支持手机发布请使用电脑端或手机浏览器切换pc模式',$mayimobile['mobiledomain']);
		exit;
	}
	
	!in_array($mod,array('category','index','information','member','login','register','forgetpass','post','search','member','history','news','goods','corp','person','space','store','aboutus','javascript','sendsms','randcode','telbook','comments','xmlmap','select_where','tianqi')) && $mod = 'index';
	
	$s_uid = $iflogin = NULL;
	include MYMPS_INC.'/member.class.php';
	
	$returnurl = GetUrl();
	$returnurl = urlencode($returnurl);
	msetcookie('returnurl',$returnurl);
	
	$iflogin = !$member_log->chk_in() ? 0 : 1;
	
	if($id && in_array($mod,array('information','news','goods'))){
	}else{
		$cityid = $cityid ? $cityid : 0;
		$city = get_city_caches($cityid);
		if(!defined('WAP')){
			$city['mdomain']=$city['domain'];
			$city['gmdomain']=$city['gdomain'];
		}
		$city_limit 	= empty($city['cityid']) ? "": " AND cityid = '$city[cityid]'";
		$city_limit_a 	= empty($city['cityid']) ? "": " AND a.cityid = '$city[cityid]'";
		$city_limit 	.= empty($areaid) ? "": " AND areaid = '$areaid'";
		$city_limit_a 	.= empty($areaid) ? "": " AND a.areaid = '$areaid'";
	}
	
	if (is_weixin() && !in_array($mod,array('javascript','sendsms','randcode','comments','member'))) {
		$wx = read_static_cache('wxlogin');
		require MYMPS_ROOT."/m/include/jssdk.php";
		$jssdk = new JSSDK($wx['appid'],$wx['appsecret']);
		$signPackage = $jssdk->GetSignPackage();
		$signPackage = $signPackage;
		$shareIcon = $mayimobile['mobiledomain'].'/mayicms.gif';
	}

	include MYMPS_ROOT.'/m/include/'.$mod.'.inc.php';
	
}else{
	$mod = in_array($mod,array('javascript','select_where','post','search','index','category','deal','information','news','goods','corp','space','store','coupon','group','aboutus','announce','friendlink','xmlmap','sendsms','tianqi'))?$mod:'index';
	require MYMPS_ROOT.'/pc/'.$mod.'.inc.php';
}

is_object($db) && $db -> Close();
?>