Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class MobileUtils extends StaticFactory
00016 {
00017 public static function extractIp(array $headers)
00018 {
00019 if (
00020 MobileRequestDetector::create()->isOperaMini($headers)
00021 && isset($headers['HTTP_X_FORWARDED_FOR'])
00022 ) {
00023 $ips = explode(',', $headers['HTTP_X_FORWARDED_FOR']);
00024
00025 if ($ips)
00026 return trim($ips[count($ips) - 1]);
00027 } elseif (isset($headers['REMOTE_ADDR']))
00028 return $headers['REMOTE_ADDR'];
00029
00030 return null;
00031 }
00032
00033 public static function extractUserAgent(array $headers)
00034 {
00035 if (
00036 MobileRequestDetector::create()->isOperaMini($headers)
00037 && isset($headers['HTTP_X_OPERAMINI_PHONE_UA'])
00038 )
00039 return $headers['HTTP_X_OPERAMINI_PHONE_UA'];
00040 elseif (isset($headers['HTTP_USER_AGENT']))
00041 return $headers['HTTP_USER_AGENT'];
00042
00043 return null;
00044 }
00045 }
00046 ?>