Browse Source

Modified lang-file constants to include prefix.

Modified lang-file constants to include prefix.  This will help avoid collisions.
Also added a few missing items to the lang-file.
Modified list_user_var_keys() to return an array so that it can be looped through.
Fixed duplicate message when sending password reset email, line 424.

	modified:   application/language/english/aauth_lang.php
	modified:   application/libraries/Aauth.php
develop
tswagger 10 years ago
parent
commit
6eddbc63cc
  1. 78
      application/language/english/aauth_lang.php
  2. 76
      application/libraries/Aauth.php

78
application/language/english/aauth_lang.php

@ -1,35 +1,47 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$lang['verification_subject'] = 'Account Vertification'; /* E-mail Messages */
$lang['reset'] = 'Pasword Reset';
// Account verification
// error mesages $lang['aauth_email_verification_subject'] = 'Account Verification';
// change to your language $lang['aauth_email_verification_code'] = 'Your verification code is: ';
$lang['aauth_email_verification_link'] = " You can also click on (or copy and paste) the following link\n\nhttp://yourdomain/account/verification/";
$lang['email_taken'] = 'E-mail is already taken';
$lang['email_invalid'] = 'E-mail invalid'; // Password reset
$lang['pass_invalid'] = 'Password invalid'; $lang['aauth_email_reset_subject'] = 'Reset Password';
$lang['name_invalid'] = 'Name invalid'; $lang['aauth_email_reset_link'] = "To reset your password click on (or copy and paste in your browser address bar) the link below:\n\nhttp://yourdomain/account/reset_password/";
$lang['code'] = 'Your code is: ';
$lang['link'] = ' or you can copy and paste falowing link http://localhost/vert/'; // Password reset success
$lang['aauth_email_reset_success_subject'] = 'Successful Pasword Reset';
$lang['remind'] = 'If you want to reset your password click the copy and go the link below http://localhost/reset/'; $lang['aauth_email_reset_success_new_password'] = 'Your password has successfully been reset. Your new password is : ';
$lang['new_password'] = 'Your new password is : ';
// no access /* Error Messages */
$lang['no_access'] = 'You dont have access.';
// Account creation errors
// $lang['aauth_error_email_exists'] = 'Email address already exists on the system. If you forgot your password, you can click the link below.';
$lang['wrong'] = 'E-mail or Password is wrong.'; $lang['aauth_error_username_exists'] = "Account already exists on the system with that username. Please enter a different username, or if you forgot your password, please click the link below.";
$lang['exceeded'] = 'Login try limit exceeded.'; $lang['aauth_error_email_invalid'] = 'Invalid e-mail address';
$lang['recaptcha_not_correct'] = 'reCAPTCHA is incorrect.'; $lang['aauth_error_password_invalid'] = 'Invalid password';
$lang['no_user'] = 'User not Exist'; $lang['aauth_error_username_invalid'] = 'Invalid Username';
$lang['not_verified'] = 'Please verify your account.'; $lang['aauth_error_username_required'] = 'Username required';
$lang['group_exist'] = 'Group already exists';
$lang['no_group'] = 'Group doesn\'t exists'; // Access errors
$lang['self_pm'] = 'It is not reasonable to send pm to yourself :)'; $lang['aauth_error_no_access'] = 'Sorry, you do not have access to the resource you requested.';
$lang['no_pm'] = 'Pm not found'; $lang['aauth_error_login_failed'] = 'E-mail Address and Password do not match.';
$lang['aauth_error_login_attempts_exceeded'] = 'You have exceeded your login attempts, your account has now been locked.';
//info $lang['aauth_error_recaptcha_not_correct'] = 'Sorry, the reCAPTCHA text entered was incorrect.';
$lang['already_member'] = 'User already member of group';
$lang['already_perm'] = 'Permission name already existed';
// Misc. errors
$lang['aauth_error_no_user'] = 'User does not exist';
$lang['aauth_error_account_not_verified'] = 'Your account has not been verified. Please check your e-mail and verify your account.';
$lang['aauth_error_no_group'] = 'Group does not exist';
$lang['aauth_error_self_pm'] = 'It is not possible to send a Message to yourself.';
$lang['aauth_error_no_pm'] = 'Private Message not found';
/* Info messages */
$lang['aauth_info_already_member'] = 'User is already member of group';
$lang['aauth_info_group_exists'] = 'Group name already exists';
$lang['aauth_info_perm_exists'] = 'Permission name already exists';

76
application/libraries/Aauth.php

@ -128,7 +128,7 @@ class Aauth {
if( !valid_email($email) or strlen($pass) < 5 or if( !valid_email($email) or strlen($pass) < 5 or
strlen($pass) > $this->config_vars['max'] ) strlen($pass) > $this->config_vars['max'] )
{ {
$this->error($this->CI->lang->line('wrong')); $this->error($this->CI->lang->line('aauth_error_login_failed'));
return false; return false;
} }
@ -139,9 +139,9 @@ class Aauth {
$row = $query->row(); $row = $query->row();
// only email found and login attempts exceeded // only email found and login attempts exceeded
if ($query->num_rows() > 0 and $this->config_vars['ddos_protection'] and ! $this->update_login_attempts($row->email)) { if ($query->num_rows() > 0 && $this->config_vars['ddos_protection'] && ! $this->update_login_attempts($row->email)) {
$this->error($this->CI->lang->line('exceeded')); $this->error($this->CI->lang->line('aauth_error_login_attempts_exceeded'));
return false; return false;
} }
@ -150,7 +150,7 @@ class Aauth {
$query = $this->CI->db->where('email', $email); $query = $this->CI->db->where('email', $email);
$query = $this->CI->db->get($this->config_vars['users']); $query = $this->CI->db->get($this->config_vars['users']);
$row = $query->row(); $row = $query->row();
if($query->num_rows() > 0 and $this->config_vars['ddos_protection'] and $this->config_vars['recaptcha_active'] and $row->login_attempts >= $this->config_vars['recaptcha_login_attempts']){ if($query->num_rows() > 0 && $this->config_vars['ddos_protection'] && $this->config_vars['recaptcha_active'] && $row->login_attempts >= $this->config_vars['recaptcha_login_attempts']){
$reCAPTCHA_cookie = array( $reCAPTCHA_cookie = array(
'name' => 'reCAPTCHA', 'name' => 'reCAPTCHA',
'value' => 'true', 'value' => 'true',
@ -168,7 +168,7 @@ class Aauth {
$query = $this->CI->db->get($this->config_vars['users']); $query = $this->CI->db->get($this->config_vars['users']);
if ($query->num_rows() > 0) { if ($query->num_rows() > 0) {
$this->error($this->CI->lang->line('not_verified')); $this->error($this->CI->lang->line('aauth_error_account_not_verified'));
return false; return false;
} }
@ -177,7 +177,7 @@ class Aauth {
$query = $this->CI->db->get($this->config_vars['users']); $query = $this->CI->db->get($this->config_vars['users']);
if($query->num_rows() == 0){ if($query->num_rows() == 0){
$this->error($this->CI->lang->line('wrong')); $this->error($this->CI->lang->line('aauth_error_login_failed'));
return false; return false;
} }
@ -198,7 +198,7 @@ class Aauth {
$resp = $reCaptcha->verifyResponse( $this->CI->input->server("REMOTE_ADDR"), $this->CI->input->post("g-recaptcha-response") ); $resp = $reCaptcha->verifyResponse( $this->CI->input->server("REMOTE_ADDR"), $this->CI->input->post("g-recaptcha-response") );
if(!$resp->success){ if(!$resp->success){
$this->error($this->CI->lang->line('recaptcha_not_correct')); $this->error($this->CI->lang->line('aauth_error_recaptcha_not_correct'));
return false; return false;
} }
} }
@ -253,7 +253,7 @@ class Aauth {
// if not matches // if not matches
else { else {
$this->error($this->CI->lang->line('wrong')); $this->error($this->CI->lang->line('aauth_error_login_failed'));
return FALSE; return FALSE;
} }
} }
@ -323,11 +323,11 @@ class Aauth {
// if user or user's group not allowed // if user or user's group not allowed
if ( ! $this->is_allowed($perm_id) or ! $this->is_group_allowed($perm_id) ){ if ( ! $this->is_allowed($perm_id) or ! $this->is_group_allowed($perm_id) ){
if( $this->config_vars['no_permission'] ) { if( $this->config_vars['no_permission'] ) {
$this->error($this->CI->lang->line('no_access')); $this->error($this->CI->lang->line('aauth_error_no_access'));
redirect($this->config_vars['no_permission']); redirect($this->config_vars['no_permission']);
} }
else { else {
echo $this->CI->lang->line('no_access'); echo $this->CI->lang->line('aauth_error_no_access');
die(); die();
} }
} }
@ -420,9 +420,8 @@ class Aauth {
$this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']); $this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']);
$this->CI->email->to($row->email); $this->CI->email->to($row->email);
$this->CI->email->subject($this->CI->lang->line('reset')); $this->CI->email->subject($this->CI->lang->line('aauth_email_reset_subject'));
$this->CI->email->message($this->CI->lang->line('remind') . ' ' . $this->CI->email->message($this->CI->lang->line('aauth_email_reset_link') . $row->id . '/' . $ver_code );
$this->CI->lang->line('remind') . $row->id . '/' . $ver_code );
$this->CI->email->send(); $this->CI->email->send();
} }
} }
@ -457,8 +456,8 @@ class Aauth {
$this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']); $this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']);
$this->CI->email->to($email); $this->CI->email->to($email);
$this->CI->email->subject($this->CI->lang->line('reset')); $this->CI->email->subject($this->CI->lang->line('aauth_email_reset_success_subject'));
$this->CI->email->message($this->CI->lang->line('new_password') . $pass); $this->CI->email->message($this->CI->lang->line('aauth_email_reset_success_new_password') . $pass);
$this->CI->email->send(); $this->CI->email->send();
return true; return true;
@ -566,28 +565,28 @@ class Aauth {
// if email is already exist // if email is already exist
if ($this->user_exsist_by_email($email)) { if ($this->user_exsist_by_email($email)) {
$this->error($this->CI->lang->line('email_taken')); $this->error($this->CI->lang->line('aauth_error_email_exists'));
$valid = false; $valid = false;
} }
if ($this->user_exsist_by_name($name)) { if ($this->user_exsist_by_name($name)) {
$this->error($this->CI->lang->line('name_taken')); $this->error($this->CI->lang->line('aauth_error_username_exists'));
$valid = false; $valid = false;
} }
if ( ! valid_email($email)){ if ( ! valid_email($email)){
$this->error($this->CI->lang->line('email_invalid')); $this->error($this->CI->lang->line('aauth_error_email_invalid'));
$valid = false; $valid = false;
} }
if ( strlen($pass) < 5 or strlen($pass) > $this->config_vars['max'] ){ if ( strlen($pass) < 5 or strlen($pass) > $this->config_vars['max'] ){
$this->error($this->CI->lang->line('pass_invalid')); $this->error($this->CI->lang->line('aauth_error_password_invalid'));
$valid = false; $valid = false;
} }
if ($name !='' and !ctype_alnum(str_replace($this->config_vars['valid_chars'], '', $name))){ if ($name !='' and !ctype_alnum(str_replace($this->config_vars['valid_chars'], '', $name))){
$this->error($this->CI->lang->line('name_invalid')); $this->error($this->CI->lang->line('aauth_error_username_invalid'));
$valid = false; $valid = false;
} }
if (empty($name)){ if (empty($name)){
$this->error($this->CI->lang->line('name_invalid')); $this->error($this->CI->lang->line('aauth_error_username_required'));
$valid = false; $valid = false;
} }
@ -725,7 +724,7 @@ class Aauth {
$query = $this->CI->db->get($this->config_vars['users']); $query = $this->CI->db->get($this->config_vars['users']);
if ($query->num_rows() <= 0){ if ($query->num_rows() <= 0){
$this->error($this->CI->lang->line('no_user')); $this->error($this->CI->lang->line('aauth_error_no_user'));
return FALSE; return FALSE;
} }
return $query->row(); return $query->row();
@ -782,9 +781,9 @@ class Aauth {
$this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']); $this->CI->email->from( $this->config_vars['email'], $this->config_vars['name']);
$this->CI->email->to($row->email); $this->CI->email->to($row->email);
$this->CI->email->subject($this->CI->lang->line('verification_subject')); $this->CI->email->subject($this->CI->lang->line('aauth_email_verification_subject'));
$this->CI->email->message($this->CI->lang->line('code') . $ver_code . $this->CI->email->message($this->CI->lang->line('aauth_email_verification_code') . $ver_code .
$this->CI->lang->line('link') . $user_id . '/' . $ver_code ); $this->CI->lang->line('aauth_email_verification_link') . $user_id . '/' . $ver_code );
$this->CI->email->send(); $this->CI->email->send();
} }
} }
@ -942,7 +941,7 @@ class Aauth {
$query = $this->CI->db->get($this->config_vars['users']); $query = $this->CI->db->get($this->config_vars['users']);
if ($query->num_rows() <= 0){ if ($query->num_rows() <= 0){
$this->error($this->CI->lang->line('no_user')); $this->error($this->CI->lang->line('aauth_error_no_user'));
return FALSE; return FALSE;
} }
return $query->row()->id; return $query->row()->id;
@ -1025,7 +1024,7 @@ class Aauth {
return $this->CI->db->insert_id(); return $this->CI->db->insert_id();
} }
$this->error($this->CI->lang->line('group_exist')); $this->info($this->CI->lang->line('aauth_info_group_exists'));
return FALSE; return FALSE;
} }
@ -1087,7 +1086,7 @@ class Aauth {
if( ! $group_id ) { if( ! $group_id ) {
$this->error( $this->CI->lang->line('no_group') ); $this->error( $this->CI->lang->line('aauth_error_no_group') );
return false; return false;
} }
@ -1103,7 +1102,7 @@ class Aauth {
return $this->CI->db->insert($this->config_vars['user_to_group'], $data); return $this->CI->db->insert($this->config_vars['user_to_group'], $data);
} }
$this->info($this->CI->lang->line('already_member')); $this->info($this->CI->lang->line('aauth_info_already_member'));
return true; return true;
} }
@ -1243,7 +1242,7 @@ class Aauth {
$this->CI->db->insert($this->config_vars['perms'], $data); $this->CI->db->insert($this->config_vars['perms'], $data);
return $this->CI->db->insert_id(); return $this->CI->db->insert_id();
} }
$this->error($this->CI->lang->line('already_perm')); $this->info($this->CI->lang->line('aauth_info_perm_exists'));
return FALSE; return FALSE;
} }
@ -1518,7 +1517,7 @@ class Aauth {
public function send_pm( $sender_id, $receiver_id, $title, $message ){ public function send_pm( $sender_id, $receiver_id, $title, $message ){
if ( !is_numeric($receiver_id) or $sender_id == $receiver_id ){ if ( !is_numeric($receiver_id) or $sender_id == $receiver_id ){
$this->error($this->CI->lang->line('self_pm')); $this->error($this->CI->lang->line('aauth_error_self_pm'));
return false; return false;
} }
@ -1529,7 +1528,7 @@ class Aauth {
// if user not exist or banned // if user not exist or banned
if ( $query->num_rows() < 1 ){ if ( $query->num_rows() < 1 ){
$this->error($this->CI->lang->line('no_user')); $this->error($this->CI->lang->line('aauth_error_no_user'));
return false; return false;
} }
@ -1540,7 +1539,7 @@ class Aauth {
// if user not exist or banned // if user not exist or banned
if ( $query->num_rows() < 1 ){ if ( $query->num_rows() < 1 ){
$this->error($this->CI->lang->line('no_user')); $this->error($this->CI->lang->line('aauth_error_no_user'));
return false; return false;
} }
@ -1597,7 +1596,7 @@ class Aauth {
$query = $this->CI->db->get( $this->config_vars['pms'] ); $query = $this->CI->db->get( $this->config_vars['pms'] );
if ($query->num_rows() < 1) { if ($query->num_rows() < 1) {
$this->error( $this->CI->lang->line('no_pm') ); $this->error( $this->CI->lang->line('aauth_error_no_pm') );
} }
if ($set_as_read) $this->set_as_read_pm($pm_id); if ($set_as_read) $this->set_as_read_pm($pm_id);
@ -1919,7 +1918,7 @@ class Aauth {
* List User Variable Keys by UserID * List User Variable Keys by UserID
* Return array of variable keys or false * Return array of variable keys or false
* @param int $user_id ; if not given current user * @param int $user_id ; if not given current user
* @return bool|string , false if var is not set, the value of var if set * @return bool|array, false if no user vars, otherwise array
*/ */
public function list_user_var_keys($user_id = false){ public function list_user_var_keys($user_id = false){
@ -1940,9 +1939,12 @@ class Aauth {
// if variable not set // if variable not set
if ($query->num_rows() < 1) { return false;} if ($query->num_rows() < 1) { return false;}
else { else {
return $query->result(); $key_list = array();
foreach( $query->result() as $row) {
$key_list[] = $row->key;
}
return $key_list;
} }
} }
######################## ########################

Loading…
Cancel
Save