Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Specific Device Information

Tags:

php

Using just PHP, is there anyway to detect if the page is being loaded from a SPECIFIC device? Say, I would want the page to react differently if only MY iPhone was loading the page, no one else's?

The only solution I have so far is to use $_SERVER['REMOTE_PORT' in conjunction with $_SERVER['HTTP_USER_AGENT'], to verify iPhone, but that doesn't ensure a specific iPhone..

like image 920
Chud37 Avatar asked Feb 01 '13 13:02

Chud37


People also ask

How do I find device information?

Navigate to the app > res > layout > activity_main. xml and add the below code to that file. Below is the code for the activity_main. xml file.

Can you identify a device by IP address?

A Public IP is given to your internet gateway (router) by your ISP. All devices on your network are using the same Public address but different Private ones. Your ISP or police with a warrant can use your Public IP to find the internet account holder but may not be able to find the individual device owner.

Can I identify a device by its MAC address?

Yes. To do so, you need to open a Command Prompt window and enter the command “arp -a”. That way you will get all of the IP addresses that are active on your network. You will get a list with the physical address, which is the MAC address and the corresponding IP address.


2 Answers

There is a really simple solution to use Mobile-detect here: https://github.com/serbanghita/Mobile-Detect/

Enjoy!

like image 125
JeanR Avatar answered Sep 22 '22 19:09

JeanR


$_SERVER['HTTP_USER_AGENT'] contains information about the browser and the device used. So if you know the User Agent - sent by your device - then you can quite easily write an if statement, that will see if it's the one you want or not.

However, usually you don't really want to play with manual aiming at the devices, especially when it comes down to mobiles. Think about using something like wurfl, a class that allows you to determine a type of device that loaded your webpage.

If you want to aim at specific iPhone you'd most likely want to compare it's user agent with user agent of another model. But as far as I know - it's very flawed method, and doesn't really work in a long term. So long answer short: There's no way to aim at very one specific iPhone model (because any of them sends roughly identical data to the server if they all got same iOS and same browser).

like image 20
MarcinWolny Avatar answered Sep 23 '22 19:09

MarcinWolny