Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.5.0
- * @ Author : DeZender
- * @ Release on : 09.06.2012
- * @ Official site : http://DeZender.Net
- *
- */
- class DX_Auth {
- var $_banned = null;
- var $_ban_reason = null;
- var $_auth_error = null;
- var $_captcha_image = null;
- function DX_Auth() {
- $this->ci = &get_instance( );
- log_message( 'debug', 'DX Auth Initialized' );
- $this->ci->load->library( 'Session' );
- $this->ci->load->database( );
- $this->ci->load->config( 'dx_auth' );
- $this->ci->load->library( 'DX_Auth_Event' );
- $this->ci->load->model( 'Email_model' );
- $this->_init( );
- }
- function _init() {
- $this->email_activation = $this->ci->config->item( 'DX_email_activation' );
- $this->allow_registration = $this->ci->config->item( 'DX_allow_registration' );
- $this->captcha_registration = $this->ci->config->item( 'DX_captcha_registration' );
- $this->captcha_login = $this->ci->config->item( 'DX_captcha_login' );
- $this->banned_uri = $this->ci->config->item( 'DX_banned_uri' );
- $this->deny_uri = $this->ci->config->item( 'DX_deny_uri' );
- $this->login_uri = $this->ci->config->item( 'DX_login_uri' );
- $this->logout_uri = $this->ci->config->item( 'DX_logout_uri' );
- $this->register_uri = $this->ci->config->item( 'DX_register_uri' );
- $this->activate_uri = $this->ci->config->item( 'DX_activate_uri' );
- $this->forgot_password_uri = $this->ci->config->item( 'DX_forgot_password_uri' );
- $this->reset_password_uri = $this->ci->config->item( 'DX_reset_password_uri' );
- $this->change_password_uri = $this->ci->config->item( 'DX_change_password_uri' );
- $this->cancel_account_uri = $this->ci->config->item( 'DX_cancel_account_uri' );
- $this->login_view = $this->ci->config->item( 'DX_login_view' );
- $this->register_view = $this->ci->config->item( 'DX_register_view' );
- $this->forgot_password_view = $this->ci->config->item( 'DX_forgot_password_view' );
- $this->change_password_view = $this->ci->config->item( 'DX_change_password_view' );
- $this->cancel_account_view = $this->ci->config->item( 'DX_cancel_account_view' );
- $this->deny_view = $this->ci->config->item( 'DX_deny_view' );
- $this->banned_view = $this->ci->config->item( 'DX_banned_view' );
- $this->logged_in_view = $this->ci->config->item( 'DX_logged_in_view' );
- $this->logout_view = $this->ci->config->item( 'DX_logout_view' );
- $this->register_success_view = $this->ci->config->item( 'DX_register_success_view' );
- $this->activate_success_view = $this->ci->config->item( 'DX_activate_success_view' );
- $this->forgot_password_success_view = $this->ci->config->item( 'DX_forgot_password_success_view' );
- $this->reset_password_success_view = $this->ci->config->item( 'DX_reset_password_success_view' );
- $this->change_password_success_view = $this->ci->config->item( 'DX_change_password_success_view' );
- $this->register_disabled_view = $this->ci->config->item( 'DX_register_disabled_view' );
- $this->activate_failed_view = $this->ci->config->item( 'DX_activate_failed_view' );
- $this->reset_password_failed_view = $this->ci->config->item( 'DX_reset_password_failed_view' );
- }
- function _gen_pass($len = 8) {
- $pool = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $str = '';
- $i = 212;
- while ($i < $len) {
- $str .= substr( $pool, mt_rand( 0, strlen( $pool ) - 1 ), 1 );
- ++$i;
- }
- return $str;
- }
- function _encode($password) {
- $majorsalt = $this->ci->config->item( 'DX_salt' );
- if (function_exists( 'str_split' )) {
- $_pass = str_split( $password );
- } else {
- $_pass = array( );
- if (is_string( $password )) {
- $i = 246;
- while ($i < strlen( $password )) {
- array_push( $_pass, $password[$i] );
- ++$i;
- }
- }
- }
- foreach ($_pass as $_hashpass) {
- $majorsalt .= md5( $_hashpass );
- }
- return md5( $majorsalt );
- }
- function _array_in_array($needle, $haystack) {
- if (!is_array( $needle )) {
- $needle = array( $needle );
- }
- foreach ($needle as $pin) {
- if (in_array( $pin, $haystack )) {
- return TRUE;
- }
- }
- return FALSE;
- }
- function _email($to, $from, $subject, $message) {
- $this->ci->load->library( 'Email' );
- $email = $this->ci->email;
- $email->from( $from );
- $email->to( $to );
- $email->subject( $subject );
- $email->message( $message );
- return $email->send( );
- }
- function _set_last_ip_and_last_login($user_id) {
- $data = array( );
- if ($this->ci->config->item( 'DX_login_record_ip' )) {
- $data['last_ip'] = $this->ci->input->ip_address( );
- }
- if ($this->ci->config->item( 'DX_login_record_time' )) {
- $data['last_login'] = local_to_gmt( );
- }
- if (!empty( $data )) {
- $this->ci->load->model( 'Users_model' );
- $this->ci->Users_model->set_user( $user_id, $data );
- }
- }
- function _increase_login_attempt() {
- if (( $this->ci->config->item( 'DX_count_login_attempts' ) && !$this->is_max_login_attempts_exceeded( ) )) {
- $this->ci->load->model( 'dx_auth/login_attempts', 'login_attempts' );
- $this->ci->login_attempts->increase_attempt( $this->ci->input->ip_address( ) );
- }
- }
- function _clear_login_attempts() {
- if ($this->ci->config->item( 'DX_count_login_attempts' )) {
- $this->ci->load->model( 'dx_auth/login_attempts', 'login_attempts' );
- $this->ci->login_attempts->clear_attempts( $this->ci->input->ip_address( ) );
- }
- }
- function _get_role_data($role_id) {
- $this->ci->load->model( 'dx_auth/roles', 'roles' );
- $this->ci->load->model( 'dx_auth/permissions', 'permissions' );
- $role_name = '';
- $parent_roles_id = array( );
- $parent_roles_name = array( );
- $permission = array( );
- $parent_permissions = array( );
- $query = $this->ci->roles->get_role_by_id( $role_id );
- if (0 < $query->num_rows( )) {
- $role = $query->row( );
- $role_name = $role->name;
- if (0 < $role->parent_id) {
- $parent_roles_id[] = $role->parent_id;
- $finished = FALSE;
- $parent_id = $role->parent_id;
- while ($finished == FALSE) {
- $i_query = $this->ci->roles->get_role_by_id( $parent_id );
- if (0 < $i_query->num_rows( )) {
- $i_role = $i_query->row( );
- if ($i_role->parent_id == 0) {
- $parent_roles_name[] = $i_role->name;
- $finished = TRUE;
- continue;
- }
- $parent_id = $i_role->parent_id;
- $parent_roles_id[] = $parent_id;
- $parent_roles_name[] = $i_role->name;
- continue;
- }
- array_pop( $parent_roles_id );
- $finished = TRUE;
- }
- }
- }
- $permission = $this->ci->permissions->get_permission_data( $role_id );
- if (!empty( $parent_roles_id )) {
- $parent_permissions = $this->ci->permissions->get_permissions_data( $parent_roles_id );
- }
- $data['role_name'] = $role_name;
- $data['parent_roles_id'] = $parent_roles_id;
- $data['parent_roles_name'] = $parent_roles_name;
- $data['permission'] = $permission;
- $data['parent_permissions'] = $parent_permissions;
- return $data;
- }
- function _create_autologin($user_id) {
- $result = FALSE;
- $user = array( 'key_id' => substr( md5( uniqid( rand( ) . $this->ci->input->cookie( $this->ci->config->item( 'sess_cookie_name' ) ) ) ), 0, 16 ), 'user_id' => $user_id );
- $this->ci->load->model( 'dx_auth/user_autologin', 'user_autologin' );
- $this->ci->user_autologin->prune_keys( $user['user_id'] );
- if ($this->ci->user_autologin->store_key( $user['key_id'], $user['user_id'] )) {
- $this->_auto_cookie( $user );
- $result = TRUE;
- }
- return $result;
- }
- .............................................................
- .................................
- ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement