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'); } } } } }
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'); }