<?php
//-------------------表处理

//广告表
$empire->query("alter table {$dbtbpre}enewsad 
	change adid adid int(10) unsigned NOT NULL auto_increment,
	change pic_width pic_width int(10) unsigned NOT NULL default '0',
	change pic_height pic_height int(10) unsigned NOT NULL default '0',
	change onclick onclick int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change adtype adtype tinyint(3) unsigned NOT NULL default '0',
	change adsay adsay varchar(255) NOT NULL default '',
	change titlefont titlefont varchar(14) NOT NULL default '',
	change t t tinyint(3) unsigned NOT NULL default '0',
	add INDEX(t);");

//广告分类表
$empire->query("alter table {$dbtbpre}enewsadclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change classname classname char(30) NOT NULL default '';");

//后台风格表
$empire->query("alter table {$dbtbpre}enewsadminstyle 
	change styleid styleid smallint(5) unsigned NOT NULL auto_increment,
	change stylename stylename char(30) NOT NULL default '',
	change path path smallint(5) unsigned NOT NULL default '0';");

//信息来源表
$empire->query("alter table {$dbtbpre}enewsbefrom 
	change befromid befromid smallint(5) unsigned NOT NULL auto_increment,
	change sitename sitename char(60) NOT NULL default '',
	change siteurl siteurl char(200) NOT NULL default '';");

//标签表
$empire->query("alter table {$dbtbpre}enewsbq 
	change bqid bqid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change myorder myorder smallint(5) unsigned NOT NULL default '0',
	add INDEX(isclose),
	add INDEX(myorder);");

$empire->query("delete from {$dbtbpre}enewsbq where bq='phomeautopic' or bq='phomenewstext' or bq='phomeshowclass' or bq='phomeshowmap' or bq='phomepic' or bq='phomemorepic'");

$empire->query("update {$dbtbpre}enewsbq set bqgs='[totaldata]栏目ID,操作类型,时间范围,统计类型[/totaldata]' where bq='totaldata' limit 1");

$empire->query("update {$dbtbpre}enewsbq set bqgs='[showtags]分类ID,显示数量,每行显示数量,显示排序,只显示推荐,推荐TAGS属性,显示间隔符,是否显示信息数,链接附加参数,链接变量名[/showtags]' where bq='showtags' limit 1");

$empire->query("update {$dbtbpre}enewsbq set bqsay=REPLACE(bqsay,'../ListZt.php','../special/ListZt.php')");

//标签分类表
$empire->query("alter table {$dbtbpre}enewsbqclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change classname classname char(30) NOT NULL default '';");

//标签模板分类表
$empire->query("alter table {$dbtbpre}enewsbqtempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change classname classname char(30) NOT NULL default '';");

//购买记录表
$empire->query("alter table {$dbtbpre}enewsbuybak 
	add `id` int(10) unsigned NOT NULL auto_increment,
	change username username char(20) NOT NULL default '',
	change card_no card_no char(120) NOT NULL default '',
	change cardfen cardfen int(10) unsigned NOT NULL default '0',
	change money money int(10) unsigned NOT NULL default '0',
	change userid userid mediumint(8) unsigned NOT NULL default '0',
	change userdate userdate int(10) unsigned NOT NULL default '0',
	add INDEX(type),
	add PRIMARY KEY(id);");

//购买类型表
$empire->query("alter table {$dbtbpre}enewsbuygroup 
	change id id smallint(5) unsigned NOT NULL auto_increment,
	change gmoney gmoney int(10) unsigned NOT NULL default '0',
	change gfen gfen int(10) unsigned NOT NULL default '0',
	change gdate gdate int(10) unsigned NOT NULL default '0',
	change ggroupid ggroupid smallint(5) unsigned NOT NULL default '0',
	change gzgroupid gzgroupid smallint(5) unsigned NOT NULL default '0',
	change buygroupid buygroupid smallint(5) unsigned NOT NULL default '0',
	change myorder myorder smallint(5) unsigned NOT NULL default '0';");

//点卡表
$empire->query("alter table {$dbtbpre}enewscard 
	change cardid cardid int(10) unsigned NOT NULL auto_increment,
	change card_no card_no char(30) NOT NULL default '',
	change password password char(20) NOT NULL default '',
	change money money int(10) unsigned NOT NULL default '0',
	change cardfen cardfen int(10) unsigned NOT NULL default '0',
	change carddate carddate int(10) unsigned NOT NULL default '0',
	change cdgroupid cdgroupid smallint(5) unsigned NOT NULL default '0',
	change cdzgroupid cdzgroupid smallint(5) unsigned NOT NULL default '0';");

//栏目表
$eclass=$empire->query("alter table {$dbtbpre}enewsclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change bclassid bclassid smallint(5) unsigned NOT NULL default '0',
	add `repagenum` smallint(5) unsigned NOT NULL default '0',
	add `keycid` smallint(6) NOT NULL default '0',
	add `allinfos` int(10) unsigned NOT NULL default '0',
	add `infos` int(10) unsigned NOT NULL default '0',
	add `addtime` int(10) unsigned NOT NULL default '0';");

$addtime=time();
$empire->query("update {$dbtbpre}enewsclass set addtime='$addtime'");

//栏目统计表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsclass_stats` (
  `classid` smallint(5) unsigned NOT NULL default '0',
  `uptime` int(10) unsigned NOT NULL default '0',
  `pvall` int(10) unsigned NOT NULL default '0',
  `pvyear` int(10) unsigned NOT NULL default '0',
  `pvhalfyear` int(10) unsigned NOT NULL default '0',
  `pvquarter` int(10) unsigned NOT NULL default '0',
  `pvmonth` int(10) unsigned NOT NULL default '0',
  `pvweek` int(10) unsigned NOT NULL default '0',
  `pvday` int(10) unsigned NOT NULL default '0',
  `pvyesterday` int(10) unsigned NOT NULL default '0',
  `ipall` int(10) unsigned NOT NULL default '0',
  `ipyear` int(10) unsigned NOT NULL default '0',
  `iphalfyear` int(10) unsigned NOT NULL default '0',
  `ipquarter` int(10) unsigned NOT NULL default '0',
  `ipmonth` int(10) unsigned NOT NULL default '0',
  `ipweek` int(10) unsigned NOT NULL default '0',
  `ipday` int(10) unsigned NOT NULL default '0',
  `ipyesterday` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`classid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//栏目统计IP表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsclass_stats_ip` (
  `ip` char(21) NOT NULL default '',
  PRIMARY KEY  (`ip`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//栏目统计设置表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsclass_stats_set` (
  `openstats` tinyint(1) NOT NULL default '0',
  `pvtime` int(10) unsigned NOT NULL default '0',
  `statsdate` int(10) unsigned NOT NULL default '0',
  `changedate` int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

$empire->query("INSERT INTO `{$dbtbpre}enewsclass_stats_set` VALUES (1, 3600, 0, 0);");

//栏目副表
$empire->query("alter table {$dbtbpre}enewsclassadd 
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//栏目字段表
$empire->query("alter table {$dbtbpre}enewsclassf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0';");

//$empire->query("update {$dbtbpre}enewsclassf set fhtml=REPLACE(fhtml,'htmlspecialchars(','ehtmlspecialchars(')");

//栏目缓存表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsclassnavcache` (
  `navtype` char(16) NOT NULL default '',
  `userid` int(10) unsigned NOT NULL default '0',
  `modid` smallint(5) unsigned NOT NULL default '0',
  KEY `navtype` (`navtype`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//封面模板分类表
$empire->query("alter table {$dbtbpre}enewsclasstempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change classname classname char(30) NOT NULL default '';");

//digg的ip表
$empire->query("alter table {$dbtbpre}enewsdiggips 
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//刷新任务表
$empire->query("alter table {$dbtbpre}enewsdo 
	change doid doid smallint(5) unsigned NOT NULL auto_increment,
	change lasttime lasttime int(10) unsigned NOT NULL default '0';");

//操作日志表
$empire->query("alter table {$dbtbpre}enewsdolog 
	add `pubid` bigint(16) unsigned NOT NULL default '0',
	add INDEX(pubid);");

//错误报告表
$empire->query("alter table {$dbtbpre}enewsdownerror 
	change errorid errorid int(10) unsigned NOT NULL auto_increment,
	change id id int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change cid cid smallint(5) unsigned NOT NULL default '0';");

//地址前缀表
$empire->query("alter table {$dbtbpre}enewsdownurlqz 
	change urlid urlid smallint(5) unsigned NOT NULL auto_increment;");

//错误报告分类表
$empire->query("alter table {$dbtbpre}enewserrorclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//字段表
$empire->query("alter table {$dbtbpre}enewsf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment,
	add `fmvnum` varchar(30) NOT NULL default '';");

//反馈表
$empire->query("alter table {$dbtbpre}enewsfeedback 
	change id id int(10) unsigned NOT NULL auto_increment,
	change bid bid smallint(5) unsigned NOT NULL default '0',
	change userid userid mediumint(8) unsigned NOT NULL default '0',
	change username username varchar(20) NOT NULL default '',
	add `haveread` tinyint(1) NOT NULL default '0',
	add INDEX(haveread);");

$fbfnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsfeedbackf where f='call' limit 1");
if($fbfnum)
{
	$empire->query("alter table {$dbtbpre}enewsfeedback 
	change `call` `mycall` varchar(30) NOT NULL default '';");

	$empire->query("update {$dbtbpre}enewsfeedbackf set f='mycall' where f='call' limit 1");

	$empire->query("update {$dbtbpre}enewsfeedbackclass set btemp=REPLACE(btemp,'call','mycall'),enter=REPLACE(enter,'call','mycall'),mustenter=REPLACE(mustenter,'call','mycall')");
}

$empire->query("update {$dbtbpre}enewsfeedback set haveread=1");

//反馈分类表
$empire->query("alter table {$dbtbpre}enewsfeedbackclass 
	change bid bid smallint(5) unsigned NOT NULL auto_increment;");

//反馈字段表
$empire->query("alter table {$dbtbpre}enewsfeedbackf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment;");

//留言表
$empire->query("alter table {$dbtbpre}enewsgbook 
	change lyid lyid int(10) unsigned NOT NULL auto_increment,
	change `call` `mycall` varchar(30) NOT NULL default '',
	change bid bid smallint(5) unsigned NOT NULL default '0',
	change userid userid mediumint(8) unsigned NOT NULL default '0',
	change username username varchar(20) NOT NULL default '';");

//留言分类表
$empire->query("alter table {$dbtbpre}enewsgbookclass 
	change bid bid smallint(5) unsigned NOT NULL auto_increment;");

//用户组表
$empire->query("alter table {$dbtbpre}enewsgroup 
	add `dofiletable` tinyint(1) NOT NULL default '0',
	add `docheckinfo` tinyint(1) NOT NULL default '0',
	add `dogoodinfo` tinyint(1) NOT NULL default '0',
	add `dodocinfo` tinyint(1) NOT NULL default '0',
	add `domoveinfo` tinyint(1) NOT NULL default '0',
	add `dodttemp` tinyint(1) NOT NULL default '0',
	add `doloadcj` tinyint(1) NOT NULL default '0',
	add `domustcheck` tinyint(1) NOT NULL default '0',
	add `docheckedit` tinyint(1) NOT NULL default '0',
	add `domemberconnect` tinyint(1) NOT NULL default '0',
	add `doprecode` tinyint(1) NOT NULL default '0';");

//后台站内消息表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewshmsg` (
  `mid` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(80) NOT NULL default '',
  `msgtext` text NOT NULL,
  `haveread` tinyint(1) NOT NULL default '0',
  `msgtime` datetime NOT NULL default '0000-00-00 00:00:00',
  `to_username` varchar(30) NOT NULL default '',
  `from_userid` int(10) unsigned NOT NULL default '0',
  `from_username` varchar(30) NOT NULL default '',
  `isadmin` tinyint(1) NOT NULL default '0',
  `issys` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`mid`),
  KEY `to_username` (`to_username`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//后台系统消息表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewshnotice` (
  `mid` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(80) NOT NULL default '',
  `msgtext` text NOT NULL,
  `haveread` tinyint(1) NOT NULL default '0',
  `msgtime` datetime NOT NULL default '0000-00-00 00:00:00',
  `to_username` varchar(30) NOT NULL default '',
  `from_userid` int(10) unsigned NOT NULL default '0',
  `from_username` varchar(30) NOT NULL default '',
  PRIMARY KEY  (`mid`),
  KEY `to_username` (`to_username`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//首页方案表
$empire->query("alter table {$dbtbpre}enewsindexpage 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment;");

//标题分类表
$empire->query("alter table {$dbtbpre}enewsinfotype 
	change typeid typeid smallint(5) unsigned NOT NULL auto_increment,
	add `tnum` tinyint(3) unsigned NOT NULL default '0',
	add `listtempid` smallint(5) unsigned NOT NULL default '0',
	add `tpath` varchar(100) NOT NULL default '',
	add `ttype` varchar(10) NOT NULL default '',
	add `maxnum` int(10) unsigned NOT NULL default '0',
	add `reorder` varchar(50) NOT NULL default '',
	add `tid` smallint(5) unsigned NOT NULL default '0',
	add `tbname` varchar(60) NOT NULL default '',
	add `timg` varchar(200) NOT NULL default '',
	add `intro` varchar(255) NOT NULL default '',
	add `pagekey` varchar(255) NOT NULL default '',
	add `newline` tinyint(3) unsigned NOT NULL default '0',
	add `hotline` tinyint(3) unsigned NOT NULL default '0',
	add `goodline` tinyint(3) unsigned NOT NULL default '0',
	add `hotplline` tinyint(3) unsigned NOT NULL default '0',
	add `firstline` tinyint(3) unsigned NOT NULL default '0',
	add `jstempid` smallint(5) unsigned NOT NULL default '0',
	add `nrejs` tinyint(1) NOT NULL default '0',
	add `listdt` tinyint(1) NOT NULL default '0',
	add `repagenum` smallint(5) unsigned NOT NULL default '0',
	DROP INDEX mid,
	add INDEX(mid),
	add INDEX(myorder);");

$infotypesql=$empire->query("select typeid,mid from {$dbtbpre}enewsinfotype");
while($infotyper=$empire->fetch($infotypesql))
{
	$tpath='t/'.$infotyper[typeid];
	$thismodr=$empire->fetch1("select tid,tbname from {$dbtbpre}enewsmod where mid='$infotyper[mid]'");
	$empire->query("update {$dbtbpre}enewsinfotype set tnum=25,listtempid=1,tpath='$tpath',ttype='.html',reorder='newstime DESC',tid='$thismodr[tid]',tbname='$thismodr[tbname]',newline=10,hotline=10,goodline=10,hotplline=10,firstline=10,jstempid=1 where typeid='$infotyper[typeid]'");
}

//JS模板分类表
$empire->query("alter table {$dbtbpre}enewsjstempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//内容关键字表
$empire->query("alter table {$dbtbpre}enewskey 
	change keyid keyid smallint(5) unsigned NOT NULL auto_increment,
	change keyname keyname char(50) NOT NULL default '',
	change keyurl keyurl char(200) NOT NULL default '',
	add `cid` smallint(5) unsigned NOT NULL default '0',
	add INDEX(cid);");

//内容关键字分类表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewskeyclass` (
  `classid` smallint(5) unsigned NOT NULL auto_increment,
  `classname` char(30) NOT NULL default '',
  PRIMARY KEY  (`classid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//友情链接表
$empire->query("alter table {$dbtbpre}enewslink 
	change lid lid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//友情链接分类表
$empire->query("alter table {$dbtbpre}enewslinkclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//列表模板分类表
$empire->query("alter table {$dbtbpre}enewslisttempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//登录日志表
$empire->query("alter table {$dbtbpre}enewslog 
	change loginid loginid int(10) unsigned NOT NULL auto_increment,
	add INDEX(status);");

//会员外部接口表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsmember_connect` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `userid` mediumint(8) unsigned NOT NULL default '0',
  `apptype` char(20) NOT NULL default '',
  `bindkey` char(32) NOT NULL default '',
  `bindtime` int(10) unsigned NOT NULL default '0',
  `loginnum` int(10) unsigned NOT NULL default '0',
  `lasttime` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `userid` (`userid`),
  KEY `bindkey` (`bindkey`),
  KEY `apptype` (`apptype`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//会员外部接口应用表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsmember_connect_app` (
  `id` smallint(5) unsigned NOT NULL auto_increment,
  `apptype` char(20) NOT NULL default '',
  `appname` char(30) NOT NULL default '',
  `appid` char(60) NOT NULL default '',
  `appkey` char(120) NOT NULL default '',
  `isclose` tinyint(1) NOT NULL default '0',
  `myorder` smallint(5) unsigned NOT NULL default '0',
  `qappname` char(30) NOT NULL default '',
  `appsay` char(255) NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `apptype` (`apptype`),
  KEY `isclose` (`isclose`),
  KEY `myorder` (`myorder`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//会员字段表
$empire->query("alter table {$dbtbpre}enewsmemberf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment;");

//会员反馈表
$empire->query("alter table {$dbtbpre}enewsmemberfeedback 
	change fid fid int(10) unsigned NOT NULL auto_increment,
	change userid userid mediumint(8) unsigned NOT NULL default '0',
	change uid uid mediumint(8) unsigned NOT NULL default '0',
	change uname uname varchar(20) NOT NULL default '';");

//会员表单表
$empire->query("alter table {$dbtbpre}enewsmemberform 
	change fid fid smallint(5) unsigned NOT NULL auto_increment;");

//会员留言表
$empire->query("alter table {$dbtbpre}enewsmembergbook 
	change gid gid int(10) unsigned NOT NULL auto_increment,
	change userid userid mediumint(8) unsigned NOT NULL default '0',
	change uid uid mediumint(8) unsigned NOT NULL default '0',
	change uname uname varchar(20) NOT NULL default '';");

//会员组表
$empire->query("alter table {$dbtbpre}enewsmembergroup 
	add `plchecked` tinyint(1) NOT NULL default '0';");

//菜单表
$empire->query("alter table {$dbtbpre}enewsmenu 
	change menuid menuid int(10) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//菜单分类表
$empire->query("alter table {$dbtbpre}enewsmenuclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0';");

//模型表
$empire->query("alter table {$dbtbpre}enewsmod 
	change mid mid smallint(5) unsigned NOT NULL auto_increment,
	change tid tid smallint(5) unsigned NOT NULL default '0';");

//内容模板分类表
$empire->query("alter table {$dbtbpre}enewsnewstempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//防采集字符表
$empire->query("alter table {$dbtbpre}enewsnotcj 
	change id id smallint(5) unsigned NOT NULL auto_increment;");

//前台系统信息表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsnotice` (
  `mid` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(80) NOT NULL default '',
  `msgtext` text NOT NULL,
  `haveread` tinyint(1) NOT NULL default '0',
  `msgtime` datetime NOT NULL default '0000-00-00 00:00:00',
  `to_username` varchar(30) NOT NULL default '',
  `from_userid` int(10) unsigned NOT NULL default '0',
  `from_username` varchar(30) NOT NULL default '',
  PRIMARY KEY  (`mid`),
  KEY `to_username` (`to_username`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//自定义页面表
$empire->query("alter table {$dbtbpre}enewspage 
	change id id int(10) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change tempid tempid smallint(5) unsigned NOT NULL default '0';");

//自定义页面分类表
$empire->query("alter table {$dbtbpre}enewspageclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//支付接口表
$empire->query("alter table {$dbtbpre}enewspayapi 
	change payid payid smallint(5) unsigned NOT NULL auto_increment;");

//支付记录表
$empire->query("alter table {$dbtbpre}enewspayrecord 
	change id id int(10) unsigned NOT NULL auto_increment,
	change userid userid int(10) unsigned NOT NULL default '0';");

//图片信息表
$empire->query("alter table {$dbtbpre}enewspic 
	change picid picid int(10) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//图片信息分类表
$empire->query("alter table {$dbtbpre}enewspicclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//评论设置表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewspl_set` (
  `id` tinyint(3) unsigned NOT NULL auto_increment,
  `pltime` smallint(5) unsigned NOT NULL default '0',
  `plsize` smallint(5) unsigned NOT NULL default '0',
  `plincludesize` smallint(5) unsigned NOT NULL default '0',
  `plkey_ok` tinyint(1) NOT NULL default '0',
  `plface` text NOT NULL,
  `plfacenum` tinyint(3) unsigned NOT NULL default '0',
  `plgroupid` smallint(5) unsigned NOT NULL default '0',
  `plclosewords` text NOT NULL,
  `plf` text NOT NULL,
  `plmustf` text NOT NULL,
  `pldatatbs` text NOT NULL,
  `defpltempid` smallint(5) unsigned NOT NULL default '0',
  `pl_num` smallint(5) unsigned NOT NULL default '0',
  `pldeftb` smallint(5) unsigned NOT NULL default '0',
  `plurl` varchar(200) NOT NULL default '',
  `plmaxfloor` smallint(5) unsigned NOT NULL default '0',
  `plquotetemp` text NOT NULL,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

$plurl=$public_r['newsurl'].'e/pl/';

$empire->query("replace into `{$dbtbpre}enewspl_set` values('1','20','500','0','1','||[~e.jy~]##1.gif||[~e.kq~]##2.gif||[~e.se~]##3.gif||[~e.sq~]##4.gif||[~e.lh~]##5.gif||[~e.ka~]##6.gif||[~e.hh~]##7.gif||[~e.ys~]##8.gif||[~e.ng~]##9.gif||[~e.ot~]##10.gif||','10','0','','','',',1,','1','12','1','$plurl','0','<div class=\\\\\"ecomment\\\\\">\r\n<span class=\\\\\"ecommentauthor\\\\\">网友 [!--username--] 的原文：</span>\r\n<p class=\\\\\"ecommenttext\\\\\">[!--pltext--]</p>\r\n</div>');");


$pubr=$empire->fetch1("select * from {$dbtbpre}enewspublic limit 1");

$empire->query("update {$dbtbpre}enewspl_set set pltime='$pubr[pltime]',plsize='$pubr[plsize]',plincludesize='$pubr[plincludesize]',plkey_ok='$pubr[plkey_ok]',plface='".addslashes($pubr[plface])."',plfacenum='$pubr[plfacenum]',plgroupid='$pubr[plgroupid]',plclosewords='".addslashes($pubr[plclosewords])."',plf='".addslashes($pubr[plf])."',plmustf='".addslashes($pubr[plmustf])."',defpltempid='$pubr[defpltempid]',pl_num='$pubr[pl_num]'");

//播放器表
$empire->query("alter table {$dbtbpre}enewsplayer 
	change id id smallint(5) unsigned NOT NULL auto_increment;");

//评论字段表
$empire->query("alter table {$dbtbpre}enewsplf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment;");

//远程发布表
$empire->query("alter table {$dbtbpre}enewspostdata 
	change postid postid bigint(20) unsigned NOT NULL auto_increment;");

//远程发布服务表
$empire->query("alter table {$dbtbpre}enewspostserver 
	change pid pid smallint(5) unsigned NOT NULL auto_increment,
	change ftpouttime ftpouttime smallint(5) unsigned NOT NULL default '0',
	change lastposttime lastposttime int(10) unsigned NOT NULL default '0';");

//商城设置表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsshop_set` (
  `id` tinyint(3) unsigned NOT NULL auto_increment,
  `shopddgroupid` smallint(5) unsigned NOT NULL default '0',
  `buycarnum` smallint(5) unsigned NOT NULL default '0',
  `havefp` tinyint(1) NOT NULL default '0',
  `fpnum` smallint(5) unsigned NOT NULL default '0',
  `fpname` text NOT NULL,
  `ddmust` text NOT NULL,
  `haveatt` tinyint(1) NOT NULL default '0',
  `shoptbs` varchar(255) NOT NULL default '',
  `buystep` tinyint(3) unsigned NOT NULL default '0',
  `shoppsmust` tinyint(1) NOT NULL default '0',
  `shoppayfsmust` tinyint(1) NOT NULL default '0',
  `dddeltime` smallint(5) unsigned NOT NULL default '0',
  `cutnumtype` tinyint(1) NOT NULL default '0',
  `cutnumtime` int(10) unsigned NOT NULL default '0',
  `freepstotal` int(10) unsigned NOT NULL default '0',
  `singlenum` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

$empire->query("replace into `{$dbtbpre}enewsshop_set` values('1','0','0','0','10','商品名称\r\n办公用品\r\n日用品',',truename,mycall,address,','0',',shop,','0','1','1','0','0','120','0','0');");


$empire->query("update {$dbtbpre}enewsshop_set set shopddgroupid='$pubr[shopddgroupid]',buycarnum='$pubr[buycarnum]',havefp='$pubr[havefp]',fpnum='$pubr[fpnum]'");

//公共设置表
$empire->query("alter table {$dbtbpre}enewspublic 
	add `id` tinyint(3) unsigned NOT NULL auto_increment,
	drop COLUMN pltime,
	drop COLUMN plsize,
	drop COLUMN plincludesize,
	drop COLUMN plkey_ok,
	drop COLUMN fpnum,
	drop COLUMN havefp,
	drop COLUMN plface,
	drop COLUMN plfacenum,
	drop COLUMN plgroupid,
	drop COLUMN plclosewords,
	drop COLUMN plf,
	drop COLUMN plmustf,
	drop COLUMN pldatatbs,
	drop COLUMN pldeftb,
	drop COLUMN defpltempid,
	drop COLUMN buycarnum,
	drop COLUMN shopddgroupid,
	drop COLUMN pl_num,
	add `fieldandtop` tinyint(1) NOT NULL default '0',
	add `fieldandclosetb` text NOT NULL,
	add `filedatatbs` text NOT NULL,
	add `filedeftb` smallint(5) unsigned NOT NULL default '0',
	add `firsttitlename` varchar(255) NOT NULL default '',
	add `isgoodname` varchar(255) NOT NULL default '',
	add `closelisttemp` varchar(255) NOT NULL default '',
	add `chclasscolor` varchar(8) NOT NULL default '',
	add `timeclose` varchar(255) NOT NULL default '',
	add `timeclosedo` varchar(255) NOT NULL default '',
	add `ipaddinfonum` int(10) unsigned NOT NULL default '0',
	add `ipaddinfotime` smallint(5) unsigned NOT NULL default '0',
	add `rewriteinfo` varchar(120) NOT NULL default '',
	add `rewriteclass` varchar(120) NOT NULL default '',
	add `rewriteinfotype` varchar(120) NOT NULL default '',
	add `rewritetags` varchar(120) NOT NULL default '',
	add `closehmenu` varchar(80) NOT NULL default '',
	add PRIMARY KEY(id);");

$empire->query("update {$dbtbpre}enewspublic set filedatatbs=',1,',filedeftb='1',firsttitlename='一级头条|二级头条|三级头条|四级头条|五级头条|六级头条|七级头条|八级头条|九级头条',isgoodname='一级推荐|二级推荐|三级推荐|四级推荐|五级推荐|六级推荐|七级推荐|八级推荐|九级推荐',chclasscolor='#99C4E3'");

//统计最新表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewspublic_update` (
  `id` tinyint(3) unsigned NOT NULL auto_increment,
  `lasttimeinfo` int(10) unsigned NOT NULL default '0',
  `lasttimepl` int(10) unsigned NOT NULL default '0',
  `lastnuminfo` int(10) unsigned NOT NULL default '0',
  `lastnumpl` int(10) unsigned NOT NULL default '0',
  `lastnuminfotb` text NOT NULL,
  `lastnumpltb` text NOT NULL,
  `todaytimeinfo` int(10) unsigned NOT NULL default '0',
  `todaytimepl` int(10) unsigned NOT NULL default '0',
  `todaynuminfo` int(10) unsigned NOT NULL default '0',
  `yesterdaynuminfo` int(10) unsigned NOT NULL default '0',
  `todaynumpl` int(10) unsigned NOT NULL default '0',
  `yesterdaynumpl` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

$empire->query("INSERT INTO `{$dbtbpre}enewspublic_update` VALUES (1, 1355124469, 1355124476, 0, 0, '', '', 1355196792, 1355196792, 0, 0, 0, 0);");

//公共变量表
$empire->query("alter table {$dbtbpre}enewspubvar 
	change varid varid smallint(5) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0';");

//公共变量分类表
$empire->query("alter table {$dbtbpre}enewspubvarclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//前台站内消息表
$empire->query("alter table {$dbtbpre}enewsqmsg 
	change mid mid int(10) unsigned NOT NULL auto_increment,
	change title title varchar(80) NOT NULL default '',
	change from_userid from_userid int(10) unsigned NOT NULL default '0',
	drop COLUMN outbox,
	add `isadmin` tinyint(1) NOT NULL default '0';");

//搜索记录表
$empire->query("alter table {$dbtbpre}enewssearch 
	change searchid searchid bigint(20) unsigned NOT NULL auto_increment,
	change searchtime searchtime int(10) unsigned NOT NULL default '0',
	change result_num result_num int(10) unsigned NOT NULL default '0',
	change onclick onclick int(10) unsigned NOT NULL default '0',
	change tempid tempid smallint(5) unsigned NOT NULL default '0',
	change trueclassid trueclassid smallint(5) unsigned NOT NULL default '0';");

//全站搜索表
$empire->query("alter table {$dbtbpre}enewssearchall 
	change sid sid int(10) unsigned NOT NULL auto_increment,
	change id id int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change infotime infotime int(10) unsigned NOT NULL default '0';");

//全站搜索数据源表
$empire->query("alter table {$dbtbpre}enewssearchall_load 
	change lid lid smallint(5) unsigned NOT NULL auto_increment,
	change loadnum loadnum smallint(5) unsigned NOT NULL default '0',
	change lasttime lasttime int(10) unsigned NOT NULL default '0',
	change lastid lastid int(10) unsigned NOT NULL default '0';");

//搜索模板分类表
$empire->query("alter table {$dbtbpre}enewssearchtempclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//配送地址表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsshop_address` (
  `addressid` int(10) unsigned NOT NULL auto_increment,
  `addressname` char(50) NOT NULL default '',
  `userid` mediumint(8) unsigned NOT NULL default '0',
  `truename` char(20) NOT NULL default '',
  `oicq` char(20) NOT NULL default '',
  `msn` char(60) NOT NULL default '',
  `email` char(60) NOT NULL default '',
  `address` char(255) NOT NULL default '',
  `zip` char(8) NOT NULL default '',
  `mycall` char(30) NOT NULL default '',
  `phone` char(30) NOT NULL default '',
  `signbuild` char(100) NOT NULL default '',
  `besttime` char(120) NOT NULL default '',
  `isdefault` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`addressid`),
  KEY `userid` (`userid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//订单日志表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsshop_ddlog` (
  `logid` int(10) unsigned NOT NULL auto_increment,
  `ddid` int(10) unsigned NOT NULL default '0',
  `userid` int(10) unsigned NOT NULL default '0',
  `username` varchar(30) NOT NULL default '',
  `ecms` varchar(30) NOT NULL default '',
  `bz` varchar(255) NOT NULL default '',
  `addbz` varchar(255) NOT NULL default '',
  `logtime` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`logid`),
  KEY `ddid` (`ddid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//优惠码表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsshop_precode` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `prename` varchar(30) NOT NULL default '',
  `precode` varchar(36) NOT NULL default '',
  `premoney` int(10) unsigned NOT NULL default '0',
  `pretype` tinyint(1) NOT NULL default '0',
  `reuse` tinyint(1) NOT NULL default '0',
  `addtime` int(10) unsigned NOT NULL default '0',
  `endtime` int(10) unsigned NOT NULL default '0',
  `groupid` varchar(255) NOT NULL default '',
  `classid` text NOT NULL,
  `musttotal` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `precode` (`precode`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//商城支付方式表
$empire->query("alter table {$dbtbpre}enewsshoppayfs 
	change payid payid smallint(5) unsigned NOT NULL auto_increment,
	add `isclose` tinyint(1) NOT NULL default '0',
	add `isdefault` tinyint(1) NOT NULL default '0';");

//商城配送方式表
$empire->query("alter table {$dbtbpre}enewsshopps 
	change pid pid smallint(5) unsigned NOT NULL auto_increment,
	add `isclose` tinyint(1) NOT NULL default '0',
	add `isdefault` tinyint(1) NOT NULL default '0';");

//碎片表
$empire->query("alter table {$dbtbpre}enewssp 
	change spid spid int(10) unsigned NOT NULL auto_increment,
	change cid cid smallint(5) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change tempid tempid smallint(5) unsigned NOT NULL default '0',
	change sptime sptime int(10) unsigned NOT NULL default '0',
	add `refile` tinyint(1) NOT NULL default '0',
	add `spfile` varchar(255) NOT NULL default '',
	add `spfileline` smallint(6) NOT NULL default '0',
	add `spfilesub` smallint(6) NOT NULL default '0',
	add INDEX(refile);");

//碎片1表
$empire->query("alter table {$dbtbpre}enewssp_1 
	change sid sid int(10) unsigned NOT NULL auto_increment,
	change spid spid int(10) unsigned NOT NULL default '0',
	change newstime newstime int(10) unsigned NOT NULL default '0';");

//碎片2表
$empire->query("alter table {$dbtbpre}enewssp_2 
	change sid sid int(10) unsigned NOT NULL auto_increment,
	change spid spid int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change id id int(10) unsigned NOT NULL default '0',
	change newstime newstime int(10) unsigned NOT NULL default '0';");

//碎片3表
$empire->query("alter table {$dbtbpre}enewssp_3 
	change sid sid int(10) unsigned NOT NULL auto_increment,
	change spid spid int(10) unsigned NOT NULL default '0';");

//碎片3备份表
$empire->query("alter table {$dbtbpre}enewssp_3_bak 
	change bid bid int(10) unsigned NOT NULL auto_increment,
	change sid sid int(10) unsigned NOT NULL default '0',
	change spid spid int(10) unsigned NOT NULL default '0',
	change lasttime lasttime int(10) unsigned NOT NULL default '0';");

//会员空间模板表
$empire->query("alter table {$dbtbpre}enewsspacestyle 
	change styleid styleid smallint(5) unsigned NOT NULL auto_increment;");

//碎片分类表
$empire->query("alter table {$dbtbpre}enewsspclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//SQL表
$empire->query("alter table {$dbtbpre}enewssql 
	change id id smallint(5) unsigned NOT NULL auto_increment;");

//数据表
$empire->query("alter table {$dbtbpre}enewstable 
	change tid tid smallint(5) unsigned NOT NULL auto_increment,
	change yhid yhid smallint(5) unsigned NOT NULL default '0',
	change mid mid smallint(5) unsigned NOT NULL default '0',
	add `intb` tinyint(1) NOT NULL default '0';");

//tags表
$empire->query("alter table {$dbtbpre}enewstags 
	change tagid tagid int(10) unsigned NOT NULL auto_increment,
	change num num int(10) unsigned NOT NULL default '0',
	change cid cid smallint(5) unsigned NOT NULL default '0';");

//tags分类表
$empire->query("alter table {$dbtbpre}enewstagsclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//tags信息表
$empire->query("alter table {$dbtbpre}enewstagsdata 
	change tid tid int(10) unsigned NOT NULL auto_increment,
	change tagid tagid int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change id id int(10) unsigned NOT NULL default '0',
	change newstime newstime int(10) unsigned NOT NULL default '0',
	change mid mid smallint(5) unsigned NOT NULL default '0';");

//计划任务表
$empire->query("alter table {$dbtbpre}enewstask 
	change id id smallint(5) unsigned NOT NULL auto_increment,
	change userid userid int(10) unsigned NOT NULL default '0',
	change lastdo lastdo int(10) unsigned NOT NULL default '0';");

//模板备份表
$empire->query("alter table {$dbtbpre}enewstempbak 
	change bid bid int(10) unsigned NOT NULL auto_increment,
	change tempid tempid smallint(5) unsigned NOT NULL default '0',
	change modid modid smallint(5) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change baktime baktime int(10) unsigned NOT NULL default '0',
	change gid gid smallint(5) unsigned NOT NULL default '0';");

//动态页面模板表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewstempdt` (
  `tempid` smallint(5) unsigned NOT NULL auto_increment,
  `tempvar` char(30) NOT NULL default '',
  `tempname` char(30) NOT NULL default '',
  `tempsay` char(255) NOT NULL default '',
  `tempfile` char(200) NOT NULL default '',
  `myorder` smallint(5) unsigned NOT NULL default '0',
  `temptype` char(20) NOT NULL default '',
  PRIMARY KEY  (`tempid`),
  UNIQUE KEY `tempvar` (`tempvar`),
  KEY `temptype` (`temptype`),
  KEY `myorder` (`myorder`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

$empire->query("replace into `{$dbtbpre}enewstempdt` values('1','header','主界面头部','主界面头部','e/template/incfile/header.php','0','incfile');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('2','footer','主界面尾部','主界面尾部','e/template/incfile/footer.php','0','incfile');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('3','qDoInfo','管理投稿首页','管理投稿首页','e/template/DoInfo/DoInfo.php','0','doinfo');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('4','qChangeClass','投稿选择栏目页','投稿选择栏目页','e/template/DoInfo/ChangeClass.php','0','doinfo');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('5','qDoInfoTran','发布投稿上传附件页面','发布投稿上传附件页面','e/template/DoInfo/tran.php','0','doinfo');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('6','qAddInfo','发布投稿页','发布投稿页','e/template/DoInfo/AddInfo.php','0','doinfo');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('7','qListInfo','默认管理投稿列表页','默认管理投稿列表页','e/data/html/list/qlistinfo.php','0','doinfo');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('8','report','提交错误报告页面','提交错误报告页面','e/template/public/report.php','0','pubtemp');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('9','payapi','在线支付页面','在线支付页面','e/template/payapi/payapi.php','0','pubtemp');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('10','infovote','信息投票页面','信息投票页面','e/template/public/vote.php','0','pubtemp');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('11','vote','投票插件页面','投票插件页面','e/template/tool/vote.php','0','pubtemp');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('12','ShopBurcar','购物车页面','购物车页面','e/template/ShopSys/buycar.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('13','ShopOrder','提交订单页面','提交订单页面','e/template/ShopSys/order.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('14','ShopSubmitOrder','确认提交订单页面','确认提交订单页面','e/template/ShopSys/SubmitOrder.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('15','ShopListDd','订单列表页面','订单列表页面','e/template/ShopSys/ListDd.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('16','ShopShowDd','订单详细页面','订单详细页面','e/template/ShopSys/ShowDd.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('17','ShopBurcarForm','购物车-加入表单模板','购物车-加入表单模板','e/template/ShopSys/buycar/buycar_form.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('18','ShopBurcarOrder','购物车-确认订单模板','购物车-确认订单模板','e/template/ShopSys/buycar/buycar_order.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('19','ShopBurcarShowdd','购物车-显示订单模板','购物车-显示订单模板','e/template/ShopSys/buycar/buycar_showdd.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('20','ShopAddAddress','增加配送地址页面','增加配送地址页面','e/template/ShopSys/AddAddress.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('21','ShopListAddress','管理配送地址页面','管理配送地址页面','e/template/ShopSys/ListAddress.php','0','shopsys');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('22','MemberReg','会员注册页面','会员注册页面','e/template/member/register.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('23','MemberChangeReg','选择注册类型页面','选择注册类型页面','e/template/member/ChangeRegister.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('24','MemberRegsend','重发注册激活邮件页面','重发注册激活邮件页面','e/template/member/regsend.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('25','MemberLogin','会员登录页面','会员登录页面','e/template/member/login.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('26','MemberLoginopen','会员登录弹出页面','会员登录弹出页面','e/template/member/loginopen.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('27','MemberEditinfo','修改会员信息页面','修改会员信息页面','e/template/member/EditInfo.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('28','MemberEditsafeinfo','修改会员安全信息页面','修改会员安全信息页面','e/template/member/EditSafeInfo.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('29','MemberGetPassword','取回密码页面','取回密码页面','e/template/member/GetPassword.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('30','MemberGetResetPass','取回密码重置页面','取回密码重置页面','e/template/member/getpass.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('31','MemberCp','会员中心首页','会员中心首页','e/template/member/cp.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('32','MemberMy','会员状态页面','会员状态页面','e/template/member/my.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('33','MemberShowInfo','查看会员信息页面','查看会员信息页面','e/template/member/ShowInfo.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('34','MemberList1','默认会员列表页面','默认会员列表页面','e/template/member/memberlist/1.php','0','member');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('35','MemberAddMsg','发送站内消息页面','发送站内消息页面','e/template/member/AddMsg.php','0','membermsg');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('36','MemberMsg','站内消息列表页面','站内消息列表页面','e/template/member/msg.php','0','membermsg');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('37','MemberViewMsg','查看站内消息页面','查看站内消息页面','e/template/member/ViewMsg.php','0','membermsg');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('38','MemberAddFriend','增加好友页面','增加好友页面','e/template/member/AddFriend.php','0','memberfriend');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('39','MemberFriend','好友列表页面','好友列表页面','e/template/member/friend.php','0','memberfriend');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('40','MemberFriendClass','好友分类页面','好友分类页面','e/template/member/FriendClass.php','0','memberfriend');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('41','MemberChangeFriend','选择好友页面','选择好友页面','e/template/member/ChangeFriend.php','0','memberfriend');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('42','MemberAddFava','增加收藏信息页面','增加收藏信息页面','e/template/member/AddFava.php','0','memberfav');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('43','MemberFava','管理收藏页面','管理收藏页面','e/template/member/fava.php','0','memberfav');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('44','MemberFavaClass','管理收藏分类页面','管理收藏分类页面','e/template/member/FavaClass.php','0','memberfav');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('45','MemberBuybak','充值记录页面','充值记录页面','e/template/member/buybak.php','0','memberother');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('46','MemberDownbak','下载记录页面','下载记录页面','e/template/member/downbak.php','0','memberother');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('47','MemberBuygroup','购买会员类型页面','购买会员类型页面','e/template/member/buygroup.php','0','memberother');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('48','MemberCard','点卡充值页面','点卡充值页面','e/template/member/card.php','0','memberother');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('49','MemberChangeStyle','选择会员空间风格页面','选择会员空间风格页面','e/template/member/mspace/ChangeStyle.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('50','MemberSetSpace','设置会员空间页面','设置会员空间页面','e/template/member/mspace/SetSpace.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('51','MemberFeedback','管理会员空间反馈页面','管理会员空间反馈页面','e/template/member/mspace/feedback.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('52','MemberShowFeedback','查看会员空间反馈页面','查看会员空间反馈页面','e/template/member/mspace/ShowFeedback.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('53','MemberGbook','管理会员空间留言页面','管理会员空间留言页面','e/template/member/mspace/gbook.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('54','MemberReGbook','回复会员空间留言页面','回复会员空间留言页面','e/template/member/mspace/ReGbook.php','0','memberspace');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('55','MemberConnectListBind','登录绑定管理页面','登录绑定管理页面','e/template/memberconnect/ListBind.php','0','memberconnect');");
$empire->query("replace into `{$dbtbpre}enewstempdt` values('56','MemberConnectTobind','绑定登录帐号页面','绑定登录帐号页面','e/template/memberconnect/tobind.php','0','memberconnect');");

//模板组表
$empire->query("alter table {$dbtbpre}enewstempgroup 
	change gid gid smallint(5) unsigned NOT NULL auto_increment;");

//模板变量分类表
$empire->query("alter table {$dbtbpre}enewstempvarclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//组合专题存放表
$empire->query("alter table {$dbtbpre}enewstogzts 
	change togid togid int(10) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change startid startid int(10) unsigned NOT NULL default '0',
	change endid endid int(10) unsigned NOT NULL default '0';");

//用户表
$empire->query("alter table {$dbtbpre}enewsuser 
	change userid userid int(10) unsigned NOT NULL auto_increment,
	change groupid groupid smallint(5) unsigned NOT NULL default '0',
	change styleid styleid smallint(5) unsigned NOT NULL default '0',
	change loginnum loginnum int(10) unsigned NOT NULL default '0',
	change lasttime lasttime int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change pretime pretime int(10) unsigned NOT NULL default '0',
	add `addtime` int(10) unsigned NOT NULL default '0',
	add `addip` varchar(20) NOT NULL default '',
	add `userprikey` varchar(50) NOT NULL default '';");

$addtime=time();
$addip=egetip();
$usersql=$empire->query("select * from {$dbtbpre}enewsuser");
while($userr=$empire->fetch($usersql))
{
	$userprikey=make_password(48);
	$empire->query("update {$dbtbpre}enewsuser set addtime='$addtime',addip='$addip',userprikey='$userprikey' where userid='$userr[userid]'");
}

//用户副表
$empire->query("alter table {$dbtbpre}enewsuseradd 
	change userid userid int(10) unsigned NOT NULL auto_increment,
	add `openip` text NOT NULL,
	add `certkey` varchar(60) NOT NULL default '',
	add `certtime` int(10) unsigned NOT NULL default '0';");

//用户分类表
$empire->query("alter table {$dbtbpre}enewsuserclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//自定义JS表
$empire->query("alter table {$dbtbpre}enewsuserjs 
	change jsid jsid smallint(5) unsigned NOT NULL auto_increment,
	change jstempid jstempid smallint(5) unsigned NOT NULL default '0',
	add `classid` smallint(5) unsigned NOT NULL default '0',
	add INDEX(classid);");

//自定义JS分类表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsuserjsclass` (
  `classid` smallint(5) unsigned NOT NULL auto_increment,
  `classname` varchar(30) NOT NULL default '',
  PRIMARY KEY  (`classid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//自定义列表表
$empire->query("alter table {$dbtbpre}enewsuserlist 
	change listid listid smallint(5) unsigned NOT NULL auto_increment,
	change listtempid listtempid smallint(5) unsigned NOT NULL default '0',
	add `pagekeywords` varchar(255) NOT NULL default '',
	add `pagedescription` varchar(255) NOT NULL default '',
	add `classid` smallint(5) unsigned NOT NULL default '0',
	add INDEX(classid);");

//自定义列表分类表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsuserlistclass` (
  `classid` smallint(5) unsigned NOT NULL auto_increment,
  `classname` varchar(30) NOT NULL default '',
  PRIMARY KEY  (`classid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//用户验证表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewsuserloginck` (
  `userid` int(10) unsigned NOT NULL auto_increment,
  `andauth` varchar(32) NOT NULL default '',
  PRIMARY KEY  (`userid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//投票表
$empire->query("alter table {$dbtbpre}enewsvote 
	change voteid voteid int(10) unsigned NOT NULL auto_increment,
	change votenum votenum int(10) unsigned NOT NULL default '0',
	change votetime votetime int(10) unsigned NOT NULL default '0',
	change tempid tempid smallint(5) unsigned NOT NULL default '0';");

//预设投票表
$empire->query("alter table {$dbtbpre}enewsvotemod 
	change voteid voteid smallint(5) unsigned NOT NULL auto_increment,
	change tempid tempid smallint(5) unsigned NOT NULL default '0',
	change votenum votenum int(10) unsigned NOT NULL default '0';");

//WAP模板表
$empire->query("alter table {$dbtbpre}enewswapstyle 
	change styleid styleid smallint(5) unsigned NOT NULL auto_increment,
	change path path smallint(5) unsigned NOT NULL default '0';");

//签发信息表
$empire->query("alter table {$dbtbpre}enewswfinfo 
	change id id int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change wfid wfid smallint(5) unsigned NOT NULL default '0',
	change tid tid int(10) unsigned NOT NULL default '0';");

//签发信息日志表
$empire->query("alter table {$dbtbpre}enewswfinfolog 
	change logid logid int(10) unsigned NOT NULL auto_increment,
	change id id int(10) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change wfid wfid smallint(5) unsigned NOT NULL default '0',
	change tid tid int(10) unsigned NOT NULL default '0',
	change checktime checktime int(10) unsigned NOT NULL default '0';");

//过滤字符表
$empire->query("alter table {$dbtbpre}enewswords 
	change wordid wordid smallint(5) unsigned NOT NULL auto_increment;");

//工作流表
$empire->query("alter table {$dbtbpre}enewsworkflow 
	change wfid wfid smallint(5) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0',
	change addtime addtime int(10) unsigned NOT NULL default '0';");

//工作流项表
$empire->query("alter table {$dbtbpre}enewsworkflowitem 
	change tid tid int(10) unsigned NOT NULL auto_increment,
	change wfid wfid smallint(5) unsigned NOT NULL default '0',
	change tbdo tbdo int(10) unsigned NOT NULL default '0',
	change tddo tddo int(10) unsigned NOT NULL default '0';");

//作者表
$empire->query("alter table {$dbtbpre}enewswriter 
	change wid wid smallint(5) unsigned NOT NULL auto_increment;");

//优化表
$empire->query("alter table {$dbtbpre}enewsyh 
	change id id smallint(5) unsigned NOT NULL auto_increment;");

//专题表
$empire->query("alter table {$dbtbpre}enewszt 
	change ztid ztid smallint(5) unsigned NOT NULL auto_increment,
	change onclick onclick int(10) unsigned NOT NULL default '0',
	change ztnum ztnum tinyint(3) unsigned NOT NULL default '0',
	change listtempid listtempid smallint(5) unsigned NOT NULL default '0',
	drop COLUMN newline,
	drop COLUMN hotline,
	drop COLUMN goodline,
	change classid classid smallint(5) unsigned NOT NULL default '0',
	drop COLUMN hotplline,
	drop COLUMN firstline,
	drop COLUMN tid,
	drop COLUMN tbname,
	drop COLUMN jstempid,
	change zcid zcid smallint(5) unsigned NOT NULL default '0',
	change classtempid classtempid smallint(5) unsigned NOT NULL default '0',
	change myorder myorder smallint(5) unsigned NOT NULL default '0',
	drop COLUMN nrejs,
	change yhid yhid smallint(5) unsigned NOT NULL default '0',
	add `endtime` int(10) unsigned NOT NULL default '0',
	add `closepl` tinyint(1) NOT NULL default '0',
	add `checkpl` tinyint(1) NOT NULL default '0',
	add `restb` tinyint(3) unsigned NOT NULL default '0',
	add `usernames` varchar(255) NOT NULL default '',
	add `addtime` int(10) unsigned NOT NULL default '0',
	add `pltempid` smallint(5) unsigned NOT NULL default '0';");

$addtime=time();
$empire->query("update {$dbtbpre}enewszt set addtime='$addtime',restb=1");

//专题副表
$empire->query("alter table {$dbtbpre}enewsztadd 
	change ztid ztid smallint(5) unsigned NOT NULL default '0';");

//专题分类表
$empire->query("alter table {$dbtbpre}enewsztclass 
	change classid classid smallint(5) unsigned NOT NULL auto_increment;");

//专题字段表
$empire->query("alter table {$dbtbpre}enewsztf 
	change fid fid smallint(5) unsigned NOT NULL auto_increment,
	change myorder myorder smallint(5) unsigned NOT NULL default '0';");

//专题子类表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewszttype` (
  `cid` mediumint(8) unsigned NOT NULL auto_increment,
  `ztid` smallint(5) unsigned NOT NULL default '0',
  `cname` varchar(20) NOT NULL default '',
  `myorder` smallint(5) unsigned NOT NULL default '0',
  `islist` tinyint(1) NOT NULL default '0',
  `listtempid` smallint(5) unsigned NOT NULL default '0',
  `maxnum` int(10) unsigned NOT NULL default '0',
  `tnum` tinyint(3) unsigned NOT NULL default '0',
  `reorder` varchar(50) NOT NULL default '',
  `ttype` varchar(10) NOT NULL default '',
  `endtime` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`cid`),
  KEY `ztid` (`ztid`),
  KEY `myorder` (`myorder`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));

//专题子类副表
$empire->query(SetCreateTable("CREATE TABLE `{$dbtbpre}enewszttypeadd` (
  `cid` mediumint(8) unsigned NOT NULL default '0',
  `classtext` mediumtext NOT NULL,
  PRIMARY KEY  (`cid`)
) TYPE=MyISAM;",$ecms_config['db']['dbchar']));



//----------- 模板相关 -------------

$tgsql=$empire->query("select gid from {$dbtbpre}enewstempgroup");
while($tgr=$empire->fetch($tgsql))
{
	$bqtb=$tgr['gid']!=1?'_'.$tgr['gid']:'';
	//标签模板表
	$empire->query("alter table {$dbtbpre}enewsbqtemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change modid modid smallint(5) unsigned NOT NULL default '0',
	change subnews subnews smallint(5) unsigned NOT NULL default '0',
	change rownum rownum smallint(5) unsigned NOT NULL default '0',
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//封面模板表
	$empire->query("alter table {$dbtbpre}enewsclasstemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//JS模板表
	$empire->query("alter table {$dbtbpre}enewsjstemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//列表模板表
	$empire->query("alter table {$dbtbpre}enewslisttemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//内容模板表
	$empire->query("alter table {$dbtbpre}enewsnewstemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//自定义页面模板表
	$empire->query("alter table {$dbtbpre}enewspagetemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment;");

	//评论模板表
	$empire->query("alter table {$dbtbpre}enewspltemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment;");

	//打印模板表
	$empire->query("alter table {$dbtbpre}enewsprinttemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment;");

	//搜索模板表
	$empire->query("alter table {$dbtbpre}enewssearchtemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0';");

	//模板变量表
	$empire->query("alter table {$dbtbpre}enewstempvar".$bqtb." 
	change varid varid smallint(5) unsigned NOT NULL auto_increment,
	change classid classid smallint(5) unsigned NOT NULL default '0',
	change myorder myorder smallint(5) unsigned NOT NULL default '0';");

	//投票模板表
	$empire->query("alter table {$dbtbpre}enewsvotetemp".$bqtb." 
	change tempid tempid smallint(5) unsigned NOT NULL auto_increment;");

}

?>