public function add() { if (isset($_POST['save_user_btn'])) { $row = []; if ($_GET['id']) { $row['id'] = $_GET['id']; } else { $row['create_date'] = date('Y-m-d H:i:s'); } $row['email'] = $_POST['email']; $row['user_name'] = $_POST['user_name']; $row['user_surname'] = $_POST['user_surname']; $row['user_group_id'] = $_POST['user_group_id']; if ($_POST['user_password']) { $row['user_password'] = md5($_POST['user_password']); } $this->model('backend_users')->insert($row); if ($_POST['user_password']) { $this->logOut(); $this->auth(registry::get('user')['email'], md5($_POST['user_password'])); registry::remove('user'); $this->checkAuth(); } header('Location: ' . SITE_DIR . 'users/'); exit; } $this->render('user_groups', $this->model('user_groups')->getAll()); if ($_GET['id']) { $this->render('user', $this->model('backend_users')->getById($_GET['id'])); } $this->view('users' . DS . 'add'); }
/** * @param $key * @param $value */ protected function setConfig($key, $value) { $row = $this->model('asanatt_system_config')->getByField('config_key', $key); $row['config_key'] = $key; $row['config_value'] = $value; $this->model('asanatt_system_config')->insert($row); $config = registry::get('config'); $config[$key] = $value; registry::remove('config'); registry::set('config', $config); }
/** * @param string $key * @return string */ protected function getConfig($key) { if (!$key) { return false; } if (!($value = registry::get('config')[$key])) { $config = registry::get('config'); $config[$key] = $this->model('system_config')->getByField('config_key', $key)['config_value']; registry::remove('config'); registry::set('config', $key); return $config[$key]; } else { return $value; } }
/** * @param string $model * @param null/string $table * @param null/string $db * @param null/string $user * @param null/string $password * @return model */ protected function model($model, $table = null, $db = null, $user = null, $password = null) { $models = registry::get('models'); if (!($m = $models[$model][$table])) { $model_file = ROOT_DIR . 'models' . DS . $model . '_model.php'; if (file_exists($model_file)) { $model_class = $model . '_model'; $m = new $model_class($table ? $table : $model, $db, $user, $password); } else { $m = new default_model($model); } $models[$model][$table] = $m; registry::remove('models'); registry::set('models', $models); } return $m; }
public function index_ajax() { switch ($_REQUEST['action']) { case "save_password": if ($_POST['password'] && $_POST['password'] == $_POST['repeat_password']) { $row = array('id' => registry::get('user')['id'], 'user_password' => md5($_POST['password'])); if ($this->model('asanatt_users')->insert($row)) { echo json_encode(array('status' => 1)); $this->logOut(); $this->auth(registry::get('user')['email'], md5($_POST['password'])); registry::remove('user'); $this->checkAuth(); } else { echo json_encode(array('status' => 2)); } } exit; break; } }
/** * @param mixed $value */ protected function log($value) { $log = registry::get('log'); registry::remove('log'); $log[] = print_r($value, 1); registry::set('log', $log); }