/** * 全站缓存 */ public function cacheAction() { $caches = array(array('20', 'plugin', 'cache'), array('21', 'auth', 'cache'), array('103', 'ip', 'cache'), array('30', 'tag', 'cache'), array('26', 'block', 'cache'), array('27', 'theme', 'cache'), array('29', 'member', 'cache'), array('25', 'relatedlink', 'cache')); $sites = App::get_site(); $body = "<?php" . PHP_EOL . "if (!defined('IN_FINECMS')) exit();" . PHP_EOL . PHP_EOL . "/**" . PHP_EOL . " * 多站点域名配置文件" . PHP_EOL . " */" . PHP_EOL . "return array(" . PHP_EOL . PHP_EOL; $body2 = "<?php" . PHP_EOL . "if (!defined('IN_FINECMS')) exit();" . PHP_EOL . PHP_EOL . "/**" . PHP_EOL . " * 移动端域名配置文件" . PHP_EOL . " */" . PHP_EOL . "return array(" . PHP_EOL . PHP_EOL; foreach ($sites as $id => $t) { $body .= "\t'" . $id . "' => '" . $t['DOMAIN'] . "', " . PHP_EOL; if ($t['SITE_MURL']) { $body2 .= "\t'" . $id . "' => '" . $t['SITE_MURL'] . "', " . PHP_EOL; } } $body .= PHP_EOL . ");"; $body2 .= PHP_EOL . ");"; file_put_contents(CONFIG_DIR . 'site.ini.php', $body); file_put_contents(CONFIG_DIR . 'mobile.ini.php', $body2); // $count = count($sites); //多网站模型缓存 foreach ($sites as $sid => $t) { $caches[] = array('22', 'model', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站栏目缓存 foreach ($sites as $sid => $t) { $caches[] = array('23', 'category', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站推荐位缓存 foreach ($sites as $sid => $t) { $caches[] = array('24', 'position', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站联动菜单缓存 foreach ($sites as $sid => $t) { $caches[] = array('28', 'linkage', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } if ($this->get('show')) { $this->cache->delete('install'); //删除安装提示文件 $this->content->clear_cache_id(); //清理内容id缓存 $form = $this->model('form'); //实例化表单对象 $form->clear_cache_id(); //清理表单id缓存 $version = CMS_VERSION; //生成版本标识符 if (substr_count($version, '.') == 1) { $version .= '.0'; } $this->cache->set('version', str_replace('.', '', $version)); // 删除全部缓存文件 $this->load->helper('file'); delete_files(FCPATH . 'cache/models/'); delete_files(FCPATH . 'cache/views/'); } else { $this->view->assign('caches', $caches); $this->view->display('admin/cache'); } }
public function __construct() { parent::__construct(); $this->user = $this->model('user'); $this->isAdminLogin(); if (!auth::check($this->roleid, $this->controller . '-' . $this->action, $this->namespace)) { $this->adminMsg(lang('a-com-0', array('1' => $this->controller, '2' => $this->action))); } $sites = App::get_site(); $this->site_url = 'http://' . $sites[$this->siteid]['DOMAIN']; $this->view->assign(array('userinfo' => $this->userinfo, 'site_url' => $this->site_url)); $this->adminLog(); }
/** * 全站缓存 */ public function cacheAction() { $caches = array(array('20', 'plugin', 'cache'), array('21', 'auth', 'cache'), array('103', 'ip', 'cache'), array('30', 'tag', 'cache'), array('26', 'block', 'cache'), array('27', 'theme', 'cache'), array('29', 'member', 'cache'), array('25', 'relatedlink', 'cache')); $sites = App::get_site(); $count = count($sites); //多网站模型缓存 foreach ($sites as $sid => $t) { $caches[] = array('22', 'model', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站栏目缓存 foreach ($sites as $sid => $t) { $caches[] = array('23', 'category', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站推荐位缓存 foreach ($sites as $sid => $t) { $caches[] = array('24', 'position', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } //多网站联动菜单缓存 foreach ($sites as $sid => $t) { $caches[] = array('28', 'linkage', 'cache', array('site' => $sid, 'text' => '(' . $sid . '/' . $count . ')')); } if ($this->get('show')) { $this->cache->delete('install'); //删除安装提示文件 $this->content->clear_cache_id(); //清理内容id缓存 $form = $this->model('form'); //实例化表单对象 $form->clear_cache_id(); //清理表单id缓存 $version = CMS_VERSION; //生成版本标识符 if (substr_count($version, '.') == 1) { $version .= '.0'; } $this->cache->set('version', str_replace('.', '', $version)); // 删除全部缓存文件 $this->load->helper('file'); delete_files(FCPATH . 'cache/models/'); delete_files(FCPATH . 'cache/views/'); } else { $this->view->assign('caches', $caches); $this->view->display('admin/cache'); } }
public function __construct() { parent::__construct(); define('IS_FC_ADMIN', intval(SYS_MODE)); if (SYS_MODE == 1) { // 中级 } elseif (SYS_MODE == 2) { // 高级 } else { // 初级 } $this->user = $this->model('user'); $this->isAdminLogin(); if (!auth::check($this->roleid, $this->controller . '-' . $this->action, $this->namespace)) { $this->adminMsg(lang('a-com-0', array('1' => $this->controller, '2' => $this->action))); } $sites = App::get_site(); $this->site_url = 'http://' . $sites[$this->siteid]['DOMAIN']; $this->view->assign(array('userinfo' => $this->userinfo, 'site_url' => $this->site_url)); //print_r($this->site_url); //exit; $this->adminLog(); }
public function __construct() { parent::__construct(); if (!file_exists(APP_ROOT . './cache/install.lock')) { $this->redirect(url('install/')); } $system_cms = $this->load_config('version'); require_once SYS_ROOT . 'libraries/cache_file.class.php'; $this->cache = new cache_file(); App::$namespace = $this->namespace = trim($this->router->directory, '/'); App::$controller = $this->controller = $this->router->class; App::$action = $this->action = $this->router->method; App::$plugin = APP_DIR; $this->_init(); $this->load->model('category'); $this->cats = $this->get_category(); $this->cats_dir = $this->get_category_dir(); $this->content = Controller::model('content'); $this->content->table_name = $this->content->prefix . 'content_' . $this->siteid; //定义网站常量 define('IS_POST', $this->post('submit')); define('SITE_PATH', $this->get_base_url()); define('SITE_URL', $this->get_server_name() . $this->get_base_url()); define('CMS_CMS', $system_cms['cms']); define('CMS_NAME', $system_cms['name']); define('CMS_COM', $system_cms['company']); define('CMS_VERSION', $system_cms['version']); define('CMS_UPDATE', $system_cms['update']); define('SITE_THEME', $this->get_theme_url()); define('ADMIN_THEME', SITE_PATH . basename(VIEW_DIR) . '/admin/'); define('EXT_PATH', SITE_PATH . EXTENSION_PATH . '/'); define('LANG_PATH', SITE_PATH . EXTENSION_PATH . '/language/' . SYS_LANGUAGE . '/'); //禁止访问 $ips = $this->cache->get('ip'); $uip = $this->input->ip_address(); if ($uip && $ips && is_array($ips)) { if (isset($ips[$uip]) && (empty($ips[$uip]['endtime']) || $ips[$uip]['endtime'] - $ips[$uip]['addtime'] >= 0)) { $this->adminMsg(lang('a-aip-6')); } foreach ($ips as $ip => $t) { if (empty($ip) || strpos($ip, '*') === false) { continue; } if (preg_match('/^' . str_replace(array('*', '.'), array('[0-9]+', '\\.'), $ip) . '$/', $uip)) { $this->adminMsg(lang('a-aip-6')); } } unset($ips, $ip); } $this->template = $this->view = new View(); //载入会员系统缓存 if (!$this->site['SYS_MEMBER'] && is_dir(CONTROLLER_DIR . 'member')) { $this->member = Controller::model('member'); $this->membergroup = $this->cache->get('membergroup'); $this->membermodel = $this->cache->get('model_member'); $this->memberconfig = $this->cache->get('member'); if ($this->memberconfig['uc_use'] == 1 && $this->namespace != 'admin') { include EXTENSION_DIR . 'ucenter' . DIRECTORY_SEPARATOR . 'config.inc.php'; include EXTENSION_DIR . 'ucenter' . DIRECTORY_SEPARATOR . 'uc_client' . DIRECTORY_SEPARATOR . 'client.php'; } $this->memberinfo = $this->getMember(); $this->view->assign(array('memberinfo' => $this->memberinfo, 'membergroup' => $this->membergroup, 'membermodel' => $this->membermodel, 'memberconfig' => $this->memberconfig)); } define('IS_ADMIN', $this->session->userdata('user_id')); $this->view->assign($this->site); $this->view->assign(array('s' => $this->namespace, 'c' => $this->controller, 'a' => $this->action, 'cats' => $this->cats, 'param' => $this->getParam(), 'sites' => App::get_site(), 'siteid' => $this->siteid, 'is_admin' => IS_ADMIN)); //加载系统函数库和自定义函数库 require EXTENSION_DIR . 'function.php'; require EXTENSION_DIR . 'custom.php'; date_default_timezone_set(SYS_TIME_ZONE); // if (!get_cookie('sb') && $this->db->query("SHOW TABLES LIKE '" . $this->db->dbprefix . "sb'")->row_array()) { $data = $this->db->limit(5)->order_by('id desc')->get('sb')->result_array(); if ($data) { set_cookie('sb', 1, 600); $delete = array(); foreach ($data as $t) { $value = string2array($t['value']); if ($t['type'] == 'content_add') { // 文章推送到baidping if (function_exists('curl_init')) { $url = 'http://ping.baidu.com/ping/RPC2'; $xml = "\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <methodCall>\n <methodName>weblogUpdates.extendedPing</methodName>\n <params>\n <param>\n <value><string>" . $data['title'] . "</string></value>\n </param>\n <param>\n <value><string>" . SITE_URL . "</string></value>\n </param>\n <param>\n <value><string>" . $data['url'] . "</string></value>\n </param>\n <param>\n <value><string></string></value>\n </param>\n </params>\n </methodCall>"; $ch = curl_init(); $head = array("POST " . $url . " HTTP/1.0", "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Content-length: " . strlen($xml)); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $head); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); $res = curl_exec($ch); curl_close($ch); if (strpos($res, "<int>0</int>")) { $delete[] = $t['id']; } } } if ($delete) { $this->db->where_in('id', $delete)->delete('sb'); } } } } }
/** * 网站地图sitemap */ function sitemap($data) { if (empty($data)) { return false; } $sites = App::get_site(); $file = count($sites) > 1 ? 'sitemap_' . App::get_site_id() . '.xml' : 'sitemap.xml'; $header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\t<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"; $footer = "\t</urlset>\n"; $map = $header . "\n"; foreach ($data as $item) { $map .= "\t\t<url>\n\t\t\t<loc>http://" . $_SERVER['HTTP_HOST'] . htmlspecialchars(strip_tags($item['url'])) . "</loc>\n"; $map .= "\t\t\t<lastmod>" . date('Y-m-d', $item['updatetime']) . "</lastmod>\n"; $map .= "\t\t\t<changefreq>daily</changefreq>\n"; $map .= "\t\t\t<priority>1.0</priority>\n"; $map .= "\t\t</url>\n\n"; } $map .= $footer . "\n"; unset($data); file_put_contents(APP_ROOT . $file, $map, LOCK_EX); }
public function __construct() { parent::__construct(); $system_cms = $this->load_config('version'); require_once SYS_ROOT . 'libraries/cache_file.class.php'; $this->cache = new cache_file(); App::$namespace = $this->namespace = trim($this->router->directory, '/'); App::$controller = $this->controller = $this->router->class; App::$action = $this->action = $this->router->method; App::$plugin = APP_DIR; $this->_init(); $this->load->model('category'); $this->cats = $this->get_category(); $this->cats_dir = $this->get_category_dir(); $this->content = Controller::model('content'); $this->content->table_name = $this->content->prefix . 'content_' . $this->siteid; //var_dump(strstr($_SERVER['HTTP_HOST'],$_SERVER['SERVER_NAME'])); if (strstr($_SERVER['HTTP_HOST'], $_SERVER['SERVER_NAME'])) { $siteUrl = $this->get_server_name() . $this->get_base_url(); $sitepath = $this->get_base_url(); define('PROXY_PATH', ''); } else { $siteUrl = $_SERVER['HTTP_HOST'] . '/' . $_SERVER['HTTP_REFERER'] . '/'; define('PROXY_PATH', 'http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['HTTP_REFERER']); $sitePath = 'http://' . $siteUrl; foreach ($this->cats as $k => $value) { $this->cats[$k]['url'] = PROXY_PATH . $value['url']; } } //定义网站常量 define('IS_POST', $this->post('submit')); define('SITE_PATH', $sitePath); define('SITE_URL', $siteUrl); define('CMS_CMS', $system_cms['cms']); define('CMS_NAME', $system_cms['name']); define('CMS_COM', $system_cms['company']); define('CMS_VERSION', $system_cms['version']); define('CMS_UPDATE', $system_cms['update']); define('SITE_THEME', "." . $this->get_theme_url()); define('ADMIN_THEME', SITE_PATH . basename(VIEW_DIR) . '/admin/'); define('EXT_PATH', SITE_PATH . EXTENSION_PATH . '/'); define('LANG_PATH', SITE_PATH . EXTENSION_PATH . '/language/' . SYS_LANGUAGE . '/'); //echo '=============='.SITE_THEME;exit; //echo SITE_PATH; //禁止访问 $ips = $this->cache->get('ip'); $uip = $this->input->ip_address(); if ($uip && $ips && is_array($ips)) { if (isset($ips[$uip]) && (empty($ips[$uip]['endtime']) || $ips[$uip]['endtime'] - $ips[$uip]['addtime'] >= 0)) { $this->adminMsg(lang('a-aip-6')); } foreach ($ips as $ip => $t) { if (empty($ip) || strpos($ip, '*') === false) { continue; } if (preg_match('/^' . str_replace(array('*', '.'), array('[0-9]+', '\\.'), $ip) . '$/', $uip)) { $this->adminMsg(lang('a-aip-6')); } } unset($ips, $ip); } $this->template = $this->view = new View(); //载入会员系统缓存 if (!$this->site['SYS_MEMBER'] && is_dir(CONTROLLER_DIR . 'member')) { $this->member = Controller::model('member'); $this->membergroup = $this->cache->get('membergroup'); $this->membermodel = $this->cache->get('model_member'); $this->memberconfig = $this->cache->get('member'); if ($this->memberconfig['uc_use'] == 1 && $this->namespace != 'admin') { include EXTENSION_DIR . 'ucenter' . DIRECTORY_SEPARATOR . 'config.inc.php'; include EXTENSION_DIR . 'ucenter' . DIRECTORY_SEPARATOR . 'uc_client' . DIRECTORY_SEPARATOR . 'client.php'; } $this->memberinfo = $this->getMember(); $this->view->assign(array('memberinfo' => $this->memberinfo, 'membergroup' => $this->membergroup, 'membermodel' => $this->membermodel, 'memberconfig' => $this->memberconfig)); } define('IS_ADMIN', $this->session->userdata('user_id')); $this->view->assign($this->site); $this->view->assign(array('s' => $this->namespace, 'c' => $this->controller, 'a' => $this->action, 'cats' => $this->cats, 'param' => $this->getParam(), 'sites' => App::get_site(), 'siteid' => $this->siteid, 'is_admin' => IS_ADMIN)); //加载系统函数库和自定义函数库 require EXTENSION_DIR . 'function.php'; require EXTENSION_DIR . 'custom.php'; date_default_timezone_set(SYS_TIME_ZONE); $this->load->library('user_agent'); }
/** * 生成首页 */ public function indexcAction() { ob_start(); $this->view->assign(array('indexc' => 1, 'meta_title' => $this->site['SITE_TITLE'], 'meta_keywords' => $this->site['SITE_KEYWORDS'], 'meta_description' => $this->site['SITE_DESCRIPTION'])); $this->view->setTheme(true); $this->view->display('index'); $this->view->setTheme(false); $sites = App::get_site(); if (count($sites) > 1) { $size = file_put_contents(APP_ROOT . 'cache/index/' . $this->siteid . '.html', ob_get_clean(), LOCK_EX); @unlink(APP_ROOT . 'index.html'); } else { $size = file_put_contents(APP_ROOT . 'index.html', ob_get_clean(), LOCK_EX); } $this->adminMsg(lang('a-con-107') . '(' . formatFileSize($size) . ')', '', 3, 1, 1); }
/** * 数据更新程序 */ public function indexAction() { $this->adminMsg('网站更新完成,请登陆后台更新全站缓存', '', 3, 1, 1); exit; $page = (int) $this->input->get('page'); if (!$page) { $this->adminMsg('正在为您清空全站数据...', dr_url('update/index', array('page' => $page + 1)), 3, 1, 2); } exit; switch ($page) { case 1: // 删除表 $_table = $this->db->query("SHOW TABLE STATUS FROM `{$this->db->database}`")->result_array(); foreach ($_table as $t) { if (strpos($t['Name'], $this->db->dbprefix) === 0) { // 删除内容表 if (strpos($t['Name'], $this->db->dbprefix . 'content_') === 0 && $t['Name'] != $this->db->dbprefix . 'content_1') { $this->db->query("DROP TABLE " . $t['Name']); } // 删除表单表 if (strpos($t['Name'], $this->db->dbprefix . 'form_') === 0) { $this->db->query("DROP TABLE " . $t['Name']); } } } // 删除内容 $this->db->query('TRUNCATE `' . $this->db->dbprefix . 'content_1`'); $this->db->query('TRUNCATE `' . $this->db->dbprefix . 'category`'); $this->db->query('TRUNCATE `' . $this->db->dbprefix . 'block`'); $this->db->query('TRUNCATE `' . $this->db->dbprefix . 'position`'); $this->db->query('TRUNCATE `' . $this->db->dbprefix . 'position_data`'); // 删除站点 $site = App::get_site(); if (count($site) > 1) { foreach ($site as $i => $t) { if ($i != 1) { @unlink(FCPATH . 'config/site/' . $i . '.ini.php'); } } } // 删除模型 $data = $this->db->get('model')->result_array(); if ($data) { $mid = array(); foreach ($data as $t) { if (strpos($t['tablename'], 'content_') === 0) { // 内容模型 $mid[] = $t['modelid']; } elseif (strpos($t['tablename'], 'form_') === 0) { // 表单模型 $mid[] = $t['modelid']; } } if ($mid) { $this->db->where_in('modelid', $mid)->delete('model'); $this->db->where_in('modelid', $mid)->delete('model_field'); } } $this->adminMsg('正在导入默认数据...', dr_url('update/index', array('page' => $page + 1)), 3, 1, 2); break; case 2: $this->adminMsg('正在导入默认数据...', dr_url('update/index', array('page' => $page + 1)), 3, 1, 2); break; default: $this->adminMsg('网站更新完成,请登陆后台更新全站缓存', '', 3, 1, 1); break; } }
public function getSiteId($site = 0) { $site = $site ? $site : App::get_site_id(); $sites = App::get_site(); return $sites[$site]['SITE_EXTEND_ID'] ? $sites[$site]['SITE_EXTEND_ID'] : $site; }
/** * 删除站点 */ public function delAction($id = 0, $show = 0) { if (!auth::check($this->roleid, 'site-del', 'admin')) { $this->adminMsg(lang('a-com-0', array('1' => 'site', '2' => 'del'))); } $site = $id ? $id : (int) $this->get('id'); if ($show && empty($site)) { $this->adminMsg(lang('a-sit-28')); } if ($site == 1) { return false; } //删除内容表 $this->delete_table('content_{site}', $site); //删除内容扩展 $this->delete_table('content_{site}_extend', $site); //删除内容审核 $this->delete_table('content_{site}_verify', $site); //删除自定义模型表中数据 $model = $this->get_model('content'); if ($model) { foreach ($model as $t) { $this->delete_table(preg_replace('/\\_([0-9]+)\\_/', '_{site}_', $t['tablename']), $site); } } //删除自定义表单中数据 $model = $this->get_model('form'); if ($model) { foreach ($model as $t) { $this->delete_table(preg_replace('/\\_([0-9]+)\\_/', '_{site}_', $t['tablename']), $site); } } //删除模型 $this->content->set_table_name('model'); $this->content->delete('site=' . $site); //删除栏目数据 $this->content->set_table_name('category'); $this->content->delete('site=' . $site); //删除block $this->content->set_table_name('block'); $this->content->delete('site=' . $site); //删除position $this->content->set_table_name('position'); $this->content->delete('site=' . $site); //删除linkage $this->content->set_table_name('linkage'); $this->content->delete('keyid<>0 AND site=' . $site); //删除网站配置文件 @unlink(CONFIG_DIR . 'site' . DIRECTORY_SEPARATOR . $site . '.ini.php'); //删除网站域名文件 $data = App::get_site(); unset($data[$site]); $this->set_site_url($data); @unlink(APP_ROOT . 'cache/index/' . $site . '.html'); $show or $this->adminMsg(lang('success'), purl('site/index'), 3, 1, 1); }
public function del($data) { $this->delete('fieldid=' . $data['fieldid']); if (in_array($data['formtype'], array('merge')) || $data['merge']) { return true; } //不处理的字段 //删除附表结构 $model = $this->from('model')->where('modelid=' . $data['modelid'])->select(false); if (empty($model)) { return false; } $table = $this->prefix . $model['tablename']; $sql = "ALTER TABLE `" . $table . "` DROP `" . $data['field'] . "`"; $this->query($sql); //删除多站点 $sites = App::get_site(); if (count($sites) > 1) { foreach ($sites as $sid => $t) { if ($model['site'] != $sid && $t['SITE_EXTEND_ID'] == $model['site']) { $sitetable = $this->prefix . preg_replace('/\\_([0-9]+)\\_/', '_' . $sid . '_', $model['tablename']); $this->query(str_replace($table, $sitetable, $sql)); } } } return true; }
public function del($data) { $table = $this->prefix . $data['tablename']; $this->query('DROP TABLE IF EXISTS `' . $table . '`'); $this->delete('modelid=' . $data['modelid']); $this->del_model($data['tablename']); $this->query('DELETE FROM `' . $this->prefix . 'model_field` where modelid=' . $data['modelid']); //删除多站点 $sites = App::get_site(); $config = App::get_config(); foreach ($sites as $sid => $t) { if ($t['SITE_EXTEND_ID'] == $data['site'] || $data['site'] == $sid) { //继承网站则同步删除模型 $table = preg_replace('/\\_([0-9]+)\\_/', '_' . $sid . '_', $data['tablename']); $this->query('DROP TABLE IF EXISTS `' . $this->prefix . $table . '`'); $this->del_model($table); } } //删除栏目 $this->query('DELETE FROM `' . $this->prefix . 'category` where modelid=' . $data['modelid']); }