load->view("install.html"); } public function save() { $host = $this->input->post("host", true); $port = (int) $this->input->post("port", true); $name = $this->input->post("name", true); $prefix = $this->input->post("prefix", true); $user = $this->input->post("user", true); $pass = $this->input->post("pass", true); $admin_name = $this->input->post("admin_name", true); $admin_pass = $this->input->post("admin_pass", true); if( $port == 0 ) { $port = ""; } if( empty($host) || empty($name) || empty($user) || empty($pass) || empty($admin_name) || empty($admin_pass) ) { exit( "" ); } $this->load->helper("string"); $Encryption_Key = random_string("alnum", 12); $driver = (is_php("5.4") ? "mysqli" : "mysql"); $config = file_get_contents(FCPATH . "libraries/database.php"); $config = preg_replace("/'CS_Sqlserver','(.*?)'/", "'CS_Sqlserver','" . $host . "'", $config); $config = preg_replace("/'CS_Sqlport','(.*?)'/", "'CS_Sqlport','" . $port . "'", $config); $config = preg_replace("/'CS_Sqlname','(.*?)'/", "'CS_Sqlname','" . $name . "'", $config); $config = preg_replace("/'CS_Sqluid','(.*?)'/", "'CS_Sqluid','" . $user . "'", $config); $config = preg_replace("/'CS_Sqlpwd','(.*?)'/", "'CS_Sqlpwd','" . $pass . "'", $config); $config = preg_replace("/'CS_Dbdriver','(.*?)'/", "'CS_Dbdriver','" . $driver . "'", $config); $config = preg_replace("/'CS_SqlPrefix','(.*?)'/", "'CS_SqlPrefix','" . $prefix . "'", $config); $config = preg_replace("/'CS_Encryption_Key','(.*?)'/", "'CS_Encryption_Key','" . $Encryption_Key . "'", $config); if( !write_file(FCPATH . 'libraries/database.php', $config) ) { exit( "" ); } $mukey = random_string("alnum", 16); $web_path = str_replace("\\", "/", str_replace(getcwd(), "", FCPATH)); $config2 = file_get_contents(FCPATH . "libraries/config.php"); $config2 = preg_replace("/'Mu_Key','(.*?)'/", "'Mu_Key','" . $mukey . "'", $config2); $config2 = preg_replace("/'Admin_Name','(.*?)'/", "'Admin_Name','" . $admin_name . "'", $config2); $config2 = preg_replace("/'Admin_Code','(.*?)'/", "'Admin_Code','" . $admin_pass . "'", $config2); $config2 = preg_replace("/'Web_Path','(.*?)'/", "'Web_Path','" . $web_path . "'", $config2); if( !write_file(FCPATH . 'libraries/config.php', $config2) ) { exit( "" ); } $sql = "CREATE TABLE IF NOT EXISTS `" . $prefix . "queue` (\n\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t `vid` int(11) DEFAULT '0' COMMENT '视频ID',\n\t\t `xu` tinyint(1) DEFAULT '1' COMMENT '转码码率序号',\n\t\t `path` varchar(255) DEFAULT '' COMMENT '源文件路径',\n\t\t `jpg` varchar(255) DEFAULT '' COMMENT 'JPG图片保存路径',\n\t\t `gif` varchar(255) DEFAULT '' COMMENT 'GIF图片保存路径',\n\t\t `m3u8` varchar(255) DEFAULT '' COMMENT 'm3u8文件保存路径',\n\t\t `duration` varchar(64) DEFAULT '' COMMENT '视频时长',\n\t\t `sid` tinyint(1) DEFAULT '0' COMMENT '0待转码1转码中',\n\t\t `addtime` int(10) DEFAULT '0' COMMENT '转码开始时间',\n\t\t PRIMARY KEY (`id`),\n\t\t KEY `vid` (`vid`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='转码队列表';\n\t\t#ctcms#\n\t\tCREATE TABLE IF NOT EXISTS `" . $prefix . "class` (\n\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t `name` varchar(255) DEFAULT '' COMMENT '分类名称',\n\t\t `xid` tinyint(4) DEFAULT '10' COMMENT '排序越小越前',\n\t\t PRIMARY KEY (`id`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='分类列表';\n\t\t#ctcms#\n\t\tCREATE TABLE IF NOT EXISTS `" . $prefix . "video` (\n\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t `cid` int(11) DEFAULT '0',\n\t\t `name` varchar(255) DEFAULT '' COMMENT '视频名称',\n\t\t `pic` varchar(255) DEFAULT '' COMMENT '图片保存路径',\n\t\t `path` varchar(255) DEFAULT '' COMMENT '原文件保存路径',\n\t\t `m3u8` varchar(255) DEFAULT '' COMMENT 'm3u8文件保存路径',\n\t\t `md5` varchar(40) DEFAULT '' COMMENT '文件md5',\n\t\t `vid` varchar(64) DEFAULT '' COMMENT '自定义ID',\n\t\t `sid` tinyint(3) DEFAULT '0' COMMENT '转码状态,0待转码,1完成,2失败,3异常',\n\t\t `duration` varchar(64) DEFAULT '' COMMENT '时长',\n\t\t `size` bigint(20) DEFAULT '0' COMMENT '大小',\n\t\t `addtime` int(10) DEFAULT '0' COMMENT '上传时间',\n\t\t PRIMARY KEY (`id`),\n\t\t KEY `vid` (`vid`),\n\t\t KEY `md5` (`md5`)\n\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='上传视频记录表'"; if( is_php('5.4') ) { $mysqli = new mysqli($host, $user, $pass); if( mysqli_connect_errno() ) { exit( '' ); } if( !$mysqli->select_db($name) ) { if( !$mysqli->query("CREATE DATABASE `" . $name . "`") ) { exit( "" ); } $mysqli->select_db($name); } $mysqli->query("SET NAMES utf8"); $sqlarr = explode("#ctcms#", $sql); $i = 0; while( $i < count($sqlarr) ) { if( !empty($sqlarr[$i]) ) { $mysqli->query($sqlarr[$i]); } $i++; } } else { $lnk = mysql_connect($host, $user, $pass); if( !$lnk ) { exit( "" ); } if( !mysql_select_db($name, $lnk) ) { if( !mysql_query("CREATE DATABASE `" . $name . "`") ) { exit( "" ); } mysql_select_db($name, $lnk); } mysql_query('SET NAMES utf8', $lnk); $sqlarr = explode("#ctcms#", $sql); $i = 0; while( $i < count($sqlarr) ) { if( !empty($sqlarr[$i]) ) { mysql_query($sqlarr[$i]); } $i++; } } if( !write_file(FCPATH . 'packs/install/install.lock', 'ctcms') ) { exit( '' ); } exit( '" ); } }