function config($params = array()) { // if saving... if ($_SERVER['REQUEST_METHOD'] == "POST") { // loop through all the other data and reorganise them properly foreach ($params as $k => $v) { // exit if the values is empty (but not false)? if (empty($v) && $v != "0") { continue; } // get the controller from the field name $name = explode("|", $k); if (count($name) < 2) { continue; } $table = $name[0]; $key = $name[1]; //#25 - encrypting 'password' fields $cipher = is_null(CIPHER) ? $v : CIPHER; $value = $key == "admin_password" ? crypt($v, $cipher) : $v; // only save the data that has changed if ($GLOBALS["config"][$table][$key] != $value) { $config = new Config(0, $table); // find the entry with the right key $config->retrieve_one("key=?", $key); //$config->pkname = 'key'; $config->set('key', $key); $config->set('value', $value); // update model $config->update(); // update memory $GLOBALS["config"][$table][$key] = $value; } } // generate the humans.txt file $humans = $this->humansText(); // redirect back to the configuration page header('Location: ' . url('admin/config')); } else { // show the configuration //$this->data['body']['admin']=View::do_fetch( getPath('views/admin/config.php'),$this->data); $data['view'] = getPath('views/admin/config.php'); $this->data['status'] = "config"; $this->data['body'][] = $data; $this->data['template'] = ADMIN_TEMPLATE; // display the page Template::output($this->data); } }