prawn_86 Posted March 4, 2009 Share Posted March 4, 2009 Hi all, Im still a newb at PHP and mySQL so go easy on me. I have a site: www.freefreeads.com Basically i did it to learn a bit of php and stuff, more out of fun than anything but now its being attacked by spammers (no surprise really). What i want to know is if there is a way for the links not to show on my page if they contain certain words? I dont know if this will be done through the PHP coding or through SQL Current code i have is: <?php //time to show you what you have in the database $sql = "SELECT * FROM `test_table` ORDER BY `id` DESC LIMIT 5000;"; $result = mysql_query($sql); print " <table border=\"0\">\n"; while ($row = mysql_fetch_assoc($result)){ $title = $row['title']; $url = $row['url']; echo " <tr> <td><a href=\"$url\" target=\"http://www.freefreeads.com\">$title</a></td> </tr> "; } print " </table>\n"; ?> Any help appreciated Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/ Share on other sites More sharing options...
revraz Posted March 4, 2009 Share Posted March 4, 2009 You can certainly search a string for particular words. And if it finds a match, then don't allow it to post. Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-776729 Share on other sites More sharing options...
prawn_86 Posted March 4, 2009 Author Share Posted March 4, 2009 thanks revraz. so i do it through SQL? any pointers as to how? this is all very new to me ??? Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-776744 Share on other sites More sharing options...
prawn_86 Posted March 5, 2009 Author Share Posted March 5, 2009 Any help with the above? Is it in the PHP script or the SQL that i would set out my banned words that wont be allowed to appear? These guys are really pissing me off, it looks like a bot doing it cause its just 5 at a time every 15min or so Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-777002 Share on other sites More sharing options...
kickstart Posted March 5, 2009 Share Posted March 5, 2009 Hi First thing I would do is to trap the IP addresses of the posters. And then block those belonging to the spammers. Likely that if it is a bot then it is just returning the form fields, so change the names of the form fields (or if you want a bit of fun, do this dynamically, maybe based on the day of the week), which will make them have to change their script to work again. To block the words you could compare them either with a LIKE in SQL or using a regular expression in php, dropping any record from being displayed when it contains a banned word. Probably easiest to store the list of banned words in a table, then loop through them and building up a regular expresssion string to use to checking against the posts (or you could check each one as you loop through them using strpos). All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-777116 Share on other sites More sharing options...
WolfRage Posted March 5, 2009 Share Posted March 5, 2009 Hey if it is a BOT you can use my technique. I just ask them a question. Simple but works like a charm. Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-777274 Share on other sites More sharing options...
kickstart Posted March 5, 2009 Share Posted March 5, 2009 Hi Another option (which you can add as well) is to send out the page with the date and time in it (no reason you cannot add or subtract a number of hours or days from it to make it less obvious, or that you cannot encode it somehow), and reject any page that is returned too quickly (ie a bot hammering away) or too slowly (ie, a bot submitting the form with details they picked up in the past). Doesn't stop them but does make their lives more difficult. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-777301 Share on other sites More sharing options...
prawn_86 Posted March 6, 2009 Author Share Posted March 6, 2009 To block the words you could compare them either with a LIKE in SQL or using a regular expression in php, dropping any record from being displayed when it contains a banned word. Probably easiest to store the list of banned words in a table, then loop through them and building up a regular expresssion string to use to checking against the posts (or you could check each one as you loop through them using strpos). This is what i want to do, as they can just change IPs etc. Im a complete newb so how would i go about coding this in SQL? I can figure out how to make the table but dont know how to intergrate the rest... Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-777764 Share on other sites More sharing options...
kickstart Posted March 6, 2009 Share Posted March 6, 2009 Hi I put a reply in you post on this in the MySQL area:- http://www.phpfreaks.com/forums/index.php/topic,241625.0.html While they can change IP addresses, chances are they only have a limited pool. You could also get them to enter an email address, and send a confirmation email to that address with a link to click to enable their post to display (although watch out for people using it to generate emails against random addresses just to be a pain). All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-778046 Share on other sites More sharing options...
prawn_86 Posted March 7, 2009 Author Share Posted March 7, 2009 Thanks for your help, i'll let you know how it goes... Quote Link to comment https://forums.phpfreaks.com/topic/147995-stopping-spammers/#findComment-778765 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.