<?
error_reporting(0);
include "class/plusform.php";
	$language = $_REQUEST[lang];
	$lang_file = "language/".$language.".lang.php";
	if(!file_exists($lang_file)){
		$lang_file = "language/zh-cn.lang.php";
		$language="zh-cn";
	}
	include $lang_file;
function installForm(){
	global $language;
echo html_table_header(_LANG_1175,3,780);
//$site_path=str_replace('/install.php','',$_SERVER[SCRIPT_FILENAME]);
$site_path=getcwd();
?>
<form name="installform" action="install.php" method=post onsubmit="return nonBlank(site_title,'<?=_LANG_1176?>') && goodEMail(site_email,'<?=_LANG_1177?>') && nonBlank(site_url,'<?=_LANG_1178?>') && nonBlank(site_path,'<?=_LANG_1179?>') && nonBlank(db_host,'<?=_LANG_1180?>') && nonBlank(db_user,'<?=_LANG_1181?>')  && nonBlank(db_name,'<?=_LANG_1182?>')  && nonBlank(db_prefix,'<?=_LANG_1183?>') ">
<input name=action type=hidden value='setdb'>
<input name=lang type=hidden value='<?=$language?>'>
<tr class=tablerow><td><?=_LANG_1186?></td><td><input name=site_title type=text size=50 maxlength=100 value=cmsez></td><td class=note><?=_LANG_1187?></td></tr>
<tr class=tablerow2><td><?=_LANG_1188?></td><td><input name=site_email type=text size=50 maxlength=100></td><td class=note>&nbsp;</td></tr>
<tr class=tablerow><td><?=_LANG_1189?></td><td><input name=site_url type=text size=50 maxlength=255 value='<?=$site_url?>'></td><td class=note><?=_LANG_1190?></td></tr>
<tr class=tablerow2><td><?=_LANG_1191?></td><td><input name=site_path type=text size=50 maxlength=100 value='<?=$site_path?>'></td><td class=note><?=_LANG_1192?></td></tr>

<tr><td colspan=3 class=tableseparator><?=_LANG_1193?></td></tr>
<tr class=tablerow><td><?=_LANG_1194?></td><td><input name=db_host type=text size=50 maxlength=100 value=localhost></td><td class=note><?=_LANG_1195?></td></tr>
<tr class=tablerow2><td><?=_LANG_1196?></td><td><input name=db_user type=text size=50 maxlength=100></td><td class=note><?=_LANG_1197?></td></tr>
<tr class=tablerow><td><?=_LANG_1198?></td><td><input name=db_password type=text size=50 maxlength=100></td><td class=note><?=_LANG_1199?></td></tr>
<tr class=tablerow2><td><?=_LANG_1200?></td><td><input name=db_name type=text size=50 maxlength=100></td><td class=note><?=_LANG_1201?></td></tr>
<tr class=tablerow><td><?=_LANG_1202?></td><td><input name=db_prefix type=text size=50 maxlength=100 value='glad_'></td><td class=note><?=_LANG_1203?></td></tr>
<tr><td colspan=3 class=tableseparator><?=_LANG_1204?></td></tr>
<tr class=tablerow><td><?=_LANG_1205?></td><td><input name=admin_name type=text size=50 maxlength=100 value='admin'></td><td class=note><?=_LANG_1206?></td></tr>
<tr class=tablerow2><td><?=_LANG_1207?></td><td><input name=admin_password type=password size=50 maxlength=100 value='admin'></td><td class=note><?=_LANG_1208?></td></tr>
<?
echo form_footer(_LANG_1209,_RESET,3,_BACK);
echo html_table_footer();
}
function WriteAccess($file){
	if(is_writable($file)){
		return TURE;
	}else{
		return FALSE;
	}
}
function setdb(){
		global $_POST,$language;
		$site_title=$_POST[site_title];
		$site_email =$_POST[site_email];
		$site_url =$_POST[site_url];
		$site_path = $_POST[site_path];
		$db_host = $_POST[db_host];
		$db_user = $_POST[db_user];
		$db_password = $_POST[db_password];
		$db_name = $_POST[db_name];
		$db_prefix = $_POST[db_prefix];
		$admin_name = $_POST[admin_name];
		$admin_password = $_POST[admin_password];
		$conn=mysql_connect($db_host,$db_user,$db_password);
		if(!$conn) die(_LANG_1210.mysql_error());
		$db=mysql_select_db($db_name,$conn);
		if(!$db) die(mysql_error());
		$sql="CREATE TABLE ".$db_prefix."ad (
  id int(11) unsigned NOT NULL auto_increment,
  title varchar(100) default '0',
  intro varchar(255) default NULL,
  url varchar(255) default NULL,
  image varchar(255) default NULL,
  height smallint(6) unsigned default NULL,
  width smallint(6) unsigned default NULL,
  img_type enum('image','flash') default 'image',
  ad_type smallint(6) unsigned default '0',
  ctime datetime default NULL,
  etime datetime default NULL,
  btimes smallint(6) unsigned default '0',
  display int(11) unsigned default '0',
  hits int(11) unsigned default '0',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."articles (
  id int(11) NOT NULL auto_increment,
  uid int(11) NOT NULL default '0',
  cid varchar(11) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  intro text NOT NULL,
  content text NOT NULL,
  author varchar(100) NOT NULL default '',
  source varchar(100) NOT NULL default '',
  img varchar(255) NOT NULL default '',
  thumb varchar(100) NOT NULL default '',
  first enum('yes','no') NOT NULL default 'no',
  isimg enum('yes','no') NOT NULL default 'no',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  etime datetime NOT NULL default '0000-00-00 00:00:00',
  utime datetime NOT NULL default '0000-00-00 00:00:00',
  voter smallint(6) NOT NULL default '0',
  vote smallint(6) NOT NULL default '0',
  hits smallint(6) NOT NULL default '0',
  active enum('yes','no') NOT NULL default 'no',
  mark enum('yes','no') NOT NULL default 'yes',
  PRIMARY KEY id (id),
  KEY article_index (cid,active,id),
  key article_index2 (id,active,ctime),
  key article_index3 (cid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."attachment (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  title varchar(100) NOT NULL default '',
  server int(11) NOT NULL default '0',
  url varchar(255) NOT NULL default '',
  length varchar(255) NOT NULL default '0.00',
  size decimal(6,2) NOT NULL default '0.00',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  hits smallint(6) NOT NULL default '0',
  ctype varchar(10) NOT NULL default '',
  point smallint(6) NOT NULL default '0',
  PRIMARY KEY id (id),
  KEY attach_index (aid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."attachments (
  id int(11) NOT NULL auto_increment,
  title varchar(100) NOT NULL default '',
  filesize int(30) NOT NULL default '0',
  filepath varchar(255) NOT NULL default '',
  filename varchar(255) NOT NULL default '',
  uid int(11) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."bank_log (
  id int(11) NOT NULL default '0',
  uid int(11) NOT NULL default '0',
  ctype varchar(20) NOT NULL default '',
  price varchar(20) NOT NULL default '',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  o_b varchar(10) NOT NULL default '',
  UNIQUE KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."bbs (
  id int(11) NOT NULL auto_increment,
  cid int(11) NOT NULL default '0',
  pid int(11) NOT NULL default '0',
  tid int(11) NOT NULL default '0',
  mark varchar(100) NOT NULL default '',
  deepth smallint(6) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  lastrly datetime NOT NULL default '0000-00-00 00:00:00',
  uid int(11) NOT NULL default '0',
  uname varchar(100) NOT NULL default '',
  uip varchar(20) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  content text NOT NULL,
  icon varchar(100) NOT NULL default '',
  show_sign enum('yes','no') NOT NULL default 'yes',
  email_notify enum('yes','no') NOT NULL default 'no',
  smile enum('yes','no') NOT NULL default 'yes',
  bbcode enum('yes','no') NOT NULL default 'yes',
  stick enum('yes','no') NOT NULL default 'no',
  `lock` enum('yes','no') NOT NULL default 'no',
  hits smallint(6) NOT NULL default '0',
  attachment varchar(255) NOT NULL default '',
  other char(1) NOT NULL default '',
  PRIMARY KEY id (id,mark),
  KEY bbs_index (cid,pid,tid,mark,ctime)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."blocks (
  id int(11) unsigned NOT NULL auto_increment,
  title varchar(100) default NULL,
  content text,
  ctype varchar(10) default '0',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."break_links (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  uid int(11) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  content varchar(255) NOT NULL default '',
  stats enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."cart (
  id int(11) unsigned NOT NULL auto_increment,
  oid varchar(20) NOT NULL default '',
  payment int(11) default NULL,
  shipping int(11) default NULL,
  name varchar(100) default NULL,
  email varchar(100) default NULL,
  telnum varchar(50) default NULL,
  rname varchar(100) default NULL,
  address varchar(255) default NULL,
  rtelnum varchar(40) default NULL,
  zip varchar(20) default NULL,
  info varchar(255) default NULL,
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  ispay enum('yes','no') default 'no',
  isover enum('yes','no') default 'no',
  PRIMARY KEY id (id),
  KEY cart_index (oid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."cart_item (
  oid int(11) unsigned default NULL,
  iid int(11) unsigned default NULL,
  title varchar(255) default NULL,
  price int(10) default NULL,
  num smallint(6) unsigned default '0',
  KEY oid (oid,iid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."category (
  id int(11) NOT NULL auto_increment,
  title varchar(255) NOT NULL default '',
  icon varchar(255) NOT NULL default '',
  english_name varchar(255) NOT NULL default '',
  pid int(11) NOT NULL default '0',
  o_num smallint(6) NOT NULL default '0',
  intro text NOT NULL,
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  cate_mod varchar(255) NOT NULL default '',
  cate_template varchar(255) NOT NULL default 'default.php',
  list_template varchar(255) NOT NULL default '',
  detail_template varchar(255) NOT NULL default '',
  other_1 varchar(20) NOT NULL default '',
  other_2 varchar(6) NOT NULL default '',
  other_3 varchar(255) NOT NULL default '',
  hits smallint(6) NOT NULL default '0',
  page_title varchar(255) NOT NULL default '',
  page_keyword varchar(255) NOT NULL default '',
  page_discription varchar(255) NOT NULL default '',
  page_num int(6) NOT NULL default '1',
  page_col int(6) NOT NULL default '1',
  status enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY id (id),
  KEY category_index (pid,o_num,other_1)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."configration (
  conf_id int(11) NOT NULL auto_increment,
  conf_intro varchar(255) default NULL,
  conf_title varchar(40) default NULL,
  conf_set blob,
  type varchar(100) NOT NULL default 'system',
  PRIMARY KEY  (conf_id)
) TYPE=MyISAM;

INSERT INTO ".$db_prefix."configration VALUES (1, '站点名称', 'site_name', '".$site_title."', 'system');
INSERT INTO ".$db_prefix."configration VALUES (2, '站点模板', 'site_template', 'default', 'template');
INSERT INTO ".$db_prefix."configration VALUES (3, '站点Email', 'site_email', '".$site_email."', 'system');
INSERT INTO ".$db_prefix."configration VALUES (4, '超时设定', 'expire_time', 0x3135, 'system');
INSERT INTO ".$db_prefix."configration VALUES (5, '版权信息', 'site_license', 0x506f7765726279207777772e6d656e746f722e636e, 'system');
INSERT INTO ".$db_prefix."configration VALUES (6, '图片存放目录', 'image_path', 0x75706c6f61642f696d61676573, 'image');
INSERT INTO ".$db_prefix."configration VALUES (7, '图片缩略图大小', 'image_thumb_size', 0x31303078313030, 'image');
INSERT INTO ".$db_prefix."configration VALUES (8, '允许图片类型', 'accept_image_type', 0x626d707c6a7065677c6a70677c6769667c706e677c737766, 'image');
INSERT INTO ".$db_prefix."configration VALUES (9, '附件存放目录', 'attach_path', 0x75706c6f61642f66696c65, 'attach');
INSERT INTO ".$db_prefix."configration VALUES (10, '附件大小限制', 'accept_attach_size', 0x32303430303030, 'attach');
INSERT INTO ".$db_prefix."configration VALUES (11, '允许附件类型', 'accept_attach_type', 0x7a69707c7261727c7461727c677a7c646f637c786c737c64627c7478747c677a7c626d707c6a70677c6a7065677c706e677c6769667c, 'attach');
INSERT INTO ".$db_prefix."configration VALUES (12, '默认栏目模板', 'default_category_template', 0x696e6465782e74706c, 'template');
INSERT INTO ".$db_prefix."configration VALUES (13, '默认列表模板', 'default_list_template', 0x64656661756c742e74706c, 'template');
INSERT INTO ".$db_prefix."configration VALUES (14, '默认页面模板', 'default_detail_template', 0x696e6465782e74706c, 'template');
INSERT INTO ".$db_prefix."configration VALUES (15, '生成缩略图方式', 'thumb_method', 0x4744, 'image');
INSERT INTO ".$db_prefix."configration VALUES (16, '发送mail方式', 'mail_method', 0x736d7470, 'system');
INSERT INTO ".$db_prefix."configration VALUES (17, '是否开放注册', 'allow_register', 0x796573, 'system');
INSERT INTO ".$db_prefix."configration VALUES (18, '是否开放站点', 'is_open', 0x796573, 'system');
INSERT INTO ".$db_prefix."configration VALUES (19, '站点关闭原因', 'site_close_reason', 0x5369746520697320636c6f73656421, 'system');
INSERT INTO ".$db_prefix."configration VALUES (20, 'SMTP服务器地址', 'smtp_host', 0x6c6f63616c686f7374, 'system');
INSERT INTO ".$db_prefix."configration VALUES (21, 'smtp端口', 'smtp_port', 0x3235, 'system');
INSERT INTO ".$db_prefix."configration VALUES (22, '图片大小限制(字节)', 'image_file_size', 0x323034303030, 'image');
INSERT INTO ".$db_prefix."configration VALUES (23, '图片尺寸限制(长x宽)', 'image_size', 0x38303078383030, 'image');
INSERT INTO ".$db_prefix."configration VALUES (24, '输出html', 'outhtml', 0x6e6f, 'system');
INSERT INTO ".$db_prefix."configration VALUES (25, '静态页面存放位置', 'html_path', 0x7765622f, 'system');
INSERT INTO ".$db_prefix."configration VALUES (26, '静态文件后缀', 'html_ext', 0x68746d6c, 'system');
INSERT INTO ".$db_prefix."configration VALUES (27, '站点语言', 'language', '$language', 'system');
INSERT INTO ".$db_prefix."configration VALUES (28, '点数汇率', 'point_change', 0x313030, 'system');
INSERT INTO ".$db_prefix."configration VALUES (30, '货币符号', 'currency', 0xa3a4, 'system');

CREATE TABLE ".$db_prefix."contents (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  cid int(11) NOT NULL default '0',
  title varchar(255) NOT NULL default '',
  content text NOT NULL,
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  utime datetime NOT NULL default '0000-00-00 00:00:00',
  o_num smallint(6) NOT NULL default '0',
  other_1 varchar(6) NOT NULL default '',
  other_2 varchar(6) NOT NULL default '',
  active enum('yes','no') NOT NULL default 'yes',
  hits smallint(6) NOT NULL default '0',
  PRIMARY  KEY id (id),
  KEY contents_index (aid,cid,o_num)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."extra_contents (
  aid int(11) unsigned NOT NULL default '0',
  cid int(11) NOT NULL default 0,
  field_00 varchar(255) default NULL,
  field_01 varchar(255) default NULL,
  field_02 varchar(255) default NULL,
  field_03 varchar(255) default NULL,
  field_04 varchar(255) default NULL,
  field_05 varchar(255) default NULL,
  field_06 varchar(255) default NULL,
  field_07 varchar(255) default NULL,
  field_08 varchar(255) default NULL,
  field_09 varchar(255) default NULL,
  KEY aid (aid),
  KEY extra_index (aid,cid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."feed_content (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  cid int(11) NOT NULL default '0',
  form varchar(50) NOT NULL default '',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  content text NOT NULL,
  ischeck enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY  (id),
  KEY feed_index (aid,ctime)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."fetch_content (
  id int(11) unsigned NOT NULL auto_increment,
  s_id int(11) unsigned default '0',
  s_url varchar(255) default '0',
  n_title varchar(255) default '0',
  n_date varchar(100) default '0',
  n_source varchar(255) default '0',
  n_content text,
  isnew tinyint(3) unsigned default '0',
  ischeck tinyint(3) unsigned default '0',
  PRIMARY KEY  (id),
  KEY id (s_id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."fetch_site (
  id int(11) unsigned NOT NULL auto_increment,
  title varchar(255) default '0',
  intro varchar(255) default '0',
  url text,
  news_url varchar(255) NOT NULL default '',
  update_time varchar(20) default '0',
  update_url varchar(255) default NULL,
  l_code varchar(255) default '0',
  p_t_code varchar(255) default '0',
  p_d_code varchar(255) default '0',
  p_s_code varchar(255) default '0',
  p_c_code varchar(255) default '0',
  p_clear_ad_code varchar(255) default NULL,
  p_next_code varchar(255) NOT NULL default '',
  site_name varchar(255) default '0',
  default_cate int(11) NOT NULL default '0',
  isactive tinyint(3) unsigned default '1',
  c_url enum('yes','no') NOT NULL default 'no',
  c_img enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."forum (
  post_id int(11) NOT NULL auto_increment,
  post_uid varchar(100) NOT NULL default '',
  post_aid int(11) NOT NULL default '0',
  post_title varchar(255) NOT NULL default '',
  post_content text NOT NULL,
  post_date int(11) NOT NULL default '0',
  post_type varchar(50) NOT NULL default '',
  PRIMARY KEY post_id (post_id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."group_right (
  gid varchar(20) NOT NULL default '',
  cid int(11) NOT NULL default '0',
  gright varchar(20) NOT NULL default ''
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."hotel_room (
  id int(11) unsigned NOT NULL auto_increment,
  aid int(11) unsigned default NULL,
  title varchar(255) default NULL,
  image varchar(255) default NULL,
  price_1 varchar(20) default NULL,
  price_2 varchar(20) default NULL,
  price_3 varchar(20) default NULL,
  price_4 varchar(20) default NULL,
  intro varchar(255) default NULL,
  ctime varchar(50) default '0',
  PRIMARY KEY  (id),
  KEY id (aid)
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."images (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  name varchar(100) NOT NULL default '',
  image varchar(255) NOT NULL default '',
  thumb varchar(255) NOT NULL default '',
  size varchar(20) NOT NULL default '',
  hits smallint(6) NOT NULL default '0',
  ot1 smallint(3) NOT NULL default '0',
  ot2 smallint(3) NOT NULL default '0',
  PRIMARY KEY id (id),
  KEY image_index (aid)
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."keyword (
  id int(11) NOT NULL auto_increment,
  cid int(11) NOT NULL,
  title varchar(100) NOT NULL default '',
  intro text NOT NULL,
  image varchar(255) NOT NULL default '',
  hits int(6) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."keyword_category (
  id int(11) NOT NULL auto_increment,
  title varchar(100) NOT NULL default '',
  intro text NOT NULL,
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  active enum('yes','no') NOT NULL default 'yes',
  image varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."keyword_links (
  id int(11) NOT NULL auto_increment,
  kid int(11) NOT NULL default '0',
  aid int(11) NOT NULL default '0',
  PRIMARY KEY  (id),
  key keyword_index (aid,kid)
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."link (
  id int(11) NOT NULL auto_increment,
  title varchar(100) NOT NULL default '',
  icon varchar(255) NOT NULL default '',
  url varchar(255) NOT NULL default '',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  hits smallint(6) NOT NULL default '0',
  PRIMARY KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."pay_method (
  id int(11) unsigned NOT NULL auto_increment,
  title varchar(100) default NULL,
  intro text,
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."poll (
  id int(11) unsigned NOT NULL auto_increment,
  title varchar(100) default '0',
  intro text,
  ctime datetime default NULL,
  etime datetime default NULL,
  polltype enum('single','multi') default NULL,
  pollnum smallint(6) unsigned default '2',
  voter smallint(6) unsigned default '0',
  PRIMARY KEY  (id)
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."poll_data (
  id int(11) unsigned NOT NULL auto_increment,
  pid int(11) unsigned NOT NULL default '0',
  content varchar(255) default NULL,
  vote smallint(6) unsigned default '0',
  PRIMARY KEY  (id,pid)
) TYPE=MyISAM;


CREATE TABLE ".$db_prefix."server (
  id int(11) NOT NULL auto_increment,
  title varchar(100) NOT NULL default '',
  host varchar(100) NOT NULL default '',
  uname varchar(100) NOT NULL default '',
  password varchar(100) NOT NULL default '',
  port smallint(6) NOT NULL default '0',
  utime datetime NOT NULL default '0000-00-00 00:00:00',
  serv_url varchar(255) NOT NULL default '',
  ctype enum('ftp','http') NOT NULL default 'http',
  PRIMARY KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."sessions (
  id varchar(32) NOT NULL default '0',
  member_name varchar(64) default NULL,
  member_id mediumint(8) NOT NULL default '0',
  ip_address varchar(16) default NULL,
  running_time int(10) NOT NULL default 0,
  login_type varchar(8) default NULL,
  position int(11) NOT NULL,
  PRIMARY KEY  (id),
  KEY session_index (member_id,running_time)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."shipping_method (
  `id` int(11) unsigned NOT NULL auto_increment,
  `title` varchar(100) default NULL,
  `intro` text,
  `price` decimal(6,2) NOT NULL default '0.00',
  `isactive` enum('yes','no') NOT NULL default 'yes',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."topic_links (
  id int(11) NOT NULL auto_increment,
  tid int(11) NOT NULL default '0',
  aid int(11) NOT NULL default '0',
  PRIMARY KEY  (id),
  key keyword_index (aid,tid)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."topics (
  id int(11) NOT NULL auto_increment,
  title varchar(100) NOT NULL default '',
  intro text NOT NULL,
  image varchar(255) NOT NULL default '',
  hits int(6) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."user_extra (
  id int(11) NOT NULL default '0',
  level varchar(20) NOT NULL default 'Uactive',
  stime datetime NOT NULL default '0000-00-00 00:00:00',
  etime datetime NOT NULL default '0000-00-00 00:00:00',
  question varchar(255) NOT NULL default '',
  answer varchar(255) NOT NULL default '',
  point smallint(6) NOT NULL default '0',
  user_type varchar(20) NOT NULL default '0',
  ccc char(3) NOT NULL default '',
  ddd char(3) NOT NULL default '',
  UNIQUE KEY id (id)
) TYPE=MyISAM;

INSERT INTO ".$db_prefix."user_extra VALUES (1, 'Admin', '0000-00-00 00:00:00', '2004-11-21 00:00:00', 'aaa', 'bbb', 2000, 'Vip', '', '');

CREATE TABLE ".$db_prefix."user_log (
  id int(11) NOT NULL auto_increment,
  aid int(11) NOT NULL default '0',
  atid int(11) NOT NULL default '0',
  uid int(11) NOT NULL default '0',
  ctime datetime NOT NULL default '0000-00-00 00:00:00',
  point smallint(6) NOT NULL default '0',
  PRIMARY KEY id (id)
) TYPE=MyISAM;

CREATE TABLE ".$db_prefix."user_right (
  uid int(11) NOT NULL default '0',
  cid int(11) NOT NULL default '0',
  uright varchar(20) NOT NULL default ''
) TYPE=MyISAM;

INSERT INTO ".$db_prefix."user_right VALUES (1, 2, '');

CREATE TABLE ".$db_prefix."users (
  uid int(11) NOT NULL auto_increment,
  username varchar(100) NOT NULL default '',
  password varchar(100) NOT NULL default '',
  email varchar(100) NOT NULL default '',
  KEY uid (uid)
) TYPE=MyISAM;

INSERT INTO `".$db_prefix."users` VALUES (1, '".$admin_name."', '".(md5($admin_password))."', '');
";
    $a_query = explode(';', $sql);
    while( list(, $query) = each($a_query) )
    {
        $query = trim($query);
        if( $query )
        {
           $rt=mysql_query($query);
           if(!$rt) die(mysql_error());
        }
    }
if($rt){
		$db_prefix=str_replace("_","",$db_prefix);
	//写入config文件
	$config='<?
/*
config 
*/
	define(\'PLUS_URL\', \''.$site_url.'\');
	define(\'PLUS_ROOT_PATH\',\''.$site_path.'\');
	if(file_exists(PLUS_ROOT_PATH.\'/install.php\')){
 		die(\'Please delete the install file install.php,and refresh this page!\');
 	}
/**
 * Database setting
 */
 	error_reporting(0);
	define(\'PLUS_DB_TYPE\', \'mysql\');	//database type
	define(\'PLUS_DB_PREFIX\', \''.$db_prefix.'\');	//database prefix
	define(\'PLUS_DB_HOST\', \''.$db_host.'\');	//database host
	define(\'PLUS_DB_USER\', \''.$db_user.'\');	//database username
	define(\'PLUS_DB_PASS\', \''.$db_password.'\');	//database user password
	define(\'PLUS_DB_NAME\', \''.$db_name.'\');	//database name
	define(\'PLUS_DB_PCONNECT\', 0);	//do u user pconnect 0 is no,1 is yes
	/*connect db*/
	if (defined(\'PLUS_DB_PREFIX\') && defined(\'PLUS_DB_HOST\') && defined(\'PLUS_DB_USER\') && defined(\'PLUS_DB_PASS\') && defined(\'PLUS_DB_NAME\')) {
		include_once(PLUS_ROOT_PATH.\'/class/database.php\');
		$PlusDB = &ADONewConnection(PLUS_DB_TYPE);
		//$PlusDB->debug = true;
		$PlusDB->setPrefix(PLUS_DB_PREFIX);
		$PlusDB->connect(PLUS_DB_HOST, PLUS_DB_USER, PLUS_DB_PASS, PLUS_DB_NAME, PLUS_DB_PCONNECT);
		if(!$PlusDB) error("Can not connect the database!");
	}
include "class/plusform.php";
include "include/common.inc.php";
##read the categoru cache
$catetree = getCategory();
##read configration
$site_conf=getConfigration();
//trace($site_conf);
/*[admin] */
	define("ADMIN","'.$admin_name.'");
/*name setting*/
	define("_POINT","点数");
/*smtp*/
	$smtp_host="localhost";
	$smtp_port = "38";
/*add by multilanguage version*/
	$language = $site_conf["system"]["language"];
	$lang_file = PLUS_ROOT_PATH."/language/".$language.".lang.php";
	if(!file_exists($lang_file)) $lang_file = PLUS_ROOT_PATH."/language/zh-cn.lang.php";
	include $lang_file;
?>';
$fp=fopen('config.inc.php',w);
fputs($fp,$config);
fclose($fp);
echo _LANG_1211;
echo _LANG_1212;
echo _LANG_1213;
}else{
  die(mysql_error());
}
}
?>
<html>
<title><?=_LANG_1214?></title>
<header>
<META http-equiv=Content-Type content="text/html; charset=<?=_CHAR?>">
<LINK href="images/admin.css" type=text/css rel=STYLESHEET>
<script src="include/form.js"></script>
</header>
<style type="text/css">
<!--
.style1 {color: #000000}
-->
</style>
<body>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#3965A5"><img src="images/cmsez2.gif" width="178" height="49"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><?
$action=$_REQUEST[action];
switch($action){
case "setdb":
	setdb();
	break;
case "install":
	$errmsg="";
	$co=1;
	if(!WriteAccess("config.inc.php") &&  !WriteAccess("./")){
		$errmsg.=_LANG_1215;
		$co=0;
	}
	if(!WriteAccess("cache")){
		$errmsg.=_LANG_1216;
		$co=0;
	}
	if(!WriteAccess("temp")){
		$errmsg.=_LANG_1217;
		$co=0;
	}
	if(!WriteAccess("upload")){
		$errmsg.=_LANG_1218;
	}
	if(!WriteAccess("images/articles")){
		$errmsg.=_LANG_1219;
	}
	if($errmsg>""){
		echo "<font color=red>$errmsg</font>";
	}
	if($co==1)
	{
		installForm();
	}else{
		echo _LANG_1220;
}
	break;
	default:
	echo html_table_header("Select the language",2);
	echo "<form name=installform action=install.php method=get>
	<input name=action value=\"install\" type=hidden>
	<tr class=tablerow><td width=200>Please Select The Language:</td><td><select name=lang>";
		   		$dir1 = "language/";
	          $d1 = dir($dir1);
	        while ($file = $d1->read()) {
	            if ($file == "." || $file == ".." || !eregi("lang.php$",$file)  ) continue;
	            $file = str_replace(".lang.php","",$file);
	            echo "<option value='$file'>$file</option>";
	          }	
	echo "</select>";
	echo form_footer("Next","Reset",2);
	//echo "<input name=\"next\" type=submit value=\"Next Step\"></td></tr></form>";
	echo html_table_footer();
	
}
?></td>
  </tr>
  <tr>
    <td><div align="right">Power by Cmsez &nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.cmsez.com" class="th">http://www.cmsez.com</a></div></td>
  </tr>
</table>
</body>
</html>