www.gusucode.com > Tatter Tools 0.961 SE GB2312 简体中文版 > upload/install.php

    <?

class db_init {

	var $con;
	var $host;
	var $db;
	var $user;
	var $pass;
	var $error_message = "";
	var $error_flag = 0;

	function db_init_proc() {
		global $host, $db, $user, $pass;

		if (trim($host)) $this->host = $host;
		if (trim($db)) $this->db = $db;
		if (trim($user)) $this->user = $user;
		if (trim($pass)) $this->pass = $pass;

		$this->con = @mysql_connect($this->host, $this->user, $this->pass);
		if (!$this->con) { print "<font color=red>DB数据库链接错误.本程序支持远程调用数据库</font><br>DB设定错误,确定主机支持MYSQL或与主机商联系安装"; return false; }
		else if (!@mysql_select_db($this->db, $this->con)) { print "<font color=red>DB数据库不存在,请确认.</font><br>DB 设定错误,确定主机支持MYSQL或与主机商联系安装"; return false; }
		return true;
	}

}

	reset($HTTP_POST_VARS);
	while (list($key, $val) = each($HTTP_POST_VARS)) {
		$$key = stripslashes($val);
		$$key = str_replace("\"", "&quot;", $$key);
		$$key = str_replace("'", "&#39;", $$key);
	}

	reset($HTTP_GET_VARS);
	while (list($key, $val) = each($HTTP_GET_VARS)) {
		$$key = stripslashes($val);
	}

	reset($HTTP_SERVER_VARS);
	while (list($key, $val) = each($HTTP_SERVER_VARS)) {
		$$key = $val;
	}

	include("inc_scheme.php");

	if (is_file("config.php") && $mode != "finish") {
		?>
		<html>
		<meta http-equiv=Content-type content=text/html; charset=gb2312>
        <meta name=keywords content="Tatter Tools,Meyu">
        <title>Tatter Tools 0.961 SE 中文版安装程序</title>
        <body background=<?=$r_root_path?>images/e_back.gif style=margin:0>
		<style type="text/css">
		table			{ font-family: Tahoma, Verdana; color: #000000; font-size: 9pt }
		</style>
        <table width=50% style=margin-top:7><tr>
		<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0 align=center>
		Tatter Tools 0.961 SE<br>
		<font color=red>config.php</font>数据库配置文件已存在,请删除此文件之后重新安装.<br>
		</td>
		</table>
		</body>
		</html>
			
		<?
		exit;
	}

	function get_this_path() {
		global $PHP_SELF, $HTTP_HOST;
		$uinfo = parse_url("http://".$HTTP_HOST.$PHP_SELF);
		$bf = substr($uinfo[path], 0, strrpos($uinfo[path],"/"));
		return $uinfo[scheme]."://".$uinfo[host].$bf."/";
	}

	function get_root_path() {
		$bf = get_this_path();
		$dh = @opendir("./");

		while($dh && false !== ($file = readdir($dh))) {
			if ($file == "flag") {
				closedir($dh);
				return array(substr($bf, 0, strrpos(substr($bf,0,strlen($bf)-1),"/")+1), "../");
			}
		}
		closedir($dh);
		return array($bf, "./");
	}

	function is_dir_permit($obj) {
		if (is_readable($obj) && is_writable($obj) && @file_exists($obj."/.")) return true;
		else return false;
	}

	function is_file_permit($obj) {
		if (is_readable($obj) && is_writable($obj)) return true;
		else return false;
	}

	function put_query($query) {
		if (!mysql_query($query)) return false;
	}

	function input_block() {
		?><table width=100% cellspacing=0 border=0 style=margin-top:3;margin-bottom:3><tr><td background=../images/dot_width2.gif></td></tr></table><?
	}

	list($s_root_path, $r_root_path)= get_root_path();

	if ($step == "7" && $mode != "finish") {

		$cn = new db_init();
		$result = $cn->db_init_proc();

		drop_scheme();
		create_scheme();
		put_query("insert into t3_".$dbid."_setting (user_pass) values (password('$lpass1'))");

		$buf = "<?
	\$host = \"$host\";
	\$db = \"$db\";
	\$user = \"$user\";
	\$pass = \"$pass\";
	\$dbid = \"$dbid\";
?>";

		$fname = "config.php";
		$out = fopen($fname, "w");
		chmod($fname, 0777);
		fwrite($out, $buf);
		fclose($out);

		header("Location: install.php?mode=finish");
		exit;
	}

?>
<meta http-equiv=Content-type content=text/html; charset=gb2312>
<meta name=keywords content="Tatter Tools,Meyu">
<link rel=stylesheet href="admin/style.css">
<script src=lib.js></script>
<title>Tatter Tools 0.961 SE 中文版安装程序</title>
<body background=<?=$r_root_path?>images/e_back.gif style=margin:0>

<table cellpadding=0 cellspacing=0 width=100% height=100%>
<form method=post name=inst action="<?=$PHP_SELF?>">
<input type=hidden name=step>

<input type=hidden name=host value="<?=$host?>">
<input type=hidden name=db value="<?=$db?>">
<input type=hidden name=user value="<?=$user?>">
<input type=hidden name=pass value="<?=$pass?>">
<input type=hidden name=dbid value="<?=$dbid?>">

<tr>
<td align=center>

	<table bgcolor=#FFFFFF width=500 height=450 style=border-style:solid;border-width:1;border-color:#444444><tr>
	<td valign=top style=padding:10;font-size:9pt;color:555555;>

		<table style=margin-bottom:10><tr>
		<td><img src=<?=$r_root_path?>images/bi_1.gif width=112 height=39></td>
		<td style=padding-left:5><img src=<?=$r_root_path?>images/install.gif width=153 height=37></td>
		</tr></table>

		<? input_block() ?>
		<table style=margin-top:8><tr><td></td></tr></table>
		<?

	 		if ($mode == "finish") {
	 			?>
				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>

				:: 感谢您使用本程序,程序已安装完毕.<br><br>

				<b>:: 登入首页<br>
				<a href=<?=$r_root_path?>index.php target=_blank><?=$s_root_path?>index.php</a><br><br>

				:: 后台管理<br>
				<a href="<?=$r_root_path?>admin/article.php" target=_blank><?=$s_root_path?>admin/article.php</a><br><br>
				</b>
				建议您先登入后台管理设定,请从FTP软件删除install.php此安装文件<br>
				
				</td>
				</tr></table>
				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>
				男儿当自强 我们将谱写新一代年轻社区团队的精神 欢迎加入我们的团体<br>
				中文用户安装使用:<a href=http://www.meyu.net/star/forumdisplay.php?fid=6 target=_blank>http://www.meyu.net/star/forumdisplay.php?fid=6</a><br>
				中文原创风格模板:<a href=http://www.meyu.net/star/forumdisplay.php?fid=45 target=_blank>http://www.meyu.net/star/forumdisplay.php?fid=45</a><br>
				</td>
				</table>
				<?
			} else if (!$step) {
	 			?>
				第一步 :: 安装协议与版权声明.

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F0F0F0 style=padding:10;border-style:solid;border-width:1;border-color:#A0A0A0>
				作者主页 : <a href=http://interlude.pe.kr target=_blank>JH</a><br>
				中文支持 : <a href=http://www.meyu.net target=_blank>梦游华人中文网</a><br>
				韩方主页 : <a href=http://www.tattertools.com target=_blank>http://www.tattertools.com</a><br>
                <b>
				中文版:Tatter Tools 0.961 Special Editon (2005.10.12)<br>
                韩文版:Tatter Tools 0.96 CountDown - Official Release</b><br>
				
                
				<? input_block() ?>

				<div style=padding-top:10><b>1</b>. 这是一个免费且自己支配的程序,任何人都可以免费使用与传播</div>
				<div style=padding-top:5> <b>2</b>. 本程序不得用于商业用途.</div>
				<div style=padding-top:5> <b>3</b>. 开发商不附带维护程序.对程序所造成的数据丢失与损坏不负带任何责任</div>
				<div style=padding-top:5> <b>4</b>. <a href=http://www.tattertools.com target=_blank>http://www.tattertools.com</a> 官方网站发布为准,不允许修改之后擅自发布</div>
				<div style=padding-top:5> <b>5</b>. 请保留官方的版权图标地址链接.</div>
				<div style=padding-top:5> <b>6</b>. 模板风格与菜单选项归风格作者所有.</div>

				</td>
				</tr></table>

				<div align=center style=margin-top:10><img class=ib src=images/b_next.gif onclick="inst.step.value='2'; inst.submit();"></div>

				<?
			}

	 		else if ($step == "2") {
	 			?>
				第二步 :: MySQL 数据库设定.如您不清楚如何填写,请联系空间主机商协助您安装.

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>

				<table cellpadding=0 cellspacing=0><tr>
				<td width=90 align=right style=padding-top:2>DB 地址 ::&nbsp;</td>
				<td><input class=text type=text name=host value=localhost>远程调用数据库请输入IP或地址</td>
				</tr></table>

				<table cellpadding=0 cellspacing=0 style=margin-top:5><tr>
				<td width=90 align=right style=padding-top:2>DB 名称 ::&nbsp;</td>
				<td><input class=text type=text name=db>如无请先登入<a href=../phpmyadmin/>Phpmyadmin</a>创建</td>
				</tr></table>

				<table cellpadding=0 cellspacing=0 style=margin-top:5><tr>
				<td width=90 align=right style=padding-top:2>DB 用户 ::&nbsp;</td>
				<td><input class=text type=text name=user>具备可写入的MYSQL登入用户名</td>
				</tr></table>

				<table cellpadding=0 cellspacing=0 style=margin-top:5><tr>
				<td width=90 align=right style=padding-top:2>DB 密码 ::&nbsp;</td>
				<td><input class=text type=text name=pass>MYSQL登入用户名密码</td>
				</tr></table>

				</td>
				</tr></table>

				<div align=center style=margin-top:10><img class=ib src=images/b_next.gif onclick="inst.step.value='3'; inst.submit();"></div>

				<?
			}

	 		else if ($step == "3") {
	 			?>
				第三步 :: 与 MySQL 链接设定创建资料库成功.

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>

	 			<?
	 				$cn = new db_init();
	 				$result = $cn->db_init_proc();

	 				if ($result) print "MYSQL设定正确,点击进入下一步";
	 			?>

				</td>
				</tr></table>

				<div align=center style=margin-top:10><?
					if (!$result) { ?><img class=ib src=images/b_back_m.gif onclick="history.go(-1);"><? }
					else { ?><img class=ib src=images/b_next.gif onclick="inst.step.value='4'; inst.submit();"><? }
				?></div>

				<?
			}

	 		else if ($step == "4") {
	 			?>
			     第四步 :: 文件夹权限设定检查.<br>
			    <table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>
			     以下修改的属性均针对 Unix 类服务器,如果你使用的是 Windows 类服务器<br>
                 那么无需做任何属性的设置(如果出现属性问题,那么请联系你主机的管理员<br>
                 让他在你的 NT 主机上设置你的目录 everyone 完全控制)<br>
                 </td>
                 </table>

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>

	 			<?
	 				$error = 0;

					$set = "./";
					if (!is_dir_permit($set)) { $error = 1; ?> <font color=red><?=$s_root_path?> TT安装根目录权限不可写入.</font><br> - 设定该权限为 777 <br> <? }
					else {

    					$set = "attach/";
    					if (!is_dir($set)) {
	    					@mkdir($set, 0777);
		    				@chmod($set, 0777);
		    			}
		    			if (!is_dir_permit($set)) { $error = 1; ?> <font color=red><?=$s_root_path.$set?> 上传附件目录不可写入.</font><br> - 设定该权限为 777 <br> <? }

		    			$set = "attach/image/";
		    			if (!is_dir($set)) {
		    				@mkdir($set, 0777);
		    				@chmod($set, 0777);
		    			}
		    			if (!is_dir_permit($set)) { $error = 1; ?> <font color=red><?=$s_root_path.$set?> 上传图片目录不可写入.</font><br> - 设定该权限为 777<br> <? }

		    			$set = "session_path/";
		    			if (!is_dir($set)) {
		    				@mkdir($set, 0777);
		    				@chmod($set, 0777);
		    			}
			    		if (!is_dir_permit($set)) { $error = 1; ?> <font color=red><?=$s_root_path.$set?> 用户安全目录不可写入.</font><br> -  - 设定该权限为 777<br> <? }

				    	$set = "index.xml";
		        		if (is_file($set)) {
		        			if (!is_file_permit($set)) { $error = 1; ?> <font color=red><?=$s_root_path.$set?> RSS文件已存在.</font><br> - <?=$set?> 请删除该文件继续下一步<br> <? }
		        		}

		        	}

					if ($error == 1) {
						?><br>FTP 权限请查看FTP软件的使用帮助或与主机商联系协助更改<?
					} else {
						?>文件夹权限检查通过,点击进入安装下一步<?
					}

	 			?>

				</td>
				</tr></table>

				<div align=center style=margin-top:10><?
					if (!$error) { ?><img class=ib src=images/b_next.gif onclick="inst.step.value='5'; inst.submit();"><? }
				?></div>

				<?
			}

	 		else if ($step == "5") {
	 			?>
				第五步 :: DB数据库ID前辍名设定.

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>
				<table cellpadding=0 cellspacing=0><tr>
				<td align=right style=padding-top:2;padding-left:10>DB前辍 ID ::&nbsp;</td>
				<td><input class=text type=text name=dbid maxlength=6 value="tts"></td>
				</tr></table>


				<div align=center style=margin-top:10><?
					if (!$error) { ?><img class=ib src=images/b_next.gif onclick="inst.step.value='6'; inst.submit();"><? }
				?></div>
				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>
				<font color=red>Warning:请勿使用标点符号作为前辍,否则安装将出错</font><br>
				在同一主机安装多个程序需更改.一般默认为tts<br>
				设定完成请点击NEXT进入管理设定.
				</td>
				</tr></table>
				<?
			}

	 		else if ($step == "6") {

				$cn = new db_init();
 				$result = $cn->db_init_proc();

				$sql = "select count(*) from t3_".$dbid."_setting";
				list ($count) = @mysql_fetch_array(@mysql_query($sql));

	 			?>
               第六步 :: 后台管理员设定

				<?
					if ($count) { ?>DB数据库ID前辍已存在,请更名<? }
					else { ?>管理密码设定<? }
				?>

				<table width=100% style=margin-top:7><tr>
				<td bgcolor=#F8F8F8 style=padding:10;border-style:solid;border-width:1;border-color:#B0B0B0>

				<?
					if ($count) { ?>DB数据库ID前辍已存在,请更名<? }
						else { ?>资料库设定完成<br> 设定管理员密码为单击FINISH完成 .<br>

					<table cellpadding=0 cellspacing=0 style=margin-top:15><tr>
					<td width=140 align=right style=padding-top:2>管理密码 ::&nbsp;</td>
					<td><input class=text type=password name=lpass1 maxlength=8></td>
					</tr></table>

					<table cellpadding=0 cellspacing=0 style=margin-top:5><tr>
					<td width=140 align=right style=padding-top:2>密码确认 ::&nbsp;</td>
					<td><input class=text type=password name=lpass2 maxlength=8></td>
					</tr></table>

					<div style="padding:10 0 0 0">请输入相同的密码确认.(限八位密码).注意大小写</div>


					<? }
				?>

				</td>
				</tr></table>

				<div align=center style=margin-top:10><?
					if (!$count) { ?><img class=ib src=images/b_finish.gif onclick="trim_all(inst); if (inst.lpass1.value != inst.lpass2.value) { alert('您输入的两次密码不一致,请返回重新输入'); return false; } inst.step.value='7'; inst.submit();"><? }
					else { ?><img class=ib src=images/b_back_m.gif onclick="history.go(-1)"><? }
				?></div>
				<?
			}
		?>


	</td>
	</tr></table>

</td>
</tr>
</form></table>

</body>
</html>
<!2005.10.10>