On Fri, 30 Jun 2000, Edwin Pratomo wrote:
> Ask Bjoern Hansen wrote:
> >
> > On Thu, 29 Jun 2000, Drew Taylor wrote:
> >
> > > I'm hoping it's been done already, because the user-agent strings are
> > > terribly inconsistent...
> >
> > I needed something like that once and ended up with this:
> >
> > sub UA {
> > my $ua = shift;
> > my $n = "";
> > my $v = "";
> ....
>
> this doesn't seem to be aware of either WAP browsers or the emulators.
> A typical usage of this is to return WML pages if the request comes from
> a WAP browser, otherwise return html pages.
This is the AxKit WAPChooser media plugin (the UA substrings are taken
from the WAP FAQ which I periodically check and update):
# $Id: WAPCheck.pm,v 1.2 2000/05/02 10:32:07 matt Exp $
package Apache::AxKit::MediaChooser::WAPCheck;
use strict;
use Apache::Constants;
sub handler {
my $r = shift;
my $type;
local $^W;
if ($ENV{HTTP_ACCEPT} =~ /vnd.wap.wml/i) {
$r->notes('preferred_media', 'handheld');
}
elsif (substr($ENV{HTTP_USER_AGENT},0,4) =~
/(
Noki
| Eric
| WapI
| MC21 # cough spit hack ;-) (I used to work at
Ericsson)
| AUR\s
| R380
| UP.B
| WinW
| UPG1
| upsi
| QWAP
| Jigs
| Java
| Alca
| MITS
| MOT-
| My\sS
| WAPJ
| fetc
| ALAV
| Wapa
)/x) {
# warn "set media to handheld!\n";
$r->notes('preferred_media', 'handheld');
}
return OK;
}
1;
--
<Matt/>
Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org