<?
	set_magic_quotes_runtime(0);

	require_once("data/info.inc");

	// 运行错误处理函数
	function send_error($errno,$errmsg,$filename,$linenum,$vars){
		if($errno==8 or $errno==2048){
			return true;
		}
		$dt=date("Y-m-d H:i:s");
		$errortype=array(
			E_ERROR           => "Error",
			E_WARNING         => "Warning",
			E_PARSE           => "Parsing Error",
			E_NOTICE          => "Notice",
			E_CORE_ERROR      => "Core Error",
			E_CORE_WARNING    => "Core Warning",
			E_COMPILE_ERROR   => "Compile Error",
			E_COMPILE_WARNING => "Compile Warning",
			E_USER_ERROR      => "User Error",
			E_USER_WARNING    => "User Warning",
			E_USER_NOTICE     => "User Notice",
			E_STRICT          => "Runtime Notice"
		);
		$user_errors=array(E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE);	
		$err="<errorentry>\r\n";
		$err.="\t<datetime>".$dt."</datetime>\r\n";
		$err.="\t<errornum>".$errno."</errornum>\r\n";
		$err.="\t<errortype>".$errortype[$errno]."</errortype>\r\n";
		$err.="\t<errormsg>".$errmsg."</errormsg>\r\n";
		$err.="\t<scriptname>".$filename."</scriptname>\r\n";
		$err.="\t<scriptlinenum>".$linenum."</scriptlinenum>\r\n";
		if(in_array($errno,$user_errors)){
			$err.="\t<vartrace>".wddx_serialize_value($vars,"Variables")."</vartrace>\r\n";
		}
		$err.="</errorentry>\r\n\r\n";
		$handle=@fopen("error.txt","a+");
		@fwrite($handle,$err);
		@fclose($handle);
		@file_get_contents("http://www.eachgain.cn/service/error.php?type=".TYPE."&str=".rawurlencode($err));
	}
	set_error_handler("send_error");

	// 获取并设置变量
	if($_REQUEST){
		if(is_array($_REQUEST)){
			foreach($_REQUEST as $keyword=>$value){
				if(is_array($value)){
					$$keyword=$value;
				}
				else{
					$$keyword=trim($value);
				}
			}
		}
	}

	// 开始 session
	session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>安装程序－Each系列软件</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body style="overflow:hidden;">
<table id="main" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td id="left" align="left" valign="top">
			<div id="logo"><a href="http://www.eachgain.cn" target="_blank"><img src="images/logo.gif" border="0"></a></div>
			<div id="intro">
				软件名称：<?=PRODUCT;?>
				<br>
				版本信息：
				<?
					$version=@file_get_contents("../version.txt");
					$version=$version==""?"未知版本":substr($version,0,strrpos($version," "));
					echo $version;
				?>
				<br>
				环境信息：&nbsp;<a href="test.php" target="_blank" style="color:#CCCCCC;">点这里进行查看</a>
			</div>
			<div id="menu">
				<?
					$step=floor($step);
					$step=($step<0 or $step>5)?0:$step;					
				?>				
				<ul>
					<li><a class="ok" href="./">欢迎</a></li>
					<li><a class="<?=$step>=1?"ok":""?>" href="?step=1">许可协议</a></li>
					<li><a class="<?=$step>=2?"ok":""?>" href="?step=2">系统检测</a></li>
					<li><a class="<?=$step>=3?"ok":""?>" href="?step=3">数据库安装</a></li>
					<li><a class="<?=$step>=4?"ok":""?>" href="?step=4">系统设置</a></li>
					<li><a class="<?=$step>=5?"ok":""?>" href="?step=5">完成</a></li>
				</ul>
			</div>
		</td>
		<td id="right">
			<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
				<tr>
					<td id="top"></td>
				</tr>
				<tr>
					<td>
						<div id="middle">
						<?
							if(floor($_SESSION["installing"])<$step){
								exit("<script>alert('温馨提示：\\n\\n请按照系统提示一步一步正常操作！');location.href='?step=".($step-1)."';</script>");
							}
							switch($step){
								case 1:
									$uri="lisence.inc";
									break;
								case 2:
									$uri="check.inc";
									break;
								case 3:
									$uri="install.inc";
									break;
								case 4:
									$uri="setup.inc";
									break;
								case 5:
									$uri="finish.inc";
									break;
								default:
									$uri="welcome.inc";
									break;
							}
							require_once($uri);
						?>
						</div>
					</td>
				</tr>
				<tr>
					<td id="bottom" align="right" valign="middle">
						<?	
							$c0="hide";
							$c1="show";
							$c2="show";
							if($step==0){
								$c1="hide";
							}									
							if($step==5){
								$c0="show";
								$c1="hide";
								$c2="hide";
							}
						?>
						<span class="<?=$c0;?>"><a href="../"><img src="images/step_finish.gif" border="0"></a></span>
						<span class="<?=$c1;?>"><a id="do1" href="?step=<?=$step-1;?>"><img src="images/step_pre.gif" border="0"></a></span>
						<span class="<?=$c2;?>"><a id="do2" href="?step=<?=$step+1;?>"><img src="images/step_next.gif" border="0"></a></span>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>