Version 4.7.23

This commit is contained in:
Neo committed 2025-12-19 16:21:27 -08:00
1 parent 7124a02564
commit 25ddeb65d6
1791 files changed
+76990 -44452

No files matched your search

+79 -44
View File
@@ -22,11 +22,25 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Useragent
{
/**
* @brief Search engine spider?
*/
public $spider = FALSE;
CONST TYPE_SEARCH = 1;
CONST TYPE_AI = 2;
CONST TYPE_CRAWLER = 3;
CONST TYPE_OTHER = 4;
/**
* @brief [Legacy] Search engine spider?
*/
public bool $spider = FALSE;
/**
* @brief Bot?
*/
public bool $bot = FALSE;
/**
* @brief Bot type
*/
public int $type = 0;
/**
* @brief Browser name
*/
@@ -99,30 +113,34 @@ class _Useragent
$this->browserVersion = $data['version'];
/* Is this a spider? */
foreach( $this->searchEngineUseragents as $key => $regex )
foreach( $this->searchEngineUseragents as $key => $data )
{
if( \is_array( $regex ) )
if( \is_array( $data[1] ) )
{
foreach( $regex as $_expression )
foreach( $data[1] as $_expression )
{
if( preg_match( "#" . $_expression . "#im", $this->useragent, $matches ) )
{
$this->spider = $key;
$this->spider = $key; // keep this for older apps
$this->bot = $key;
$this->type = $data[0];
break 2;
}
}
}
else
{
if( preg_match( "#" . $regex . "#im", $this->useragent, $matches ) )
if( preg_match( "#" . $data[1] . "#im", $this->useragent, $matches ) )
{
$this->spider = $key;
$this->spider = $key; // Keep this for older apps
$this->bot = $key;
$this->type = $data[0];
break;
}
}
}
}
/**
* @brief List of search engine user agent strings with regex to parse out the data.
* @note Matches will be checked based on the order of this list - put more specific matches first and more generic matches later
@@ -131,38 +149,45 @@ class _Useragent
* @note If the UA matches an entry in this array, $this->spider will be set to TRUE
*/
protected $searchEngineUseragents = array(
'about' => "Libby[_/ ]([0-9.]{1,10})",
'adsense' => array( "Mediapartners-Google/([0-9.]{1,10})", "Mediapartners-Google" ),
'ahrefs' => "AhrefsBot",
'alexa' => "^ia_archive",
'altavista' => "Scooter[ /\-]*[a-z]*([0-9.]{1,10})",
'ask' => "Ask[ \-]?Jeeves",
'baidu' => array( "^baiduspider\-", "baiduspider[ /]([0-9.]{1,10})" ),
'bing' => array( "bingbot[ /]([0-9.]{1,10})", "msnbot(?:-media)?[ /]([0-9.]{1,10})" ),
'brandwatch' => "magpie-crawler",
'excite' => "Architext[ \-]?Spider",
'google' => array( "Googl(?:e|ebot)(?:-Image|-Video|-News)?/([0-9.]{1,10})", "Googl(?:e|ebot)(?:-Image|-Video|-News)?/?" ),
'googlemobile' => array( "Googl(?:e|ebot)(?:-Mobile)?/([0-9.]{1,10})", "Googl(?:e|ebot)(?:-Mobile)?/" ),
'facebook' => "facebookexternalhit/([0-9.]{1,10})",
'infoseek' => array( "SideWinder[ /]?([0-9a-z.]{1,10})", "Infoseek" ),
'inktomi' => "slurp@inktomi\.com",
'internetseer' => "^InternetSeer\.com",
'look' => "www\.look\.com",
'looksmart' => "looksmart-sv-fw",
'lycos' => "Lycos_Spider_",
'majestic' => "MJ12bot\/v([0-9.]{1,10})",
'msproxy' => "MSProxy[ /]([0-9.]{1,10})",
'webcrawl' => "webcrawl\.net",
'websense' => "(?:Sqworm|websense|Konqueror/3\.(?:0|1)(?:\-rc[1-6])?; i686 Linux; 2002[0-9]{4})",
'yahoo' => "Yahoo(?:.*?)(?:Slurp|FeedSeeker)",
'yandex' => "Yandex(?:[^\/]+?)\/([0-9.]{1,10})",
'seznam' => array( "SeznamBot[ /]([0-9.]{1,10})", "Seznam screenshot-generator ([0-9.]{1,10})" ),
'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})",
'semrush' => "SemrushBot/([0-9.]{1,10})"
'about' => [ self::TYPE_OTHER, "Libby[_/ ]([0-9.]{1,10})" ],
'adsense' => [ self::TYPE_OTHER, array( "Mediapartners-Google/([0-9.]{1,10})", "Mediapartners-Google" ) ],
'ahrefs' => [ self::TYPE_CRAWLER, "AhrefsBot" ],
'alexa' => [ self::TYPE_SEARCH, "^ia_archive" ],
'altavista' => [ self::TYPE_OTHER, "Scooter[ /\-]*[a-z]*([0-9.]{1,10})" ],
'amazon' => [ self::TYPE_AI, [ "developer\.amazon\.com", "amazonbot" ] ],
'ask' => [ self::TYPE_OTHER, "Ask[ \-]?Jeeves" ],
'baidu' => [ self::TYPE_OTHER, array( "^baiduspider\-", "baiduspider[ /]([0-9.]{1,10})" ) ],
'bing' => [ self::TYPE_SEARCH, array( "bingbot[ /]([0-9.]{1,10})", "msnbot(?:-media)?[ /]([0-9.]{1,10})" ) ],
'brandwatch' => [ self::TYPE_OTHER, "magpie-crawler" ],
'chatgpt' => [ self::TYPE_AI, [ "OAI-SearchBot/([0-9.]{1,10})", "ChatGPT-User/([0-9.]{1,10})", "GPTBot/([0-9.]{1,10})", "openai.com/"] ],
'commoncrawl' => [ self::TYPE_OTHER, "CCBot" ],
'excite' => [ self::TYPE_OTHER, "Architext[ \-]?Spider" ],
'google' => [ self::TYPE_SEARCH, array( "Googl(?:e|ebot)(?:-Image|-Video|-News)?/([0-9.]{1,10})", "Googl(?:e|ebot)(?:-Image|-Video|-News)?/?" ) ],
'googlemobile' => [ self::TYPE_SEARCH, array( "Googl(?:e|ebot)(?:-Mobile)?/([0-9.]{1,10})", "Googl(?:e|ebot)(?:-Mobile)?/" ) ],
'facebook' => [ self::TYPE_OTHER, "facebookexternalhit/([0-9.]{1,10})" ],
'infoseek' => [ self::TYPE_OTHER, array( "SideWinder[ /]?([0-9a-z.]{1,10})", "Infoseek" ) ],
'inktomi' => [ self::TYPE_OTHER, "slurp@inktomi\.com" ],
'internetseer' => [ self::TYPE_SEARCH, "^InternetSeer\.com" ],
'look' => [ self::TYPE_OTHER, "www\.look\.com" ],
'looksmart' => [ self::TYPE_OTHER, "looksmart-sv-fw" ],
'lycos' => [ self::TYPE_OTHER, "Lycos_Spider_" ],
'majestic' => [ self::TYPE_OTHER, "MJ12bot\/v([0-9.]{1,10})" ],
'meta' => [ self::TYPE_OTHER, [ "meta-externalagent/", "developers\.facebook\.com" ] ],
'msproxy' => [ self::TYPE_OTHER, "MSProxy[ /]([0-9.]{1,10})" ],
'perplexity' => [ self::TYPE_OTHER, "PerplexityBot" ],
'pinterest' => [ self::TYPE_OTHER, "Pinterestbot/([0-9.]{1,10})" ],
'webcrawl' => [ self::TYPE_CRAWLER, "webcrawl\.net" ],
'websense' => [ self::TYPE_OTHER, "(?:Sqworm|websense|Konqueror/3\.(?:0|1)(?:\-rc[1-6])?; i686 Linux; 2002[0-9]{4})" ],
'yahoo' => [ self::TYPE_SEARCH, "Yahoo(?:.*?)(?:Slurp|FeedSeeker)" ],
'yandex' => [ self::TYPE_OTHER, "Yandex(?:[^\/]+?)\/([0-9.]{1,10})" ],
'seznam' => [ self::TYPE_OTHER, array( "SeznamBot[ /]([0-9.]{1,10})", "Seznam screenshot-generator ([0-9.]{1,10})" ) ],
'dotbot' => [ self::TYPE_OTHER, "DotBot[ /]([0-9.]{1,10})" ],
'sogou' => [ self::TYPE_OTHER, "Sogou web spider[ /]([0-9.]{1,10})" ],
'isetallabot' => [ self::TYPE_OTHER, "istellabot[ /][a-z]([0-9.]{1,10})" ],
'blexbot' => [ self::TYPE_OTHER, "BLEXBot[ /]([0-9.]{1,10})" ],
'semrush' => [ self::TYPE_CRAWLER, "SemrushBot/([0-9.]{1,10})" ]
);
/**
* Human-Readable Browser Name
@@ -173,6 +198,16 @@ class _Useragent
{
return \IPS\Member::loggedIn()->language()->addToStack( 'user_agent_parsed', FALSE, array( 'sprintf' => array( $this->browser, $this->browserVersion, $this->platform ) ) );
}
/**
* Is this a low value bot?
*
* @return bool
*/
public function isLowValue(): bool
{
return $this->bot === true and $this->type !== self::TYPE_SEARCH;
}
/**
* @brief List of Facebook IP addresses
@@ -203,7 +238,7 @@ class _Useragent
continue;
}
list( $net, $maskBits ) = explode( '/', $range );
[ $net, $maskBits ] = explode( '/', $range );
$net = $this->_convertCompressedIpv6ToBits( inet_pton( $net ) );
@@ -222,7 +257,7 @@ class _Useragent
continue;
}
list( $net, $maskBits ) = explode( '/', $range );
[ $net, $maskBits ] = explode( '/', $range );
if( ( ip2long( $ip ) & ~( ( 1 << ( 32 - $maskBits ) ) - 1 ) ) == ip2long( $net ) )
{