|  | Posted by Juan Jos Gutirrez de Quevedo Prez on 04/12/06 13:30 
El 12 Apr 2006 03:13:01 -0700fletch escribió:
 
 [..]
 > foreach($aSpiderUAs as $iPos=>$sSpiderUA) {
 > 		if (strpos($sHTTPUserAgent,$sSpiderUA)!==false)
 > 		{
 > 			$iSpiderID = $iPos;
 > 			$sSID = $iSpiderID.'00000000';
 > 			$bCaughtASpider = true;
 > 		}
 > 	}
 > }
 
 just an off-topic note:
 
 you really want to break from the foreach loop once you have found a
 spider so that you don't have to loop through the whole array once you
 have found a spider(that array may become really big with time).
 
 also, you are keeping $iSpiderID, so for example if altavista user
 agent is "altavista spider", you'll get the $iSpiderID of spider, NOT
 of altavista.
 
 it should be like this:
 
 foreach($aSpiderUAs as $iPos=>$sSpiderUA)
 if(strpos($sHTTPUserAgent,$sSpiderUA)!==false)
 {
 $iSpiderID=$iPos;
 $sSID=$iSpiderID.'00000000';
 $bCaughtASpider=true;
 break;
 }
 
 you should also initialize $bCaughtASpider as false(you may already be
 doing it, but you haven't pasted it in this bit) as it's always good to
 initialize variables.
 
 
 --
 Juan José Gutiérrez de Quevedo
 Director Técnico (juanjo@iteisa.com)
 ITEISA (http://www.iteisa.com)
 942544036 - 637447953
  Navigation: [Reply to this message] |