private function __update() { $old_version = cms_config('__cms_version'); $current_version = '0.7.9'; if ($old_version == $current_version) { return 0; } // get major, minor and rev version $old_version_component = explode('-', $old_version); $old_version_component = $old_version_component[0]; $old_version_component = explode('.', $old_version_component); $major_version = $old_version_component[0]; $minor_version = $old_version_component[1]; $rev_version = $old_version_component[2]; $this->load->dbforge(); // 0.7.6 if ($major_version <= '0' && $minor_version <= '7' && $rev_version < '6') { $this->__update_to_0_7_6(); } // 0.7.7 if ($major_version <= '0' && $minor_version <= '7' && $rev_version < '7') { $this->__update_to_0_7_7(); } // 0.7.8 if ($major_version <= '0' && $minor_version < -'7' && $rev_version <= '8') { $this->__update_to_0_7_8(); } // TODO : Write your upgrade script here // write new version if ($old_version !== NULL && $old_version != '' && $old_version !== $current_version) { cms_config('__cms_version', $current_version); } }
private function __update() { $old_version = cms_config('__cms_version'); $current_version = '0.7.5'; // get major, minor and rev version $old_version_component = explode('-', $old_version); $old_version_component = $old_version_component[0]; $old_version_component = explode('.', $old_version_component); $major_version = $old_version_component[0]; $minor_version = $old_version_component[1]; $rev_version = $old_version_component[2]; if ($old_version !== NULL && $old_version != '' && $old_version !== $current_version) { // write new version cms_config('__cms_version', $current_version); } }
/** * @author goFrendiAsgard * @param string name, bool raw * @return string * @desc get configuration variable */ public function cms_get_config($name, $raw = FALSE) { $value = cms_config($name); if ($value === FALSE) { if (!isset($this->__cms_model_properties['config'][$name])) { $query = $this->db->query("SELECT " . $this->db->protect_identifiers('value') . " FROM " . cms_table_name('main_config') . " WHERE\n config_name = '" . addslashes($name) . "'"); if ($query->num_rows() > 0) { $row = $query->row(); $value = $row->value; $this->__cms_model_properties['config'][$name] = $value; } else { $value = NULL; } } else { $value = $this->__cms_model_properties['config'][$name]; } cms_config($name, $value); } // if raw is false, then don't parse keyword if (!$raw && isset($value)) { $value = $this->cms_parse_keyword($value); } return $value; }
/** * @author goFrendiAsgard * @param string name, bool raw * @return string * @desc get configuration variable */ public function cms_get_config($name, $raw = FALSE) { $value = cms_config($name); if ($value === NULL || !$value) { if (!isset($this->__cms_model_properties['config'][$name])) { $query = $this->db->select('value')->from(cms_table_name('main_config'))->where('config_name', $name)->get(); if ($query->num_rows() > 0) { $row = $query->row(); $value = $row->value; $this->__cms_model_properties['config'][$name] = $value; } else { $value = NULL; } } else { $value = $this->__cms_model_properties['config'][$name]; } cms_config($name, $value); } // if raw is false, then don't parse keyword if (!$raw && isset($value)) { $value = $this->cms_parse_keyword($value); } return $value; }
function cms_decode($data, $chipper = NULL) { $chipper = $chipper === NULL ? cms_config('__cms_chipper') : $chipper; //$data_array = explode('-', $data); //$data = base64_decode(urldecode($data)); $data = urldecode($data); $data_array = array(); for ($i = 0; $i < strlen($data); $i++) { $data_array[] = ord($data[$i]); } $chipper_array = array(); for ($i = 0; $i < strlen($chipper); $i++) { $chipper_array[] = ord($chipper[$i]); } $decoded_array = _xor($data_array, $chipper_array); $decoded_str = ''; for ($i = 0; $i < count($decoded_array); $i++) { $decoded_str .= chr($decoded_array[$i]); } return $decoded_str; }
/** * @author go frendi * * @param string name, bool raw * * @return string * @desc get configuration variable */ public function cms_get_config($name, $raw = false) { $value = cms_config($name); if ($value === null || !$value) { if (!self::$__cms_model_properties['is_config_cached']) { $query = $this->db->select('value, config_name')->from(cms_table_name('main_config'))->get(); foreach ($query->result() as $row) { // get value and config_name $value = $row->value; $value = $value === null ? '' : $value; $config_name = $row->config_name; // save to cache self::$__cms_model_properties['config'][$config_name] = $value; //cms_config($config_name, $value); if ($config_name == $name) { $found = true; } } self::$__cms_model_properties['is_config_cached'] = true; } if (array_key_exists($name, self::$__cms_model_properties['config'])) { $value = self::$__cms_model_properties['config'][$name]; } else { $value = null; } } // if raw is false, then don't parse keyword if (!$raw && isset($value)) { $value = $this->cms_parse_keyword($value); } return $value; }
private function __update() { $old_version = cms_config('__cms_version'); $current_version = $this->CURRENT_VERSION; if ($old_version == $current_version) { return 0; } // get current major, minor and rev version $current_version_component = explode('-', $current_version); $current_version_component = $current_version_component[0]; $current_version_component = explode('.', $current_version_component); $current_major_version = $current_version_component[0]; $current_minor_version = $current_version_component[1]; $current_rev_version = $current_version_component[2]; // get old major, minor and rev version $old_version_component = explode('-', $old_version); $old_version_component = $old_version_component[0]; $old_version_component = explode('.', $old_version_component); $old_major_version = $old_version_component[0]; $old_minor_version = $old_version_component[1]; $old_rev_version = $old_version_component[2]; $this->load->dbforge(); if ($old_major_version <= $current_major_version) { for ($i = $old_major_version; $i <= $current_major_version; $i++) { // determine max minor version $max_minor_version = 9; $min_minor_version = 0; if ($i == $current_major_version) { $max_minor_version = $current_minor_version; } if ($i == $old_major_version) { $min_minor_version = $old_minor_version; } // do until max minor version for ($j = $min_minor_version; $j <= $max_minor_version; $j++) { // determine max minor version $max_rev_version = 9; $min_rev_version = 0; if ($i == $current_major_version && $j == $max_minor_version) { $max_rev_version = $current_rev_version; } if ($i == $old_major_version && $j == $old_minor_version) { $min_rev_version = $old_rev_version + 1; } if ($min_rev_version > 9) { break; } // do until max rev version for ($k = $min_rev_version; $k <= $max_rev_version; $k++) { $method = '__update_to_' . $i . '_' . $j . '_' . $k; if (method_exists($this, $method)) { call_user_func_array(array($this, $method), array()); } } } } } // write new version if ($old_version !== null && $old_version != '' && $old_version !== $current_version) { cms_config('__cms_version', $current_version); } }
public function _before_delete_config($primary_key) { $query = $this->db->select('config_name')->from(cms_table_name('main_config'))->where('config_id', $primary_key)->get(); if ($query->num_rows() > 0) { $row = $query->row(); $config_name = $row->config_name; // delete configuration file entry cms_config($config_name, '', true); } return true; }
function cms_table_prefix($new_prefix = NULL) { return cms_config('cms_table_prefix', $new_prefix); }
private function __update() { $old_version = cms_config('__cms_version'); $current_version = '0.8.1'; if ($old_version == $current_version) { return 0; } // get major, minor and rev version $old_version_component = explode('-', $old_version); $old_version_component = $old_version_component[0]; $old_version_component = explode('.', $old_version_component); $major_version = $old_version_component[0]; $minor_version = $old_version_component[1]; $rev_version = $old_version_component[2]; $this->load->dbforge(); // 0.7.6 if ($major_version <= '0' && $minor_version <= '7' && $rev_version < '6') { $this->__update_to_0_7_6(); } // 0.7.7 if ($major_version <= '0' && $minor_version <= '7' && $rev_version < '7') { $this->__update_to_0_7_7(); } // 0.7.8 if ($major_version <= '0' && $minor_version <= '7' && $rev_version <= '8') { $this->__update_to_0_7_8(); } // 0.8.1 if ($major_version <= '0' && $minor_version <= '8' && $rev_version <= '1') { // make extended route inclussion absolute $pattern = 'include(\'extended_routes.php\');'; if (CMS_SUBSITE == '') { $path = APPPATH . '/config/main/routes.php'; $replace = 'include(APPPATH.\'config/main/extended_routes.php\');'; } else { $path = APPPATH . '/config/site-' . CMS_SUBSITE . '/routes.php'; $replace = 'include(APPPATH.\'config/site-' . CMS_SUBSITE . '/extended_routes.php\');'; } file_put_contents($path, str_replace($pattern, $replace, file_get_contents($path))); } // TODO : Write your upgrade script here // write new version if ($old_version !== null && $old_version != '' && $old_version !== $current_version) { cms_config('__cms_version', $current_version); } }