defined('BASEPATH') OR exit('No direct script access allowed'); class Hb_auth { public $userData = null; public $userDataError = ''; private $salt = 'hbhslab'; function __construct(){ $this->ci =& get_instance(); $this->ci->load->database(); $this->_init(); } function _init() { $this->is_login(); } public function logout() { $this->ci->load->helper('url'); setcookie('auth-data', '', 0, '/'); return true; } private function cookie_login($user) { $auth = array( 'id' => $user['id'], 'hash' => md5($user['pass'] . $this->salt), 'remember' => $user['remember'] ?1 : 0 ); setcookie('auth-data', serialize($auth), $user['remember'] ? time()+60*60*24*360 : 0, '/'); } public function is_login() { if (isset($_COOKIE['auth-data']) && $auth = $_COOKIE['auth-data']) { if ($auth = @unserialize($auth)) { if (is_array($auth) && isset($auth['id']) && isset($auth['hash'])) { $this->ci->load->model('auth/auth_model', 'auth_model'); $user = $this->ci->auth_model->getUserById($auth['id']); if ($user && isset($user['code']) && md5($user['code'] . $this->salt) == $auth['hash']) { $user['pass'] = $user['code']; $user['remember'] = isset($auth['remember']) && $auth['remember'] ? true : false; if ($user['remember']) { $this->cookie_login($user); } $this->userData = $user; return true; } } } } return false; } public function do_login($email, $pass, $remember) { $data = array(); $this->ci->load->model('auth/auth_model', 'auth_model'); $users = $this->ci->auth_model->getUsersByEmail($email); if ($users) { foreach ($users AS $user) { $user['pass'] = $user['code']; if ((string)$user['pass'] == (string)$pass) { $user['remember'] = $remember ? true : false; $this->cookie_login($user); $this->userData = $user; return true; } else { $this->userDataError = 'Diese Lizenznummer ist ungültig'; } } } else { $this->userDataError = 'Die eingegebene E-Mail Adresse wurde nicht gefunden'; } return false; } public function do_login_fb($email, $remember) { $data = array(); $this->ci->load->model('auth/auth_model', 'auth_model'); $users = $this->ci->auth_model->getUsersByEmail($email); if ($users) { if (count($users) == 1) { foreach ($users AS $user) { $user['pass'] = $user['code']; $user['remember'] = $remember ? true : false; $this->cookie_login($user); $this->userData = $user; return true; } } } else { $this->userDataError = 'Die eingegebene E-Mail Adresse wurde nicht gefunden'; } return false; } public function setMailing($id, $mailing) { $this->ci->load->model('auth/auth_model', 'auth_model'); return $this->ci->auth_model->setUserMailing($id, $mailing); } public function update($id, $save) { $this->ci->load->model('auth/auth_model', 'auth_model'); if ($this->ci->auth_model->updUserById($id, $save)) { $user = $this->ci->auth_model->getUserById($id); $this->userData = $user; return $this->userData; } return false; } public function getUserMail() { if ($this->userData && isset($this->userData['id'])) { $this->ci->load->model('auth/auth_model', 'auth_model'); return $this->ci->auth_model->getUserMail($this->userData['id']); } return false; } public function readUserMail($id) { if ($this->userData && isset($this->userData['id'])) { $this->ci->load->model('auth/auth_model', 'auth_model'); return $this->ci->auth_model->readUserMail($this->userData['id'], $id); } return false; } public function deleteUserMail($id) { if ($this->userData && isset($this->userData['id'])) { $this->ci->load->model('auth/auth_model', 'auth_model'); return $this->ci->auth_model->deleteUserMail($this->userData['id'], $id); } return false; } } ?>
Non-existent class: Hb_auth