@@ -34,21 +34,21 @@ discard block |
||
| 34 | 34 | $replace_pat = '$7$8|$2$3|$9|${17}${15}$5$3|${18}${13}$6${11}'; |
| 35 | 35 | |
| 36 | 36 | // Run the preg_replace .. and explode on | |
| 37 | - $ua_array = explode("|",preg_replace($regex_pat, $replace_pat, $ua, PREG_PATTERN_ORDER)); |
|
| 37 | + $ua_array = explode("|", preg_replace($regex_pat, $replace_pat, $ua, PREG_PATTERN_ORDER)); |
|
| 38 | 38 | |
| 39 | - if (count($ua_array)>1) |
|
| 39 | + if (count($ua_array) > 1) |
|
| 40 | 40 | { |
| 41 | - $return['platform'] = $ua_array[0]; // Windows / iPad / MacOS / BlackBerry |
|
| 42 | - $return['type'] = $ua_array[1]; // Mozilla / Opera etc. |
|
| 43 | - $return['renderer'] = $ua_array[2]; // WebKit / Presto / Trident / Gecko etc. |
|
| 44 | - $return['browser'] = $ua_array[3]; // Chrome / Safari / MSIE / Firefox |
|
| 41 | + $return['platform'] = $ua_array[0]; // Windows / iPad / MacOS / BlackBerry |
|
| 42 | + $return['type'] = $ua_array[1]; // Mozilla / Opera etc. |
|
| 43 | + $return['renderer'] = $ua_array[2]; // WebKit / Presto / Trident / Gecko etc. |
|
| 44 | + $return['browser'] = $ua_array[3]; // Chrome / Safari / MSIE / Firefox |
|
| 45 | 45 | |
| 46 | 46 | /* |
| 47 | 47 | Not necessary but this will filter out Chromes ridiculously long version |
| 48 | 48 | numbers 31.0.1234.122 becomes 31.0, while a "normal" 3 digit version number |
| 49 | 49 | like 10.2.1 would stay 10.2.1, 11.0 stays 11.0. Non-match stays what it is. |
| 50 | 50 | */ |
| 51 | - if (preg_match("/^[\d]+\.[\d]+(?:\.[\d]{0,2}$)?/",$ua_array[4],$matches)) |
|
| 51 | + if (preg_match("/^[\d]+\.[\d]+(?:\.[\d]{0,2}$)?/", $ua_array[4], $matches)) |
|
| 52 | 52 | { |
| 53 | 53 | $return['version'] = $matches[0]; |
| 54 | 54 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Replace some browsernames e.g. MSIE -> Internet Explorer |
| 66 | - switch(strtolower($return['browser'])) |
|
| 66 | + switch (strtolower($return['browser'])) |
|
| 67 | 67 | { |
| 68 | 68 | case "msie": |
| 69 | 69 | case "trident": |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | break; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - switch(strtolower($return['platform'])) |
|
| 80 | + switch (strtolower($return['platform'])) |
|
| 81 | 81 | { |
| 82 | 82 | case "android": // These browsers claim to be Safari but are BB Mobile |
| 83 | 83 | case "blackberry": // and Android Mobile |
| 84 | - if ($return['browser'] =="Safari" || $return['browser'] == "Mobile" || $return['browser'] == "") |
|
| 84 | + if ($return['browser'] == "Safari" || $return['browser'] == "Mobile" || $return['browser'] == "") |
|
| 85 | 85 | { |
| 86 | 86 | $return['browser'] = "{$return['platform']} mobile"; |
| 87 | 87 | } |