Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?

2002-07-05 Thread JJ Harrison

Because!

Also the audiance that will probably see the site will highly likely not
have the knowledge or intention to change the user agent var. So my Q
remains.

To add to my original Q is there seperate vars for browser and OS?

JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

Alberto Serra [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 JJ Harrison wrote:
  Is there an easy way to divide up $_SERVER['HTTP_USER_AGENT'] or do I
have
  to use regular expressions(Which I have little experiance with)?

 Why would you want to use that? People write in their HTTP_USER_AGENT
 whatever they want to, and many times you'll find there a set of 4
 letter words instead of the info you look for. There is a nice add-on
 for Mozilla to make that trick even easier.

 Alberto
 Kiev


 --


 @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@

 LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
 lOrD i'M sHiNiNg...
 YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
 tHe TeSt, YeS iT iS
 ThE tEsT, yEs It Is
 tHe TeSt, YeS iT iS
 ThE tEsT, yEs It Is...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?

2002-07-05 Thread John Legg

Hi

As far as I can see you need to manipulate HTTP_USER_AGENT yourself.  Here
is an example that I used to determine if the browser is MSIE and if so what
version it is.  What are you trying to determine?  A specific browser?

if (strStr($HTTP_USER_AGENT, MSIE)) {
  $agent_array = split(;, $HTTP_USER_AGENT);

  $ie_version = subStr($agent_array[1], 6,7);
}

Regards

John

- Original Message -
From: JJ Harrison [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, July 05, 2002 3:25 PM
Subject: Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?


 Because!

 Also the audiance that will probably see the site will highly likely not
 have the knowledge or intention to change the user agent var. So my Q
 remains.

 To add to my original Q is there seperate vars for browser and OS?

 JJ Harrison
 [EMAIL PROTECTED]
 www.tececo.com

 Alberto Serra [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]...
  JJ Harrison wrote:
   Is there an easy way to divide up $_SERVER['HTTP_USER_AGENT'] or do I
 have
   to use regular expressions(Which I have little experiance with)?
 
  Why would you want to use that? People write in their HTTP_USER_AGENT
  whatever they want to, and many times you'll find there a set of 4
  letter words instead of the info you look for. There is a nice add-on
  for Mozilla to make that trick even easier.
 
  Alberto
  Kiev
 
 
  --
 
 
  @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@
 
  LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
  lOrD i'M sHiNiNg...
  YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
  tHe TeSt, YeS iT iS
  ThE tEsT, yEs It Is
  tHe TeSt, YeS iT iS
  ThE tEsT, yEs It Is...
 



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?

2002-07-05 Thread Chris Garaffa

JJ,

I don't know of an *easy* way, but this script (with regex's ) isn't too
bad; you can figure it out with a little bit of research.
/* begin script
ereg(^([[:alpha:]]+)/([[:digit:]\.]+)( .*)$, $HTTP_USER_AGENT, $match);
$Browser_Name=$match[1];
$Browser_Version=$match[2];
$Browser_Description=$match[3];
If(eregi(msie, $Browser_Description))
eregi(MSIE ([[:digit:]\.]+);, $Browser_Description, $match);
$Browser_Name=MSIE;
$Browser_Version = $match[1];
}
// end script
*/
So now, you have a script which gets the Name, Version and Description, and
also looks to specify MSIE as the browser. Read up on Regular Expressions,
and you can modify this for any browser/version combo.
(adopted from Listing 16.3 in Core PHP Programming by Leon Atkinson)


-- 
Chris Garaffa
#!/usr/local/lib/php
$contact_info[Name]   = Chris Garaffa;
$contact_info[Email]  = [EMAIL PROTECTED];
$contact_info[Work]   = [EMAIL PROTECTED];
$contact_info[cell]   = 203.803.9066;


He who calles himself JJ Harrison (from [EMAIL PROTECTED]) wrote on
7/5/02 10:25 AM:

 Because!
 
 Also the audiance that will probably see the site will highly likely not
 have the knowledge or intention to change the user agent var. So my Q
 remains.
 
 To add to my original Q is there seperate vars for browser and OS?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?

2002-07-05 Thread Alberto Serra

ðÒÉ×ÅÔ!

 Because!

LOLOL okay. You can use this javascript stuff, it's more accurate and 
does not get fooled by the rubbish people write in their user_agents



// This function attempts to determine visitor's spoken language
// 
function browser_language() {
   if (navigator.appName == 'Netscape')
 var language = navigator.language;
   else
 var language = navigator.browserLanguage;

   return language;
}


// This function states whether browser is java_enabled
// 
function java_enabled() {
   // Find whether java is here
   if (navigator.javaEnabled() == 1) return Y; else return N;
}


// This function states whether browser is font smoothing capable
// 
function fontSmoothing_enabled() {
   // Find whether fonts smoothing available
   if (window.screen.fontSmoothingEnabled == true) return Y; else 
return N;
}


// This function is used to generate  the SRC parameter for the iframe
// in order to pass it all estracted parameters on clients workstation
// without using cookies
// 
function launch() {
   window.onerror=null;


   document.location = somescript.php?+
   language=+ browser_language() ++
   screen=+ 
window.screen.width+x+window.screen.height ++
   screenavailable=+ 
window.screen.availWidth+x+window.screen.availHeight ++
   colours=+ window.screen.colorDepth ++
   fonts_smoothing=+ fontSmoothing_enabled() ++
   java=+ java_enabled() ++
   browser=+ navigator.appName ++
   version=+ navigator.appVersion ++
   mozilla=+ navigator.appCodeName ++
   os=+ navigator.platform ++
   ref=+ document.referrer;


ÐÏËÁ
áÌØÂÅÒÔÏ
ëÉÅ×





-- 


-_=}{=_-@-_=}{=_--_=}{=_-@-_=}{=_--_=}{=_-@-_=}{=_--_=}{=_-

LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
lOrD i'M sHiNiNg...
YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is
tHe TeSt, YeS iT iS
ThE tEsT, yEs It Is...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Is there an easy way to divid up HTTP_USER_AGENT?

2002-07-05 Thread JJ Harrison

After A bit of research I wrote this(File is also attached in case e-mail
programs/servers interfere with formatting):

?
// Browser Detection
 if( eregi((opera)
([0-9]{1,2}.[0-9]{1,3}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs) ||
eregi((opera/)([0-9]{1,2}.[0-9]{1,3}){0,1},$_SERVER['HTTP_USER_AGENT'],$re
gs)){$browser = Opera $regs[2];}
 elseif(
eregi((konqueror)/([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$reg
s) ){$browser = Konqueror $regs[2];}
 elseif(
eregi((omniweb/)([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs)
 ){$browser = OmniWeb $regs[2];}
 elseif(
eregi((webtv/)([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) )
{$browser = WebTV $regs[2];}
 elseif(
eregi((lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}),$_SERVER['HTTP_USER_AGENT'
],$regs) ){$browser = Lynx $regs[2];}
 elseif( eregi((links)
\(([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$browser =
Links $regs[2];}
 elseif( eregi((msie)
([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$browser =
MSIE $regs[2];}
 elseif(
eregi((netscape6)/(6.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs) ){$bro
wser = Netscape $regs[2];}
 elseif( eregi(mozilla/5,$_SERVER['HTTP_USER_AGENT']) ){$browser =
Netscape;}
 elseif(
eregi((mozilla)/([0-9]{1,2}.[0-9]{1,3}),$_SERVER['HTTP_USER_AGENT'],$regs)
 ){$browser = Netscape $regs[2];}
 elseif( eregi(w3m,$_SERVER['HTTP_USER_AGENT']) ){$browser = w3m;}
 else{$browser = Unknown;}

// OS Detection
if(eregi(linux,$_SERVER['HTTP_USER_AGENT'])){$system = Linux;}
 elseif(eregi(win32,$_SERVER['HTTP_USER_AGENT'])){$system = Windows;}
 elseif(eregi(Win 9x 4.90,$_SERVER['HTTP_USER_AGENT'])){$system = Windows
Me;}
  elseif(eregi(windows 2000,$_SERVER['HTTP_USER_AGENT']) ||
eregi((windows nt)( ){0,1}(5.0),$_SERVER['HTTP_USER_AGENT']) ){$system =
Windows 2000;}
  elseif(eregi((windows
nt)( ){0,1}(5.1),$_SERVER['HTTP_USER_AGENT']) ){$system = Windows XP;}
 elseif( (eregi((win)([0-9]{2}),$_SERVER['HTTP_USER_AGENT'],$regs)) ||
(eregi((windows) ([0-9]{2}),$_SERVER['HTTP_USER_AGENT'],$regs)) ){$system
= Windows $regs[2];}

elseif(eregi((winnt)([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT
'],$regs) ){$system = Windows NT $regs[2];}
 elseif(eregi((windows
nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs) 
){$system = Windows NT $regs[3];}
 elseif(eregi(mac,$_SERVER['HTTP_USER_AGENT'])){$system = Macintosh;}
 elseif(eregi((sunos)
([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs)){$system =
SunOS $regs[2];}
 elseif(eregi((beos)
r([0-9]{1,2}.[0-9]{1,2}){0,1},$_SERVER['HTTP_USER_AGENT'],$regs)){$system =
BeOS $regs[2];}
 elseif(eregi(freebsd,$_SERVER['HTTP_USER_AGENT'])){$system = FreeBSD;}
 elseif(eregi(openbsd,$_SERVER['HTTP_USER_AGENT'])){$system = OpenBSD;}
 elseif(eregi(irix,$_SERVER['HTTP_USER_AGENT'])){$system = IRIX;}
 elseif(eregi(os/2,$_SERVER['HTTP_USER_AGENT'])){$system = OS/2;}
 elseif(eregi(plan9,$_SERVER['HTTP_USER_AGENT'])){$system = Plan9;}
 elseif(eregi(unix,$_SERVER['HTTP_USER_AGENT']) ||
eregi(hp-ux,$_SERVER['HTTP_USER_AGENT']) ||
eregi(X11,$_SERVER['HTTP_USER_AGENT']) ){$system = Unix;}
 elseif(eregi(osf,$_SERVER['HTTP_USER_AGENT'])){$system = OSF;}
 else{$system = Unknown;}

 echo You are using $browser on a $system system;
?

I seems to work quite well.


--
JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

P.S. My proxy seems to interfere with the Weberdev site. If Boaz Yahav
[EMAIL PROTECTED] or someone else wants to post this to Weberdev or
any other similar site as long as it remains free/open source etc.

Jj Harrison [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Because!

 Also the audiance that will probably see the site will highly likely not
 have the knowledge or intention to change the user agent var. So my Q
 remains.

 To add to my original Q is there seperate vars for browser and OS?

 JJ Harrison
 [EMAIL PROTECTED]
 www.tececo.com

 Alberto Serra [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]...
  JJ Harrison wrote:
   Is there an easy way to divide up $_SERVER['HTTP_USER_AGENT'] or do I
 have
   to use regular expressions(Which I have little experiance with)?
 
  Why would you want to use that? People write in their HTTP_USER_AGENT
  whatever they want to, and many times you'll find there a set of 4
  letter words instead of the info you look for. There is a nice add-on
  for Mozilla to make that trick even easier.
 
  Alberto
  Kiev
 
 
  --
 
 
  @-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@-_=}{=_-@
 
  LoRd, CaN yOu HeAr Me, LiKe I'm HeArInG yOu?
  lOrD i'M sHiNiNg...
  YoU kNoW I AlMoSt LoSt My MiNd, BuT nOw I'm HoMe AnD fReE
  tHe TeSt, YeS iT iS
  ThE tEsT, yEs It Is
  tHe TeSt, YeS iT iS
  ThE tEsT, yEs It Is...
 




begin 666 eregi.php
M/#\-B\O($)R;W=S97(@15T96-T:6]N#0H):68H(5R96=I*(H;W!EF$I
M(A;,TY77LQ+#)]+ELP+3E=S$L,WTIS L,7TB+1?4T525D526R=(5%10
M7U5315)?04=%3E0G72PDF5GRD@?'P@97)E9VDH(BAO5R82\I*%LP+3E=
MS$L,GTN6S