@ -150,7 +150,7 @@ class Aauth {
$this->error($this->CI->lang->line('aauth_error_login_failed_name'));
$this->error($this->CI->lang->line('aauth_error_login_failed_name'));
return FALSE;
return FALSE;
}
}
$db_identifier = 'name';
$db_identifier = 'user name';
}else{
}else{
if( !valid_email($identifier) OR strlen($pass) < $this->config_vars['min'] OR strlen($pass) > $this->config_vars['max'] )
if( !valid_email($identifier) OR strlen($pass) < $this->config_vars['min'] OR strlen($pass) > $this->config_vars['max'] )
{
{
@ -306,7 +306,7 @@ class Aauth {
// create session
// create session
$data = array(
$data = array(
'id' => $row->id,
'id' => $row->id,
'name' => $row->name,
'user name' => $row->user name,
'email' => $row->email,
'email' => $row->email,
'loggedin' => TRUE
'loggedin' => TRUE
);
);
@ -526,7 +526,7 @@ class Aauth {
// create session
// create session
$data = array(
$data = array(
'id' => $row->id,
'id' => $row->id,
'name' => $row->name,
'user name' => $row->user name,
'email' => $row->email,
'email' => $row->email,
'loggedin' => TRUE
'loggedin' => TRUE
);
);
@ -715,20 +715,20 @@ class Aauth {
* Creates a new user
* Creates a new user
* @param string $email User's email address
* @param string $email User's email address
* @param string $pass User's password
* @param string $pass User's password
* @param string $name User's name
* @param string $user name User's user name
* @return int|bool False if create fails or returns user id if successful
* @return int|bool False if create fails or returns user id if successful
*/
*/
public function create_user($email, $pass, $name = FALSE) {
public function create_user($email, $pass, $user name = FALSE) {
$valid = TRUE;
$valid = TRUE;
if($this->config_vars['login_with_name'] == TRUE){
if($this->config_vars['login_with_name'] == TRUE){
if (empty($name)){
if (empty($user name)){
$this->error($this->CI->lang->line('aauth_error_username_required'));
$this->error($this->CI->lang->line('aauth_error_username_required'));
$valid = FALSE;
$valid = FALSE;
}
}
}
}
if ($this->user_exist_by_name($name) & & $name != FALSE) {
if ($this->user_exist_by_user name($user name) & & $user name != FALSE) {
$this->error($this->CI->lang->line('aauth_error_username_exists'));
$this->error($this->CI->lang->line('aauth_error_username_exists'));
$valid = FALSE;
$valid = FALSE;
}
}
@ -746,7 +746,7 @@ class Aauth {
$this->error($this->CI->lang->line('aauth_error_password_invalid'));
$this->error($this->CI->lang->line('aauth_error_password_invalid'));
$valid = FALSE;
$valid = FALSE;
}
}
if ($name != FALSE & & !ctype_alnum(str_replace($this->config_vars['additional_valid_chars'], '', $name))){
if ($user name != FALSE & & !ctype_alnum(str_replace($this->config_vars['additional_valid_chars'], '', $user name))){
$this->error($this->CI->lang->line('aauth_error_username_invalid'));
$this->error($this->CI->lang->line('aauth_error_username_invalid'));
$valid = FALSE;
$valid = FALSE;
}
}
@ -757,7 +757,7 @@ class Aauth {
$data = array(
$data = array(
'email' => $email,
'email' => $email,
'pass' => $this->hash_password($pass, 0), // Password cannot be blank but user_id required for salt, setting bad password for now
'pass' => $this->hash_password($pass, 0), // Password cannot be blank but user_id required for salt, setting bad password for now
'name' => (!$name) ? '' : $name ,
'user name' => (!$user name) ? '' : $user name ,
'date_created' => date("Y-m-d H:i:s"),
'date_created' => date("Y-m-d H:i:s"),
);
);
@ -805,7 +805,7 @@ class Aauth {
* @param string|bool $name User's name, or FALSE if not to be updated
* @param string|bool $name User's name, or FALSE if not to be updated
* @return bool Update fails/succeeds
* @return bool Update fails/succeeds
*/
*/
public function update_user($user_id, $email = FALSE, $pass = FALSE, $name = FALSE) {
public function update_user($user_id, $email = FALSE, $pass = FALSE, $user name = FALSE) {
$data = array();
$data = array();
$valid = TRUE;
$valid = TRUE;
@ -836,20 +836,20 @@ class Aauth {
$data['pass'] = $this->hash_password($pass, $user_id);
$data['pass'] = $this->hash_password($pass, $user_id);
}
}
if ($user->name == $name) {
if ($user->user name == $user name) {
$name = FALSE;
$user name = FALSE;
}
}
if ($name != FALSE) {
if ($user name != FALSE) {
if ($this->user_exist_by_name($name)) {
if ($this->user_exist_by_user name($user name)) {
$this->error($this->CI->lang->line('aauth_error_update_username_exists'));
$this->error($this->CI->lang->line('aauth_error_update_username_exists'));
$valid = FALSE;
$valid = FALSE;
}
}
if ($name !='' & & !ctype_alnum(str_replace($this->config_vars['additional_valid_chars'], '', $name))){
if ($user name !='' & & !ctype_alnum(str_replace($this->config_vars['additional_valid_chars'], '', $user name))){
$this->error($this->CI->lang->line('aauth_error_username_invalid'));
$this->error($this->CI->lang->line('aauth_error_username_invalid'));
$valid = FALSE;
$valid = FALSE;
}
}
$data['name'] = $name;
$data['user name'] = $user name;
}
}
if ( !$valid || empty($data)) {
if ( !$valid || empty($data)) {
@ -1073,14 +1073,14 @@ class Aauth {
}
}
/**
/**
* user_exist_by_name
* user_exist_by_user name
* Check if user exist by name
* Check if user exist by user name
* @param $user_id
* @param $user_id
*
*
* @return bool
* @return bool
*/
*/
public function user_exist_by_name( $name ) {
public function user_exist_by_user name( $name ) {
$query = $this->aauth_db->where('name', $name);
$query = $this->aauth_db->where('user name', $name);
$query = $this->aauth_db->get($this->config_vars['users']);
$query = $this->aauth_db->get($this->config_vars['users']);
@ -1090,6 +1090,17 @@ class Aauth {
return FALSE;
return FALSE;
}
}
/**
* user_exist_by_name !DEPRECATED!
* Check if user exist by name
* @param $user_id
*
* @return bool
*/
public function user_exist_by_name( $name ) {
return $this->user_exist_by_name($name);
}
/**
/**
* user_exist_by_email
* user_exist_by_email
* Check if user exist by user email
* Check if user exist by user email
@ -1884,10 +1895,13 @@ class Aauth {
$this->error($this->CI->lang->line('aauth_error_self_pm'));
$this->error($this->CI->lang->line('aauth_error_self_pm'));
return FALSE;
return FALSE;
}
}
if (($this->is_banned($receiver_id) || !$this->user_exist_by_id($receiver_id)) || ($this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id))){
if (($this->is_banned($receiver_id) || !$this->user_exist_by_id($receiver_id)) || ($sender_id & & ($ this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id) ))){
$this->error($this->CI->lang->line('aauth_error_no_user'));
$this->error($this->CI->lang->line('aauth_error_no_user'));
return FALSE;
return FALSE;
}
}
if ( !$sender_id){
$sender_id = 0;
}
if ($this->config_vars['pm_encryption']){
if ($this->config_vars['pm_encryption']){
$this->CI->load->library('encrypt');
$this->CI->load->library('encrypt');
@ -1921,10 +1935,13 @@ class Aauth {
$title = $this->CI->encrypt->encode($title);
$title = $this->CI->encrypt->encode($title);
$message = $this->CI->encrypt->encode($message);
$message = $this->CI->encrypt->encode($message);
}
}
if (($this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id))){
if ($sender_id & & ($this->is_banned($sender_id) || !$this->user_exist_by_id($sender_id))){
$this->error($this->CI->lang->line('aauth_error_no_user'));
$this->error($this->CI->lang->line('aauth_error_no_user'));
return FALSE;
return FALSE;
}
}
if ( !$sender_id){
$sender_id = 0;
}
if (is_numeric($receiver_ids)) {
if (is_numeric($receiver_ids)) {
$receiver_ids = array($receiver_ids);
$receiver_ids = array($receiver_ids);
}
}
@ -1964,7 +1981,7 @@ class Aauth {
* @return object Array of private messages
* @return object Array of private messages
*/
*/
public function list_pms($limit=5, $offset=0, $receiver_id=NULL, $sender_id=NULL){
public function list_pms($limit=5, $offset=0, $receiver_id=NULL, $sender_id=NULL){
if (is_numeric($send er_id)){
if (is_numeric($receiv er_id)){
$query = $this->aauth_db->where('receiver_id', $receiver_id);
$query = $this->aauth_db->where('receiver_id', $receiver_id);
$query = $this->aauth_db->where('pm_deleted_receiver', 0);
$query = $this->aauth_db->where('pm_deleted_receiver', 0);
}
}
@ -2048,7 +2065,7 @@ class Aauth {
}
}
return $this->aauth_db->update( $this->config_vars['pms'], array('pm_deleted_sender'=>1), array('id' => $pm_id));
return $this->aauth_db->update( $this->config_vars['pms'], array('pm_deleted_sender'=>1), array('id' => $pm_id));
}else if ($user_id == $result->result->re ceiver_id){
}else if ($user_id == $result->receiver_id){
if($result->pm_deleted_sender == 1){
if($result->pm_deleted_sender == 1){
return $this->aauth_db->delete( $this->config_vars['pms'], array('id' => $pm_id));
return $this->aauth_db->delete( $this->config_vars['pms'], array('id' => $pm_id));
}
}