Created
May 18, 2016 11:59
-
-
Save ifahrentholz/eb8ed47e7d96a3707f01144d0c62aaf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub plGetDeviceType { | |
my ($szUAgt) = shift; | |
if (3 >= length($szUAgt)) { return 0; } # unknown | |
if ($szUAgt =~ /Windows NT/) { return 1; } # desktop | |
if ($szUAgt =~ /iPad/ || ($szUAgt =~ /Android/i && $szUAgt !~ /mobile/i) || $szUAgt =~ /tablet/i || $szUAgt =~ /iPod/) { | |
return 2; # tablet | |
} elsif (($szUAgt =~ /Android/i && $szUAgt =~ /mobile/i) || $szUAgt =~ /CPU iPhone/ || $szUAgt =~ /mobile safari/i || $szUAgt =~ /Windows Phone/i || | |
$szUAgt =~ /Opera Mobi/i) { | |
return 3; # smartphone | |
} | |
return 1; # desktop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes. it's perl.