diff --git a/application/controllers/auth.php b/application/controllers/auth.php deleted file mode 100644 index e6b04486..00000000 --- a/application/controllers/auth.php +++ /dev/null @@ -1,95 +0,0 @@ -load->model('auth_model'); - - echo "
";
- echo "Querying for user...\n";
- $u = $this->auth_model->get("m0vkga");
- print_r($u);
- echo "Test hashing\n";
- echo $this->auth_model->test();
-
- }
- /*
- $this->load->model('note');
- $data['notes'] = $this->note->list_all();
-
- $this->load->view('layout/header');
- $this->load->view('notes/main', $data);
- $this->load->view('layout/footer');
- }
-
- function add() {
-
- $this->load->model('note');
-
- $this->load->library('form_validation');
-
- $this->form_validation->set_rules('title', 'Note Title', 'required');
- $this->form_validation->set_rules('content', 'Content', 'required');
-
-
- if ($this->form_validation->run() == FALSE)
- {
- $this->load->view('layout/header');
- $this->load->view('notes/add');
- $this->load->view('layout/footer');
- }
- else
- {
- $this->note->add();
-
- redirect('notes');
- }
- }
-
- function view($id) {
- $this->load->model('note');
-
- $data['note'] = $this->note->view($id);
-
- // Display
- $this->load->view('layout/header');
- $this->load->view('notes/view',$data);
- $this->load->view('layout/footer');
- }
-
- function edit($id) {
- $this->load->model('note');
- $data['id'] = $id;
-
- $data['note'] = $this->note->view($id);
-
- $this->load->library('form_validation');
-
- $this->form_validation->set_rules('title', 'Note Title', 'required');
- $this->form_validation->set_rules('content', 'Content', 'required');
-
-
- if ($this->form_validation->run() == FALSE)
- {
- $this->load->view('layout/header');
- $this->load->view('notes/edit', $data);
- $this->load->view('layout/footer');
- }
- else
- {
- $this->note->edit();
-
- redirect('notes');
- }
- }
-
- function delete($id) {
- $this->load->model('note');
- $this->note->delete($id);
-
- redirect('notes');
- }
-*/
-}
diff --git a/application/models/auth_model.php b/application/models/auth_model.php
deleted file mode 100644
index 3d46c02f..00000000
--- a/application/models/auth_model.php
+++ /dev/null
@@ -1,95 +0,0 @@
-_hash("password");
- echo "Password hashed is '".$hash."\n";
- echo "Does 'password' match '$hash'? result is ".$this->_auth("password", $hash)."\n";
-
- }
-
- // Retrieve a user
- function get($username) {
- $this->db->where('user_name', $username);
- $r = $this->db->get($this->config->item('auth_table'));
- if($r->num_rows == 1) {
- return $r->result();
- } else {
- return 0;
- }
- }
-
- function exists($username) {
- if($this->get($username)->num_rows == 0) {
- return 0;
- } else {
- return 1;
- }
- }
-
- function add($username, $password, $email, $type) {
- if(!$this->exists($username)) {
- $data = array(
- 'user_name' => $username,
- 'user_password' => $this->_hash($password),
- 'user_email' => $email,
- 'user_type' => $type
- );
-
- $this->db->insert($this->config->item('auth_table'));
- return 1;
- } else {
- return 0;
- }
- }
-
- function authenticate($username, $password) {
- $u = $this->get($username);
- if($this->_hash($password, $u['user_password'])) {
- return 1;
- } else {
- return 0;
- }
- }
-
- function set($username, $data) {
- $this->db->where('user_name', $username);
- $this->db->update($this->config->item('auth_table', $data));
- return 1;
- }
-
- private function _auth($password, $hash) {
- $h = new PasswordHash(8, FALSE);
- if($h->CheckPassword($password, $hash)) {
- return 1;
- } else {
- return 0;
- }
- }
-
- private function _hash($password) {
- $h = new PasswordHash(8, FALSE);
- $hash = $h->HashPassword($password);
- unset($h);
-
- if(strlen($hash) < 20) {
- return 0;
- } else {
- return $hash;
- }
- }
-
-}
-
-?>