note 35558 deleted from function.stristr by nlopess

From: Date: Sat, 12 Mar 2005 22:57:34 +0000
Subject: note 35558 deleted from function.stristr by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86337@lists.php.net to get a copy of this message
Note Submitter: jubi at irc dot pl ---- There are many more web spiders than those mentioned by Radu. I wrote this function to make storing their user_agent strings easier: <? //returns TRUE if the haystack string contains one of the strings from needle array, if needle is not found returns FALSE (case-insensitive) function arristr($haystack='', $needle=array()) { foreach($needle as $n) { if (stristr($haystack, $n) !== FALSE ) { return TRUE; } } return FALSE; } $haystack=$_SERVER['HTTP_USER_AGENT']; $needle=array('bot', 'slurp', 'grub', 'crawl', 'scan', 'szukacz'); if(!arristr($haystack, $needle)) { //session start } ?> ------------ JUBI http://www.jubi.buum.pl

« previous php.notes (#86337) next »