note 85709 added to function.eregi

From: Date: Sat, 13 Sep 2008 08:04:53 +0000
Subject: note 85709 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-144392@lists.php.net to get a copy of this message
Here is a simple way of checking if the visitor if your page is a search engine or a normal person. It does this by checking if the user agent returned by $_SERVER['HTTP_USER_AGENT'] contains one of the keywords search engine's user agents usually contain. <?php //check if user is a bot of some sort function is_bot() { $bots = array('google','yahoo','msn'); //takes the list above and returns (google)|(yahoo)|(msn) $regex = '('.implode($bots, ')|(').')'; /*uses the generated regex above to see if those keywords are contained in the user agent variable*/ return eregi($regex, $_SERVER['HTTP_USER_AGENT']); } ?> ---- Server IP: 209.41.74.194 Probable Submitter: 65.34.27.38 ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- https://master.php.net/note/edit/85709 Del: integrated -- https://master.php.net/note/delete/85709/integrated Del: useless -- https://master.php.net/note/delete/85709/useless Del: bad code -- https://master.php.net/note/delete/85709/bad+code Del: spam -- https://master.php.net/note/delete/85709/spam Del: non-english -- https://master.php.net/note/delete/85709/non-english Del: in docs -- https://master.php.net/note/delete/85709/in+docs Del: other reasons-- https://master.php.net/note/delete/85709 Reject -- https://master.php.net/note/reject/85709 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144392) next »