Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief MaxMind Request
|
||||
* @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
|
||||
* @subpackage Nexus
|
||||
* @since 07 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -42,15 +42,7 @@ class _Request
|
||||
|
||||
if ( $session )
|
||||
{
|
||||
$this->setIpAddress( $_SERVER['REMOTE_ADDR'] );
|
||||
if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
|
||||
{
|
||||
$this->data['forwardedIP'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
elseif( isset( $_SERVER['HTTP_CLIENT_IP'] ) )
|
||||
{
|
||||
$this->data['forwardedIP'] = $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
$this->setIpAddress( \IPS\Request::i()->ipAddress() );
|
||||
|
||||
$this->data['sessionID'] = session_id();
|
||||
|
||||
@@ -85,7 +77,7 @@ class _Request
|
||||
*/
|
||||
public function setTransaction( \IPS\nexus\Transaction $transaction )
|
||||
{
|
||||
$this->setMember( $transaction->member );
|
||||
$this->setMember( $transaction->member->member_id ? $transaction->member : $transaction->invoice->member );
|
||||
|
||||
if ( $billingAddress = $transaction->invoice->billaddress )
|
||||
{
|
||||
@@ -96,7 +88,7 @@ class _Request
|
||||
$this->setShippingAddress( $transaction->invoice->shipaddress );
|
||||
}
|
||||
|
||||
$this->data['order_amount'] = $transaction->amount->amount;
|
||||
$this->data['order_amount'] = (string) $transaction->amount->amount;
|
||||
$this->data['order_currency'] = $transaction->amount->currency;
|
||||
}
|
||||
|
||||
@@ -117,7 +109,7 @@ class _Request
|
||||
/**
|
||||
* Set Shipping Address
|
||||
*
|
||||
* @param \IPS\GeoLocation $billingAddress
|
||||
* @param \IPS\GeoLocation $shippingAddress
|
||||
* @return void
|
||||
*/
|
||||
public function setShippingAddress( \IPS\GeoLocation $shippingAddress )
|
||||
@@ -156,7 +148,7 @@ class _Request
|
||||
/**
|
||||
* Set Credit Card
|
||||
*
|
||||
* @param string $cardNumber The card number
|
||||
* @param string $card The card number
|
||||
* @return void
|
||||
*/
|
||||
public function setCard( \IPS\nexus\CreditCard $card )
|
||||
@@ -194,7 +186,14 @@ class _Request
|
||||
* @throws \IPS\Http\Request\Exception
|
||||
*/
|
||||
public function request()
|
||||
{
|
||||
return new \IPS\nexus\Fraud\MaxMind\Response( \IPS\Http\Url::external( 'https://minfraud.maxmind.com/app/ccv2r' )->request()->post( $this->data ) );
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'https://minfraud.maxmind.com/app/ccv2r' )->request()->post( $this->data );
|
||||
|
||||
if ( isset( $response->httpHeaders['Content-Type'] ) and preg_match( '/; charset=(.+?)$/', $response->httpHeaders['Content-Type'], $matches ) )
|
||||
{
|
||||
$response = mb_convert_encoding( $response, 'UTF-8', $matches[1] );
|
||||
}
|
||||
|
||||
return new \IPS\nexus\Fraud\MaxMind\Response( (string) $response );
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief MaxMind Response
|
||||
* @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
|
||||
* @subpackage Nexus
|
||||
* @since 07 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -32,10 +32,10 @@ class _Response
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Response
|
||||
* @param string|NULL $data Data from MaxMind
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Response $data = NULL )
|
||||
public function __construct( $data = NULL )
|
||||
{
|
||||
if ( $data )
|
||||
{
|
||||
@@ -94,4 +94,41 @@ class _Response
|
||||
{
|
||||
return ( 100 - 10 ) / 3 * $this->proxyScore + ( $this->proxyScore > 3 ? ( 10 * ( $this->proxyScore - 3 ) ) : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* minFraud error codes
|
||||
*
|
||||
* @see https://dev.maxmind.com/minfraud/#Error_Reporting
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $responseErrors = array( 'INVALID_LICENSE_KEY', 'IP_REQUIRED', 'IP_NOT_FOUND ', 'MAX_REQUESTS_REACHED', 'LICENSE_REQUIRED ');
|
||||
|
||||
/**
|
||||
* Does the response include an error?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
if ( $this->err AND in_array($this->err, static::$responseErrors ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the response include a warning?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function warning()
|
||||
{
|
||||
if ( $this->err AND !in_array($this->err, static::$responseErrors ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Fraud Rule Node
|
||||
* @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
|
||||
* @subpackage Nexus
|
||||
* @since 11 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -428,7 +428,7 @@ class _Rule extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
/* Country */
|
||||
if ( $this->country != '*' )
|
||||
if ( $this->country != '*' and $transaction->invoice->billaddress )
|
||||
{
|
||||
if ( !in_array( $transaction->invoice->billaddress->country, explode(',', $this->country ) ) )
|
||||
{
|
||||
@@ -468,15 +468,15 @@ class _Rule extends \IPS\Node\Model
|
||||
{
|
||||
/* If there was an error, we cannot check any of these */
|
||||
$maxMind = $transaction->fraud;
|
||||
if ( $maxMind->err )
|
||||
if ( $maxMind->error() )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Score */
|
||||
if ( $this->maxmind )
|
||||
{
|
||||
if ( !$this->_checkCondition( $maxMind->score, $this->maxmind, $this->maxmind_unit ) )
|
||||
{
|
||||
if ( !$this->_checkCondition( $maxMind->riskScore !== NULL ? $maxMind->riskScore : round( $maxMind->score * 10 ), $this->maxmind, $this->maxmind_unit ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -551,14 +551,44 @@ class _Rule extends \IPS\Node\Model
|
||||
*/
|
||||
protected function _checkCondition( $a, $operator, $b )
|
||||
{
|
||||
if ( $a instanceof \IPS\Math\Number and !( $b instanceof \IPS\Math\Number ) )
|
||||
{
|
||||
$b = new \IPS\Math\Number( "{$b}" );
|
||||
}
|
||||
if ( !( $a instanceof \IPS\Math\Number ) and $b instanceof \IPS\Math\Number )
|
||||
{
|
||||
$a = new \IPS\Math\Number( "{$a}" );
|
||||
}
|
||||
|
||||
switch ( $operator )
|
||||
{
|
||||
case 'g':
|
||||
return $a > $b;
|
||||
if ( $a instanceof \IPS\Math\Number )
|
||||
{
|
||||
return $a->compare( $b ) === 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $a > $b;
|
||||
}
|
||||
case 'e':
|
||||
return $a == $b;
|
||||
if ( $a instanceof \IPS\Math\Number )
|
||||
{
|
||||
return $a->compare( $b ) === 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $a == $b;
|
||||
}
|
||||
case 'l':
|
||||
return $a < $b;
|
||||
if ( $a instanceof \IPS\Math\Number )
|
||||
{
|
||||
return $a->compare( $b ) === -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $a < $b;
|
||||
}
|
||||
case 'c':
|
||||
return mb_strpos( $a, $b ) !== FALSE;
|
||||
case 'mm':
|
||||
|
||||
Reference in new issue
Block a user