What is proper way to update serbanghita-mobile-detect - php

I have most recent version of serbanghita-mobile-detect (serbanghita).
However, I have a Asus PadFone2 tablet/phone device which is not being handled correctly by it:
Mozilla/5.0
(Linux; U; Android 4.1.1; en-gb; PadFone 2 Build/JRO03L)
AppleWebKit/534.30
(KHTML, like Gecko)
Version/4.0 Safari/534.30
So I would like to manually update it for this device.

Stijn responded correct. I look at the issues, do some research and then update the library after all the UnitTests pass.
If you don't know how to add an issue, just send me the feedback via http://demo.mobiledetect.net

Related

Why does Chrome user agent string change in windows 8?

In my computer with windows 8 and Google Chrome 35, the variable $_SERVER['HTTP_USER_AGENT'] sometimes returns
Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire HD Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
when the correct value would be:
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
Why does it happen and how can I prevent it?
Kindle is both a hardware e-reader and a piece of software to read e-books on computers, laptops and tablets. Could it be that you installed that on your machine and that it nested itself in Chrome, like a plug-in/add-on?
If you're sure no such thing is the case, consider the suggestion by Alok in the comments. If you wouldn't know how to work with the console, check here whether the PHP- and JS-detected uAs read the same. If not, that would indeed be the cause.
Although I wouldn't know how to cure that then, other than by removing the (other) plug-ins/add-ons one by one.

How to force user agent on mobile browser

Im integrating Magento and Expression Engine. EE is pulling header and footer from Magento. And Magento has a mobile theme for specific agents but EE does not. So I wanna force mobile users to load desktop version of the site so the approach I took was to set desktop user agent in the header. Here were a few methods I've tried. However, things aren't working out. Is there a better solution?
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36');
and
$request = new HttpRequest();
$request->setHeaders(array('User-Agent' => 'Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2'));
and
ini_set('user_agent','Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
If your site is displaying a distinct version of itself to mobile users, what you have to do is find where this content switching is happening and make it stop doing so. According to what you said, messing around with cURL and whatnot won't change a thing.

PHP sniff out Safari Desktop version

Super quick one, I know that browser sniffing is frowned upon but I need to (using PHP) detect Desktop version Safari only, cannot seem to find specifically this combination on Google, or SO for that matter.
I know how to use $_SERVER['HTTP_USER_AGENT'] but don't know which bit to look for for Mac OSX/Windows 7/8.
Thanks.
The User Agent string for Safari on the Mac will be something like this:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
on Windows you will find something like this:
Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27

Change User Agent in php.ini

i am trying to change user agent in php.ini file as follows.
user_agent="Mozilla/5.0 (iPhone Simulator; U;
CPU iPhone OS 4_3_2 like Mac OD X; en-us)
AppleWebKit/535.17.9(KHTML, like Gecko)
Version/5.0.2 Mobile/8H7Safari/6533.18.5"
after that when i check user agent in my php file with following command and this show that user agent has not been change.
echo $_SERVER['HTTP_USER_AGENT'];
this shows : Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
which is still not iphone user agent which i have set in php.ini file.
so please help me how to set user agent in php.ini file which switch my browser request as iphone browser request.
i have also tried with following command.
ini_set('user_agent', 'Mozilla/5.0 (iPhone Simulator; U;
CPU iPhone OS 4_3_2 like Mac OD X; en-us)
AppleWebKit/535.17.9 (KHTML, like Gecko) Version/5.0.2
Mobile/8H7 Safari/6533.18.5');
this also gives same result and i am unable to switch to iphone browser request.
I'm afraid you've misunderstood. The user_agent setting in php.ini has nothing to do with $_SERVER['HTTP_USER_AGENT].
The setting in php.ini is used as a default for when PHP does HTTP requests, for example with cURL.
$_SERVER['HTTP_USER_AGENT'] contains the user agent that the web browser sent along with its request to your PHP script. That's why it's showing MSIE because you're viewing the page in MSIE.
If you want to send a different user agent from your browser, you'll have to use a browser plugin unless the browser allows you to freely modify it. For example like this.

Check if iOS version is 3.0 or higher with PHP or Javascript

I need to check if an iOS device visiting my Website has iOS 3.0 or higher installed.
Can I do that?
If you wish to check what browser/mobile device is accessing you site - then the answer is that you can use read the userAgent string and search for OS and the number. For example:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
and another useful online tool to check your browser UA is: http://whatsmyuseragent.com/
Yes you can. Either PHP or Javascript will do the trick. iOS devices report their iOS version in their user-agent string. Here are the Apple docs: Using the Safari User Agent String. Some example user-agent strings might look like:
Mozilla/5.0 (iPhone; U; CPU iOS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/XXXXX Safari/525.20
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.05 Mobile/8A293 Safari/6531.22.7
Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5
From there it's easy to see which version of iOS is being run.
Bit of an older question, but I believe none of the answers currently given answer the question appropriately.
If you want to do something like
if(iOS_version > 3){
// Open something
}
Then I believe you are looking for
if(/(iPhone|iPad|iPod)\sOS\s3/.test(navigator.userAgent)) {
// use apple maps
}
Where s3 is looking for iOS3. Change s3 to s9 to check for iOS9
You can use the user-agent which is send with the HTTP-request. This can then be processed by PHP.
See this tutorial (note that this targets the iPad. But the iPhone should have something similar).

Categories