Stop spambots on your Coppermine Gallery!21 Jan 2007, 652 read(s) Tags:
Coppermine is one of the best php galleries ever created. I use it on one of my website and I'm very satisfied. However, spambots are making me nervous. Everything started when two-three links per day appeared as comments on my galleries. It wasn't that hard to remove them manually. But the number increased to 10-50/daily, so I decided to make something ...
I looked for any spambot protection for Coppermine Photo Gallery. However, I couldn't find any. One advice I could find on a forum was "Email verify, and don't allow unverified signups.". That won't deal with it. It still requires too much manual work. So ... I decided to make some necessary changes in the code of Coppermine and stop that SPAM/SCAM once and for all.
Fight them all!
Open the /db_input.php file of the Coppermine Photo Gallery and find the line that contains "// Comment update" (without slashes, around line 59):
db_input.php $event = isset($HTTP_POST_VARS['event']) ? $HTTP_POST_VARS['event'] : $HTTP_GET_VARS['event']; switch ($event) { // Comment update case 'comment_update':
Between the first and second line in the above code add the following:
code to add... $msg_body = $HTTP_POST_VARS['msg_body']; $bw[] = "http"; $bw[] = "(...)"; $bw[] = "www"; $bw[] = "a href"; $bw[] = ".html"; foreach($bw as $w) if(strpos($msg_body, $w) !== false){ die("Illegal chars found!"); } $HTTP_POST_VARS['msg_body'] = $msg_body ; $msg_body = '';
Each line like this $bw[] = "..."; defines what string to look for in the comments. If the string is found, the comment is not posted and a message appears on the screen: "Illegal chars found!". If you'd like, you can add more "black"-strings. It depends on what do the spambots write in your gallery. These are the ones I use. I should admin that I have had no problems since the modifications. Here is what we get as a final result:
db_input.php $event = isset($HTTP_POST_VARS['event']) ? $HTTP_POST_VARS['event'] : $HTTP_GET_VARS['event']; $msg_body = $HTTP_POST_VARS['msg_body']; $bw[] = "http"; $bw[] = "(...)"; $bw[] = "www"; $bw[] = "a href"; $bw[] = ".html"; foreach($bw as $w) if(strpos($msg_body, $w) !== false){ die("Illegal chars found!"); } $HTTP_POST_VARS['msg_body'] = $msg_body ; $msg_body = ''; switch ($event) { // Comment update case 'comment_update':
Quite simple, but quite effective! You can see a live demo here.
Comments Linda: I just changed my file and I really hope it works fine. Tomorrow I will check if it works...
Anyway..thank you very much for your help! Anonymous:
|