帝国cms插件安装,包含数据表的生成和删除,后台管理菜单的生成和删除。
先看引导页面,代码为:
<?php error_reporting(E_ALL ^ E_NOTICE); @set_time_limit(10000); define('EmpireCMSAdmin','1'); require('../../../class/connect.php'); require('../../../class/db_sql.php'); require('../../../class/functions.php'); $link=db_connect(); $empire=new mysqlquery(); $editor=2; if($_GET['ecms']=="install") { $doinstall=$_GET['doinstall']; if($doinstall=='install')//安装操作 { include('install.php'); $word='已安装完毕!'; } elseif($doinstall=='uninstall')//卸载操作 { include('uninstall.php'); $word='已卸载完毕!'; } echo"置顶插件 $word 感谢您的关注。插件定制QQ 110102296"; exit(); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>置顶插件安装/卸载程序</title> <style> a:link { COLOR: #000000; TEXT-DECORATION: none } a:visited { COLOR: #000000 ; TEXT-DECORATION: none } a:active { COLOR: #000000 ; TEXT-DECORATION: underline } a:hover { COLOR: #000000 ; TEXT-DECORATION:underline } .home_top { border-top:2px solid #4798ED; } .home_path { background:#4798ED; padding-right:10px; color:#F0F0F0; font-size: 11px; } td, th, caption { font-family: "宋体"; font-size: 14px; color:#000000; LINE-HEIGHT: 165%; } .hrLine{MARGIN: 0px 0px; BORDER-BOTTOM: #807d76 1px dotted;} </style> <script> function CheckUpdate(obj){ if(confirm('确认操作?')) { obj.updatebutton.disabled=true; return true; } return false; } </script> </head> <body> <form method="GET" action="index.php" name="formupdate" onsubmit="return CheckUpdate(document.formupdate);"> <br> <br> <br> <table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#4FB4DE"> <tr> <td height="30" colspan="2"> <div align="center"><strong><font color="#FFFFFF">置顶插件安装/卸载程序</font></strong></div></td> </tr> <tr bgcolor="#FFFFFF"> <td width="141" height="36"> <div align="right">选择操作:</div></td> <td width="344"> <input name="doinstall" type="radio" value="install" checked> 安装 <input type="radio" name="doinstall" value="uninstall"> 卸载 </td> </tr> <tr bgcolor="#FFFFFF"> <td height="30"> <div align="center"></div></td> <td> <input type=submit name=updatebutton value="提交操作"> <input name="ecms" type="hidden" id="ecms" value="install"> </td> </tr> </table> </form> </body> </html>
然后是,安装页面,示范了数据表的建立和菜单的建立:
<?php if(!defined('InEmpireCMS')) { exit(); } if(file_exists("install.off")) { echo"置顶插件安装程序已锁定。如果要重新安装,请删除<b>/e/extend/zhiding/install/install.off</b>文件!"; exit(); } //------ 插件安装 ------ //存放置顶套餐的表单 $empire->query("DROP TABLE IF EXISTS `{$dbtbpre}zhiding_taocan`"); $empire->query(SetCreateTable(" CREATE TABLE `{$dbtbpre}zhiding_taocan` ( `taocanid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `taocanname` varchar(50) NOT NULL DEFAULT '' COMMENT '套餐名称', `toplong` tinyint(3) NOT NULL DEFAULT '0' COMMENT '置顶时长', `price` float(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '原价', `newprice` float(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '优惠价', `saytext` varchar(255) NOT NULL DEFAULT '' COMMENT '套餐说明', `jibie` int(2) unsigned NOT NULL DEFAULT '1' COMMENT '置顶级别', PRIMARY KEY (`taocanid`) ) ENGINE=MyISAM;",$ecms_config['db']['dbchar']) ); //置顶消费记录 $empire->query("DROP TABLE IF EXISTS `{$dbtbpre}zhiding_jilu`"); $empire->query(SetCreateTable(" CREATE TABLE `{$dbtbpre}zhiding_jilu` ( `zhidingid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `userid` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '会员id', `username` char(20) NOT NULL DEFAULT '' COMMENT '会员名', `riqi` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '置顶日期', `id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '信息id', `classid` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '栏目id', `toplong` int(3) unsigned NOT NULL DEFAULT '0' COMMENT '置顶时长', `jibie` int(2) unsigned NOT NULL DEFAULT '1' COMMENT '置顶级别', `price` float(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '价格', `ischeck` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '过期检查', PRIMARY KEY (`zhidingid`), KEY `ischeck` (`ischeck`) ) TYPE=MyISAM;",$ecms_config['db']['dbchar']) ); //增加插件菜单 $empire->query("insert into `{$dbtbpre}enewsmenuclass` values(NULL,'置顶管理','0','0','2','');"); $menuclassid=$empire->lastid(); $empire->query("insert into `{$dbtbpre}enewsmenu` values(NULL,'管理置顶记录','/e/extend/zhiding/batEditTable/batEditTable.php','0','$menuclassid',2);"); $empire->query("insert into `{$dbtbpre}enewsmenu` values(NULL,'管理置顶套餐','/e/extend/zhiding/showtaocan.php','0','$menuclassid',2);"); $empire->query("insert into `{$dbtbpre}enewsmenu` values(NULL,'管理百度推送','/e/extend/p2b/index.php','0','$menuclassid',2);"); //锁定安装程序 $fp=@fopen("install.off","w"); @fclose($fp); ?>
卸载插件的代码则是这样的:
<?php if(!defined('InEmpireCMS')) { exit(); } //------ 插件卸载 ------ if(file_exists("install.off")) { echo"插件安装程序已锁定。如果要重新安装,请删除<b>/e/extend/sms/install/install.off</b>文件!"; exit(); } $empire->query("drop table if exists `{$dbtbpre}zhiding_taocan`;"); $empire->query("drop table if exists `{$dbtbpre}zhiding_jilu`;"); //删除插件菜单 $menuclassr=$empire->fetch1("select classid from {$dbtbpre}enewsmenuclass where classname='置顶管理' limit 1"); $empire->query("delete from {$dbtbpre}enewsmenuclass where classid='$menuclassr[classid]'"); $empire->query("delete from {$dbtbpre}enewsmenu where classid='$menuclassr[classid]'"); ?>