<?php
define('CURSCRIPT','index');
define('IN_MYMPS',true);
define('IN_MEMBERADMIN',true);
define('MEMBERDIR',dirname(__FILE__));

require MEMBERDIR.'./../include/global.php';
require MEMBERDIR.'./../data/config.php';
require MEMBERDIR.'./../data/config.db.php';
require MYMPS_INC.'/db.class.php';

$uid = $s_uid = $s_pwd = $mymps_image = '';

require MYMPS_INC."/member.class.php";
if(!$log = $member_log->chk_in()) write_msg("","../".$mymps_global['cfg_member_logfile']."?url=".urlencode(GetUrl()));

$box= isset($box) ? intval($box) : 0;
$id= isset($id) ? intval($id) : 0;
$type = in_array($type,array('user','corp')) ? $type : 'user';
$success = isset($success) ? intval($success) : '';
$error = isset($error) ? intval($error) : '';
$alert = isset($alert) ? intval($alert) : '';
$page = isset($page) ? intval($page) : 1;
$cityid= isset($cityid) ? intval($cityid) : 0;

$frame = in_array($frame,array('home','ma_yicms_left','ma_yicms_right','ma_yicms_top')) ? $frame:'ma_yicms_right';

if($frame=='home'){
	$pm_total = mymps_count("member_pm","WHERE touser = '$s_uid' AND if_read = '0'");
	include mayi_tpl('ma_yicms_home');
}elseif($frame == 'ma_yicms_left'){
	$where = 'WHERE userid = \''.$s_uid.'\'';
	$row = $db -> getRow("SELECT * FROM `{$db_mymps}member` $where");
	$if_corp	 = $row['if_corp'];
	$city=get_city_caches($row['cityid']);
	$citydomain=$city['domain'];
	include mayi_tpl('ma_yicms_left');
}elseif($frame == 'ma_yicms_top'){
	$where = 'WHERE userid = \''.$s_uid.'\'';
	$row = $db -> getRow("SELECT * FROM `{$db_mymps}member` $where");
	$if_corp	 = $row['if_corp'];
	$uid		= $row['id'];
	$pm_total = mymps_count("member_pm","WHERE touser = '$s_uid' AND if_read = '0'");
	include mayi_tpl('ma_yicms_top');
}elseif($frame='ma_yicms_right'){
	//echo '<div id="loading" style="font-size:13px;position:absolute;top:0;left:0;background-color:#ff9900;color:white;padding:3px 25px;">数据加载中...</div>';
	$where = 'WHERE userid = \''.$s_uid.'\'';
	$wherea = 'WHERE a.userid = \''.$s_uid.'\'';
	
	$row = '';
	$row = $db -> getRow("SELECT * FROM `{$db_mymps}member` $where");
	$face = $row['prelogo'];
	$normalface = $row['logo'];
	
	$face = $row['prelogo'] == "" ? "/images/noavatar_small.gif" : $face;
	$money_own = $row['money_own'];
	$pm_total = mymps_count("member_pm","WHERE touser = '$s_uid' AND if_read = '0'");
	$levelid = $row['levelid'];
	$group = get_member_group($levelid);
	$levelname = $group['levelname'];
	$per_certify = $row['per_certify'];
	$com_certify = $row['com_certify'];
	$sj_certify = $row['sj_certify'];
	$if_corp	 = $row['if_corp'];
	$uid		= $row['id'];
	$cityid		= $cityid ? $cityid : 0;
	if($if_corp == 0){
		$mysite = Rewrite('space',array('user'=>$row['userid']));
	}elseif($if_corp ==1){
		$mysite = Rewrite('store',array('uid'=>$row['id']));
	}
	$allowm = $mymps_global['cfg_if_corp'] == 1 ? array('resume','resumePost','resumeCreate','tougao','info','pm','base','avatar','levelup','certify','pay','password','album','comment','document','certifycorp','shop','goods','shoucang') : array('resume','resumePost','resumeCreate','tougao','info','pm','base','avatar','levelup','certify','pay','password','shoucang');
	require MEMBERDIR.'/include/mymps.menu.inc.php';
	is_array($data) && $allowm = array_merge(array_keys($data),$allowm);
	if(!in_array($m,$allowm)) $m = 'index';
	unset($data,$allowm);
	if($m != 'index' && !chk_member_purview('purview_'.$m)){
		 write_msg('您的会员级别没有该栏目的操作权限!');
	}
	if($alert){
		$score_change = get_credit_score();
		if($alert == 1){
			$score_changer = $score_change['score']['rank']['login'];
		} elseif ($alert == 2){
			$score_changer = $score_change['score']['rank']['coupon'];
		} elseif ($alert == 3) {
			$score_changer = $score_change['score']['rank']['group'];
		} elseif ($alert == 4) {
			$score_changer = $score_change['score']['rank']['goods'];
		}
		if(empty($score_changer)) $alert = NULL;
		$score_changer = ' <font color=red><b>'.$score_changer.'</font></b>';
	}
	
	if($if_corp != 1 && in_array($m,array('goods','coupon','group','document','album','comment'))) write_msg('您非商铺会员，请先申请网上店铺再进行操作！','index.php?m=shop');
	if($m=='shop' && $ac == 'template' && $row['if_corp']!=1) write_msg('您非商铺会员，请先申请网上店铺再进行操作！');
	
	$face = $face == $mymps_global['SiteUrl'] ? '' : $face;
	include MEMBERDIR.'/include/'.$m.'.inc.php';
	
	is_object($db) && $db -> Close();
	$mymps_global = $m = $ac = $success = $error = $where = $page = $timestamp = $log = $member_log = $face = $money_own = NULL;
	$levelid = $pm_total = $row = NULL;
	unset($row);
	if($selectedids) unset($selectedids);
}

function mymps_member_purview($purview='',$member_menu,$if_corp=1)
{
	$purview=$purview?explode(',',$purview):'';
	$member_menu['banner']		= '店铺装修';
	if(empty($if_corp)) unset($member_menu['shop'],$member_menu['resume'],$member_menu['comment'],$member_menu['document'],$member_menu['album'],$member_menu['goods'],$member_menu['group'],$member_menu['coupon'],$member_menu['banner']);
    foreach($member_menu as $w => $y){
		
			$mymps_member_purview .= "<div><input type=\"checkbox\" class=\"magic-checkbox\" name=\"purview[]\" id=\"purview_".$w."\" value=\"purview_".$w."\"";
			$mymps_member_purview .= ((is_array($purview)&&in_array('purview_'.$w,$purview))||empty($purview))? "checked":"";
			$mymps_member_purview .= "><label for=\"purview_".$w."\">".$y."</label></div>";
		
	}
	return $mymps_member_purview;
}

function location($str=''){
	global $mymps_global,$member_menu,$m,$here;
	$str = $member_menu[$m];
	$here = '<font class="here">'.($here? $here : $str).'</font>';
	$return = $here.'<a href="javascript:;" onClick="window.location.href=\'?\'" class="ihome">中心首页</a> <font class="separator">&rsaquo;</font> '.$str;
	return $return;
	unset($raquo,$return);
}
?>