<?
/*
 
 本软件版权归作者所有,在投入使用之前注意获取许可
 作者：程威（wiwiboy）
 项目：PHPStat流量统计 1.0
 电话：13553166317
 邮箱：wiwiboy@126.com
 QQ号：158839753
 网址：http://www.phpstat.net
 phpstat.net保留全部权力，受相关法律和国际		  		
		公约保护，请勿非法修改、转载、散播，或用于其他赢利行为，		
		并请勿删除版权声明。
*/
/*	
	verson:v1.2 2007-3-23
	author:wiwiboy
	last update:2007-3-23	
*/
	session_start();
	include_once './include.inc/config.inc.php';
	include_once './include.inc/global.inc.php';
	include_once './session.php';
	include_once './include.inc/conn.db.inc.php';
	include_once './include.inc/tpl.inc.php';
	include_once './include.inc/function.php';
	include_once './parse_site.php';
	
	$manager = $_SESSION[SESSION_MANAGER];
	$managergroup = $_SESSION[SESSION_USERGROUP];
	$managercode = $_SESSION[SESSION_USERGROUP_CODE];
	Initialize( $_GET, array( 'ac'=>'strval', 'website'=>'strval' ,'type'=>'strval','page'=>'intval' ) );
	Initialize( $_POST, array( 'managerid'=>'intval' ,'password'=>'strval','sitename'=>'strval','website'=>'strval','sitedes'=>'strval','action'=>'strval','websiteid'=>'intval','site'=>'strval','sitetype'=>'strval','siteshow'=>'strval','qq'=>'strval','email'=>'strval','msn'=>'strval','group'=>'strval') );
	$website = $_GET[website];	
	
	
	if($_GET[website] != '')
	{	
		$Time = time();
		$Year = date( 'Y', $Time );
		$Month = date( 'm', $Time );
		$Day = date( 'j', $Time );
		$Week = date( 'w', $Time );
		$Hour = date('G', $Time );
		$DayStartTime = date('Ymd').".phpstat";
		@unlink( TMPDIR . '/count/' . $website .'_'.$DayStartTime );
		
		if($_GET[ac] == 'truncate')
		{	

			if( $_GET[type] == '0' or $_GET[type] == $_GET[website]  )
			{
				$Conn->Execute("truncate ".DB_PREFIX.$_GET[website]."_ip_hits");
				$Conn->Execute("truncate ".DB_PREFIX.$_GET[website]."_ip_limit");
			}
			else
			{
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_hits where website = '$_GET[website]'");
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_limit where website = '$_GET[website]'");
			}

			if( $_GET[type] == $_GET[website] )
			{
				$sitelist = $Conn->Execute("select website from $TableList[site] where website = '$_GET[website]' or sitetype = '$_GET[website]'");
				while( $sitelisttmp  = $sitelist->FetchRow() )
				{
					$sitelistarray[] = $sitelisttmp[website];
				}
			}
			if( count($sitelistarray) > 0 )
				$_GET[website] = @implode( '|',$sitelistarray );
			else
				$_GET[website] = $_GET[website];

			foreach($TableList as $key=>$value)
			{
				if($key != 'ip_data' and $key != 'users' and $key !='holiday' and $key != 'site')
				{						
					$Conn->Execute("delete from $TableList[$key] where website regexp '$_GET[website]'");					
					
					
				}				
			}
			
			if( count($sitelistarray) > 0 )
			{
				unset( $sitelistarray );
				$rs = $Conn->Execute("select * from $TableList[site] where website regexp '$_GET[website]'");
				while( $rows = $rs->FetchRow() )
				{
					$sitelistarray[] = $rows;
				}
				$Conn->Execute("delete from $TableList[site] where website regexp '$_GET[website]'");	
				foreach( $sitelistarray as $row )		
				$Conn->Execute("insert into  $TableList[site] (managerid,site,sitename,website,sitedes,sitetype,siteshow,email,msn) values('$row[managerid]','$row[site]','$row[sitename]','$row[website]','$row[sitedes]','$row[sitetype]','$row[siteshow]','$row[email]','$row[msn]')");
			}
			else
			{
				$rs = $Conn->Execute("select * from $TableList[site] where website = '$_GET[website]'");
				$row = $rs->FetchRow();	
				$Conn->Execute("delete from $TableList[site] where website = '$_GET[website]'");	
						
				$Conn->Execute("insert into  $TableList[site] (managerid,site,sitename,website,sitedes,sitetype,siteshow,email,msn) values('$row[managerid]','$row[site]','$row[sitename]','$row[website]','$row[sitedes]','$row[sitetype]','$row[siteshow]','$row[email]','$row[msn]')");
			}
			
		}
		
		if($_GET[ac] == 'truncatetoday')
		{	
			if( $_GET[type] == '0' or $_GET[type] == $_GET[website] )
			{
				$Conn->Execute("truncate ".DB_PREFIX.$_GET[website]."_ip_hits");
				$Conn->Execute("truncate ".DB_PREFIX.$_GET[website]."_ip_limit");
			}
			else
			{
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_hits where website = '$_GET[website]'");
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_limit where website = '$_GET[website]'");
			}

			if( $_GET[type] == $_GET[website] )
			{
				$sitelist = $Conn->Execute("select website from $TableList[site] where website = '$_GET[website]' or sitetype = '$_GET[website]'");
				while( $sitelisttmp  = $sitelist->FetchRow() )
				{
					$sitelistarray[] = $sitelisttmp[website];
				}
			}
			if( count($sitelistarray) > 0 )
				$_GET[website] = @implode( '|',$sitelistarray );
			else
				$_GET[website] = $_GET[website];
						
			$StartTime = mktime( '0','0','0',date('m'),date('d'),date('Y') );		
			$Conn->Execute("delete from $TableList[day_data] where website regexp '$_GET[website]' and times = $StartTime");
			
			$msg ="<div align=center>恭喜,全部处理成功!<BR>";
			$goback = "<a href=# onclick=\"history.go(-1)\">请您返回</a></div>";
			showMsg ( $msg , $goback );
		}

		if($_GET[ac] == 'del')
		{	
			$manager = $_SESSION[SESSION_MANAGER];
			
			if( $_GET[type] == '0' or $_GET[type] == $_GET[website] )
			{
				$Conn->Execute("DROP TABLE ".DB_PREFIX.$_GET[website]."_ip_hits");			
				$Conn->Execute("DROP TABLE ".DB_PREFIX.$_GET[website]."_ip_limit");
			}
			else
			{
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_hits where website = '$_GET[website]'");
				$Conn->Execute("delete from ".DB_PREFIX.$_GET[type]."_ip_limit where website = '$_GET[website]'");
			}

			if( $_GET[type] == $_GET[website] )
			{
				$sitelist = $Conn->Execute("select website from $TableList[site] where website = '$_GET[website]' or sitetype = '$_GET[website]'");
				while( $sitelisttmp  = $sitelist->FetchRow() )
				{
					$sitelistarray[] = $sitelisttmp[website];
				}
			}
			if( count($sitelistarray) > 0 )
				$_GET[website] = @implode( '|',$sitelistarray );
			else
				$_GET[website] = $_GET[website];

			
			foreach($TableList as $key=>$value)
			{
				if($key != 'ip_data' and $key != 'users' and $key !='holiday')
				{
					$Conn->Execute("delete from $TableList[$key] where website regexp '$_GET[website]'");					
				}
				if( $key == 'user_site' )
				{
					$Conn->Execute("delete from $TableList[user_site] where websiteid regexp '$_GET[website]'");		
				}
			}	
			
			
			$msg ="<div align=center>恭喜,全部处理成功!<BR>";
			$goback = "<a href=# onclick=\"history.go(-1)\">请您返回</a></div>";
			showMsg ( $msg , $goback );
		}
	}
	
	if( $_GET[ac] == 'repairsite' or $_GET[ac] == 'truncate')
	{
		$sql = "SELECT * FROM $TableList[site]";
		$res = $Conn->Execute( $sql );
		while( $row = $res->FetchRow() )
		{
			unset( $IpArray	); unset( $exclusionipArray	); 
			unset( $DomainArray	);unset( $exclusioninterArray );
			$IpArray = @explode("|",$row[exclusionip]);
			$IpArray = @array_unique ($IpArray);
			if( count($IpArray) > 1 )
			foreach( $IpArray as $Key => $Value )
			{	
				
				$ValueArray = @explode( '.', $Value );
				if( $ValueArray[3] == "" )
				{
					$ValueStart = $Value.'0';
					$ValueEnd	= $Value.'255';
				}
				else
				{
					$ValueStart = $Value;	
					$ValueEnd	= $Value;
				}
				$exclusionip[startip]  = ip2num($ValueStart);
				$exclusionip[endip]    = ip2num($ValueEnd);
				$exclusionipArray[]    = $exclusionip;
			}
			else
			{	
				$ValueArray = @explode( '.', $row[exclusionip] );
				if( $ValueArray[3] == "" )
				{
					$ValueStart = $row[exclusionip].'0';
					$ValueEnd	= $row[exclusionip].'255';
				}
				else
				{
					$ValueStart = $row[exclusionip];	
					$ValueEnd	= $row[exclusionip];
				}
				$exclusionip[startip]  = ip2num($ValueStart);
				$exclusionip[endip]    = ip2num($ValueEnd);
				$exclusionipArray[]	   = $exclusionip;
			}

			$fileStr = "<?\nif( !defined('WEB_HOME') ) exit('Access Denied');\n";
			$fileStr .= "if( file_exists( \"../count/exclusion/website_\".\$websiteid.\"_regexp.php\")  )\n";
			$fileStr .= "include_once \"../count/exclusion/website_\".\$websiteid.\"_regexp.php\";\n";
			
			$fileStr .= "\n//统计网站地址\n";	
			$fileStr .= "\$siteurl = \"$row[site]\";\n";	
			$fileStr .= "\n//程序排除IP地址列表\n";	
			for($i=0;$i < count($exclusionipArray);$i++)
			{	
				if($exclusionipArray[$i]['startip'] != "0" and $exclusionipArray[$i]['endip'] != "0")
				{
					$fileStr .= "\$exclusionip[$i][startip] = \"".$exclusionipArray[$i]['startip']."\";\n";
					$fileStr .= "\$exclusionip[$i][endip]   = \"".$exclusionipArray[$i]['endip']."\";\n";
				}
			}
			
			$DomainArray = @explode("|",$row[exclusioninter]);
			$DomainArray = @array_unique ($DomainArray);
			if( count($DomainArray) > 1 )
			foreach( $DomainArray as $Key => $Value )
			{				
				$exclusioninterArray[] = $Value;
			}
			else
			{	
				$exclusioninterArray[]	= $row[exclusioninter];
			}		
			$exclusioninterArray = @array_unique ($exclusioninterArray);
			
			$fileStr .= "\n//程序包含目录地址列表\n";		
			for($i=0;$i < count($exclusioninterArray);$i++)
			{
				if($exclusioninterArray[$i] != "" and $exclusioninterArray[$i] != "0")
				$fileStr .= "\$exclusioninter[$i] = \"".$exclusioninterArray[$i]."\";\n";
			}
			$fileStr .= "\n//程序所属主站点代码\n";
			if( $row[sitetype] == '0' or $row[sitetype] == '' )
			{					
				$fileStr .= "\$mainsitecode = \"".$row[website]."\";\n";
				$row[sitetype] = '0';
			}
			else
			{
				$fileStr .= "\$mainsitecode = \"".$row[sitetype]."\";\n";
			}
			$fileStr .= "?>";
			$fileStr1 = $fileStr;

			if( $row[sitetype] == '0' )
			{
				unset($SiteListArray);
				$ResList = $Conn->Execute( "select website from $TableList[site] where sitetype = '$row[website]'");
					while( $TmpList = $ResList->FetchRow() )
					{
						$SiteListArray[] = $TmpList[website];
					}
					$SiteListArray[] = $row[website];
					//$SiteListArray[] = $row[website];
					$SiteListStr = @implode('|',$SiteListArray);
					$fileStr = "<?\nif( !defined('WEB_HOME') ) exit('Access Denied');\n";		
					$fileStr .= "\n//程序主站所包含子站列表\n";	
					$fileStr .= "\$mainsiteregexp = \"$SiteListStr\";\n";	
					$fileStr .= "?>";
					$fileStr2 = $fileStr;
				
				$Res = $Conn->Execute("SELECT id FROM ".DB_PREFIX.$row[website]."_ip_hits  LIMIT 1");
				$mark = false;
				if( !$Res )
				{
					$mark = true;
					$content = str_replace( 'PREFIX_' , DB_PREFIX.$row[website].'_', file_get_contents( './count/js/structure_ip_hits.sql' ) );
					if( $Versions > 40 )
					$content = ereg_replace(";"," DEFAULT CHARACTER SET ".DB_CHARSET." ;",$content);
					$r1 = $Conn->Execute( $content );
				}

				$Res = $Conn->Execute("SELECT id FROM ".DB_PREFIX.$row[website]."_ip_limit LIMIT 1");
				if( !$Res )
				{
					$mark = true;
					$content = str_replace( 'PREFIX_' , DB_PREFIX.$row[website].'_', file_get_contents( './count/js/structure_ip_limit.sql' ) );
					if( $Versions > 40 )
					$content = ereg_replace(";"," DEFAULT CHARACTER SET ".DB_CHARSET." ;",$content);
					$r2 = $Conn->Execute( $content );
				}
				if( $mark and (!$r1 or !$r2) )
				{
					$msg ="<div align=center>".$row[sitename]." 相关数据库配置失败，请重新编辑。<BR>仔细检查是否拥有权限创建数据表".DB_PREFIX.$row[website]."_limit，".DB_PREFIX.$row[website]."_hits<BR>";
					$goback = "<a href=# onclick=\"history.go(-1)\">请您返回</a></div>";
					showMsg ( $msg , $goback );
				}
					
			}
			
			if( !is_writable( COUNT_DIRNAME."/exclusion/website_".$row[id].".php" ) or !is_writable( COUNT_DIRNAME."/exclusion/website_".$row[id]."_regexp.php" ) )
			{				
				$msg ='<div align=center>缺失文件或文件无写入权限,属性设置为777 '.COUNT_DIRNAME.'/exclusion/website_'.$row[id].'.php ,manage_all_site.php,line:'.__LINE__.'<BR>';
				$goback = "<a href=# onclick=\"history.go(-2)\">请您返回</a></div>";	
				showMsg ( $msg , $goback );
			}
			
			write_to_file(COUNT_DIRNAME."/exclusion/website_".$row[id].".php",$fileStr1,'w+');
			write_to_file(COUNT_DIRNAME."/exclusion/website_".$row[id]."_regexp.php",$fileStr2,'w+');
			$website = $row[website];
			$replace[$website] = $row[id];
			

		}
		if( count($replace) > 0 )
		foreach( $replace as $key => $value )
		{
			$replacearray .= "\$WebSiteId['$key'] = \"$value\";\r\n";	
		}		
		$content = @read_from_file(COUNT_DIRNAME."/js/websiteid.php");
		$content = ereg_replace("\[WEBSITEID\]",$replacearray,$content);

		if( !file_exists( COUNT_DIRNAME."/websiteid.php" ) or !is_writable( COUNT_DIRNAME."/websiteid.php" ) )
		{				
			$msg ='<div align=center>缺失文件或文件无写入权限,属性设置为777 '.COUNT_DIRNAME.'/websiteid.php ,manage_all_site.php,line:'.__LINE__.'<BR>';
			$goback = "<a href=# onclick=\"history.go(-2)\">请您返回</a></div>";	
			showMsg ( $msg , $goback );
		}
		write_to_file(COUNT_DIRNAME."/websiteid.php",$content);

		$msg ="<div align=center>恭喜,全部处理成功!<BR>";
		$goback = "<a href=# onclick=\"history.go(-1)\">请您返回</a></div>";
		showMsg ( $msg , $goback );
	}

	if( $_GET[ac] == 'common' )
	{		

			//创建人
			if($_SESSION[SESSION_USERGROUP] == 'strongsuperadmin')
			{
				$Where = "  ";
			}
			//账户管理员
			if($_SESSION[SESSION_USERGROUP] == 'superadmin')
			{
				$Where = " and msn = '$managercode' ";
			}
			//管理员
			if($_SESSION[SESSION_USERGROUP] == 'admin')
			{
		
				$ResSite = $Conn->Execute( " select websiteid from $TableList[user_site] where managerid = '$manager'");
				while($TmpSite = $ResSite->FetchRow())
				$WebsiteID[] = $TmpSite[websiteid];
				$WhereList = @implode("|",$WebsiteID);
				if( count($Where) > 0)
					$Where = " and (website REGEXP '".$WhereList."' or managerid = '$manager') ";
				else
					$Where = " and managerid = '$manager' ";
			}
			if($_SESSION[SESSION_USERGROUP] == 'guest')
			{

				$ResSite = $Conn->Execute( " select websiteid from $TableList[user_site] where managerid = '$manager'");
				while($TmpSite = $ResSite->FetchRow())
				$WebsiteID[] = $TmpSite[websiteid];
				$WhereList = @implode("|",$WebsiteID);
				if( count($Where) > 0)
					$Where = " and website REGEXP '".$WhereList."' ";
			}
			//记录总数
			$Res = $Conn->Execute( " select count(*) as count from $TableList[site] where sitetype = '0' $Where" );
			$Count = $Res->FetchRow();
			$DataCount = $Count[count];
			$PageSize = 20;
			if( $DataCount > 0 )
			{
				include_once ( './include.inc/page_class.php' );
				include_once ( './include.inc/page.inc.php' );
				$PageItems = MakePageItems ( $DataCount, $PageSize );
				$PageLinks = MakePageLinks ( $PageItems, '记录','条' );
				$Tpl->assign( 'PageLinks', $PageLinks );
			}

			$MRes = $Conn->SelectLimit( " select id, site,sitename,sitetype,website,all_count,all_count_ip from $TableList[site] where sitetype = '0' $Where order by id desc ", $PageSize ,$PageItems[Offset] );
			$Yestoday = mktime("0","0","0",date("m"),date("d"),date("Y")) - 86400;
			if($Res)
			while($MTmp = $MRes->FetchRow())
			{	
				$MTmp[statue] = '0';
				$Res1 = $Conn->Execute("SELECT id FROM ".DB_PREFIX.$MTmp[website]."_ip_hits  LIMIT 1");
				$Res2 = $Conn->Execute("SELECT id FROM ".DB_PREFIX.$MTmp[website]."_ip_limit LIMIT 1");
				
				$Res3 = $Conn->Execute("SELECT day_count,day_count_ip FROM $TableList[day_data]  where website = '$MTmp[website]' and times = '$Yestoday'");
				$Tmp3 = $Res3->FetchRow();
				if( file_exists( COUNT_DIRNAME."/count/".$MTmp[website]."_".date("Ymd").".phpstat" ) and file_exists( COUNT_DIRNAME."/exclusion/website_".$MTmp[id].".php" ) and $Res1 and $Res2 and ( filesize( COUNT_DIRNAME."/exclusion/website_".$MTmp[id].".php" ) > 0 ) )
				{
					$MTmp[statue] = '1';
				}
				else
				{	
					$MTmp[statue] = '0';
					if( !file_exists( COUNT_DIRNAME."/count/".$MTmp[website]."_".date("Ymd").".phpstat" ) )
						$MTmp[statuedes] = '[还未检测到今日数据]  ';
					if(  !file_exists( COUNT_DIRNAME."/exclusion/website_".$MTmp[id].".php" )  and filesize( COUNT_DIRNAME."/exclusion/website_".$MTmp[id].".php" ) <= 0   or !$Res1 or !$Res2 )
						$MTmp[statuedes] .= '[缺少站点配置文件,重新编辑该站点即可]  ';
				}
					
				if($MTmp[sitetype] == "0")
						$MTmp[sitename] = "<B>".$MTmp[sitename]."(主站)</B>";
				$MTmp[session] = $_SESSION[SESSION_USERGROUP];
				$MTmp[day_count] = $Tmp3[day_count];
				$MTmp[day_count_ip] = $Tmp3[day_count_ip];
				$MainSite[] = $MTmp;
				$sitetype = $MTmp[sitetype];
				$Ress = $Conn->Execute( " select id, site,sitename,sitetype,website,all_count,all_count_ip from $TableList[site] where sitetype = '$MTmp[website]'" );
				
				while($Tmp = $Ress->FetchRow())
				{
					$Tmp[statue] = '0';
					if( file_exists( COUNT_DIRNAME."/count/".$Tmp[website]."_".date("Ymd").".phpstat" ) and file_exists( COUNT_DIRNAME."/exclusion/website_".$Tmp[id].".php" ) and ( filesize( COUNT_DIRNAME."/exclusion/website_".$Tmp[id].".php" ) > 0 ) )
					{
						$Tmp[statue] = '1';
					}
					else
					{
						$Tmp[statue] = '0';
						if( !file_exists( COUNT_DIRNAME."/count/".$Tmp[website]."_".date("Ymd").".phpstat" ) )
						$Tmp[statuedes] = '[还未检测到今日数据]  ';
						if( !file_exists( COUNT_DIRNAME."/exclusion/website_".$Tmp[id].".php" ) and filesize( COUNT_DIRNAME."/exclusion/website_".$Tmp[id].".php" ) <= 0   or !$Res1 or !$Res2 )
							$Tmp[statuedes] .= '[缺少站点配置文件,重新编辑该站点即可]  ';
					}						
					$Res4 = $Conn->Execute("SELECT day_count,day_count_ip FROM $TableList[day_data]  where website = '$Tmp[website]' and times = '$Yestoday'");
					$Tmp4 = $Res4->FetchRow();
					$Tmp[day_count] = $Tmp4[day_count];
					$Tmp[day_count_ip] = $Tmp4[day_count_ip];
					$Tmp[session] = $_SESSION[SESSION_USERGROUP];
					
					if( $Tmp[sitetype] != '0' )
					{	$sitetype = $Tmp[sitetype];$SubSite[$sitetype][] = $Tmp;}
					else
						$MainSite[] = $Tmp;					
				}
			}
			if( count( $MainSite ) > 0 )
			foreach( $MainSite as $value)
			{	
			    $websiteid = $value[website];
				//$SubSite[$websiteid][] = $value;
				$value[sub] = $SubSite[$websiteid];
				$allcount = $allcountip = 0;
				if( count( $SubSite[$websiteid] ) > 0 )
				foreach( $SubSite[$websiteid] as $subvalue )
				{
					$allcount    += $subvalue[all_count];
					$allcountip  += $subvalue[all_count_ip];
					$yallcount   += $subvalue[day_count];
					$yallcountip += $subvalue[day_count_ip];
				}
				$allcount    += $value[all_count];
				$allcountip  += $value[all_count_ip];
				$yallcount   += $value[day_count];
				$yallcountip += $value[day_count_ip];

				if( $allcountip > 0 )
				{
					$value[all_count_m]    = $allcount;
					$value[all_count_ip_m] = $allcountip;
					$value[day_count_y]    = $yallcount;
					$value[day_count_ip_y] = $yallcountip;
				}
				unset($SubSite[$websiteid]);			
				$Datas[] = $value;
			}
			if( count( $SubSite ) > 0 )
			foreach( $SubSite as $value)
			{	
				if( count( $value ) > 0 )
				foreach( $value as $value2)
				{		
					$OthDatas[] = $value2;
				}				
			}
		
	}


	########################START###########################
	

	if( file_exists(COUNT_DIRNAME."/system.php") )
	include_once COUNT_DIRNAME."/system.php";
	if( $CHECKSYSTEMDATE != date("Ymd") )
	{	
		$URes = $Conn->Execute( " select count(*) as counts from $TableList[users] " );
		$UTmp = $URes->FetchRow();
		$Ucounts = $UTmp[counts];

		$SRes = $Conn->Execute( " select count(*) as counts from $TableList[site] " );
		$STmp = $SRes->FetchRow();
		$Scounts = $STmp[counts];
		echo "<script language=\"javascript\" type=\"text/javascript\" src=\"http://%6D%79%2E%70%68%70%73%74%61%74%2E%6E%65%74/CheckSystem.php?p=".$PHPStatProductKey."&d=".$LOCALDOMAIN."&u=".$Ucounts."&s=".$Scounts."&c=".$SYSTEMCHECKDCODE."\"></script>";	
	}

	if( function_exists( CheckSystem ) )
	{
		CheckSystem( $SYSTEMCHECKDCODE );
	}
	else
	{
		echo "<SCRIPT LANGUAGE=\"JavaScript\">
			
			alert( '系统文件丢失!' );
			-->
			</SCRIPT>";
			exit;
	}
	########################END###########################

	$Tpl->assign( 'username', $_SESSION[SESSION_MANAGER] );
	$Tpl->assign( 'UserData1', $Datas );
	$Tpl->assign( 'OthUserData1', $OthDatas );
	$Tpl->assign( 'Main', $Tpl->fetch( 'all_site_code.html' ) );
	$Tpl->assign( 'Title', '统计站点信息管理 - '.$SoftWareName .$SoftWareVersion );
	$Tpl->assign( 'NowView', '统计站点信息管理' );
	if($_SESSION[SESSION_USERGROUP] == "strongsuperadmin")
	{
		$Tpl->assign( 'QuickLink', "<A HREF=\"site_list.php?website=true&action=sitelist\">网站配置信息</A> <a href=\"manage_db.php\">数据库管理</a> <a href=\"manage_all_site.php?website=true&ac=common\">站点列表管理</a> <a href=\"manage_user.php\">用户列表管理</a> <a href=\"syscfg.php\">软件配置信息</a> <a href=\"error_log.php\">错误日志信息</a> <a href=\"_php_info.php\" target=_blank>PHP信息</a>" );
	}
	elseif($_SESSION[SESSION_USERGROUP] == "superadmin" )
	{
		$Tpl->assign( 'QuickLink', " <A HREF=\"site_list.php?website=true&action=sitelist\">网站配置信息</A> <a href=\"manage_all_site.php?website=true&ac=common\">站点列表管理</a> <a href=\"manage_user.php\">用户列表管理</a>" );
	}
	elseif( $_SESSION[SESSION_USERGROUP] == "admin")
	{
		$Tpl->assign( 'QuickLink', " <A HREF=\"site_list.php?website=true&action=sitelist\">网站配置信息</A> <a href=\"manage_all_site.php?website=true&ac=common\">站点列表管理</a>" );
	}
	else
	{
		$Tpl->assign( 'QuickLink', " <A HREF=\"site_list.php?website=true&action=sitelist\">网站配置信息</A> <a href=\"manage_all_site.php?website=true&ac=common\">站点列表管理</a>" );
	}
	$Tpl->assign( 'CopyRight', $PHPStatBottomRight );
	_out( $Tpl->fetch( 'main_index.html' )  );
?>