<?php
error_reporting(0);
@set_time_limit(0);
@set_magic_quotes_runtime(0);
ob_start();
define('IA_ROOT', str_replace("\\",'/', dirname(__FILE__)));
if($_GET['res']) {
	$res = $_GET['res'];
	$reses = tpl_resources();
	if(array_key_exists($res, $reses)) {
		if($res == 'css') {
			header('content-type:text/css');
		} else {
			header('content-type:image/png');
		}
		echo base64_decode($reses[$res]);
		exit();
	}
}

$actions = array('license', 'env', 'db', 'finish');
$action = $_COOKIE['action'];
$action = in_array($action, $actions) ? $action : 'license';
$ispost = strtolower($_SERVER['REQUEST_METHOD']) == 'post';

if(file_exists(IA_ROOT . '/data/install.lock') && $action != 'finish') {
	header('location: ./index.php');
}
header('content-type: text/html; charset=utf-8');
if($action == 'license') {
	if($ispost) {
		setcookie('action', 'env');
		header('location: ?refresh');
	}
	tpl_install_license();
}
if($action == 'env') {
	if($ispost) {
		setcookie('action', isset($_POST['continue']) ? 'db' : 'license');
		header('location: ?refresh');
	}
	$result = array();
	$result['env_os'] = PHP_OS;
	$result['env_version'] = PHP_VERSION;
	$result['env_server'] = $_SERVER['SERVER_SOFTWARE'];
	$result['env_pathroot'] = IA_ROOT;
	$result['env_uploadsize'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
	if(function_exists('disk_free_space')) {
		$result['env_diskspace'] = floor(disk_free_space(IA_ROOT) / (1024*1024)).'M';
	} else {
		$result['env_diskspace'] = 'unknow';
	}
	$tmp = function_exists('gd_info') ? gd_info() : array();
	$result['env_gd'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version'];
	
	$chk_func = array(
		array('method' => 'ini_get',			'name' => 'allow_url_fopen'), 
		array('method' => 'function_exists',	'name' => 'mysql_connect'),
		array('method' => 'function_exists',	'name' => 'file_get_contents'),
		array('method' => 'function_exists',	'name' => 'fsockopen'),
		array('method' => 'function_exists',	'name' => 'xml_parser_create'),
		array('method' => 'extension_loaded',	'name' => 'pdo_mysql'),
		array('method' => 'function_exists',	'name' => 'curl_init')
	);
	$result['iscontinue'] = true;
	foreach ($chk_func as $func) {
		$check[$func['name']] = $func['method']($func['name']) ? true : false;
		$result[$func['name']] = $func['method']($func['name']) ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>';
	}
	if (!empty($check['mysql_connect']) || !empty($check['pdo_mysql'])) {
		$result['iscontinue'] = true;
	} else {
		$result['iscontinue'] = false;
	}
	unset($check['mysql_connect']);unset($check['pdo_mysql']);
	
	foreach ($check as $condition) {
		if (empty($condition)) {
			$result['iscontinue'] = false;
		}
	}
	
	$result['chk_dir'] = array(
		'/',
	);
	foreach ($result['chk_dir'] as $dir) {
		if(!local_writeable(IA_ROOT . $dir)) {
			$result['chk_'.md5($dir)] = '<font color=red>[×]不可写</font>';
			$result['iscontinue'] = false;
		} else {
			$result['chk_'.md5($dir)] = '<font color=green>[√]可写</font>';
		}
	}
	tpl_install_check_env($result);
}
if($action == 'db') {
	if($ispost) {
		if(isset($_POST['back'])) {
			setcookie('action', 'env');
			header('location: ?refresh');
			exit();
		}

		$error_msg = '';
		
		$family = $_POST['family'] == 'x' ? 'x' : 'v';
		$dbhost = $_POST['dbhost'];
		$dbuser = $_POST['dbuser'];
		$dbpwd = $_POST['dbpwd'];
		$dbname = $_POST['dbname'];
		$dbprefix = $_POST['dbprefix'];
		$adminuser = $_POST['adminuser'];
		$adminpwd = $_POST['adminpwd'];
		$cookiepre = local_salt(4).'_';
		$authkey = local_salt(16).'_';
		$link = mysql_connect($dbhost, $dbuser, $dbpwd);
		if(empty($link)) {
			$error = mysql_error();
			$error_msg = "$error <br />";
		} else {
			mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
			mysql_query("SET sql_mode=''");
			if(mysql_errno()) {
				$error_msg = mysql_error() ." <br />";
			} else {
				$query = mysql_query("SHOW DATABASES LIKE  '{$dbname}';");
				if (!mysql_fetch_assoc($query)) {
					if(mysql_get_server_info() > '4.1') {
						mysql_query("CREATE DATABASE IF NOT EXISTS `{$dbname}` DEFAULT CHARACTER SET utf8", $link);
					} else {
						mysql_query("CREATE DATABASE IF NOT EXISTS `{$dbname}`", $link);
					}
				}
				$query = mysql_query("SHOW DATABASES LIKE  '{$dbname}';");
				if (!mysql_fetch_assoc($query)) {
					$error_msg .= "数据库不存在且创建数据库失败. <br />";
				}
				if(mysql_errno()) {
					$error_msg .= mysql_error() . " <br />";
				}
			}
		}
		if (empty($error_msg)) {
			//写入配置信息
			$dbport = explode(':', $dbhost);
			$dbport = !empty($dbport[1]) ? $dbport[1] : '3306';
			$config = local_config();
			$config = str_replace(array(
				'{dbhost}', '{dbuser}', '{dbpwd}', '{dbport}', '{dbname}', '{dbtablepre}', '{cookiepre}', '{authkey}', '{attachdir}'
			), array(
				"'$dbhost'", "'$dbuser'", "'$dbpwd'", "'$dbport'", $dbname, $dbprefix, $cookiepre, $authkey, 'resource/attachment/'
			), $config);

			mysql_select_db($dbname);
			$query = mysql_query("SHOW TABLES LIKE '{$dbprefix}%';");
			if (mysql_fetch_assoc($query)) {
				die('<script type="text/javascript">alert("您的数据库不为空，请重新建立数据库或是清空该数据库！");history.back();</script>');
			}
			if($_POST['install'] == 'remote') {
				$ins = remote_install();
				if(empty($ins) || !is_array($ins)) {
					die('<script type="text/javascript">alert("连接不到服务器, 请稍后重试！");history.back();</script>');
				}
				if($ins['error']) {
					die('<script type="text/javascript">alert("链接微擎更新服务器失败, 错误为: ' . $ins['error'] . '！");history.back();</script>');
				}
				if(empty($ins['scripts']) || !is_array($ins['scripts'])) {
					die('<script type="text/javascript">alert("此服务器未授权, 不能安装！");history.back();</script>');
				}
				$archive = remote_download($ins['attachments']);
				if(!$archive) {
					die('<script type="text/javascript">alert("未能下载程序包, 请确认你的安装程序目录有写入权限. 多次安装失败, 请访问论坛获取解决方案！");history.back();</script>');				
				}
				$fp = fopen($archive, 'r');
				if ($fp) {
					$buffer = '';
					while (!feof($fp)) {
						$buffer .= fgets($fp, 4096);
						if($buffer[strlen($buffer) - 1] == "\n") {
							$pieces = explode(':', $buffer);
							$path = base64_decode($pieces[0]);
							$dat = base64_decode($pieces[1]);
							$fname = IA_ROOT . $path;
							local_mkdirs(dirname($fname));
							file_put_contents($fname, $dat);
							$buffer = '';
						}
					}
					fclose($fp);
				}
				unlink($archive);
				mysql_close($link);
				$link = mysql_connect($dbhost, $dbuser, $dbpwd);
				mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary");
				mysql_query("SET sql_mode=''");
				mysql_select_db($dbname);

				$version = '';
				$release = '';
				foreach($ins['scripts'] as $sch) {
					$version = $sch['version'];
					$release = $sch['release'];
					runquery($sch['content']);
				}
				$verfile = IA_ROOT . '/source/version.inc.php';
				$verdat = <<<VER
<?php
/**
 * 版本号
 * 
 * [WeEngine System] Copyright (c) 2013 WE7.CC
 */

defined('IN_IA') or exit('Access Denied');

define('IMS_FAMILY', '{$ins['family']}');
define('IMS_VERSION', '{$version}');
define('IMS_RELEASE_DATE', '{$release}');
VER;
				file_put_contents($verfile, $verdat);
			} else {
				$verfile = IA_ROOT . '/source/version.inc.php';
				if(file_exists(IA_ROOT . '/index.php') && file_exists(IA_ROOT . '/setting.php') && file_exists($verfile)) {
					$sql = file_get_contents(IA_ROOT . '/data/install.sql');
					if(empty($sql)) {
						die('<script type="text/javascript">alert("安装包不正确, 数据安装脚本缺失.");history.back();</script>');
					}
					runquery($sql);
				} else {
					die('<script type="text/javascript">alert("你正在使用本地安装, 但未下载完整安装包, 请从微擎官网下载完整安装包后重试.");history.back();</script>');
				}
			}

			$salt = local_salt(8);
			$password = sha1("{$adminpwd}-{$salt}-{$authkey}");
			mysql_query("INSERT INTO {$dbprefix}members (username, password, salt, joindate) VALUES('{$adminuser}', '$password', '$salt', '".time()."')");
			$uid = mysql_insert_id();
			//新建默认公众号
			$wechat = array(
				'hash' => local_salt(5),
				'type' => '1',
				'uid' => $uid,
				'token' => local_salt(32),
				'access_token' => '',
				'name' => '默认公众号',
				'account' => '默认公众号',
				'original' => '',
				'signature' => '',
				'country' => '',
				'province' => '',
				'city' => '',
				'username' => '',
				'password' => '',
				'welcome' => '欢迎信息',
				'default' => '默认回复',
				'default_period' => '0',
				'lastupdate' => '',
				'key' => '',
				'secret' => '',
				'styleid' => '1',
			);
			mysql_query("INSERT INTO `{$dbprefix}wechats` (`".implode("`,`", array_keys($wechat))."`) VALUES ('".implode("','", $wechat)."')");
			local_mkdirs(IA_ROOT . '/data');
			file_put_contents(IA_ROOT . '/data/config.php', $config);
			touch(IA_ROOT . '/data/install.lock');
			setcookie('action', 'finish');
			header('location: ?refresh');
			exit();
		}
	}
	tpl_install_db($error_msg);
	
}
if($action == 'finish') {
	setcookie('action', '', -10);
	@unlink(IA_ROOT . '/data/install.sql');
	define('IN_SYS', true);
	require_once IA_ROOT . '/source/bootstrap.inc.php';
	require_once IA_ROOT . '/source/model/setting.mod.php';
	$_W['uid'] = $_W['isfounder'] = 1;
	cache_build_setting();
	cache_build_announcement();
	cache_build_modules();
	cache_build_fans_struct();
	cache_build_hook();
	tpl_install_finish();
}

function local_writeable($dir) {
	$writeable = 0;
	if(!is_dir($dir)) {
		@mkdir($dir, 0777);
	}
	if(is_dir($dir)) {
		if($fp = fopen("$dir/test.txt", 'w')) {
			fclose($fp);
			unlink("$dir/test.txt");
			$writeable = 1;
		} else {
			$writeable = 0;
		}
	}
	return $writeable;
}

function local_salt($length = 8) {
	$result = '';
	while(strlen($result) < $length) {
		$result .= sha1(uniqid('', true));
	}
	return substr($result, 0, $length);
}

function local_config() {
	$cfg = <<<EOF
<?php
defined('IN_IA') or exit('Access Denied');

\$config = array();

\$config['db']['host'] = {dbhost};
\$config['db']['username'] = {dbuser};
\$config['db']['password'] = {dbpwd};
\$config['db']['port'] = {dbport};
\$config['db']['database'] = '{dbname}';
\$config['db']['charset'] = 'utf8';
\$config['db']['pconnect'] = 0;
\$config['db']['tablepre'] = '{dbtablepre}';

// --------------------------  CONFIG COOKIE  --------------------------- //
\$config['cookie']['pre'] = '{cookiepre}';
\$config['cookie']['domain'] = '';
\$config['cookie']['path'] = '/';

// --------------------------  CONFIG SETTING  --------------------------- //
\$config['setting']['charset'] = 'utf-8';
\$config['setting']['cache'] = 'mysql';
\$config['setting']['timezone'] = 'Asia/Shanghai';
\$config['setting']['memory_limit'] = '256M';
\$config['setting']['filemode'] = 0644;
\$config['setting']['authkey'] = '{authkey}';
\$config['setting']['founder'] = '1';
\$config['setting']['development'] = 0;
\$config['setting']['referrer'] = 28262;


// --------------------------  CONFIG UPLOAD  --------------------------- //
\$config['upload']['image']['extentions'] = array('gif', 'jpg', 'jpeg', 'png');
\$config['upload']['image']['limit'] = 5000;
\$config['upload']['attachdir'] = '{attachdir}';

EOF;
	return trim($cfg);
}

function local_mkdirs($path) {   
	if(!is_dir($path)) {
		local_mkdirs(dirname($path));
		mkdir($path);   
	}   
	return is_dir($path);   
}

function runquery($sql) {
	global $link, $dbprefix;

	if(!isset($sql) || empty($sql)) return;

	$sql = str_replace("\r", "\n", str_replace(' ims_', ' '.$dbprefix, $sql));
	$sql = str_replace("\r", "\n", str_replace(' `ims_', ' `'.$dbprefix, $sql));
	$ret = array();
	$num = 0;
	foreach(explode(";\n", trim($sql)) as $query) {
		$ret[$num] = '';
		$queries = explode("\n", trim($query));
		foreach($queries as $query) {
			$ret[$num] .= (isset($query[0]) && $query[0] == '#') || (isset($query[1]) && isset($query[1]) && $query[0].$query[1] == '--') ? '' : $query;
		}
		$num++;
	}
	unset($sql);
	foreach($ret as $query) {
		$query = trim($query);
		if($query) {
			mysql_query($query, $link);
		}
	}
}

function __remote_install_headers($ch = '', $header = '') {
    static $hash;
    if(!empty($header)) {
        $pieces = explode(':', $header);
        if(trim($pieces[0]) == 'hash') {
            $hash = trim($pieces[1]);
        }
    }
    if($ch == '' && $header == '') {
        return $hash;
    }
    return strlen($header);
}

function remote_install() {
	global $family;
	$token = '';
	$pars = array();
	$pars['host'] = $_SERVER['HTTP_HOST'];
	$pars['version'] = '';
	$pars['release'] = '';
	$url = 'http://addons.we7.cc/gateway.php';
	$ch = curl_init($url); 
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $pars);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_HEADERFUNCTION, '__remote_install_headers');
	$content = curl_exec($ch);
	curl_close($ch);
	$sign = __remote_install_headers();
	$ret = array(); 
	if($content) {
		$obj = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA);
		$ret['version'] = strval($obj->version);
		$ret['release'] = strval($obj->release);
		$ret['family'] = strval($obj->family);
		$ret['announcement'] = strval($obj->announcement);
		$ret['error'] = strval($obj->error);
        if(empty($ret['error']) && $sign == md5($content . $token)) {
            if($obj->scripts) {
                $ret['scripts'] = array();
                foreach($obj->scripts->script as $schema) {
                    $attr = $schema->attributes();
                    $v = strval($attr['version']);
                    $r = strval($attr['release']);
                    $c = strval($schema);
                    $ret['scripts'][] = array(
                        'version' => $v,
                        'release' => $r,
                        'content' => $c
                    );
                }
            }
            if($obj->attachments) {
                $ret['attachments'] = array();
                foreach($obj->attachments->file as $file) {
                    $attr = $file->attributes();
                    $path = strval($attr['path']);
                    $sum = strval($attr['checksum']);
                    $entry = IA_ROOT . $path;
                    if(!is_file($entry) || md5_file($entry) != $sum) {
                        $ret['attachments'][] = $path;
                    }
                }
            }
        }
	}
	return $ret;
}

function __remote_download_headers($ch = '', $header = '') {
    static $hash;
    if(!empty($header)) {
        $pieces = explode(':', $header);
        if(trim($pieces[0]) == 'hash') {
            $hash = trim($pieces[1]);
        }
    }
    if($ch == '' && $header == '') {
        return $hash;
    }
    return strlen($header);
}

function remote_download($archive) {
	$pars = array();
	$pars['host'] = $_SERVER['HTTP_HOST'];
	$pars['version'] = '';
	$pars['release'] = '';
	$pars['archive'] = base64_encode(json_encode($archive));
	$url = 'http://addons.we7.cc/gateway.php';
	$tmpfile = IA_ROOT . '/we7.zip';
	$fp = fopen($tmpfile, 'w+');
	if(!$fp) {
		return false;
	}
	$ch = curl_init($url); 
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $pars);
	curl_setopt($ch, CURLOPT_FILE, $fp);
	curl_setopt($ch, CURLOPT_HEADERFUNCTION, '__remote_download_headers');
	if(!curl_exec($ch)) {
		return false;
	}
	curl_close($ch);
	fclose($fp);
	$sign = __remote_download_headers();
	if(md5_file($tmpfile) == $sign) {
		return $tmpfile;
	}
	return false;
}

function tpl_frame() {
	global $action, $actions;
	$steps = array('许可协议', '环境检测', '参数配置', '安装完成');

	$contents = ob_get_contents();
	ob_clean();
	echo <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=7" />
<title>微擎 - 微信公众平台自助开源引擎</title>
<link href="?res=css" rel="stylesheet" type="text/css" />

</head>
<body>
<div class="header">
	<div class="top">
		<div class="top-logo">
		</div>
		<div class="top-link">
			<ul>
				<li><a href="http://www.we7.cc" target="_blank">微擎官方网站</a></li>
				<li><a href="http://bbs.we7.cc" target="_blank">微擎官方论坛</a></li>
			</ul>
		</div>
	</div>
</div>
<div class="main">
	<div class="pleft">
		<dl class="setpbox t1">
			<dt>安装步骤</dt>
			<dd>
				<ul>
EOF;
	foreach ($steps as $index => $value) {
		$classname = $index == array_search($action, $actions) ? 'now' : 'succeed';
		echo '<li class="'.$classname.'">'.$value.'</li>';
	}
	echo <<<EOF
				</ul>
			</dd>
		</dl>
	</div>
	<div class="pright">
		{$contents}
	</div>
</div>

<div class="foot">
</div>
</body>
</html>
EOF;
}

function tpl_install_license() {
	echo <<<EOF
		<div class="pr-title"><h3>阅读许可协议</h3></div>
		<div class="pr-agreement">
				<p>版权所有 (c)2013，微擎团队保留所有权利。 </p>
				<p>感谢您选择微擎 - 微信公众平台自助开源引擎（以下简称WE7，WE7基于 PHP + MySQL的技术开发，全部源码开放。</p>
				<p>为了使你正确并合法的使用本软件，请你在使用前务必阅读清楚下面的协议条款：</p>
			<strong>一、本授权协议适用且仅适用于W7任何版本，WE7官方对本授权协议的最终解释权。</strong>
			<strong>二、协议许可的权利 </strong>
				<p>1、您可以在完全遵守本最终用户授权协议的基础上，将本软件应用于非商业用途，而不必支付软件版权授权费用。 </p>
				<p>2、您可以在协议规定的约束和限制范围内修改 WE7 源代码或界面风格以适应您的网站要求。 </p>
				<p>3、您拥有使用本软件构建的网站全部内容所有权，并独立承担与这些内容的相关法律义务。 </p>
				<p>4、获得商业授权之后，您可以将本软件应用于商业用途，同时依据所购买的授权类型中确定的技术支持内容，自购买时刻起，在技术支持期限内拥有通过指定的方式获得指定范围内的技术支持服务。商业授权用户享有反映和提出意见的权力，相关意见将被作为首要考虑，但没有一定被采纳的承诺或保证。 </p>
			<strong>二、协议规定的约束和限制 </strong>
				<p>1、未获商业授权之前，不得将本软件用于商业用途（包括但不限于企业网站、经营性网站、以营利为目的或实现盈利的网站）。</p>
				<p>2、未经官方许可，不得对本软件或与之关联的商业授权进行出租、出售、抵押或发放子许可证。</p></p>
				<p>4、未经官方许可，禁止在 WE7 的整体或任何部分基础上以发展任何派生版本、修改版本或第三方版本用于重新分发。</p>
				<p>5、如果您未能遵守本协议的条款，您的授权将被终止，所被许可的权利将被收回，并承担相应法律责任。 </p>
			<strong>三、有限担保和免责声明 </strong>
				<p>1、本软件及所附带的文件是作为不提供任何明确的或隐含的赔偿或担保的形式提供的。 </p>
				<p>2、用户出于自愿而使用本软件，您必须了解使用本软件的风险，在尚未购买产品技术服务之前，我们不承诺对免费用户提供任何形式的技术支持、使用担保，也不承担任何因使用本软件而产生问题的相关责任。 </p>
				<p>3、电子文本形式的授权协议如同双方书面签署的协议一样，具有完全的和等同的法律效力。您一旦开始确认本协议并安装  WE7，即被视为完全理解并接受本协议的各项条款，在享有上述条款授予的权力的同时，受到相关的约束和限制。协议许可范围以外的行为，将直接违反本授权协议并构成侵权，我们有权随时终止授权，责令停止损害，并保留追究相关责任的权力。</p>
				<p>4、如果本软件带有其它软件的整合API示范例子包，这些文件版权不属于本软件官方，并且这些文件是没经过授权发布的，请参考相关软件的使用许可合法的使用。</p>
		</div>
		<div class="btn-box">
			<form action="" method="post" onsubmit="return document.getElementById('readpact').checked ? true : (!!alert('您必须同意软件许可协议才能安装！') && false);">
				<input type="checkbox" id="readpact" value="" /><label for="readpact"><strong class="fc-690 fs-14">我已经阅读并同意此协议</strong></label>
				<input type="submit" class="btn-next" value="继续" />
			</form>
		</div>
	</div>
</div>
EOF;
	tpl_frame();
}

function tpl_install_check_env($result = array()) {
	extract($result);
	$chk_dir_html = '';
	foreach ($chk_dir as $dir) {
		$status = 'chk_'.md5($dir);
		$chk_dir_html .= '
		 <tr>
			<td>'.$dir.'</td>
			<td><font color=green>[√]可写</font></td>
			<td>'.$$status.'</td>
		</tr>';	
	}
echo <<<EOF
<div class="pr-title"><h3>服务器信息</h3></div>
<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
	<tr>
		<th width="300" align="center"><strong>参数</strong></th>
		<th width="424"><strong>值</strong></th>
	</tr>
	<tr>
		<td><strong>服务器操作系统</strong></td>
		<td>{$env_os}</td>
	</tr>
	<tr>
		<td><strong>服务器解译引擎</strong></td>
		<td>{$env_server}</td>
	</tr>
	<tr>
		<td><strong>PHP版本</strong></td>
		<td>{$env_version}</td>
	</tr>
	<tr>
		<td><strong>系统安装目录</strong></td>
		<td>{$env_pathroot}</td>
	</tr>
	<tr>
		<td><strong>磁盘空间</strong></td>
		<td>{$env_diskspace}</td>
	</tr>
	<tr>
		<td><strong>附件上传</strong></td>
		<td>{$env_uploadsize}</td>
	</tr>
	<tr>
		<td><strong>GD 库</strong></td>
		<td>{$env_gd}</td>
	</tr>
</table>
<div class="pr-title"><h3>程序依赖性检查</h3></div>
<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
	<tr>
		<th width="200" align="center"><strong>需开启的变量或函数</strong></th>
		<th width="80"><strong>要求</strong></th>
		<th width="400"><strong>实际状态及建议</strong></th>
	</tr>
	<tr>
		<td>mysql_connect()</td>
		<td align="center">On </td>
		<td>{$mysql_connect} <small>(mysql_connect与pdo必须支持其中一个)</small></td>
	</tr>
	<tr>
		<td>PDO</td>
		<td align="center">On </td>
		<td>{$pdo_mysql} <small>(mysql_connect与pdo必须支持其中一个)</small></td>
	</tr>
	<tr>
		<td>allow_url_fopen</td>
		<td align="center">On </td>
		<td>{$allow_url_fopen} <small></small></td>
	</tr>
	<tr>
		<td>file_get_contents()</td>
		<td align="center">On</td>
		<td>{$file_get_contents} <small></small></td>
	</tr>
	<tr>
		<td>xml_parser_create()</td>
		<td align="center">On</td>
		<td>{$xml_parser_create} <small></small></td>
	</tr>
	<tr>
		<td>fsockopen()</td>
		<td align="center">On</td>
		<td>{$fsockopen} <small></small></td>
	</tr>
	<tr>
		<td>curl</td>
		<td align="center">On</td>
		<td>{$curl_init} <small></small></td>
	</tr>
</table>
<div class="notice">系统环境要求必须满足下列所有条件，否则系统或系统部份功能将无法使用。</div>

<div class="pr-title"><h3>目录权限检测</h3></div>
<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
	<tr>
		<th width="300" align="center"><strong>目录名</strong></th>
		<th width="212"><strong>所需状态</strong></th>
		<th width="212"><strong>当前状态</strong></th>
	</tr>
	{$chk_dir_html}
</table>
<div class="notice">
	系统要求微擎整个安装目录必须可写, 才能使用微擎所有功能.
</div>
<div class="btn-box">
	<form action="" method="post">
	<input type="submit" name="back" class="btn-back" value="" />
EOF;

if (!empty($iscontinue)) {
	echo <<<EOF
	<input type="submit" name="continue" class="btn-next" value="" />
	</form>
</div>
EOF;
} else {
	echo <<<EOF
	<font color=red>请先解决环境依赖，以便继续进行安装</font>
</div>
EOF;
}
	tpl_frame();
}

function tpl_install_db($error_msg = '') {
	if (!empty($error_msg)) {
		echo <<<EOF
		<div class="pr-title"><h3>错误信息</h3></div>
		<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
			<tr>
				<td><div style="color:red;">{$error_msg}</div></td>
			</tr>
		</table>	
EOF;
	}
	$insTypes = array();
	if(file_exists(IA_ROOT . '/index.php') && file_exists(IA_ROOT . '/setting.php')) {
		$insTypes['local'] = ' checked="checked"';
	} else {
		$insTypes['remote'] = ' checked="checked"';
	}
	$disabled = empty($insTypes['local']) ? ' disabled="disabled"' : '';
	echo <<<EOF
	<form action="" method="post" onsubmit="return check(this)">
	<div class="pr-title"><h3>安装选项</h3></div>
	<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
		<tr>
			<td class="onetd"><strong>请选择安装方式：</strong></td>
			<td>
				<input name="install" type="radio" value="remote" {$insTypes['remote']}/> 在线安装 &nbsp; &nbsp; 
				<input name="install" type="radio" value="local" {$insTypes['local']}{$disabled}/> 离线安装 
				<p><small>在线安装能够直接安装最新版本微擎系统, 如果在线安装困难, 请下载离线安装包后使用本地安装.</small></p>
				<p><small>离线安装包可能不是最新程序, 如果你不确定, 可以现在访问官网重新下载一份最新的.^_^</small></p>
			</td>
		</tr>
	</table>
	<div class="pr-title"><h3>数据库设定</h3></div>
	<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
		<tr>
			<td class="onetd"><strong>数据库主机：</strong></td>
			<td><input name="dbhost" id="dbhost" type="text" value="localhost" class="input-txt" />
			<small>一般为localhost</small></td>
		</tr>
		<tr>
			<td class="onetd"><strong>数据库用户：</strong></td>
			<td><input name="dbuser" id="dbuser" type="text" value="root" class="input-txt" /></td>
		</tr>
		<tr>
			<td class="onetd"><strong>数据库密码：</strong></td>
			<td>
			  <input name="dbpwd" id="dbpwd" type="text" class="input-txt" />
			</td>
		</tr>
		<tr>
			<td class="onetd"><strong>数据表前缀：</strong></td>
			<td><input name="dbprefix" id="dbprefix" type="text" value="ims_" class="input-txt" />
			<small>如无特殊需要,请不要修改</small></td>
		</tr>
		<tr>
			<td class="onetd"><strong>数据库名称：</strong></td>
			<td>
				<input name="dbname" id="dbname" type="text" value="we7" class="input-txt" />
			</td>
		</tr>
	</table>

	<div class="pr-title"><h3>管理员初始密码</h3></div>
	<table width="726" border="0" align="center" cellpadding="0" cellspacing="0" class="twbox">
		<tr>
			<td class="onetd"><strong>管理员帐号：</strong></td>
			<td>
				<input name="adminuser" type="text" value="admin" class="input-txt" />
				<p><small>只能用'0-9'、'a-z'、'A-Z'、'.'、'@'、'_'、'-'、'!'以内范围的字符</small></p>
			</td>
		</tr>
		<tr>
			<td class="onetd"><strong>管理员密码：</strong></td>
			<td><input name="adminpwd" type="password" value="" class="input-txt" /></td>
		</tr>
		<tr>
			<td class="onetd"><strong>确认密码：</strong></td>
			<td><input name="confirmpwd" type="password" value="" class="input-txt" /></td>
		</tr>
	</table>

	<div class="btn-box">
		<input type="submit" name="back" class="btn-back" value="" onclick="window.chk = false;" />
		<input type="submit" id="install" name="continue" class="btn-next" value="" onclick="window.chk = true;" />
  </div>
	</form>
	<script type="text/javascript">
	function check(form) {
		if(!window.chk) {
			return true;
		}
		if (!form['dbhost'].value) {
			alert('请填写数据库主机地址！');
			form['dbhost'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['dbuser'].value) {
			alert('请填写数据库用户！');
			form['dbuser'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['dbpwd'].value) {
			alert('请填写数据库密码！');
			form['dbpwd'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['dbprefix'].value) {
			alert('请填写数据库表前缀！');
			form['dbprefix'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['dbname'].value) {
			alert('请填写数据库名称！');
			form['dbname'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['adminuser'].value) {
			alert('请填写管理员帐号！');
			form['adminuser'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (!form['adminpwd'].value) {
			alert('请填写管理员帐号密码！');
			form['adminpwd'].focus();
			form['install'].disabled = '';
			return false;
		}
		if (form['adminpwd'].value != form['confirmpwd'].value) {
			alert('您两次输入的管理员帐号密码不相同，请检查！');
			form['adminpwd'].focus();
			form['install'].disabled = '';
			return false;
		}
		document.getElementById('install').disabled = 'disabled';
		return true;
	}
	</script>
EOF;
	tpl_frame();
}

function tpl_install_finish() {
	echo <<<EOF
<div class="pr-title"><h3>安装完成</h3></div>
<div class="install-msg">
	恭喜您!已成功安装“微擎 - 微信公众平台自助开源引擎”系统，您现在可以:
	<br />
</div>
<div class="over-link fs-14">
	<a href="./index.php">访问网站首页</a>
</div>
EOF;
	tpl_frame();
}

function tpl_resources() {
	static $res = array(
		'css' => '[encoded data, 7676 characters]',
		'logo' => '[encoded data, 18352 characters]',
		'step-ico-bg' => 'iVBORw0KGgoAAAANSUhEUgAAAA0AAACtCAIAAADklWLFAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAArwAAAK8AFCrDSYAAAAFnRFWHRDcmVhdGlvbiBUaW1lADEwLzI0LzA4KQ6r+wAAAB90RVh0U29mdHdhcmUATWFjcm9tZWRpYSBGaXJld29ya3MgOLVo0ngAAAF/SURBVFiF7dnNjpswFIbhzwc7/iGBTBTU+7+8UUZMEhJsY2O6IEqrSq3STRfTc5bmETIY6V0gpjkCADDl4Kch5LEshQQZ6exmt5FmvSpWdxlPcQ61brSyArSgxOTv8aor07ru4S7jKZfU1kcBwk+zoFzuH5JU6zo55RDncNh+E6CU4xA+c0mS1M68Kanb+tjf3qccpJ+GWjcruvq+MQetXEj3y/jRuqOSutaNnwYKedTKAhjCuTGHrW4VqZ3eN/YwhDMArWzII5WlrNvKJWnlnpvT0uaSAAhQWQqRoAUFgCQZ0/h0Po2S1Po0JEga6WLyRtU783YeT3PJdrP16X4Ln607AojJG+nELV7O/vS7511Q+tv73navvr9Xz+Nxg9Z1e9tdfZ9T0mRySlff7223oh8OwHrkM+ZYwoz5ufKr+/OwY8fuf3JTDgAqVJpMheq5sg734zHcj7/8rtixY/f1HfeD+wFwP9ix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