public function themeDetail($theme_name) { $theme = D("Theme")->where(array("theme_name" => $theme_name))->find(); if (!$theme) { $this->error("主题尚未安装"); } $config = json_decode($theme['theme_config'], true); $tpl_static_path = WEB_ROOT . 'Public/' . $theme_name . '/'; $theme_xml_path = $tpl_static_path . 'theme.xml'; if (file_exists($theme_xml_path)) { $theme_xml = File::readFile($theme_xml_path); $theme_obj = simplexml_load_string($theme_xml); $theme_temp = object_to_array($theme_obj); $this->assign("theme_xml", $theme_temp); } $this->assign("config", $config); $this->assign("theme", $theme); $this->assign("action", $theme['theme_name'] . "主题详细"); $this->display("themedetail"); }
/** * @param $filename */ public function catImport($filename) { if (!file_exists($filename)) { exit; } $file_content = File::readFile($filename); $wordpress_xml = new \SimpleXMLElement($file_content); $wordpress_channel = $wordpress_xml->channel->children('wp', true); foreach ($wordpress_channel as $key => $value) { if ($value->category_nicename != '') { $value->cat_name = simplexml_load_string($value->cat_name->asXML(), 'SimpleXMLElement', LIBXML_NOCDATA); $item = object_to_array($value); $cat_temp = array(); $cat_temp['cat_id'] = $item['term_id']; $cat_temp['cat_slug'] = $item['category_nicename']; $cat_temp['cat_name'] = $item['cat_name']; $cat_father = D('Cats', 'Logic')->detail($item['category_parent']); $cat_temp['cat_father'] = (int) $cat_father['cat_id']; D('Cats', 'Logic')->data($cat_temp)->add(); } } }
/** * */ public function step4() { $time = date("Y-m-d H:m:s"); $db_host = $_POST["db_host"]; $db_port = $_POST["db_port"]; $db_user = $_POST["db_user"]; $db_password = $_POST["db_password"]; $db_name = $_POST["db_name"]; $db_prefix = $_POST["db_prefix"]; if ($_POST['admin_password'] != $_POST['admin_password2'] || trim($_POST['admin_password']) == '' || trim($_POST['admin_password2']) == '') { $this->error("两次输入的密码不一致,请重新设定!,或者密码为空"); } else { $admin_user = $_POST['admin_user']; $admin_password = encrypt($_POST['admin_password']); $admin_email = $_POST['admin_email']; $user_session = encrypt($admin_user . $admin_password . time()); } $title = $_POST['cfg_title']; $site_url = $_POST['cfg_basehost'] . $_POST['cfg_cmspath']; if (!test_db_connect($db_host . ":" . $db_port, $db_user, $db_password)) { $this->error("数据库服务器或登录密码无效,\n\n无法连接数据库,请重新设定!"); } $conn = mysql_connect($db_host . ":" . $db_port, $db_user, $db_password); mysql_query("CREATE DATABASE IF NOT EXISTS `" . $db_name . "`;", $conn); if (!mysql_select_db($db_name)) { $this->error("选择数据库失败,可能是你没权限,请预先创建一个数据库!"); } mysql_query("set character set 'utf8'"); mysql_query("set names 'utf8'"); $file = WEB_ROOT . 'Data/Install/db_config_sample.php'; if (!File::file_exists($file)) { $this->error('Data/Install/db_config_sample.php文件不存在,请检查'); } $content = File::readFile($file); $content = str_replace("~dbhost~", $db_host, $content); $content = str_replace("~dbport~", $db_port, $content); $content = str_replace("~dbname~", $db_name, $content); $content = str_replace("~dbuser~", $db_user, $content); $content = str_replace("~dbpwd~", $db_password, $content); $content = str_replace("~dbprefix~", $db_prefix, $content); if (!File::writeFile(WEB_ROOT . 'db_config.php', $content, 'w+')) { $this->error("数据库配置文件写入失败,请您手动根据Data/Install/db_config_sample.php文件在根目录创建文件"); } File::makeDir(WEB_ROOT . 'Data/Cache'); $sql_empty = File::readFile(WEB_ROOT . 'Data/Install/greencms_empty.sql'); $sql_query = str_replace('{$db_prefix}', $db_prefix, $sql_empty); $file = WEB_ROOT . 'Data/Cache/greencms_sample.sql'; File::writeFile($file, $sql_query, 'w+'); insertDB($file, $conn); File::delFile($file); $sql_empty = File::readFile(WEB_ROOT . 'Data/Install/greencms_init.sql'); $sql_query = str_replace('{$db_prefix}', $db_prefix, $sql_empty); $file2 = WEB_ROOT . 'Data/Cache/greencms_init_sample.sql'; File::writeFile($file2, $sql_query, 'w+'); insertDB($file2, $conn); File::delFile($file2); /** * 插入管理员数据&更新配置 */ $admin_query = "INSERT INTO `{$db_prefix}user` (`user_id`, `user_login`, `user_pass`, `user_nicename`, `user_email`,\n `user_url`, `user_registered`, `user_activation_key`, `user_status`, `user_intro`,\n `user_level`, `user_session`) VALUES(1, '{$admin_user}', '" . $admin_password . "', '管理员', '{$admin_email}',\n '', '{$time}', '', 1, '我是admin,欢迎使用', 2, '{$user_session}');"; if (!mysql_query($admin_query, $conn)) { $this->error(' 插入管理员数据出错'); } $cquery = "Update `{$db_prefix}options` set option_value='{$title}' where option_name='title';"; if (!mysql_query($cquery, $conn)) { $this->error(' 更新配置数据出错'); } $cquery = "Update `{$db_prefix}options` set option_value='{$site_url}' where option_name='site_url';"; if (!mysql_query($cquery, $conn)) { $this->error(' 更新配置数据出错'); } $software_version = GreenCMS_Version; $software_build = GreenCMS_Build; $cquery = "Update `{$db_prefix}options` set option_value='{$software_version}' where option_name='software_version';"; if (!mysql_query($cquery, $conn)) { $this->error(' 更新配置数据出错'); } $cquery = "Update `{$db_prefix}options` set option_value='{$software_build}' where option_name='software_build';"; if (!mysql_query($cquery, $conn)) { $this->error(' 更新配置数据出错'); } //TODO 写不下去了 $this->redirect('Install/Index/step5'); }