/**
  * Converge_Server::onPasswordChange()
  *
  * handles new password change
  *
  * This will return a param "response" with either
  * - FAILED    		 (Unknown failure)
  * - SUCCESS    	 (Added OK)
  *
  * @access	public
  * @param	int		$product_id				Product ID
  * @param	string	$auth_key				Authentication Key
  * @param	string	$email_address			Email address
  * @param	string	$md5_once_password		Plain text password hashed by MD5
  * @return	mixed	xml / boolean
  */
 public function onPasswordChange($auth_key, $product_id, $email_address, $md5_once_password)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $auth_key = IPSText::md5Clean($auth_key);
     $product_id = intval($product_id);
     $email_address = IPSText::parseCleanValue($email_address);
     $md5_once_password = IPSText::md5Clean($md5_once_password);
     $return = 'FAILED';
     //-----------------------------------------
     // Authenticate
     //-----------------------------------------
     if ($this->__authenticate($auth_key, $product_id) !== FALSE) {
         IPSMember::updatePassword($email_address, $md5_once_password);
         $return = 'SUCCESS';
         $this->classApiServer->apiSendReply(array('complete' => 1, 'response' => $return));
         exit;
     }
 }
Beispiel #2
0
 /**
  * Clean up the converted data
  *
  * @access	public
  * @param	string		new password
  * @return	@e void
  */
 public function cleanConvertData($new_pass)
 {
     IPSMember::save($this->_memberData['email'], array('core' => array('misc' => '', $this->password_field => '')), 'email');
     IPSMember::updatePassword($this->_memberData['email'], $new_pass);
 }
 public function changePW($newPass, $member, $currentPass = false)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $save_array = array();
     //-----------------------------------------
     // Generate a new random password
     //-----------------------------------------
     $new_pass = IPSText::parseCleanValue(urldecode($newPass));
     //-----------------------------------------
     // Generate a new salt
     //-----------------------------------------
     $salt = IPSMember::generatePasswordSalt(5);
     $salt = str_replace('\\', "\\\\", $salt);
     //-----------------------------------------
     // New log in key
     //-----------------------------------------
     $key = IPSMember::generateAutoLoginKey();
     //-----------------------------------------
     // Update...
     //-----------------------------------------
     $save_array['members_pass_salt'] = $salt;
     $save_array['members_pass_hash'] = md5(md5($salt) . md5($new_pass));
     $save_array['member_login_key'] = $key;
     $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
     $save_array['failed_logins'] = null;
     $save_array['failed_login_count'] = 0;
     //-----------------------------------------
     // Load handler...
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
     $this->han_login = new $classToLoad($this->registry);
     $this->han_login->init();
     $this->han_login->changePass($member['email'], md5($new_pass), $new_pass, $member);
     IPSMember::save($member['member_id'], array('members' => $save_array));
     IPSMember::updatePassword($member['member_id'], md5($new_pass));
     IPSLib::runMemberSync('onPassChange', $member['member_id'], $new_pass);
 }
 /**
  * Change account data
  *
  * @param	int		ID number
  * @param	string	md5( IPS Connect Key (see login method) . ID number )
  * @param	string	New username (blank means do not change)
  * @param	string	New displayname (blank means do not change)
  * @param	string	New email address (blank means do not change)
  * @param	string	New password, md5 encoded (blank means do not change)
  * @param	string	Redirect URL, Base64 encoded
  * @param	string	md5( IPS Connect Key . $redirect )
  * @return	mixed	If the redirect URL is provided, this function should redirect the user to that URL with a single paramater - 'status'
  *					If blank, will output to screen a JSON object with the same parameter
  *					Values:
  *						BAD_KEY				Invalid Key
  *						NO_USER				ID number not match any member account
  *						SUCCESS				Information changed successfully
  *						USERNAME_IN_USE		The chosen username was in use and as a result NO information was changed
  *						DISPLAYNAME_IN_USE	The chosen username was in use and as a result NO information was changed
  *						EMAIL_IN_USE		The chosen username was in use and as a result NO information was changed
  *						MISSING_DATA		No details to be changed were provided
  */
 public function change($id, $key, $username, $displayname, $email, $md5Password, $redirect, $redirectHash)
 {
     if ($key != md5($this->masterKey . $id)) {
         $this->_return(base64_encode($this->settings['board_url']), array('status' => 'BAD_KEY'));
     }
     $member = IPSMember::load(intval($id), 'none', 'id');
     if (!$member['member_id']) {
         $this->_return($redirect, array('status' => 'NO_USER'));
     }
     $update = array();
     if ($username) {
         if (IPSMember::getFunction()->checkNameExists($username, $member, 'name', TRUE)) {
             $this->_return($redirect, array('status' => 'USERNAME_IN_USE'));
         }
         $update['name'] = $username;
     }
     if ($displayname) {
         if (IPSMember::getFunction()->checkNameExists($displayname, $member, 'members_display_name', TRUE)) {
             $this->_return($redirect, array('status' => 'DISPLAYNAME_IN_USE'));
         }
         $update['members_display_name'] = $displayname;
     }
     if ($email) {
         if (IPSMember::checkByEmail($email)) {
             $this->_return($redirect, array('status' => 'EMAIL_IN_USE'));
         }
         $update['email'] = $email;
     }
     if (empty($update)) {
         if (!$md5Password) {
             $this->_return($redirect, array('status' => 'MISSING_DATA'));
         }
     } else {
         IPSMember::save($member['member_id'], array('members' => $update));
     }
     if ($md5Password) {
         IPSMember::updatePassword($member['member_id'], $md5Password);
     }
     if ($redirect) {
         $redirect = $redirectHash == md5($this->masterKey . $redirect) ? $redirect : base64_encode($this->settings['board_url']);
     }
     $this->_return($redirect, array('status' => 'SUCCESS'));
 }
 /**
  * UserCP Save Form: Email Address
  *
  * @return	mixed		Array of errors / boolean true
  */
 public function saveFormEmailPassword()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $_emailOne = strtolower(trim($this->request['in_email_1']));
     $_emailTwo = strtolower(trim($this->request['in_email_2']));
     $cur_pass = trim($this->request['current_pass']);
     $new_pass = trim($this->request['new_pass_1']);
     $chk_pass = trim($this->request['new_pass_2']);
     $isRemote = (!$this->memberData['bw_local_password_set'] and $this->memberData['members_created_remote']) ? true : false;
     if ($cur_pass or $new_pass) {
         if ($this->memberData['g_access_cp']) {
             return array(0 => $this->lang->words['admin_emailpassword']);
         }
         if ($isRemote === false and (!$_POST['current_pass'] or empty($new_pass) or empty($chk_pass))) {
             return array(0 => $this->lang->words['complete_entire_form']);
         }
         //-----------------------------------------
         // Do the passwords actually match?
         //-----------------------------------------
         if ($new_pass != $chk_pass) {
             return array(0 => $this->lang->words['passwords_not_matchy']);
         }
         //-----------------------------------------
         // Check password...
         //-----------------------------------------
         if ($isRemote === false) {
             if ($this->_checkPassword($cur_pass) !== TRUE) {
                 return array(0 => $this->lang->words['current_pw_bad']);
             }
         } else {
             /* This is INIT in _checkPassword */
             $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
             $this->han_login = new $classToLoad($this->registry);
             $this->han_login->init();
         }
         //-----------------------------------------
         // Create new password...
         //-----------------------------------------
         $md5_pass = md5($new_pass);
         //-----------------------------------------
         // han_login was loaded during check_password
         //-----------------------------------------
         $this->han_login->changePass($this->memberData['email'], $md5_pass, $new_pass, $this->memberData);
         if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
             return array(0 => $this->lang->words['hanlogin_pw_failed']);
         }
         //-----------------------------------------
         // Update the DB
         //-----------------------------------------
         IPSMember::updatePassword($this->memberData['email'], $md5_pass);
         IPSLib::runMemberSync('onPassChange', $this->memberData['member_id'], $new_pass);
         //-----------------------------------------
         // Update members log in key...
         //-----------------------------------------
         $key = IPSMember::generateAutoLoginKey();
         IPSMember::save($this->memberData['member_id'], array('core' => array('member_login_key' => $key, 'bw_local_password_set' => 1)));
         $this->ok_message = $this->lang->words['pw_change_successful'];
     }
     if ($_emailOne or $_emailTwo) {
         //-----------------------------------------
         // Do not allow validating members to change
         // email when admin validation is on
         // @see	http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
         //-----------------------------------------
         if ($this->memberData['member_group_id'] == $this->settings['auth_group'] and in_array($this->settings['reg_auth_type'], array('admin', 'admin_user'))) {
             $this->registry->output->showError($this->lang->words['admin_val_no_email_chg'], 10190);
         }
         //-----------------------------------------
         // Check input
         //-----------------------------------------
         if ($this->memberData['g_access_cp']) {
             return array(0 => $this->lang->words['admin_emailpassword']);
         }
         if (!$_POST['in_email_1'] or !$_POST['in_email_2']) {
             return array(0 => $this->lang->words['complete_entire_form']);
         }
         //-----------------------------------------
         // Check password...
         //-----------------------------------------
         if (!$this->_isFBUser) {
             if ($this->_checkPassword($this->request['password']) === FALSE) {
                 return array(0 => $this->lang->words['current_pw_bad']);
             }
         }
         //-----------------------------------------
         // Test email addresses
         //-----------------------------------------
         if ($_emailOne != $_emailTwo) {
             return array(0 => $this->lang->words['emails_no_matchy']);
         }
         if (IPSText::checkEmailAddress($_emailOne) !== TRUE) {
             return array(0 => $this->lang->words['email_not_valid']);
         }
         //-----------------------------------------
         // Is this email addy taken?
         //-----------------------------------------
         if (IPSMember::checkByEmail($_emailOne) == TRUE) {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         //-----------------------------------------
         // Load ban filters
         //-----------------------------------------
         $banfilters = array();
         $this->DB->build(array('select' => '*', 'from' => 'banfilters'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $banfilters[$r['ban_type']][] = $r['ban_content'];
         }
         //-----------------------------------------
         // Check in banned list
         //-----------------------------------------
         if (isset($banfilters['email']) and is_array($banfilters['email']) and count($banfilters['email'])) {
             foreach ($banfilters['email'] as $email) {
                 $email = str_replace('\\*', '.*', preg_quote($email, "/"));
                 if (preg_match("/^{$email}\$/i", $_emailOne)) {
                     return array(0 => $this->lang->words['email_is_taken']);
                 }
             }
         }
         //-----------------------------------------
         // Load handler...
         //-----------------------------------------
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
         $this->han_login = new $classToLoad($this->registry);
         $this->han_login->init();
         if ($this->han_login->emailExistsCheck($_emailOne) !== FALSE) {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         $this->han_login->changeEmail($this->memberData['email'], $_emailOne, $this->memberData);
         if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
             return array(0 => $this->lang->words['email_is_taken']);
         }
         //-----------------------------------------
         // Want a new validation? NON ADMINS ONLY
         //-----------------------------------------
         if ($this->settings['reg_auth_type'] and !$this->memberData['g_access_cp']) {
             //-----------------------------------------
             // Remove any existing entries
             //-----------------------------------------
             $_previous = $this->DB->buildAndFetch(array('select' => 'prev_email, real_group', 'from' => 'validating', 'where' => "member_id={$this->memberData['member_id']} AND email_chg=1"));
             if ($_previous['prev_email']) {
                 $this->DB->delete('validating', "member_id={$this->memberData['member_id']} AND email_chg=1");
                 $this->memberData['email'] = $_previous['prev_email'];
                 $this->memberData['member_group_id'] = $_previous['real_group'];
             }
             $validate_key = md5(IPSMember::makePassword() . time());
             //-----------------------------------------
             // Update the new email, but enter a validation key
             // and put the member in "awaiting authorisation"
             // and send an email..
             //-----------------------------------------
             $db_str = array('vid' => $validate_key, 'member_id' => $this->memberData['member_id'], 'temp_group' => $this->settings['auth_group'], 'entry_date' => time(), 'coppa_user' => 0, 'email_chg' => 1, 'ip_address' => $this->member->ip_address, 'prev_email' => $this->memberData['email']);
             if ($this->memberData['member_group_id'] != $this->settings['auth_group']) {
                 $db_str['real_group'] = $this->memberData['member_group_id'];
             }
             $this->DB->insert('validating', $db_str);
             IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($_emailOne), $this->memberData['email']);
             IPSMember::save($this->memberData['member_id'], array('core' => array('member_group_id' => $this->settings['auth_group'], 'email' => $_emailOne)));
             //-----------------------------------------
             // Update their session with the new member group
             //-----------------------------------------
             if ($this->member->session_id) {
                 $this->member->sessionClass()->convertMemberToGuest();
             }
             //-----------------------------------------
             // Kill the cookies to stop auto log in
             //-----------------------------------------
             IPSCookie::set('pass_hash', '-1', 0);
             IPSCookie::set('member_id', '-1', 0);
             IPSCookie::set('session_id', '-1', 0);
             //-----------------------------------------
             // Dispatch the mail, and return to the activate form.
             //-----------------------------------------
             IPSText::getTextClass('email')->getTemplate("newemail");
             IPSText::getTextClass('email')->buildMessage(array('NAME' => $this->memberData['members_display_name'], 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=auto_validate&type=newemail&uid=" . $this->memberData['member_id'] . "&aid=" . $validate_key, 'publicNoSession', 'false'), 'ID' => $this->memberData['member_id'], 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global&section=register&do=07", 'publicNoSession', 'false'), 'CODE' => $validate_key));
             IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'] . ' ' . $this->settings['board_name'];
             IPSText::getTextClass('email')->to = $_emailOne;
             IPSText::getTextClass('email')->sendMail();
             $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=core&module=global&section=register&do=07');
         } else {
             //-----------------------------------------
             // No authorisation needed, change email addy and return
             //-----------------------------------------
             IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($_emailOne), $this->memberData['email']);
             IPSMember::save($this->memberData['member_id'], array('core' => array('email' => $_emailOne)));
             //-----------------------------------------
             // Add to OK message
             //-----------------------------------------
             $this->ok_message = $this->lang->words['ok_email_changed'];
         }
     }
     return TRUE;
 }
Beispiel #6
0
 /**
  * Change a member's password
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function save_password()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $member_id = intval($this->request['member_id']);
     $password = IPSText::parseCleanValue($_POST['password']);
     $password2 = IPSText::parseCleanValue($_POST['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));
     //-----------------------------------------
     // AJAX debug
     //-----------------------------------------
     IPSDebug::fireBug('info', array('Password: '******'password_nogood']);
     }
     if ($password != $password2) {
         $this->registry->output->showError($this->lang->words['m_passmatch']);
     }
     //-----------------------------------------
     // 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->registry->output->showError($this->lang->words['m_editadmin']);
     }
     //-----------------------------------------
     // Check Converge: Password
     //-----------------------------------------
     $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
     $han_login = new $classToLoad($this->registry);
     $han_login->init();
     $han_login->changePass($member['email'], $md5_once, $password, $member);
     /*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));
     $this->registry->output->global_message = $this->lang->words['pw_updated_success'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=members&do=viewmember&member_id=' . $member_id);
 }
 /**
  * Save new email and/or pass
  *
  * @return	@e void
  */
 protected function _saveForm()
 {
     if (!$this->request['email'] and !$this->request['password']) {
         $this->registry->output->global_error = $this->lang->words['change_nothing_update'];
         $this->_showForm();
         return;
     }
     if ($this->request['email']) {
         if (!$this->request['email_confirm']) {
             $this->registry->output->global_error = $this->lang->words['change_both_fields'];
             $this->_showForm();
             return;
         } else {
             if ($this->request['email'] != $this->request['email_confirm']) {
                 $this->registry->output->global_error = $this->lang->words['change_not_match'];
                 $this->_showForm();
                 return;
             }
         }
         $email = trim($this->request['email']);
         if (!IPSText::checkEmailAddress($email)) {
             $this->registry->output->global_error = $this->lang->words['bad_email_supplied'];
             $this->_showForm();
             return;
         }
         $email_check = IPSMember::load(strtolower($email));
         if ($email_check['member_id']) {
             if ($email_check['member_id'] == $this->memberData['member_id']) {
                 $this->registry->output->global_error = $this->lang->words['already_using_email'];
             } else {
                 $this->registry->output->global_error = $this->lang->words['change_email_already_used'];
             }
             $this->_showForm();
             return;
         }
         //-----------------------------------------
         // Load handler...
         //-----------------------------------------
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
         $han_login = new $classToLoad($this->registry);
         $han_login->init();
         $han_login->changeEmail(trim(strtolower($this->memberData['email'])), trim(strtolower($email)), $this->memberData);
         IPSLib::runMemberSync('onEmailChange', $this->memberData['member_id'], strtolower($email), $this->memberData['email']);
         IPSMember::save($this->memberData['member_id'], array('core' => array('email' => 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_error = $this->lang->words['change_both_fields'];
             $this->_showForm();
             return;
         } else {
             if ($this->request['password'] != $this->request['password_confirm']) {
                 $this->registry->output->global_error = $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));
         $classToLoad = IPSLib::loadLibrary(IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login');
         $han_login = new $classToLoad($this->registry);
         $han_login->init();
         $han_login->changePass($this->memberData['email'], $md5_once, $password, $this->memberData);
         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']);
 }
Beispiel #8
0
 /**
  * Authenticate the request
  *
  * @access	public
  * @param	string		Username
  * @param	string		Email Address
  * @param	string		Password
  * @return	boolean		Authentication successful
  */
 public function authenticate($username, $email_address, $password)
 {
     //-----------------------------------------
     // Set basic data
     //-----------------------------------------
     $send = array('act' => 'login', 'key' => $this->connectConfig['master_key'], 'password' => md5($password));
     //-----------------------------------------
     // Load to check if we have master ID already
     //-----------------------------------------
     if ($username) {
         $_member = IPSMember::load($username, 'all', 'username');
     } else {
         $_member = IPSMember::load($email_address, 'all', 'email');
     }
     if ($_member['ipsconnect_id']) {
         $send['idType'] = 'id';
         $send['id'] = $_member['ipsconnect_id'];
     } else {
         if ($username) {
             $send['idType'] = 'username';
             $send['id'] = $username;
         } else {
             $send['idType'] = 'email';
             $send['id'] = $email_address;
         }
     }
     //-----------------------------------------
     // Send API Call
     //-----------------------------------------
     $send['key'] = md5($send['key'] . $send['id']);
     $url = $this->connectConfig['master_url'] . '?' . http_build_query($send);
     $return = $this->cfm->getFileContents($url);
     $data = @json_decode($return, TRUE);
     if (!isset($data['connect_status']) or !$data['connect_status']) {
         $this->return_code = 'WRONG_AUTH';
         return false;
     }
     //-----------------------------------------
     // If unsuccessful, return
     //-----------------------------------------
     if ($data['connect_status'] != 'SUCCESS') {
         $this->return_code = $data['connect_status'];
         if ($this->return_code == 'ACCOUNT_LOCKED') {
             $this->account_unlock = $data['connect_unlock'];
             /* @link http://community.invisionpower.com/resources/bugs.html/_/ip-board/ipsconnect-account-unlock-time-r40812 */
             if ($data['connect_unlock_period']) {
                 $this->settings['ipb_bruteforce_period'] = $data['connect_unlock_period'];
             }
         }
         if ($this->return_code == 'VALIDATING') {
             $this->revalidate_url = $data['connect_revalidate_url'];
         }
         return false;
     }
     //-----------------------------------------
     // Create or update member accordingly
     //-----------------------------------------
     $update = array();
     $this->member_data = IPSMember::load($data['connect_id'], 'all', 'ipsconnect');
     if (!isset($this->member_data['member_id']) and isset($_member['member_id'])) {
         $this->member_data = $_member;
         $update['ipsconnect_id'] = $data['connect_id'];
     }
     if (!isset($this->member_data['member_id'])) {
         if (IPSText::mbstrlen($data['connect_username']) > ipsRegistry::$settings['max_user_name_length']) {
             $data['connect_username'] = IPSText::mbsubstr($data['connect_username'], 0, ipsRegistry::$settings['max_user_name_length']);
         }
         $this->member_data = $this->createLocalMember(array('members' => array('name' => $data['connect_username'], 'members_display_name' => $data['connect_displayname'], 'email' => $email_address, 'password' => $password, 'ipsconnect_id' => $data['connect_id'])));
     } else {
         if ($this->member_data['name'] != $data['connect_username'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['name'] = $data['connect_username'];
         }
         if ($this->member_data['members_display_name'] != $data['connect_displayname'] and !defined('CONNECT_NOSYNC_NAMES')) {
             $update['members_display_name'] = $data['connect_displayname'];
         }
         if ($this->member_data['email'] != $data['connect_email']) {
             $update['email'] = $data['connect_email'];
         }
         IPSMember::updatePassword($this->member_data['member_id'], md5($password));
     }
     //-----------------------------------------
     // Privacy
     //-----------------------------------------
     $privacy = $this->member_data['g_hide_online_list'] || empty($this->settings['disable_anonymous']) && !empty($this->request['anonymous']) ? 1 : 0;
     $update['login_anonymous'] = intval($privacy) . '&1';
     //-----------------------------------------
     // Update
     //-----------------------------------------
     if (!empty($update)) {
         IPSMember::save($this->member_data['member_id'], array('members' => $update));
     }
     //-----------------------------------------
     // If this is ACP or cross domain, just log in without SSO
     // http://community.invisionpower.com/resources/bugs.html/_/ip-board/cross-domain-connect-logins-r41932
     //-----------------------------------------
     $local = strtolower(@parse_url($this->settings['board_url'], PHP_URL_HOST));
     $connect = strtolower(@parse_url($this->connectConfig['master_url'], PHP_URL_HOST));
     if (strstr($local, '.') && !IPSLib::validateIPv4($local)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $local)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $local = '.' . implode('.', array_reverse($_domain));
     }
     if (strstr($connect, '.') && !IPSLib::validateIPv4($connect)) {
         $_domain = array();
         foreach (array_reverse(explode('.', $connect)) as $bit) {
             $_domain[] = $bit;
             if (!in_array($bit, array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'ac', 'ad', 'ae', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'as', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'bj', 'bl', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cc', 'cd', 'cf', 'cg', 'ch', 'ci', 'ck', 'cl', 'cm', 'cn', 'co', 'cr', 'cu', 'cv', 'cx', 'cy', 'cz', 'de', 'dj', 'dk', 'dm', 'do', 'dz', 'ec', 'ee', 'eg', 'eh', 'er', 'es', 'et', 'eu', 'fi', 'fj', 'fk', 'fm', 'fo', 'fr', 'ga', 'gb', 'gd', 'ge', 'gf', 'gg', 'gh', 'gi', 'gl', 'gm', 'gn', 'gp', 'gq', 'gr', 'gs', 'gt', 'gu', 'gw', 'gy', 'hk', 'hm', 'hn', 'hr', 'ht', 'hu', 'id', 'ie', 'il', 'im', 'in', 'io', 'iq', 'ir', 'is', 'it', 'je', 'jm', 'jo', 'jp', 'ke', 'kg', 'kh', 'ki', 'km', 'kn', 'kp', 'kr', 'kw', 'ky', 'kz', 'la', 'lb', 'lc', 'li', 'lk', 'lr', 'ls', 'lt', 'lu', 'lv', 'ly', 'ma', 'mc', 'md', 'me', 'mg', 'mh', 'mk', 'ml', 'mm', 'mn', 'mo', 'mp', 'mq', 'mr', 'ms', 'mt', 'mu', 'mv', 'mw', 'mx', 'my', 'mz', 'na', 'nc', 'ne', 'nf', 'ng', 'ni', 'nl', 'no', 'np', 'nr', 'nu', 'nz', 'om', 'pa', 'pe', 'pf', 'pg', 'ph', 'pk', 'pl', 'pm', 'pn', 'pr', 'ps', 'pt', 'pw', 'py', 'qa', 're', 'ro', 'rs', 'ru', 'rw', 'sa', 'sb', 'sc', 'sd', 'se', 'sg', 'sh', 'si', 'sj', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'st', 'su', 'sv', 'sy', 'sz', 'tc', 'td', 'tf', 'tg', 'th', 'tj', 'tk', 'tl', 'tm', 'tn', 'to', 'tp', 'tr', 'tt', 'tv', 'tw', 'tz', 'ua', 'ug', 'uk', 'um', 'us', 'uy', 'uz', 'va', 'vc', 've', 'vg', 'vi', 'vn', 'vu', 'wf', 'ws', 'ye', 'yt', 'yu', 'za', 'zm', 'zw'))) {
                 break;
             }
         }
         $connect = '.' . implode('.', array_reverse($_domain));
     }
     if ($this->is_admin_auth or $this->is_password_check or $local != $connect) {
         $this->return_code = 'SUCCESS';
         return;
     }
     //-----------------------------------------
     // And redirect to log us in centrally
     //-----------------------------------------
     $redirect = $this->request['referer'] ? $this->request['referer'] : $this->settings['board_url'];
     if (strpos($redirect, '?') === FALSE) {
         $redirect .= '?';
     }
     $this->registry->output->silentRedirect($url . '&noparams=1&redirect=' . base64_encode($redirect) . '&redirectHash=' . md5($this->connectConfig['master_key'] . base64_encode($redirect)));
 }
Beispiel #9
0
 public function updateUser($api_key, $api_module, $username, $email, $md5_passwordHash)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $api_key = IPSText::md5Clean($api_key);
     $api_module = IPSText::parseCleanValue($api_module);
     //-----------------------------------------
     // Authenticate
     //-----------------------------------------
     if ($this->__authenticate($api_key, $api_module, 'updateUser') !== FALSE) {
         //-----------------------------------------
         // Add log
         //-----------------------------------------
         $this->addLogging($api_key);
         //-----------------------------------------
         // Load our user
         //-----------------------------------------
         $member = IPSMember::load($username, 'all', 'username');
         if ($member != null) {
             $email_result = IPSMember::save(array('core' => array('field' => 'member_id', 'value' => $member['member_id'])), array('core' => array('email' => $email)));
             $password_result = $password_result = IPSMember::updatePassword($member['member_id'], $md5_passwordHash);
             if ($email_result && $password_result) {
                 $this->classApiServer->apiSendReply(array('result' => 'success'));
             } else {
                 $this->classApiServer->apiSendReply(array('result' => 'failure'));
             }
         }
         $this->classApiServer->apiSendReply(array('result' => 'failure'));
         exit;
     }
 }
    /**
     * 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);
    }
 /**
  * UserCP Save Form: Password
  *
  * @access	public
  * @param	array	Array of member / core_sys_login information (if we're editing)
  * @return	mixed	Array of errors / boolean true
  */
 public function saveFormPassword($member = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $cur_pass = trim($this->request['current_pass']);
     $new_pass = trim($this->request['new_pass_1']);
     $chk_pass = trim($this->request['new_pass_2']);
     //-----------------------------------------
     // Checks...
     //-----------------------------------------
     if ($this->memberData['g_access_cp']) {
         return array(0 => $this->lang->words['admin_emailpassword']);
     }
     if (!$_POST['current_pass'] or empty($new_pass) or empty($chk_pass)) {
         return array(0 => $this->lang->words['complete_entire_form']);
     }
     //-----------------------------------------
     // Do the passwords actually match?
     //-----------------------------------------
     if ($new_pass != $chk_pass) {
         return array(0 => $this->lang->words['passwords_not_matchy']);
     }
     //-----------------------------------------
     // Check password...
     //-----------------------------------------
     if ($this->_checkPassword($cur_pass) !== TRUE) {
         return array(0 => $this->lang->words['current_pw_bad']);
     }
     /*if ( IPSText::mbstrlen( $new_pass ) > 32)
     		{
     			return array( 0 => $this->lang->words['new_pw_too_long'] );
     		}*/
     //-----------------------------------------
     // Create new password...
     //-----------------------------------------
     $md5_pass = md5($new_pass);
     //-----------------------------------------
     // han_login was loaded during check_password
     //-----------------------------------------
     $this->han_login->changePass($this->memberData['email'], $md5_pass);
     if ($this->han_login->return_code and $this->han_login->return_code != 'METHOD_NOT_DEFINED' and $this->han_login->return_code != 'SUCCESS') {
         return array(0 => $this->lang->words['hanlogin_pw_failed']);
     }
     //-----------------------------------------
     // Update the DB
     //-----------------------------------------
     IPSMember::updatePassword($this->memberData['email'], $md5_pass);
     IPSLib::runMemberSync('onPassChange', $this->memberData['member_id'], $new_pass);
     //-----------------------------------------
     // Update members log in key...
     //-----------------------------------------
     $key = IPSMember::generateAutoLoginKey();
     IPSMember::save($this->memberData['member_id'], array('core' => array('member_login_key' => $key)));
     $this->ok_message = $this->lang->words['pw_change_successful'];
     return TRUE;
 }