Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+26 -7
View File
@@ -11,7 +11,7 @@
namespace IPS\Http;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -26,11 +26,11 @@ class _Useragent
* @brief Search engine spider?
*/
public $spider = FALSE;
/**
* @brief Mobile or tablet device?
* @brief Invision Community mobile app?
*/
public $mobile = FALSE;
public $ipsApp = FALSE;
/**
* @brief Browser name
@@ -96,6 +96,24 @@ class _Useragent
*/
public function parseUserAgent()
{
/* Is it ours? */
if ( preg_match( '/^InvisionCommunityApp\/(\d+\.\d+\.\d+) \((.+?)\) (.+?) \((.+?)\)$/', $this->useragent, $matches ) ) // Matches: 1 = App version, 2 = App name (differentiates multicommunity vs white-label) 3 = "Android" or "iOS/X.Y.Z" 4 = Semi-human-friendly name (e.g. "iPhone11,6" is iPhone XS Max)
{
if ( $matches[3] === 'Android' )
{
$this->platform = $matches[4];
}
else
{
$this->platform = preg_replace( '/^(.+?)\d+,\d+$/', '$1', $matches[4] );
}
$this->browser = 'InvisionCommunityApp';
$this->browserVersion = $matches[1];
$this->ipsApp = $matches[2];
return;
}
/* Set basic data */
require_once( \IPS\ROOT_PATH . '/system/3rd_party/PhpUserAgent/UserAgentParser.php' );
$data = parse_user_agent( $this->useragent );
@@ -106,7 +124,7 @@ class _Useragent
/* Is this a spider? */
foreach( $this->searchEngineUseragents as $key => $regex )
{
if( is_array( $regex ) )
if( \is_array( $regex ) )
{
foreach( $regex as $_expression )
{
@@ -165,7 +183,8 @@ class _Useragent
'dotbot' => "DotBot[ /]([0-9.]{1,10})",
'sogou' => "Sogou web spider[ /]([0-9.]{1,10})",
'isetallabot' => "istellabot[ /][a-z]([0-9.]{1,10})",
'blexbot' => "BLEXBot[ /]([0-9.]{1,10})"
'blexbot' => "BLEXBot[ /]([0-9.]{1,10})",
'semrush' => "SemrushBot/([0-9.]{1,10})"
);
/**
@@ -253,7 +272,7 @@ class _Useragent
foreach( $unpackedAddress as $char )
{
$ipAddress .= str_pad( decbin( ord( $char ) ), 8, '0', STR_PAD_LEFT );
$ipAddress .= str_pad( decbin( \ord( $char ) ), 8, '0', STR_PAD_LEFT );
}
return $ipAddress;