mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-27 22:33:10 +09:00
Remove trailing whitespace
This commit is contained in:
parent
3b0030e82b
commit
a9f72a5cd2
81 changed files with 2455 additions and 2455 deletions
|
|
@ -13,7 +13,7 @@ class UA
|
|||
protected static $_mobile_cache = array();
|
||||
protected static $_tablet_cache = array();
|
||||
protected static $_robot_cache = array();
|
||||
|
||||
|
||||
/**
|
||||
* Windows version lookup table.
|
||||
*/
|
||||
|
|
@ -25,10 +25,10 @@ class UA
|
|||
'6.2' => '8',
|
||||
'6.3' => '8.1',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Check whether the current visitor is using a mobile device.
|
||||
*
|
||||
*
|
||||
* @param string $ua (optional)
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -44,37 +44,37 @@ class UA
|
|||
{
|
||||
$using_header = false;
|
||||
}
|
||||
|
||||
|
||||
// If the User-Agent header is missing, it's probably not a mobile browser.
|
||||
if (is_null($ua))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Look for headers that are only used in mobile browsers.
|
||||
if ($using_header && (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Look up the cache.
|
||||
if (isset(self::$_mobile_cache[$ua]))
|
||||
{
|
||||
return self::$_mobile_cache[$ua];
|
||||
}
|
||||
|
||||
|
||||
// Look for the 'mobile' keyword and common mobile platform names.
|
||||
if (preg_match('/android|ip(hone|ad|od)|blackberry|nokia|palm|mobile/i', $ua))
|
||||
{
|
||||
return self::$_mobile_cache[$ua] = true;
|
||||
}
|
||||
|
||||
|
||||
// Look for common non-mobile OS names.
|
||||
if (preg_match('/windows|linux|os [x9]|bsd/i', $ua))
|
||||
{
|
||||
return self::$_mobile_cache[$ua] = false;
|
||||
}
|
||||
|
||||
|
||||
// Look for other platform, manufacturer, and device names that are known to be mobile.
|
||||
if (preg_match('/kindle|opera (mini|mobi)|polaris|netfront|fennec|motorola|symbianos|webos/i', $ua))
|
||||
{
|
||||
|
|
@ -84,14 +84,14 @@ class UA
|
|||
{
|
||||
return self::$_mobile_cache[$ua] = true;
|
||||
}
|
||||
|
||||
|
||||
// If we're here, it's probably not a mobile device.
|
||||
return self::$_mobile_cache[$ua] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the current visitor is using a tablet.
|
||||
*
|
||||
*
|
||||
* @param string $ua (optional)
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -99,44 +99,44 @@ class UA
|
|||
{
|
||||
// Get the User-Agent header if the caller did not specify $ua.
|
||||
$ua = $ua ?: (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
||||
|
||||
|
||||
// If the User-Agent header is missing, it's probably not a tablet.
|
||||
if (is_null($ua))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Look up the cache.
|
||||
if (isset(self::$_tablet_cache[$ua]))
|
||||
{
|
||||
return self::$_tablet_cache[$ua];
|
||||
}
|
||||
|
||||
|
||||
// Check if the user-agent is mobile.
|
||||
if (!self::isMobile($ua))
|
||||
{
|
||||
return self::$_tablet_cache[$ua] = false;
|
||||
}
|
||||
|
||||
|
||||
// Check for Android tablets without the 'mobile' keyword.
|
||||
if (stripos($ua, 'android') !== false && stripos($ua, 'mobile') === false)
|
||||
{
|
||||
return self::$_tablet_cache[$ua] = true;
|
||||
}
|
||||
|
||||
|
||||
// Check for common tablet identifiers.
|
||||
if (preg_match('/tablet|pad\b|tab\b|\bgt-\d+|kindle|nook|playbook|webos|xoom/i', $ua))
|
||||
{
|
||||
return self::$_tablet_cache[$ua] = true;
|
||||
}
|
||||
|
||||
|
||||
// If we're here, it's probably not a tablet.
|
||||
return self::$_tablet_cache[$ua] = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check whether the current visitor is a robot.
|
||||
*
|
||||
*
|
||||
* @param string $ua (optional)
|
||||
* @return bool
|
||||
*/
|
||||
|
|
@ -144,25 +144,25 @@ class UA
|
|||
{
|
||||
// Get the User-Agent header if the caller did not specify $ua.
|
||||
$ua = $ua ?: (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
||||
|
||||
|
||||
// If the User-Agent header is missing, it's probably not a robot.
|
||||
if (is_null($ua))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Look up the cache.
|
||||
if (isset(self::$_robot_cache[$ua]))
|
||||
{
|
||||
return self::$_robot_cache[$ua];
|
||||
}
|
||||
|
||||
|
||||
// Look for common search engine names and the 'bot' keyword.
|
||||
if (preg_match('/bot|spider|crawler|archiver|wget|curl|php|slurp|wordpress|facebook|teoma|yeti|daum|apachebench|mediapartners-google|[(<+]https?:|@/i', $ua))
|
||||
{
|
||||
return self::$_robot_cache[$ua] = true;
|
||||
}
|
||||
|
||||
|
||||
// Use the custom user-agent list.
|
||||
$customlist = Config::get('security.robot_user_agents') ?: array();
|
||||
foreach ($customlist as $item)
|
||||
|
|
@ -172,14 +172,14 @@ class UA
|
|||
return self::$_robot_cache[$ua] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we're here, it's probably not a robot.
|
||||
return self::$_robot_cache[$ua] = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method parses the Accept-Language header to guess the browser's default locale.
|
||||
*
|
||||
*
|
||||
* @param string $header (optional)
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -187,14 +187,14 @@ class UA
|
|||
{
|
||||
// Get the Accept-Language header if the caller did not specify $header.
|
||||
$header = $header ?: (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'en-US');
|
||||
|
||||
|
||||
// Return the first locale name found.
|
||||
return preg_match('/^([a-z0-9_-]+)/i', $header, $matches) ? $matches[1] : 'en-US';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method parses the User-Agent string to guess what kind of browser it is.
|
||||
*
|
||||
*
|
||||
* @param string $ua (optional)
|
||||
* @return object
|
||||
*/
|
||||
|
|
@ -202,7 +202,7 @@ class UA
|
|||
{
|
||||
// Get the User-Agent header if the caller did not specify $ua.
|
||||
$ua = $ua ?: (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
||||
|
||||
|
||||
// Initialize the result.
|
||||
$result = (object)array(
|
||||
'browser' => null,
|
||||
|
|
@ -219,7 +219,7 @@ class UA
|
|||
{
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// Try to guess the OS.
|
||||
if (preg_match('#(Windows|Android|Linux|i(?:Phone|P[ao]d)|OS X|Macintosh)#i', $ua, $matches))
|
||||
{
|
||||
|
|
@ -258,13 +258,13 @@ class UA
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fill in miscellaneous fields.
|
||||
$result->is_mobile = self::isMobile($ua);
|
||||
$result->is_tablet = self::isTablet($ua);
|
||||
$result->is_webview = strpos($ua, '; wv)') !== false;
|
||||
$result->is_robot = self::isRobot($ua);
|
||||
|
||||
|
||||
// Try to match some of the most common browsers.
|
||||
if ($result->os === 'Android' && preg_match('#Android ([0-9]+\\.[0-9]+)#', $ua, $matches))
|
||||
{
|
||||
|
|
@ -361,15 +361,15 @@ class UA
|
|||
$result->version = isset($matches[2]) ? ($matches[2] ?: null) : null;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method encodes a UTF-8 filename for downloading in the current visitor's browser.
|
||||
*
|
||||
* See: https://blog.bloodcat.com/302
|
||||
*
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $ua (optional)
|
||||
* @return string
|
||||
|
|
@ -378,10 +378,10 @@ class UA
|
|||
{
|
||||
// Get the User-Agent header if the caller did not specify $ua.
|
||||
$ua = $ua ?: (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
||||
|
||||
|
||||
// Get the browser name and version.
|
||||
$browser = self::getBrowserInfo($ua);
|
||||
|
||||
|
||||
// Find the best format that this browser supports.
|
||||
if ($browser->browser === 'Chrome' && $browser->version >= 11 & !$browser->is_webview)
|
||||
{
|
||||
|
|
@ -419,30 +419,30 @@ class UA
|
|||
{
|
||||
$output_format = 'old_ie';
|
||||
}
|
||||
|
||||
|
||||
// Clean the filename.
|
||||
$filename = Filters\FilenameFilter::clean($filename);
|
||||
|
||||
|
||||
// Apply the format and return.
|
||||
switch ($output_format)
|
||||
{
|
||||
case 'raw':
|
||||
return 'filename="' . $filename . '"';
|
||||
|
||||
|
||||
case 'rfc5987':
|
||||
$filename = rawurlencode($filename);
|
||||
return "filename*=UTF-8''" . $filename;
|
||||
|
||||
|
||||
case 'old_ie':
|
||||
default:
|
||||
$filename = rawurlencode($filename);
|
||||
return 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current color scheme (auto, light, dark)
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getColorScheme(): string
|
||||
|
|
@ -456,10 +456,10 @@ class UA
|
|||
return 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the color scheme (auto, light, dark)
|
||||
*
|
||||
*
|
||||
* @param string $color_scheme
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue