/** * Save new email and/or pass * * @access protected * @return void */ protected function _saveForm() { if (!$this->request['email'] and !$this->request['password']) { $this->registry->output->global_message = $this->lang->words['change_nothing_update']; $this->_showForm(); return; } if ($this->request['email']) { if (!$this->request['email_confirm']) { $this->registry->output->global_message = $this->lang->words['change_both_fields']; $this->_showForm(); return; } else { if ($this->request['email'] != $this->request['email_confirm']) { $this->registry->output->global_message = $this->lang->words['change_not_match']; $this->_showForm(); return; } } $email = trim($this->request['email']); $email_check = IPSMember::load(strtolower($email)); if ($email_check['member_id'] and $email_check['member_id'] != $member_id) { $this->registry->output->global_message = $this->lang->words['change_email_already_used']; $this->_showForm(); return; } else { if ($email_check['member_id'] == $this->memberData['member_id']) { $this->registry->output->global_message = $this->lang->words['already_using_email']; $this->_showForm(); return; } } //----------------------------------------- // Load handler... //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php'; $han_login = new han_login($this->registry); $han_login->init(); $han_login->changeEmail(trim(strtolower($this->memberData['email'])), trim(strtolower($email))); IPSMember::save($this->memberData['member_id'], array('core' => array('email' => strtolower($email)))); IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($email)); ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['changed_email'], $email)); } if ($this->request['password']) { if (!$this->request['password_confirm']) { $this->registry->output->global_message = $this->lang->words['change_both_fields']; $this->_showForm(); return; } else { if ($this->request['password'] != $this->request['password_confirm']) { $this->registry->output->global_message = $this->lang->words['change_not_match_pw']; $this->_showForm(); return; } } $password = $this->request['password']; $salt = str_replace('\\', "\\\\", IPSMember::generatePasswordSalt(5)); $key = IPSMember::generateAutoLoginKey(); $md5_once = md5(trim($password)); require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php'; $han_login = new han_login($this->registry); $han_login->init(); $han_login->changePass($this->memberData['email'], $md5_once); IPSMember::save($this->memberData['member_id'], array('core' => array('members_pass_salt' => $salt, 'member_login_key' => $key))); IPSMember::updatePassword($this->memberData['member_id'], $md5_once); IPSLib::runMemberSync('onPassChange', $this->memberData['member_id'], $password); ipsRegistry::getClass('adminFunctions')->saveAdminLog($this->lang->words['changed_password']); } $this->registry->output->global_message = $this->lang->words['details_updated']; $this->registry->output->silentRedirectWithMessage($this->settings['base_url']); }
/** * Change a member's password * * @access protected * @return void [Outputs to screen] */ protected function save_password() { //----------------------------------------- // INIT //----------------------------------------- $member_id = intval($this->request['member_id']); $password = $this->request['password']; $password2 = $this->request['password2']; $new_key = intval($this->request['new_key']); $new_salt = intval($this->request['new_salt']); $salt = str_replace('\\', "\\\\", IPSMember::generatePasswordSalt(5)); $key = IPSMember::generateAutoLoginKey(); $md5_once = md5(trim($password)); //----------------------------------------- // Check //----------------------------------------- if (!$password or !$password2) { $this->returnJsonError($this->lang->words['password_nogood']); exit; } if ($password != $password2) { $this->returnJsonError($this->lang->words['m_passmatch']); exit; } //----------------------------------------- // Get member //----------------------------------------- $member = IPSMember::load($member_id); //----------------------------------------- // Allowed to edit administrators? //----------------------------------------- if ($member['g_access_cp'] and !$this->registry->getClass('class_permissions')->checkPermission('member_edit_admin', 'members', 'members')) { $this->returnJsonError($this->lang->words['m_editadmin']); exit; } //----------------------------------------- // Check Converge: Password //----------------------------------------- require_once IPS_ROOT_PATH . 'sources/handlers/han_login.php'; $han_login = new han_login($this->registry); $han_login->init(); $han_login->changePass($member['email'], $md5_once); /*if ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) { $this->returnJsonError( $this->lang->words['m_passchange']); exit(); }*/ //----------------------------------------- // Local DB //----------------------------------------- $update = array(); if ($new_salt) { $update['members_pass_salt'] = $salt; } if ($new_key) { $update['member_login_key'] = $key; } if (count($update)) { IPSMember::save($member_id, array('core' => $update)); } IPSMember::updatePassword($member_id, $md5_once); IPSLib::runMemberSync('onPassChange', $member_id, $password); ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['m_passlog'], $member_id)); $_string = <<<EOF \t\t{ \t\t\t'success' : true, \t\t\t'password' : "*************" \t\t} \t\t EOF; $this->returnString($_string); }