/** * @return int */ public function activate() { $this->db->select('id, voornaam, tussenvoegsel, achternaam, email, active, admin'); $this->db->from('users'); $this->db->where('pepper', base64_decode($this->uri->rsegment(3))); $query = $this->db->get(); if (!empty($query) && $query->num_rows() > 0) { $row = $query->row_array(); if (md5($row['email']) == $this->uri->rsegment(4)) { if ($row['active'] == 0) { $data = array('active' => 1); $this->db->where('pepper', base64_decode($this->uri->rsegment(3))); $this->db->update('users', $data); $this->load->library('session'); $data = array('userid' => $row['id'], 'firstname' => Crypt::rijndaelDecrypt($row['voornaam'], base64_decode($this->uri->rsegment(3))), 'affix' => Crypt::rijndaelDecrypt($row['tussenvoegsel'], base64_decode($this->uri->rsegment(3))), 'lastname' => Crypt::rijndaelDecrypt($row['achternaam'], base64_decode($this->uri->rsegment(3))), 'email' => $row['email'], 'admin' => $row['admin']); $this->session->set_userdata($data); return 0; } else { if ($row['active'] == 1) { return 1; } } } } return 2; }