WAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreWAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 22nd, 2004, 01:27 PM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,613 jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 3 Days 5 h 32 m 57 sec
Reputation Power: 1550
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Quicker / more effective moblie device detection script

Hi,

Not sure whether I should have posted this in the PHP forum or not, but thought I would try here first.

What I want to do it detect whether a user is on a PDA / phone or on a web browser to browse HTML pages. I have been playing around with some scripts but would like to have comments on a more effective way. I was thinking of additional stuff if it was a WAP browser, but just going for the (x)html first

PHP Code:
<?php
$browser 
file('/path/browser.txt');
$match '';
foreach (
$browser as $line_num => $line) {
$match .= strstr(strtoupper($_SERVER['HTTP_USER_AGENT']), strtoupper($line)) ? TRUE FALSE;        
}
echo 
$match == TRUE 'PDS or phone' 'proper browser';

Basically it loops though a text file and if it returns true at all, it prints proper browser. So is there a better way?

I have attached teh browser list text that the script it reading. I have also included the current script that I have running to redirect to a wap site, but doesn't seem to work too well, so any comments on that much appreciated.

Thanks in advance..
Attached Files
File Type: txt browser.txt (272 Bytes, 314 views)
File Type: txt live_index.txt (959 Bytes, 257 views)
__________________
Cheers,

Jamie


# skiFFie | Home of the 'accessibility module' for Drupal
# Jamie Burns [me] Accessibility Module [drupal]
# guidelines | search | wap resources | not getting help | fold to cure

# Any form of employment is strictly prohibited ......


__________________

Let the might of your compassion arise to bring a quick end
to the flowing stream of the blood and tears .....
Please hear my anguished words of truth.

__________________

Reply With Quote
  #2  
Old September 22nd, 2004, 09:31 PM
andymoo's Avatar
andymoo andymoo is offline
Timelord
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Loughborough, Leicestershire
Posts: 605 andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level)andymoo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 5 h 53 m 46 sec
Reputation Power: 63
Hi Jamie,

Your live index is from the same script I used on some of our wap sites, it seemed to do the trick most of the time but I modded ours to include more user agents then the default came with. Having more agents makes it more stable but I dumped it in the end.
PHP Code:
// check to see http_accept is wml
if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0) {

$br "WML";
}else{

// check to see if browser is recognised as a mobile or wap emulator
$browser=strtolower(substr(trim($HTTP_USER_AGENT),0,4));

// run if's against user agent
if($browser=="noki" || $browser=="sony" || $browser=="sec-" || $browser=="siem" ||
$browser=="sie-" || $browser=="pana" || $browser=="maxo" || $browser=="shar" ||
$browser=="eric" || $browser=="lge-" || $browser=="sams" || $browser=="wapI" ||
$browser=="mc21" || $browser=="aur " || $browser=="r380" || $browser=="qco7" ||
$browser=="up.B" || $browser=="winw" || $browser=="upg1" || $browser=="upsi" ||
$browser=="qwap" || $browser=="tsm-" || $browser=="jigs" || $browser=="java" ||
$browser=="alca" || $browser=="mits" || $browser=="moto" || $browser=="mot-" ||
$browser=="sage" || $browser=="webc" || $browser=="my s" || $browser=="wap j" ||
$browser=="fetc" || $browser=="alav" || $browser=="wapa"){
$br "WML";
}else{
$br "HTML";
}
}

//  manage output to reflect user agent
if($br == "WML") {

// user is mobile based echo wml
// check for xhtml?

}else{

// user is on a pc echo html


This list shows a load of user agents that have been by one of our wap sites if that helps. It should download as an Excel file but I just made it on a Mac without Office so if it's buggy let me know and I'll try to sort it.

In fact thinking about that list makes me realise how out of date that code snippet is, If I was still using it I'd prolly butcher it to eregi up.link as a match and add the other agents too in the hope it makes it more stable.

HTH
__________________
Andy Moore << oh no it's got a blog.....
Word Press WAP Plugin with Ad Mob Advertising revenue
PHP developer
deploying ringtones, mp3 downloads and realtones
I'm a geek who's obsessed with stats and gadgets

Reply With Quote
  #3  
Old September 23rd, 2004, 02:18 AM
jabba_29's Avatar
jabba_29 jabba_29 is offline
Back in HEL
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Feb 2002
Location: Finland
Posts: 8,613 jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)jabba_29 User rank is General 9th Grade (Above 100000 Reputation Level)  Folding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner FolderFolding Points: 57777 Folding Title: Beginner Folder
Time spent in forums: 3 Months 3 Weeks 3 Days 5 h 32 m 57 sec
Reputation Power: 1550
Send a message via ICQ to jabba_29 Send a message via AIM to jabba_29 Send a message via MSN to jabba_29 Send a message via Yahoo to jabba_29 Send a message via Google Talk to jabba_29 Send a message via Skype to jabba_29
Facebook
Hi Andy,
Thanks for the info.
I have actually modded my script a bit (now at work so no access to it).
Will play around some more when I get home.
Jamie

Reply With Quote
  #4  
Old September 29th, 2004, 05:33 AM
tompercival tompercival is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2001
Location: London, England
Posts: 1 tompercival User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
your wap agent strings

Quote:
Originally Posted by andymoo
This list shows a load of user agents that have been by one of our wap sites if that helps.


Hi - took me a while to work out what you meant by eregi the Up.link but i've got it after looking at your browser string list - quick question though - what is the significance of the Up.link?

appreciate your help

tommy

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreWAP Programming > Quicker / more effective moblie device detection script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway