<?php
!defined('MayiCMS') && exit('Access Denied!');
if($part == 'left'){
	require dirname(__FILE__)."/../global.php";
	$dmm = read_static_cache('admin');
	if($dmm === false){
		require MYMPS_INC."/db.class.php";
		write_admin_cache();
	}
	require dirname(__FILE__)."/../include/".($admin_cityid ? 'mymps.citymenu.inc.php' : 'mymps.menu.inc.php');
	$mymps_admin_menu = mymps_admin_menu("left");
	include mayi_tpl('MayiLeft');
}elseif($part == 'default'){
	require dirname(__FILE__)."/../global.php";
	include mayi_tpl('html_baby');
}elseif($part == 'top'){
	require dirname(__FILE__)."/../global.php";
	$dmm = read_static_cache('admin');
	if($dmm === false){
		require MYMPS_INC."/db.class.php";
		write_admin_cache();
	}
	require dirname(__FILE__)."/../include/".($admin_cityid ? 'mymps.citymenu.inc.php' : 'mymps.menu.inc.php');
	include mayi_tpl('owen');
}elseif($part == 'side'){
	include './template/MayiSide.tpl.php';
}elseif($part == 'right'){
	require dirname(__FILE__)."/../global.php";
	define(CURSCRIPT,'adminhome');
	require MYMPS_INC."/db.class.php";
	require dirname(__FILE__). ($admin_cityid ? "/../include/mymps.citycount.inc.php" : "/../include/mymps.count.inc.php");
	
	$gd_info 		  = @gd_info();
	$gd_version 	  = is_array($gd_info) ? $gd_info['GD Version'] : '<font color=red>不支持GD库</font>';
	//$cfg_if_tpledit   = ($mymps_mymps[cfg_if_tpledit]==0)?"<font color=green>关闭</font>":"<font color=red>开启</font>";
	$if_del_install   = !is_file(MYMPS_ROOT."/install/index.php") ? "<font color=green>已删除</font>":"<font color=red>未删除</font>";
	//$Register_Globals = ini_get('Register_Globals')?'on':'off';
	//$Magic_Quotes_Gpc = MAGIC_QUOTES_GPC ? 'on' : 'off';
	//$expose_php		  = ini_get('expose_php') ? 'on' : 'off';
	//$eAccelerator	  = function_exists('eAccelerator_info') ? '支持 ' : '不支持';
	//$eAcceleratorr	  = function_exists('eAccelerator_info') ? eAccelerator_info() : array(); 
	//$eAccelerator	 .= $eAcceleratorr['version'];
	$cur_dir		  = in_array($admindir,array('/admin','/mayicms')) ? '<font color=red>'.$admindir.' 【不安全】</font>' : '<font color=green>'.$admindir.'</font>';
	$latestbackup	  = $db -> getOne("SELECT value FROM `{$db_mymps}config` WHERE description = 'latestbackup' AND type = 'database'");
	$parttime = round(($latestbackup > 0 ? ($timestamp - $latestbackup) : 0)/(3600*24));
	if(!$latestbackup){
		$message = '<font color=red>您尚未备份过蚂蚁CMS系统数据</font>';
	} else {
		if($parttime > 13){
			$message = '<font color=red>'.base64_decode("5oKo5bey6LaF6L+H5Lik5ZGo5rKh5pyJ5aSH5Lu9572R56uZ5pWw5o2u5LqG").'</font>';
		} elseif($parttime == 0) {
			$message = '<font color=green>'.base64_decode("5oKo5LuK5aSp5bey57uP5aSH5Lu96L+H572R56uZ5pWw5o2u").'</font>';
		} else{
			$message = '您在 <font color=green>'.$parttime.'</font> 天前备份过网站数据，上次备份：<font color=green>'.GetTime($latestbackup).'</font>';
		}
	}
	
	$message .= '，<a href="javascript:void(0);" onclick="window.location.href=\'database.php?part=backup\'" style="text-decoration:underline">点此备份网站数据</a>';
	
	if($admin_cityid){
		$dsxx = mymps_count("information","WHERE info_level = '0' AND cityid = '$admin_cityid'");
		$dshy = mymps_count("member","WHERE status = '0' AND cityid = '$admin_cityid'");
		$dsyl = mymps_count("flink","WHERE ischeck = '1' AND cityid = '$admin_cityid'");
		$dsxw = mymps_count("news","WHERE iscommend = '0' AND cityid = '$admin_cityid'");
	}else{
		$dsxx = mymps_count("information","WHERE info_level = '0'");
		$dshy = mymps_count("member","WHERE status = '0'");
		$dsyl = mymps_count("flink","WHERE ischeck = '1'");
		$dsxw = mymps_count("news","WHERE iscommend = '0'");
	}
	$dsjgwz = mymps_count("member_docu","WHERE if_check= '0'") ;
	$dspl = mymps_count("comments","WHERE comment_level= '0' AND type = 'information'") ;
	$dsplxw = mymps_count("comments","WHERE comment_level= '0' AND type = 'news'") ;
	$dshydp = mymps_count("member_comments","WHERE commentlevel= '0'") ;
	ifplugin('goods') && $dssp = mymps_count("goods","WHERE onsale = '0'");
	if(@strstr(MPS_VERSION,'V')){
		$dzftx = mymps_count("member_cash","WHERE cashStatus= '0'");
	}else{
		$dzftx = 0;
	}
	
	$safe='
<span>系统 <font color=red>/install</font> 目录</span> 当前：'.$if_del_install.'。'.base64_decode("5Li66Ziy5q2i56uZ5aSW5Lq65ZGY5Yip55So77yM5bu66K6u5oKo5a6J6KOF5a6M5oiQ5ZCO77yM5Yig6Zmk6K+l55uu5b2V").'<br />
'.(in_array($admindir,array('/admin','/mayicms')) ? '<span>后台目录</span> 当前：'.$cur_dir.'。建议您安装完成后，及时修改（<a href="https://www.mayicms.com/jiaocheng/article-20.htm" target="_blank">'.base64_decode("5aaC5L2V5L+u5pS55ZCO5Y+w55uu5b2V77yf").'</a>）。<br />':'').'
<span>数据安全</span>'.$message;
	$here = urldecode('%E9%A6%96%E9%A1%B5');
	$postfile=Rewrite("post");

	$daozhang=intval($db->getOne("SELECT SUM(money) FROM `{$db_mymps}payrecord` WHERE ifadd='1'"));
	$chongzhi=intval($db->getOne("SELECT COUNT(id) FROM `{$db_mymps}payrecord`"));
	$xiaofei=intval($db->getOne("SELECT SUM(paycost) FROM `{$db_mymps}member_record_use`"));
	$infos=intval($admin_cityid?$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information` WHERE cityid='$admin_cityid'"):$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information`"));

	$todayInfos=intval($admin_cityid?$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information` WHERE cityid = '$admin_cityid' AND begintime >= '".strtotime('today')."'"):$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information` WHERE begintime >= '".strtotime('today')."'"));
	$todayMembers=intval($admin_cityid?$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member` WHERE cityid = '$admin_cityid' AND jointime >= '".strtotime('today')."'"):$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member` WHERE jointime >= '".strtotime('today')."'"));
	$todayPays=$admin_cityid?"":intval($db->getOne("SELECT SUM(money) FROM `{$db_mymps}payrecord` WHERE posttime >= '".strtotime('today')."' AND ifadd = '1'"));
	$todayLogins=$admin_cityid?"":intval($db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member_record_login` WHERE pubdate >= '".strtotime('today')."'"));
	$yedayInfos=intval($admin_cityid?$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information` WHERE cityid = '$admin_cityid' AND begintime >= '".strtotime('yesterday')."' AND begintime <= '".strtotime('today')."'"):$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}information` WHERE begintime >= '".strtotime('yesterday')."' AND begintime <= '".strtotime('today')."'"));
	$yedayMembers=intval($admin_cityid?$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member` WHERE cityid = '$admin_cityid' AND jointime >= '".strtotime('yesterday')."' AND jointime <= '".strtotime('today')."'"):$db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member` WHERE jointime >= '".strtotime('yesterday')."' AND jointime <= '".strtotime('today')."'"));
	$yedayPays=$admin_cityid?"":intval($db->getOne("SELECT SUM(money) FROM `{$db_mymps}payrecord` WHERE posttime >= '".strtotime('yesterday')."' AND posttime <= '".strtotime('today')."' AND ifadd = '1'"));
	$yedayLogins=$admin_cityid?"":intval($db->getOne("SELECT COUNT(id) FROM `{$db_mymps}member_record_login` WHERE pubdate >= '".strtotime('yesterday')."' AND pubdate <= '".strtotime('today')."'"));
	
	$beiwang=$db->getOne("SELECT value FROM `{$db_mymps}config` WHERE description = 'beiwang' AND type='beiwang'");
	include mayi_tpl('html_direct');
	echo '<script type="text/javascript">document.getElementById("loading").style.display=\'none\';</script>';
	unset($ele,$element);
}
?>