Need a simple PHP script that detects what device a user is viewing a web page from, and serves different content accordingly. Detection is via a mix of HTTP_USER_AGENT and HTTP_PROFILE.
I just need the detection part, with placeholders for the content.
———- Background on HTTP_PROFILE ———–
An example of the contents of HTTP_PROFILE on a BlackBerry is the following string: “http://www.blackberry.net/go/mobile/profiles/uaprof/7290/4.0.0.rdf”
The model number of the phone is 7290. Sometimes there are additional characters after the 4-digit model number, so we want to read the model number by taking the 4 characters immediately following “uaprof/”.
The OS version in this example is 4.0.0
All BlackBerry detection must use HTTP_PROFILE, not HTTP_USER_AGENT, as users have the option of altering their user agent to spoof other browsers. Non-BlackBerry devices can be detected via HTTP_USER_AGENT.
———– Logic will flow like this: ————–
1. Check if user is on a BlackBerry whose model number is 8800, 8520, or begins with 9 (BlackBerrys all have 4-digit model numbers); if they are, redirect them to “Content A”.
2. Else, check if user is on a BlackBerry model that wasn’t already in that list (again using HTTP_PROFILE, not HTTP_USER_AGENT). Then check their OS version; if it’s 4.5.0 or greater, redirect them to “content B”; if it’s below 4.5.0, output “Content C” on the current page.
3. Else, check if user is on an iPhone or iPod (using HTTP_USER_AGENT), and redirect them to “Content D”
4. Else, check if user is on a non-mobile version of Firefox/Safari/IE/Chrome/etc, and output “content E” on the current page
5. Else, output “content F” on the current page
————–
Hoping to have the script by Friday 30 Oct, 3pm EDT if possible.
Thanks!