Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+102 -116
View File
@@ -1,19 +1,19 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* Login handler abstraction
* Last Updated: $Date: 2009-11-11 20:48:24 -0500 (Wed, 11 Nov 2009) $
* Last Updated: $Date: 2010-11-12 13:07:33 -0500 (Fri, 12 Nov 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
* @version $Revision: 5376 $
*
* @version $Revision: 7174 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -25,57 +25,18 @@ if ( ! defined( 'IN_IPB' ) )
class han_login
{
/**
* Registry object
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
/**
* Database object
*
* @access protected
* @var object
*/
protected $DB;
/**
* Settings object
*
* @access protected
* @var object
*/
protected $settings;
/**
* Request object
*
* @access protected
* @var object
*/
protected $request;
/**
* Language object
*
* @access protected
* @var object
*/
protected $lang;
/**
* Member object
*
* @access protected
* @var object
*/
protected $member;
/**
* Login module registry
*
* @access private
* @var array
*/
private $modules = array();
@@ -83,7 +44,6 @@ class han_login
/**
* Flag :: ACP Login
*
* @access public
* @var integer
*/
public $is_admin_auth = 0;
@@ -91,7 +51,6 @@ class han_login
/**
* Login handler return code
*
* @access public
* @var string
*/
public $return_code = 'WRONG_AUTH';
@@ -99,7 +58,6 @@ class han_login
/**
* Login handler return details
*
* @access public
* @var string
*/
public $return_details = "";
@@ -107,7 +65,6 @@ class han_login
/**
* Flag :: Account unlocked
*
* @access public
* @var integer
*/
public $account_unlock = 0;
@@ -115,7 +72,6 @@ class han_login
/**
* Member data returned
*
* @access public
* @var array
*/
public $member_data = array( 'member_id' => 0 );
@@ -123,7 +79,6 @@ class han_login
/**
* Login methods
*
* @access protected
* @var array
*/
protected $login_methods = array();
@@ -131,7 +86,6 @@ class han_login
/**
* Login configuration details
*
* @access protected
* @var array
*/
protected $login_confs = array();
@@ -139,7 +93,6 @@ class han_login
/**
* Constructor
*
* @access public
* @param object ipsRegistry reference
* @return void
*/
@@ -150,9 +103,11 @@ class han_login
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
//-----------------------------------------
// Do not set member, memberData or lang
// Causes issues with SSO implementations
//-----------------------------------------
}
/**
@@ -160,12 +115,11 @@ class han_login
* DOES NOT CHECK FOR A USERNAME OR PASSWORD.
* << USE WITH CAUTION >>
*
* @access public
* @param int Member ID to log in
* @param boolean Set cookies
* @return mixed FALSE on error or array [0=Words to show, 1=URL to send to] on success
*/
public function loginWithoutCheckingCredentials( $memberID, $setCookies=TRUE)
public function loginWithoutCheckingCredentials( $memberID, $setCookies=TRUE )
{
//-----------------------------------------
// Load member
@@ -196,7 +150,7 @@ class han_login
$member['timenow'] = $partial['partial_date'];
}
return array( $this->lang->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid='.$member['member_id'].'&amp;key='.$member['timenow'] );
return array( $this->registry->getClass('class_localization')->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid='.$member['member_id'].'&amp;key='.$member['timenow'] );
}
//-----------------------------------------
@@ -243,7 +197,7 @@ class han_login
if ( $member['ip_address'] == "" OR $member['ip_address'] == '127.0.0.1' )
{
$core['ip_address'] = $this->member->ip_address;
$core['ip_address'] = $this->registry->member()->ip_address;
}
//-----------------------------------------
@@ -257,13 +211,13 @@ class han_login
$privacy = 1;
}
$session_id = $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
$session_id = $this->registry->member()->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
'member_id' => $member['member_id'],
'member_group' => $member['member_group_id'],
'login_type' => $privacy ) );
if ( $this->request['referer'] AND $this->request['referer'] AND $this->request['section'] != 'register' )
if ( isset( $this->request['referer'] ) AND $this->request['referer'] AND $this->request['section'] != 'register' )
{
if ( stripos( $this->request['referer'], 'section=register' ) OR stripos( $this->request['referer'], 'section=login' ) OR stripos( $this->request['referer'], 'section=lostpass' ) )
{
@@ -276,7 +230,7 @@ class han_login
//$url = str_replace( "{$this->settings['board_url']}/", "", $url );
//$url = str_replace( "{$this->settings['board_url']}", "", $url );
//$url = preg_replace( "#^(.+?)\?#", "" , $url );
$url = preg_replace( "#s=(\w){32}#", "" , $url );
$url = preg_replace( '#s=(\w){32}#', "" , $url );
$url = ltrim( $url, '?' );
}
}
@@ -284,6 +238,7 @@ class han_login
{
$url = $this->settings['base_url'];
}
//-----------------------------------------
// Set our privacy status
@@ -299,20 +254,20 @@ class han_login
// Clear out any passy change stuff
//-----------------------------------------
$this->DB->delete( 'validating', 'member_id=' . $this->memberData['member_id'] . ' AND lost_pass=1' );
$this->DB->delete( 'validating', 'member_id=' . $this->registry->member()->getProperty('member_id') . ' AND lost_pass=1' );
//-----------------------------------------
// Redirect them to either the board
// index, or where they came from
//-----------------------------------------
if ( $this->request['return'] AND $this->request['return'] != "" )
if ( !empty($this->request['return']) )
{
$return = urldecode($this->request['return']);
if ( strpos( $return, "http://" ) === 0 )
{
return array( $this->lang->words['partial_login'], $return );
return array( $this->registry->getClass('class_localization')->words['partial_login'], $return );
}
}
@@ -323,12 +278,12 @@ class han_login
/* Member Sync */
IPSLib::runMemberSync( 'onLogin', $member );
return array( $this->lang->words['partial_login'], str_replace( '?&', '?', $url . '&s=' . $session_id ) );
return array( $this->registry->getClass('class_localization')->words['partial_login'], str_replace( '?&', '?', $url . '&s=' . $session_id ) );
}
/**
* Wrapper for loginAuthenticate - returns more information
*
* @access public
* @return mixed array [0=Words to show, 1=URL to send to, 2=error message language key]
*/
public function verifyLogin()
@@ -409,7 +364,7 @@ class han_login
if ( $member['members_created_remote'] AND isset($member['full']) AND !$member['full'] )
{
return array( $this->lang->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid='.$member['member_id'].'&amp;key='.$member['timenow'] );
return array( $this->registry->getClass('class_localization')->words['partial_login'], $this->settings['base_url'] . 'app=core&amp;module=global&amp;section=register&amp;do=complete_login&amp;mid='.$member['member_id'].'&amp;key='.$member['timenow'] );
}
//-----------------------------------------
@@ -456,7 +411,7 @@ class han_login
if ( $member['ip_address'] == "" OR $member['ip_address'] == '127.0.0.1' )
{
$core['ip_address'] = $this->member->ip_address;
$core['ip_address'] = $this->registry->member()->ip_address;
}
//-----------------------------------------
@@ -470,7 +425,7 @@ class han_login
$privacy = 1;
}
$session_id = $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
$session_id = $this->registry->member()->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
'member_id' => $member['member_id'],
'member_group' => $member['member_group_id'],
'login_type' => $privacy ) );
@@ -480,22 +435,21 @@ class han_login
{
if ( stripos( $this->request['referer'], 'section=register' ) OR stripos( $this->request['referer'], 'section=login' ) OR stripos( $this->request['referer'], 'section=lostpass' ) OR stripos( $this->request['referer'], CP_DIRECTORY . '/' ) )
{
$url = $this->settings['base_url'] . '?act=idx';
$url = $this->settings['base_url'];
}
else
{
$url = str_replace( '&amp;' , '&', $this->request['referer'] );
$url = preg_replace( "#s=(\w){32}#", "" , $url );
if( $this->member->session_type != 'cookie' )
$url = str_replace( '&amp;', '&', $this->request['referer'] );
if( $this->registry->member()->session_type == 'cookie' )
{
$url = $this->settings['board_url'] . '/index.php?s=' . $session_id;
$url = preg_replace( '#s=(\w){32}#', "" , $url );
}
}
}
else
{
$url = $this->settings['base_url'] . '?act=idx';
$url = $this->settings['base_url'];
}
//-----------------------------------------
@@ -512,20 +466,20 @@ class han_login
// Clear out any passy change stuff
//-----------------------------------------
$this->DB->delete( 'validating', 'member_id=' . $this->memberData['member_id'] . ' AND lost_pass=1' );
$this->DB->delete( 'validating', 'member_id=' . $this->registry->member()->getProperty('member_id') . ' AND lost_pass=1' );
//-----------------------------------------
// Redirect them to either the board
// index, or where they came from
//-----------------------------------------
if ( $this->request['return'] )
if ( !empty($this->request['return']) )
{
$return = urldecode($this->request['return']);
if ( strpos( $return, "http://" ) === 0 )
{
return array( $this->lang->words['partial_login'], $return );
return array( $this->registry->getClass('class_localization')->words['partial_login'], $return );
}
}
@@ -533,16 +487,19 @@ class han_login
// Still here?
//-----------------------------------------
$member['plainPassword'] = $password;
/* Member Sync */
IPSLib::runMemberSync( 'onLogin', $member );
return array( $this->lang->words['partial_login'], $url );
unset( $member['plainPassword'] );
return array( $this->registry->getClass('class_localization')->words['partial_login'], $url );
}
/**
* Initialize class
*
* @access public
* @return void
*/
public function init()
@@ -585,10 +542,8 @@ class han_login
$this->login_confs[ $login_method['login_order'] ] = $LOGIN_CONF;
}
$classname = "login_" . $login_method['login_folder_name'];
require_once( $classes[ $login_method['login_order'] ] );
$this->modules[ $login_method['login_order'] ] = new $classname( $this->registry, $login_method, $this->login_confs[ $login_method['login_order'] ] );
$classname = IPSLib::loadLibrary( $classes[ $login_method['login_order'] ], 'login_' . $login_method['login_folder_name'] );
$this->modules[ $login_method['login_order'] ] = new $classname( $this->registry, $login_method, $this->login_confs[ $login_method['login_order'] ] );
}
}
}
@@ -654,7 +609,7 @@ class han_login
if( !count($this->modules) )
{
$this->registry->output->showError( $this->lang->words['no_login_methods'], 4000 );
$this->registry->output->showError( $this->registry->getClass('class_localization')->words['no_login_methods'], 4000 );
}
//-----------------------------------------
@@ -672,7 +627,6 @@ class han_login
/**
* Force email check flag in any modules, currently used for facebook
*
* @access public
* @param boolean
* @return null
*/
@@ -690,7 +644,6 @@ class han_login
/**
* Checks if password authenticates
*
* @access public
* @param string Username
* @param string Email Address
* @param string Password
@@ -716,7 +669,6 @@ class han_login
/**
* Authenticate the user - creates account if possible
*
* @access public
* @param string Username
* @param string Email Address
* @param string Password
@@ -727,7 +679,7 @@ class han_login
foreach( $this->modules as $k => $obj_reference )
{
$obj_reference->authenticate( $username, $email_address, $password );
$this->return_code = ( $obj_reference->return_code == 'SUCCESS' ? 'SUCCESS' : $obj_reference->return_code );
$this->return_code = $obj_reference->return_code;
$this->member_data = $obj_reference->member_data;
$this->account_unlock = ( $obj_reference->account_unlock ) ? $obj_reference->account_unlock : $this->account_unlock;
@@ -747,7 +699,7 @@ class han_login
// Want to redirect somewhere to login?
//-----------------------------------------
if( !$redirect AND $this->login_methods[ $k ]['login_login_url'] )
if( $this->login_methods[ $k ]['login_login_url'] )
{
$redirect = $this->login_methods[ $k ]['login_login_url'];
}
@@ -770,7 +722,6 @@ class han_login
/**
* Logout callback - called when a user logs out
*
* @access public
* @return mixed Possible redirection based on login method config, else array of messages
*/
public function logoutCallback()
@@ -810,7 +761,6 @@ class han_login
/**
* Alternate login URL redirection
*
* @access public
* @return mixed Possible redirection based on login method config, else false
*/
public function checkLoginUrlRedirect()
@@ -849,7 +799,6 @@ class han_login
/**
* User maintenance callback
*
* @access public
* @return mixed Possible redirection based on login method config, else false
*/
public function checkMaintenanceRedirect()
@@ -884,12 +833,46 @@ class han_login
return false;
}
/**
* Check if the username is already in use
*
* @param string User Name
* @param string Array of member data
* @param srting Field to check, members_l_username or members_l_display_name
* @return boolean Authenticate successful
*/
public function nameExistsCheck( $nameToCheck, $memberData, $fieldToCheck='members_l_username' )
{
$this->return_code = 'METHOD_NOT_DEFINED';
foreach( $this->modules as $k => $obj_reference )
{
if( method_exists( $obj_reference, 'nameExistsCheck' ) )
{
$obj_reference->nameExistsCheck( $nameToCheck, $memberData, $fieldToCheck );
$this->return_code = $obj_reference->return_code;
if( $this->return_code AND !in_array( $this->return_code, array( 'NAME_NOT_IN_USE', 'METHOD_NOT_DEFINED', 'WRONG_AUTH', 'WRONG_OPENID' ) ) )
{
break;
}
}
}
if( $this->return_code AND !in_array( $this->return_code, array( 'NAME_NOT_IN_USE', 'METHOD_NOT_DEFINED', 'WRONG_AUTH', 'WRONG_OPENID' ) ) )
{
return true;
}
else
{
return false;
}
}
/**
* Check if the email is already in use
*
* @access public
* @param string Email address
* @return boolean Authenticate successful
*/
@@ -924,12 +907,11 @@ class han_login
/**
* Change a user's email address
*
* @access public
* @param string Old Email address
* @param string New Email address
* @return boolean Email changed successfully
*/
public function changeEmail( $old_email, $new_email )
public function changeEmail( $old_email, $new_email, $memberData )
{
$this->return_code = 'METHOD_NOT_DEFINED';
@@ -937,7 +919,7 @@ class han_login
{
if( method_exists( $obj_reference, 'changeEmail' ) )
{
$obj_reference->changeEmail( $old_email, $new_email );
$obj_reference->changeEmail( $old_email, $new_email, $memberData );
$this->return_code = $obj_reference->return_code;
}
}
@@ -948,12 +930,13 @@ class han_login
/**
* Change a user's password
*
* @access public
* @param string Email address
* @param string New password
* @param string Plain Text Password
* @param string Member Array
* @return boolean Password changed successfully
*/
public function changePass( $email, $new_pass )
public function changePass( $email, $new_pass, $plain_pass, $memberData )
{
$this->return_code = 'METHOD_NOT_DEFINED';
@@ -961,8 +944,8 @@ class han_login
{
if( method_exists( $obj_reference, 'changePass' ) )
{
$obj_reference->changePass( $email, $new_pass );
$this->return_code = $obj_reference->return_code;
$obj_reference->changePass( $email, $new_pass, $plain_pass, $memberData );
$this->return_code = $this->return_code == 'SUCCESS' ? 'SUCCESS' : $obj_reference->return_code;
}
}
@@ -972,13 +955,13 @@ class han_login
/**
* Change a login name
*
* @access public
* @param string Old Name
* @param string New Name
* @param string User's email address
* @param array Arra of Member Data
* @return boolean Request was successful
*/
public function changeName( $old_name, $new_name, $email_address )
public function changeName( $old_name, $new_name, $email_address, $memberData )
{
$this->return_code = 'METHOD_NOT_DEFINED';
@@ -986,7 +969,7 @@ class han_login
{
if( method_exists( $obj_reference, 'changeName' ) )
{
$obj_reference->changeName( $old_name, $new_name, $email_address );
$obj_reference->changeName( $old_name, $new_name, $email_address, $memberData );
$this->return_code = $obj_reference->return_code;
}
}
@@ -997,7 +980,6 @@ class han_login
/**
* Create a user's account
*
* @access public
* @param array Array of member information
* @return boolean Account created successfully
*/
@@ -1025,7 +1007,6 @@ class han_login
/**
* Determine email address or username login
*
* @access public
* @return integer [1=Username, 2=Email, 3=Both]
*/
public function emailOrUsername()
@@ -1035,6 +1016,12 @@ class han_login
foreach( $this->login_methods as $k => $method )
{
if( $method['login_user_id'] == 'either' )
{
$username = true;
$email = true;
break;
}
if( $method['login_user_id'] == 'username' )
{
$username = true;
@@ -1072,7 +1059,6 @@ class han_login
/**
* Get additional login form HTML add/replace
*
* @access public
* @return mixed Null or Array [0=Add or replace flag, 1=Array of HTML blocks to add/replace with]
*/
public function additionalFormHTML()