function add() { $data = array('title' => 'Add User', 'view' => 'users_add'); $this->load->helper(array('form')); $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_dash'); $this->form_validation->set_rules('password', 'Password', 'trim|required'); if ($this->form_validation->run() == FALSE) { $this->load->view('template', $data); } else { htpasswd_add($this->config->item('htpasswd_file'), $this->input->post('username'), $this->input->post('password')); redirect('users'); } }
public function users_add($user) { htpasswd_add(__DIR__ . '/htpasswd.users', $user['email'], crypt($user['pass'])); }