Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+68 -13
View File
@@ -2,9 +2,9 @@
/**
* @brief IPS Connect Login Handler
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 18 Mar 2013
* @version SVN_VERSION_NUMBER
*/
@@ -55,11 +55,11 @@ class _Ipsconnect extends LoginAbstract
try
{
/* Are we being returned from a cross-domain login? */
if( \IPS\Request::i()->loginProcess == 'ipsconnect' AND \IPS\Request::i()->id AND \IPS\Request::i()->key )
if( \IPS\Request::i()->loginProcess == 'ipsconnect' AND \IPS\Request::i()->ipsconnectId AND \IPS\Request::i()->ipsconnectKey )
{
$member = \IPS\Member::load( \IPS\Request::i()->id, 'ipsconnect_id' );
$member = \IPS\Member::load( \IPS\Request::i()->ipsconnectId, 'ipsconnect_id' );
if( $member->member_id AND \IPS\Login::compareHashes( \IPS\Request::i()->key, md5( $this->settings['key'] . $member->ipsconnect_id ) ) )
if( $member->member_id AND \IPS\Login::compareHashes( \IPS\Request::i()->ipsconnectKey, md5( $this->settings['key'] . $member->ipsconnect_id ) ) )
{
return $member;
}
@@ -75,7 +75,14 @@ class _Ipsconnect extends LoginAbstract
/* No response or status is not 'SUCCESS' */
if ( empty( $response ) OR empty( $response['status'] ) OR $response['status'] != 'SUCCESS' OR !$response['pass_salt'] )
{
throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR );
if( isset( $response['status'] ) AND $response['status'] == 'ACCOUNT_NOT_FOUND' )
{
throw new \IPS\Login\Exception( \IPS\Member::loggedIn()->language()->addToStack('login_err_no_account', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $this->getLoginType( $this->authTypes ) ) ) ) ), \IPS\Login\Exception::NO_ACCOUNT );
}
else
{
throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR );
}
}
/* Now create a dummy user to get password hash */
@@ -154,19 +161,17 @@ class _Ipsconnect extends LoginAbstract
$this->connectSuccessful( $member );
/* If we are still here and successful, redirect to master to log us in to each installation */
$url = \IPS\Http\Url::internal( '' );
\IPS\Request::i()->ref = (string) \IPS\Http\Url::external( $this->settings['url'] )->setQueryString(
array(
'do' => 'crossLogin',
'key' => md5( $this->settings['key'] . $member->ipsconnect_id ),
'url' => \IPS\Settings::i()->base_url . '/applications/core/interface/ipsconnect/ipsconnect.php',
'id' => $member->ipsconnect_id,
'returnTo' => (string) $url->setQueryString(
'returnTo' => (string) \IPS\Login::getDestination()->setQueryString(
array(
'loginProcess' => 'ipsconnect',
'key' => md5( $this->settings['key'] . $member->ipsconnect_id ),
'id' => $member->ipsconnect_id,
'ref' => (string) \IPS\Login::getDestination()
'ipsconnectKey' => md5( $this->settings['key'] . $member->ipsconnect_id ),
'ipsconnectId' => $member->ipsconnect_id
)
)
)
@@ -240,6 +245,28 @@ class _Ipsconnect extends LoginAbstract
{
return (bool) $this->_getConnectId( $member );
}
/**
* [Node] Get whether or not this node is enabled
*
* @note Return value NULL indicates the node cannot be enabled/disabled
* @return bool|null
*/
protected function get__enabled()
{
$result = parent::get__enabled();
/* If we are not enabled, determine if we are a master installation already - if so, we can't be enabled */
if( $result === FALSE )
{
if( \IPS\Db::i()->select( 'COUNT(*)', 'core_ipsconnect_slaves', array( 'slave_enabled=?', 1 ) )->first() > 0 )
{
return NULL;
}
}
return $result;
}
/**
* Can a member change their email/password with this login handler?
@@ -266,10 +293,16 @@ class _Ipsconnect extends LoginAbstract
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('login_error_ipsconnect_self') );
}
/* If we are already a master, we can't be a slave too */
if( \IPS\Db::i()->select( 'COUNT(*)', 'core_ipsconnect_slaves' )->first() > 0 )
{
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('login_error_ipsconnect_master') );
}
try
{
$response = \IPS\Http\Url::external( $this->settings['url'] )
->setQueryString( array( 'do' => 'verifySettings', 'key' => $this->settings['key'], 'url' => \IPS\Settings::i()->base_url . '/applications/core/interface/ipsconnect/ipsconnect.php', 'ourKey' => md5( md5( \IPS\Settings::i()->sql_user . \IPS\Settings::i()->sql_pass ) . \IPS\Settings::i()->board_start ) ) )
->setQueryString( array( 'do' => 'verifySettings', 'key' => $this->settings['key'], 'url' => \IPS\Settings::i()->base_url . '/applications/core/interface/ipsconnect/ipsconnect.php', 'ourKey' => \IPS\CONNECT_MASTER_KEY ?: md5( md5( \IPS\Settings::i()->sql_user . \IPS\Settings::i()->sql_pass ) . \IPS\Settings::i()->board_start ) ) )
->request()
->get()
->decodeJson();
@@ -428,7 +461,9 @@ class _Ipsconnect extends LoginAbstract
'url' => \IPS\Settings::i()->base_url . '/applications/core/interface/ipsconnect/ipsconnect.php',
'id' => $connectId,
'returnTo' => (string) $redirectUrl,
) )
) ),
'',
303
);
}
}
@@ -683,4 +718,24 @@ class _Ipsconnect extends LoginAbstract
->decodeJson();
}
}
/**
* Perform an action when the login handler is disabled
*
* @return bool
*/
public function onDisable()
{
try
{
$response = \IPS\Http\Url::external( $this->settings['url'] )
->setQueryString( array( 'do' => 'disableSlave', 'key' => $this->settings['key'], 'url' => \IPS\Settings::i()->base_url . '/applications/core/interface/ipsconnect/ipsconnect.php' ) )
->request()
->get()
->decodeJson();
}
catch( \RuntimeException $e ){}
return TRUE;
}
}