<!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" />
<title>AiFreePhp在线安装程序</title>
<style type="text/css">
.Tables {
	line-height: 150%;
	text-indent: 20px;
	text-align: justify;
	color: #069;
}
#form1 {
	text-align: center;
}
#form1 table tr td table {
	text-align: center;
	background-color: #D6D6D6;
	border: 1px none #999;
	line-height: 25px;
	font-size: 12px;
	color: #036;
}
</style>
</head>
<body>
<div align="center">
  <?php
    ini_set("error_reporting","E_ALL & ~E_NOTICE");
	include_once("../admin/comm/db_sql.php");
	include_once("../admin/comm/config.php");
	//include_once("../admin/comm/connect.php");
	 $Install = $_GET["Install"]; 
	 $HostName = $_POST["HostName"];
	 $MysqlUserName = $_POST["MysqlUserName"];
	 $MysqlPassWord = $_POST["MysqlPassWord"];
	 $MysqlDB = $_POST["MysqlDB"];
	 $UserName = $_POST["UserName"];
	 $PassWord = $_POST["PassWord"];
	 $RePassWord = $_POST["RePassWord"];
	 if($Install == "true" && $PassWord ==  $RePassWord)
	 {

		 
		$link = mysql_connect($HostName,$MysqlUserName,$MysqlPassWord) or die(mysql_error());
		@mysql_select_db($MysqlDB);
		$result = mysql_query("show table status from $MysqlDB",$link);
		while($data=mysql_fetch_array($result))
		{
			mysql_query("drop table $data[Name]")  or die(mysql_error());
		}
		
		@mysql_query("CREATE DATABASE ".$MysqlDB,$link);
		@mysql_select_db($MysqlDB);
		$sql = "CREATE TABLE yyth_channel
		(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			type int(4), 
			url varchar(255),
			is_zt int(4)		    
		)default charset=utf8;";
		echo "正在创建频道数据库<BR>";
		mysql_query($sql) or die(mysql_error());

		$sql = "CREATE TABLE yyth_article_category
		(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			Is_sub int(4)		    
		)default charset=utf8;";
		echo "正在创建文章大类数据库<BR>";
		mysql_query($sql) or die(mysql_error());
	
		$sql = "CREATE TABLE yyth_article_sub_category
		(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			category int(11)	    
		)default charset=utf8;";
		echo "正在创建文章子类数据库<BR>";
		mysql_query($sql) or die(mysql_error());
		
		$sql = "CREATE TABLE yyth_article_info
		(
			 Id int(11) primary key auto_increment, 
			 Title varchar(200),
			 Description varchar(200),
			 Text text,
			 Add_date varchar(200),
			 Picture varchar(200),
			 Up_File varchar(200),
			 Review int(11),
			 author varchar(50),
			 source varchar(150),
			 Hit int(11),	
			 Hot int(11),	
			 TOP int(11),
			 Recommend int(11),
			 Cate_id int(11),
			 big_cate_id int(11),
			 Flash_file varchar(200),
			 channel int(11),
			 typefile varchar(20)
		)default charset=utf8;";
		echo "正在创建文章信息数据库<BR>";
		mysql_query($sql) or die(mysql_error());	
		
		$sql = "CREATE TABLE yyth_product_category
		(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			Is_sub int(4)		    
		)default charset=utf8;";
		echo "正在创建产品分类数据库<BR>";
		mysql_query($sql) or die(mysql_error());
		
		
		$sql = "CREATE TABLE yyth_product_sub_category
		(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			category int(11)	    
		)default charset=utf8;";
		echo "正在创建产品子类数据库<BR>";
		mysql_query($sql) or die(mysql_error());
			
		$sql = "CREATE TABLE yyth_product_info
		(
			 Id int(11) primary key auto_increment, 
			 Title varchar(200),
			 model varchar(200),
			 Description varchar(200),
			 Text text,
			 Add_date varchar(200),
			 Picture varchar(200),
			 Up_File varchar(200),
			 Review int(11),
			 price varchar(50),
			 vip_price varchar(150),
			 Hit int(11),	
			 Hot int(11),	
			 TOP int(11),
			 Recommend int(11),
			 Cate_id int(11),
			 big_cate_id int(11),
			 Flash_file varchar(200),
			 channel int(11),
			 typefile varchar(20)
		)default charset=utf8;";
		echo "正在创建产品数据库<BR>";
		mysql_query($sql) or die(mysql_error());
			

		$sql = "CREATE TABLE yyth_download_category
			(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			Is_sub int(4)		    
			)default charset=utf8;";
			echo "正在创建下载分类数据库<BR>";
			mysql_query($sql) or die(mysql_error());

		$sql = "CREATE TABLE yyth_download_sub_category
			(
			Id int(11) primary key auto_increment, 
			channel int(4), 
			name varchar(50), 
			category int(11)	    
			)default charset=utf8;";
			echo "正在创建下载分类数据库<BR>";
			mysql_query($sql) or die(mysql_error());
			
			
		/*创建友情链接*/	
		$sql = "CREATE TABLE yyth_Links
		(
		Id int(11) primary key auto_increment, 
		Linkname varchar(50),
		LinkUrl varchar(50)	    
		)default charset=utf8;";
		echo "正在创建友情链接<BR>";
		mysql_query($sql) or die(mysql_error());	
		
		

		$sql = "CREATE TABLE yyth_download_info
		(
		     Id int(11) primary key auto_increment, 
			 Title varchar(200),
			 Description varchar(200),
			 Text text,
			 Add_date varchar(200),
			 Picture varchar(200),
			 Up_File varchar(200),
			 Review int(11),
			 author varchar(50),
			 source varchar(150),
			 down_server1 text(1000),
			 down_server2 text(1000),
			 down_server3 text(1000),
			 down_server4 text(1000),
			 Hit int(11),	
			 Hot int(11),	
			 TOP int(11),
			 Recommend int(11),
			 Cate_id int(11),
			 big_cate_id int(11),
			 Flash_file varchar(200),
			 channel int(11),
			 typefile varchar(20)
		)default charset=utf8;";
			echo "正在创建下载信息数据库<BR>";
			mysql_query($sql) or die(mysql_error());
			
			/* 保存用户名与密码并锁定文件
			$HostName = $_POST["HostName"];
			$MysqlUserName = $_POST["MysqlUserName"];
			$MysqlPassWord = $_POST["MysqlPassWord"];
			$MysqlDB = $_POST["MysqlDB"];
			$UserName = $_POST["UserName"];
			$PassWord = $_POST["PassWord"];
			$RePassWord = $_POST["RePassWord"];
			
			 */
		$file = fopen("../admin/comm/Inc.php","w"); 
		$SetText = "<?php 
		";
		$SetText = $SetText."\$localhost = "."\"".$HostName."\";
		";
		$SetText = $SetText."\$datebase = "."\"".$MysqlDB."\";
		";
		$SetText = $SetText."\$username = "."\"".$MysqlUserName."\";
		";
		$SetText = $SetText."\$passwd = "."\"".$MysqlPassWord."\";
		";
		$SetText = $SetText."\$db = "."'yyth_';
		";
		$SetText = $SetText."\$server_name = "."\"".$server_name."\";
		";
		$SetText = $SetText."\$adminUser = "."\"".$UserName."\";
		";
		$SetText = $SetText."\$adminPass = "."\"".$PassWord."\";
		";
		$SetText = $SetText."\$img_file_url = "."\"".$server_name."\";
		";
		$SetText = $SetText."\$companyName = \"\";	
		\$Address = \"\";
		\$SaleTel = \"\";
		\$TechTel = \"\";
		\$Fax = \"\";
		\$mobile = \"\";
		\$QQ = \"\";
		\$Mail = \"\";
		\$CopyRight = \"http://www.yywdyb.com\";
		?>"
		;
		fwrite($file,$SetText); 
		fclose($file); 
		?>
		安装完成,为了数据安全，请删除安装目录Install下的Index.php文件!<a href="../admin/index.php">进入管理后台</a> <a href="../index.php">查看主页</a> 
  <? 
	 }else
	 {
?>
</div>
<form id="form1" name="form1" method="post" action="index.php?Install=true">
<table width="695" height="167" border="0" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td height="39" bgcolor="#999999"><h1>AiFreePhp 在线安装程序</h1></td>
  </tr>
  <tr>
    <td height="123" valign="top"><p class="Tables">AiFreePhp(爱免费php企业建站程序是一个免费开源的PHP建站程序),基于PHP + MYSQL 与模板技术,具有产品展示，文章栏目，下载管理，友情链接等功能。无任何限制功能，程序简单实用，可用于中小企业网站建设，不收取任何费用。使用本程序，不可将程序变相转售,二次开发发布，本软件受计算机知识产权国际法保护。对于出售本程序或二次开发发布者，作者将保留追就法律责任的权利。对于安装或使用本软件而造成的任何损失与法律责任与本软件无关。你必需同意才能安装本软件，否则请删除。</p>
      <table width="568" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr>
          <td bgcolor="#FFFFFF">数据库服务器名</td>
          <td bgcolor="#FFFFFF"><input name="HostName" type="text" id="HostName" value="Localhost" /></td>
        </tr>
        <tr>
          <td width="180" bgcolor="#FFFFFF">MySql用户名</td>
          <td width="385" bgcolor="#FFFFFF"><input type="text" name="MysqlUserName" id="MysqlUserName" /></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">Mysql密码</td>
          <td bgcolor="#FFFFFF"><input type="text" name="MysqlPassWord" id="MysqlPassWord" /></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">Mysql数据库</td>
          <td bgcolor="#FFFFFF"><input type="text" name="MysqlDB" id="MysqlDB" /></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">后台管理用户名</td>
          <td bgcolor="#FFFFFF"><input type="text" name="UserName" id="UserName" /></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">后台管理密码</td>
          <td bgcolor="#FFFFFF"><input type="text" name="PassWord" id="PassWord" /></td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">再次确认管理员密码</td>
          <td bgcolor="#FFFFFF"><input type="text" name="RePassWord" id="RePassWord" /></td>
        </tr>
        <tr>
          <td colspan="2" bgcolor="#FFFFFF"><input name="button" type="submit" class="Tables" id="button" value="同意并安装" /></td>
          </tr>
      </table>
      <p class="Tables">&nbsp;</p>
      <span id="form1"></span>
    </td>
  </tr>
</table>
</form>
<?
}
?>
</body>
</html>