note 44995 added to function.get-browser

From: Date: Sun, 22 Aug 2004 21:25:34 +0000
Subject: note 44995 added to function.get-browser
Groups: php.notes 
Request: Send a blank email to php-notes+get-75128@lists.php.net to get a copy of this message
you know replace _ with @ and . ;) Ok, here for all who can't get the function working because you can't configure the php.ini Just use these functions: http://nopaste.php-q.net/79823 (I would have posted it directly but thanks to: Your note is too long. You'll have to make it shorter before you can post it. Keep in mind that this is not the place for long code examples!) Ok, some examples: <? echo gather_os(); ?> This will echo the visitors System. If the useragent can't be matched *useragent* will be returned/echoed. useragent stands for the agent the user has. This is useful to see if theres a new browser that isn't detected so you can add it to the list. <? print_r gather_browser(); ?> Ok, more difficult here. This will return an array. First the Browser, then the Versionnumber if detected and the engine. An example could be: array("Firefox","0.9.3","Gecko") Ok. The 2nd argument of gather_os and gather_browser should be clear, you can use the function to detect eg. old useragents from a database or from a log file. But the first one: If set to 1 (or to true) it will return false, if a bot is detected. If it's set to 0 (or false) it will return "Bot" as it would be a normal OS/Browser (browser without version and engine). If you eg. want to count all visitors without bots you could use <? for($i=0;$i<$useragents;$i++) { if(gather_os(1,$useragents)) $visitor++; else $bot++; } ?> If you have got undetected useragents or improovements (I think Konqueror posts its version number in the useragent, too... but I'm not sure and I don't got any examples to test it), please mail them to me. Ah, and don't change the order the browsers are detected. eg. Opera must be on top because you can still detect opera though it's "disguised" as IE. hf using the functions, but please keep the author note in the source. thanks. xeen ---- Manual Page -- http://www.php.net/manual/en/function.get-browser.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44995 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44995&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44995&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75128) next »