public function __construct() { parent::__construct(); $config = $this->session->userdata("db_config"); if ($config) { $this->db = $this->load->database($config, TRUE); } }
public function __construct() { parent::__construct(); // PHP 5.3 ask for timezone, and throw a warning whenever it is not available // so, just give this one :) $timezone = @date_default_timezone_get(); if (!isset($timezone) || $timezone == '') { $timezone = @ini_get('date.timezone'); } if (!isset($timezone) || $timezone == '') { $timezone = 'UTC'; } date_default_timezone_set($timezone); // load helpers and libraries $this->load->helper('url'); $this->load->helper('html'); $this->load->helper('form'); $this->load->helper('string'); $this->load->library('user_agent'); $this->load->driver('session'); $this->load->helper('cms_helper'); $this->load->library('form_validation'); $this->load->database(); // accessing file is faster than accessing database // but I think accessing variable is faster than both of them if (self::$__cms_model_properties == NULL || defined('CMS_OVERRIDDEN_SUBSITE') && !defined('CMS_RESET_OVERRIDDEN_SUBSITE')) { self::$__cms_model_properties = array(); } $default_properties = array('session' => array(), 'language_dictionary' => array(), 'config' => array(), 'module_name' => array(), 'module_path' => array(), 'module_version' => array(), 'navigation' => array(), 'quicklink' => array(), 'widget' => array(), 'super_admin' => NULL, 'properties' => array(), 'is_config_cached' => FALSE, 'is_module_name_cached' => FALSE, 'is_module_path_cached' => FALSE, 'is_module_version_cached' => FALSE, 'is_user_last_active_extended' => FALSE, 'is_navigation_cached' => FALSE, 'is_quicklink_cached' => FALSE, 'is_widget_cached' => FALSE, 'is_language_dictionary_cached' => FALSE); foreach ($default_properties as $key => $val) { if (!array_key_exists($key, self::$__cms_model_properties)) { self::$__cms_model_properties[$key] = $val; } } if (self::$__cms_model_properties['super_admin'] === NULL) { $query = $this->db->select('user_name, real_name')->from(cms_table_name('main_user'))->where('user_id', 1)->get(); $super_admin = $query->row(); self::$__cms_model_properties['super_admin'] = $super_admin; } // kcfinder include APPPATH . 'config/main/cms_config.php'; if (array_key_exists('__cms_chipper', $config)) { $chipper = $config['__cms_chipper']; } else { $chipper = 'Love Song Storm Gravity Tonight End of Sorrow Rosier'; } $default_cookie = array('__cms_base_url' => base_url(), '__cms_subsite' => CMS_SUBSITE, '__cms_user_id' => $this->cms_user_id()); foreach ($default_cookie as $key => $val) { if (!array_key_exists(cms_encode($key, $chipper), $_COOKIE)) { setcookie(cms_encode($key, $chipper), cms_encode($val, $chipper)); } } // extend user last active status $this->__cms_extend_user_last_active($this->cms_user_id()); }
public function __construct() { parent::__construct(); // core seamless update $this->__update(); // module update if (!self::$module_updated) { self::$module_updated = TRUE; $this->__update_module(); } }
public function __construct() { parent::__construct(); // core seamless update $this->db->trans_start(); $this->__update(); $this->db->trans_complete(); // module update if (!self::$module_updated) { self::$module_updated = true; $this->__update_module(); } }
public function __construct() { parent::__construct(); $this->page_break_separator = "/<div(\\s)*style(\\s)*=(\\s)*\"page-break-after(\\s)*:(\\s)*always(;)*\"(\\s)*>(\\s)*<span(\\s)*style(\\s)*=(\\s)*\"display(\\s)*:(\\s)*none(;)*\">(\\s)* (\\s)*<\\/span>(\\s)*<\\/div>/i"; if (self::$__article_properties == NULL) { self::$__article_properties = array(); } $default_properties = array('is_article_cached' => FALSE, 'is_category_cached' => FALSE, 'is_category_article_cached' => FALSE, 'articles' => array(), 'categories' => array(), 'article_categories' => array(), 'photos' => array()); foreach ($default_properties as $key => $val) { if (!array_key_exists($key, self::$__article_properties)) { self::$__article_properties[$key] = $default_properties[$key]; } } }
public function __construct() { parent::__construct(); $this->page_break_separator = "/<div(\\s)*style(\\s)*=(\\s)*\"page-break-after(\\s)*:(\\s)*always(;)*\"(\\s)*>(\\s)*<span(\\s)*style(\\s)*=(\\s)*\"display(\\s)*:(\\s)*none(;)*\">(\\s)* (\\s)*<\\/span>(\\s)*<\\/div>/i"; }
public function __construct() { parent::__construct(); }
public function __construct() { parent::__construct(); // load helpers and libraries $this->load->helper('url'); $this->load->helper('html'); $this->load->helper('form'); $this->load->helper('string'); $this->load->library('user_agent'); $this->load->driver('session'); $this->load->helper('cms_helper'); $this->load->library('form_validation'); // for the first-time installation, it might not load main configuration even if the main configuration // is already exists. Thus we need to explicitly code it if (CMS_SUBSITE == '' && ENVIRONMENT == 'first-time' && file_exists(APPPATH . 'config/main/database.php')) { unset($db); include APPPATH . 'config/main/database.php'; $this->load->database($db['default']); } else { $this->load->database(); } // accessing file is faster than accessing database // but I think accessing variable is faster than both of them if (self::$__cms_model_properties == null || defined('CMS_OVERRIDDEN_SUBSITE') && !defined('CMS_RESET_OVERRIDDEN_SUBSITE')) { self::$__cms_model_properties = array(); } $default_properties = array('session' => array(), 'language_dictionary' => array(), 'config' => array(), 'module_name' => array(), 'module_path' => array(), 'module_version' => array(), 'navigation' => array(), 'quicklink' => array(), 'widget' => array(), 'super_admin' => null, 'group_name' => array(), 'group_id' => array(), 'properties' => array(), 'route' => array(), 'user_language' => null, 'user_theme' => null, 'is_super_admin' => false, 'is_config_cached' => false, 'is_module_name_cached' => false, 'is_module_path_cached' => false, 'is_module_version_cached' => false, 'is_user_last_active_extended' => false, 'is_navigation_cached' => false, 'is_quicklink_cached' => false, 'is_widget_cached' => false, 'is_language_dictionary_cached' => false, 'is_group_name_cached' => false, 'is_group_id_cached' => false, 'is_super_admin_cached' => false, 'is_route_cached' => false, 'is_user_language_cached' => false, 'is_user_theme_cached' => false, 'profile_pictures' => array()); foreach ($default_properties as $key => $val) { if (!array_key_exists($key, self::$__cms_model_properties)) { self::$__cms_model_properties[$key] = $val; } } // cache super_admin if (self::$__cms_model_properties['super_admin'] === null) { $query = $this->db->select('user_name, real_name, email, language, theme, last_active')->from($this->cms_user_table_name())->where('user_id', 1)->get(); $super_admin_array = $query->row_array(); self::$__cms_model_properties['super_admin'] = $super_admin_array; // also cache user language and user theme if current user is super_admin. if ($this->cms_user_id() == 1) { if (self::$__cms_model_properties['is_user_language_cached'] === false || self::$__cms_model_properties['is_user_theme_cached'] === false) { self::$__cms_model_properties['user_language'] = $super_admin_array['language']; self::$__cms_model_properties['user_theme'] = $super_admin_array['theme']; self::$__cms_model_properties['is_user_language_cached'] = true; self::$__cms_model_properties['is_user_theme_cached'] = true; // last active extended if ($super_admin_array['last_active'] >= microtime(true) - $this->last_active_tolerance) { self::$__cms_model_properties['is_user_last_active_extended'] = true; } } } } // if user is login, then cache theme and language (if user is also super admin this won't run) if ($this->cms_user_id() != '' && $this->cms_user_id() > 0) { if (self::$__cms_model_properties['is_user_language_cached'] === false || self::$__cms_model_properties['is_user_theme_cached'] === false) { $query = $this->db->select('language, theme, last_active')->from($this->cms_user_table_name())->where('user_id', $this->cms_user_id())->get(); if ($query->num_rows() > 0) { $row = $query->row(); self::$__cms_model_properties['user_language'] = $row->language; self::$__cms_model_properties['user_theme'] = $row->theme; // last active extended if ($row->last_active >= microtime(true) - $this->last_active_tolerance) { self::$__cms_model_properties['is_user_last_active_extended'] = true; } } self::$__cms_model_properties['is_user_language_cached'] = true; self::$__cms_model_properties['is_user_theme_cached'] = true; } } // KCFINDER's stuffs ========= if (!$this->input->is_ajax_request()) { // clear old secret files $clean_timer_file = APPPATH . 'config/tmp/_time.php'; if (!file_exists($clean_timer_file)) { $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$last = ' . time() . ';'; file_put_contents($clean_timer_file, $content); } include $clean_timer_file; $last == isset($last) ? $last : 0; if (time() - $last >= 300) { $files = scandir(APPPATH . 'config/tmp'); foreach ($files as $file) { if (in_array($file, array('.', '..'))) { continue; } elseif (substr($file, 0, 7) == '_secret' || substr($file, 0, 6) == '_token') { $file = APPPATH . 'config/tmp/' . $file; if (file_exists($file) && filemtime($file) < strtotime('-1 hour')) { unlink($file); } } } $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$last = ' . time() . ';'; file_put_contents($clean_timer_file, $content); } // create secret data and save $secret_data = array('__cms_base_url' => base_url(), '__cms_subsite' => CMS_SUBSITE, '__cms_user_id' => $this->cms_user_id()); $secret_data = json_encode($secret_data); // set cookie if (!isset($_COOKIE['__secret_code'])) { $secret_code = $this->cms_random_string(20); setcookie('__secret_code', $secret_code, time() + 300, '/'); } else { $secret_code = $_COOKIE['__secret_code']; } $secret_file = APPPATH . 'config/tmp/_secret_' . $secret_code . '.php'; // only rewrite secret if necessary $rewrite_secret_file = true; if (file_exists($secret_file)) { include $secret_file; $secret = isset($secret) ? $secret : ''; if ($secret == $secret_data) { $rewrite_secret_file = false; } } if ($rewrite_secret_file) { $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$secret = \'' . $secret_data . '\';'; file_put_contents($secret_file, $content); } } // END OF KCFINDER's stuffs ==== // extend user last active status $this->__cms_extend_user_last_active($this->cms_user_id()); }
public function __construct() { parent::__construct(); $this->separator = '<div style="page-break-after: always;">' . PHP_EOL . ' <span style="display: none;"> </span></div>'; }
public function __construct() { parent::__construct(); // load helpers and libraries $this->load->helper('url'); $this->load->helper('html'); $this->load->helper('form'); $this->load->helper('string'); $this->load->library('user_agent'); $this->load->driver('session'); $this->load->helper('cms_helper'); $this->load->library('form_validation'); $this->load->database(); // accessing file is faster than accessing database // but I think accessing variable is faster than both of them if (self::$__cms_model_properties == NULL || defined('CMS_OVERRIDDEN_SUBSITE') && !defined('CMS_RESET_OVERRIDDEN_SUBSITE')) { self::$__cms_model_properties = array(); } $default_properties = array('session' => array(), 'language_dictionary' => array(), 'config' => array(), 'module_name' => array(), 'module_path' => array(), 'module_version' => array(), 'navigation' => array(), 'quicklink' => array(), 'widget' => array(), 'super_admin' => NULL, 'group_name' => array(), 'group_id' => array(), 'properties' => array(), 'route' => array(), 'is_super_admin' => FALSE, 'is_config_cached' => FALSE, 'is_module_name_cached' => FALSE, 'is_module_path_cached' => FALSE, 'is_module_version_cached' => FALSE, 'is_user_last_active_extended' => FALSE, 'is_navigation_cached' => FALSE, 'is_quicklink_cached' => FALSE, 'is_widget_cached' => FALSE, 'is_language_dictionary_cached' => FALSE, 'is_group_name_cached' => FALSE, 'is_group_id_cached' => FALSE, 'is_super_admin_cached' => FALSE, 'is_route_cached' => FALSE); foreach ($default_properties as $key => $val) { if (!array_key_exists($key, self::$__cms_model_properties)) { self::$__cms_model_properties[$key] = $val; } } if (self::$__cms_model_properties['super_admin'] === NULL) { $query = $this->db->select('user_name, real_name')->from($this->cms_user_table_name())->where('user_id', 1)->get(); $super_admin = $query->row(); self::$__cms_model_properties['super_admin'] = $super_admin; } // KCFINDER's stuffs ========= if (!$this->input->is_ajax_request()) { // clear old secret files $clean_timer_file = APPPATH . 'config/tmp/_time.php'; if (!file_exists($clean_timer_file)) { $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$last = ' . time() . ';'; file_put_contents($clean_timer_file, $content); } include $clean_timer_file; $last == isset($last) ? $last : 0; if (time() - $last >= 300) { $files = scandir(APPPATH . 'config/tmp'); foreach ($files as $file) { if (in_array($file, array('.', '..'))) { continue; } else { if (substr($file, 0, 7) == '_secret' || substr($file, 0, 6) == '_token') { $file = APPPATH . 'config/tmp/' . $file; if (filemtime($file) < strtotime('-1 hour')) { unlink($file); } } } } $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$last = ' . time() . ';'; file_put_contents($clean_timer_file, $content); } // create secret data and save $secret_data = array('__cms_base_url' => base_url(), '__cms_subsite' => CMS_SUBSITE, '__cms_user_id' => $this->cms_user_id()); $secret_data = json_encode($secret_data); // set cookie if (!isset($_COOKIE['__secret_code'])) { $secret_code = $this->cms_random_string(20); setcookie('__secret_code', $secret_code, time() + 300, '/'); } else { $secret_code = $_COOKIE['__secret_code']; } $secret_file = APPPATH . 'config/tmp/_secret_' . $secret_code . '.php'; // only rewrite secret if necessary $rewrite_secret_file = TRUE; if (file_exists($secret_file)) { include $secret_file; $secret = isset($secret) ? $secret : ''; if ($secret == $secret_data) { $rewrite_secret_file = FALSE; } } if ($rewrite_secret_file) { $content = '<?php if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');' . PHP_EOL; $content .= '$secret = \'' . $secret_data . '\';'; file_put_contents($secret_file, $content); } } // END OF KCFINDER's stuffs ==== // extend user last active status $this->__cms_extend_user_last_active($this->cms_user_id()); }
public function __construct() { parent::__construct(); $this->page_break_separator = '/(<div style=\\"page-break-after: always;\\">\\s*<span style=\\"display: none;\\"> <\\/span><\\/div>)/i'; }