blogscrubber Posted March 21, 2008 Share Posted March 21, 2008 Hi, I'm working on a script to scan an url for adult keywords and having nothing but problems, please help! $adult = array("lesbians", "porn"); for($i=0; $i<sizeof($adult); $i++) { if (preg_match($adult[$i],$website_uri)===false) { $website = 'block.gif'; } else { $website = 'accept.gif'; } } please tell me what i'm doing wrong? should work, I think! Link to comment https://forums.phpfreaks.com/topic/97259-auto-scan-url-for-bad-keywords-return-results/ Share on other sites More sharing options...
rhodesa Posted March 21, 2008 Share Posted March 21, 2008 try this: <?php $website = 'accept.gif'; $adult = array("lesbians", "porn"); foreach($adult as $word){ if(strpos($website_uri) !== false){ $website = 'block.gif'; break; } } echo $website; ?> Link to comment https://forums.phpfreaks.com/topic/97259-auto-scan-url-for-bad-keywords-return-results/#findComment-497668 Share on other sites More sharing options...
blogscrubber Posted March 21, 2008 Author Share Posted March 21, 2008 $website1 = 'accept.gif'; $adult = array("lesbians", "porn", "xxx", "pron"); foreach($adult as $word){ if(strpos($website_uri, $word) == true){ $website1 = 'blocked.gif'; break; } } thank you so much, had to modify it a bit to get it to work! works perfect now! filled array! Link to comment https://forums.phpfreaks.com/topic/97259-auto-scan-url-for-bad-keywords-return-results/#findComment-497714 Share on other sites More sharing options...
rhodesa Posted March 21, 2008 Share Posted March 21, 2008 the only catch is if the url string starts with one of the bad words (which theoretically will never happen), but just in case: <?php $website = 'accept.gif'; $adult = array("lesbians", "porn", "xxx", "pron"); foreach($adult as $word){ if(strpos($website_uri,$word) !== false){ $website = 'block.gif'; break; } } ?> Link to comment https://forums.phpfreaks.com/topic/97259-auto-scan-url-for-bad-keywords-return-results/#findComment-497721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.