<?php
/**
* +------------------------------------------------------------------------
* | 程序名称:贤诚建站系统
* +------------------------------------------------------------------------
* | Copyright www.mydecms.com All rights reserved.
* +------------------------------------------------------------------------
* | Author: 小贤 <e-mail:admin@mydecms.com> <QQ:306282268>
* +------------------------------------------------------------------------
* | 声明:本程序禁止未经作者商业授权之前用于商业用途,违者追究法律责任
* | 如需要用于商业用途,请联系程序作者小贤<QQ:306282268>购买程序商业授权
* +------------------------------------------------------------------------
* | 文件说明:程序安装控制器
* +------------------------------------------------------------------------
**/
class indexControl extends mydecmsClass {
public $db;//数据库链接
public $conf;//配置信息
public $config;//程序设置对象
public $template = "template/";//模板目录
public $control="index";
public $action = "index";//默认调用方法
/**
* 程序安装首页
**/
public function index()
{
if(!is_writable(MYDECMS_PATH)){
$this -> errlog("程序根目录没有写入文件权限,程序因此无法安装,请手动增加权限后再刷新本页");
}
if(!file_exists(MYDECMS_PATH.$this->template."/index.php")){
exit("没有找到对应的模板文件");
}
include MYDECMS_PATH.$this->template."/index.php";
exit();
}
/**
* 删除安装包文件
**/
public function del(){
$this -> delDir(MYDECMS_PATH);
exit('安装包文件删除完毕');
}
/**
* 第一步
**/
public function first(){
$yes = isset($_GET['yes']) ? $_GET['yes'] : "";
if($yes==''){
header("HTTP/1.1 301 Moved Permanently");
header("Location: ./index.php?c=index&a=index");
exit();
}
if(!file_exists(MYDECMS_PATH.$this->template."/first.php")){
exit("没有找到对应的模板文件");
}
include MYDECMS_PATH.$this->template."/first.php";
}
/**
* 第二步
**/
public function second(){
$mysqlhost = $this -> p("mysqlhost","localhost","2");
$mysqluser = $this -> p("mysqluser","root","2");
$mysqlpass = $this -> p("mysqlpass","","2");
$mysqldb = $this -> p("mysqldb","","2");
$mysqldbqz = $this -> p("mysqldbqz","mydecms_","2");
$admindir = $this -> p("admindir","","2");
$webadmin = $this -> p("webadmin","","2");
$webpass = $this -> p("webpass","","2");
$webname = $this -> p("webname","","2");
if($mysqldb == ""){
$this -> errlog("数据库表不能为空");
}
if($webadmin == ""){
$this -> errlog("网站管理员账号不能为空");
}
if($webpass == ""){
$this -> errlog("网站管理员密码不能为空");
}
if($webname == ""){
$this -> errlog("网站名称不能为空");
}
$conf = array(
"dbtype" => "mysql", //数据库类型
"host" => $mysqlhost, //数据库访问地址
"user" => $mysqluser, //数据库访问用户名
"pass" => $mysqlpass, //数据库访问密码
"dbname" => $mysqldb, //数据库名
"prefix" => $mysqldbqz, //表前缀
"charset"=> "utf8", //编码
"port" => "3306" //数据库连接端口
);
$url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"];
$url = dirname($url);
if($url !='') $url = substr($url,0,strpos($url,"/install"));
$this -> db = new mydecmsMysql($conf);
$this -> db -> query("drop table if exists {$conf['prefix']}adminmenu");
$this -> db -> query("drop table if exists {$conf['prefix']}article");
$this -> db -> query("drop table if exists {$conf['prefix']}cachearticle");
$this -> db -> query("drop table if exists {$conf['prefix']}category");
$this -> db -> query("drop table if exists {$conf['prefix']}control");
$this -> db -> query("drop table if exists {$conf['prefix']}friendlink");
$this -> db -> query("drop table if exists {$conf['prefix']}glspider");
$this -> db -> query("drop table if exists {$conf['prefix']}group");
$this -> db -> query("drop table if exists {$conf['prefix']}menu");
$this -> db -> query("drop table if exists {$conf['prefix']}method");
$this -> db -> query("drop table if exists {$conf['prefix']}role");
$this -> db -> query("drop table if exists {$conf['prefix']}spiderlogs");
$this -> db -> query("drop table if exists {$conf['prefix']}system");
$this -> db -> query("drop table if exists {$conf['prefix']}tag");
$this -> db -> query("drop table if exists {$conf['prefix']}tplfile");
$this -> db -> query("drop table if exists {$conf['prefix']}tplsubject");
$this -> db -> query("drop table if exists {$conf['prefix']}user");
$this -> db -> query("drop table if exists {$conf['prefix']}user_action_logs");
$this -> db -> query("drop table if exists {$conf['prefix']}user_login_logs");
$this -> db -> query("CREATE TABLE IF NOT EXISTS `{$conf['prefix']}adminmenu` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cid` int(10) NOT NULL, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `url` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, `img` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `type` int(10) NOT NULL DEFAULT '1', `sort` int(10) NOT NULL DEFAULT '11',PRIMARY KEY (`id`), KEY `name` (`name`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 COMMENT='后台权限菜单'");
$this -> db -> query("CREATE TABLE IF NOT EXISTS `{$conf['prefix']}article` ( `id` int(10) NOT NULL AUTO_INCREMENT, `cid` int(10) NOT NULL, `title` varchar(160) COLLATE utf8_unicode_ci NOT NULL, `keyword` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL, `desc` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, `img` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, `content` longtext COLLATE utf8_unicode_ci NOT NULL, `tpl` varchar(1600) COLLATE utf8_unicode_ci DEFAULT NULL, `userid` int(10) NOT NULL, `date` int(11) NOT NULL, `type` int(10) NOT NULL DEFAULT '1', `tags` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,PRIMARY KEY (`id`), UNIQUE KEY `title` (`title`), KEY `cid` (`cid`), KEY `type` (`type`), KEY `date` (`date`), KEY `userid` (`userid`), KEY `tags` (`tags`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 COMMENT='文章表'");
$this -> db -> query("CREATE TABLE IF NOT EXISTS `{$conf['prefix']}cachearticle` ( `id` int(10) NOT NULL AUTO_INCREMENT, `aid` int(10) NOT NULL, `ids` text COLLATE utf8_unicode_ci, `date` int(11) NOT NULL, `views` int(10) NOT NULL DEFAULT '0',PRIMARY KEY (`id`), UNIQUE KEY `aid` (`aid`), KEY `views` (`views`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 COMMENT='相关文章缓存表'");
$this -> db -> query("CREATE TABLE IF NOT EXISTS `{$conf['prefix']}category` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `urlname` varchar(50) COLLATE utf8_unicode_ci NOT NULL, `cid` int(10) NOT NULL DEFAULT '0', `fids` text COLLATE utf8_unicode_ci, `zids` text COLLATE utf8_unicode_ci, `tpl` varchar(200) COLLATE utf8_unicode_ci DEFAULT NULL, `title` text COLLATE utf8_unicode_ci, `keyword` varchar(160) COLLATE utf8_unicode_ci DEFAULT NULL, `desc` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL, `type` int(10) NOT NULL DEFAULT '1', `sort` int(10) NOT NULL DEFAULT '1000',PRIMARY KEY (`id`),UNIQUE KEY `urlname` (`urlname`),KEY `name` (`name`),KEY `cid` (`cid`),KEY `type` (`type`),KEY `sort` (`sort`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 COMMENT='文章分类'");
$this -> db -> query("CREATE TABLE IF NOT EXISTS `{$conf['prefix']}control` ( `id` int(10) NOT NU