Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: [1] 2 3 ... 5

Author Topic: [MOD] Comment box anti spammers v.0.1 (sNews 1.4)  (Read 43170 times)

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« on: May 05, 2006, 09:32:35 PM »

[MOD] Comments and Contact box anti spammers v.0.3 for sNews v1.4
LAST UPDATE: Thuesday, 6, Jun.
UPDATED: Now, the code validates! :D
THIS MOD IF FOR PROTECT COMMENTS AND CONTACT BOX

I've read some problems about spamm into comments and, for now, until Luka make a
better solution about this, and he will integrate into sNews, I've created this mod for the moment.
With it, I'm very sure that your comments box don't be spammed again.

********** MAKE A BACKUP!!! *************
      This module requires GD library

First of all, create this two scripts in the same folder of sNews are:

1st- Named it as :button.php
Code: [Select]
<?php

$image 
imagecreate(12030);

$white    imagecolorallocate($image0xFF0xFF0xFF);
$gray    imagecolorallocate($image0xC00xC00xC0);
$darkgray imagecolorallocate($image0x500x500x50);

srand((double)microtime()*1000000);

for (
$i 0$i 30$i++) {
  
$x1 rand(0,120);
  
$y1 rand(0,30);
  
$x2 rand(0,120);
  
$y2 rand(0,30);
  
imageline($image$x1$y1$x2$y2 $gray);
}

for (
$i 0$i 5$i++) {
$cnum[$i] = rand(0,9);
}


for (
$i 0$i 5$i++) {
 
$fnt rand(3,5);
 
$x $x rand(12 20);
 
$y rand(12);
 
imagestring($image$fnt$x$y$cnum[$i] , $darkgray);
}

$digit "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";

session_start();
$_SESSION['digit'] = $digit;

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);

?>
2on- Named it as :audit.php
Code: [Select]
<?php
 
function audit() {
  
session_start();
  
$digit $_SESSION['digit'];
  
$userdigit $_POST['userdigit'];
  
session_destroy();

  if ((
$digit == $userdigit) && ($digit 1)) {
    return 
true;
  } else {
    return 
false;
  }

}
?>
The next step... 
In the snews.php, locate this line under //COMMENTS:
Code: [Select]
if (isset($_POST['comment']) AND strlen($_POST['name']) > 2 AND strlen($_POST['comment']) > 5) {And change it to this:
Code: [Select]
if (isset($_POST['comment']) AND audit() AND strlen($_POST['name']) > 2 AND strlen($_POST['comment']) > 5) {Next...
Locate this line, under //COMMENTS too:
Code: [Select]
<p><input name="name" type="text" class="field" id="name" /></p>And, after this line, add this:
Code: [Select]
<!-- Mod commets validation by bramsyuur -->
<p><? echo l('code_validation'); ?></p>
<p><img width="120" height="30" src="button.php" alt="" /></p>
<p><? echo l('enter_validation_code'); ?></p>
<p><input maxlength="5" size="5" name="userdigit" type="text" class="field" value="" /></p>
<!-- End comments validation by bramsyuur-->
Next...
Add two Language variables, for a betther localization:
Code: [Select]
$l['code_validation'] = "Validation code:";
$l['enter_validation_code'] = "Enter validation code:";
Next...
Edit your index.php and add: include ("audit.php"); like this:
Code: [Select]
<?php
  session_start
();
  include (
"snews.php");
  include (
"audit.php");
?>
EDITED:
Next... for add this feature, too, into contact form,
Locate into //CONTACT function, this line:
Code: [Select]
<p><textarea name="message" rows="4" cols="5" class="text"></textarea></p>After this line, add these code:
Code: [Select]
<!-- Mod commets validation by bramsyuur -->
<p><? echo l('code_validation'); ?></p>
<p><img width="120" height="30" src="button.php" alt="" /></p>
<p><? echo l('enter_validation_code'); ?></p>
<p><input maxlength="5" size="5" name="userdigit" type="text" class="field" value="" /></p>
<!-- End comments validation by bramsyuur-->
And, locate this line, under //CONTACT function, too:
Code: [Select]
if (strlen(clean($_POST['name'])) > 1 AND strlen(clean($_POST['message'])) > 1) {And add audit() like this:
Code: [Select]
if (strlen(clean($_POST['name'])) > 1 AND strlen(clean($_POST['message'])) > 1 AND audit()) {And this is all!!! :D

This is a working screenshot for comments:

This is a working screenshot for contact form:


This mod is based on the code from Script Auditor v.1.0
You can found this original code here > http://php.webmaster-kit.com/

Thanks to all! ;)
bramsyuur.
« Last Edit: September 28, 2007, 10:19:00 PM by bakercad »
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Español

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #1 on: May 05, 2006, 09:40:11 PM »

Nice job bram :)
Logged

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #2 on: May 05, 2006, 09:42:12 PM »

Thanks Luka! :)
I hope this helps, for the moment...
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Español

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #3 on: May 06, 2006, 08:45:52 AM »

niceeeeeeeeeeeeeeeeee! ^_^
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #4 on: May 06, 2006, 10:28:07 AM »

God, Bram... If Barca don't deserve to win now, whane you did this, I don't know when ;)...

Good job. Now it's only the mailform left, hehe...
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

brauck

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 18
  • Posts: 572
    • http://www.hbw-webdesign.nl/
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #5 on: May 06, 2006, 10:32:10 AM »

Great Bram, works like a charm!! Thanks
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #6 on: May 06, 2006, 01:00:52 PM »

I've added protection into CONTACT form, too, with my MOD. See my first post.
Thanks! ;)
bram.
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Español

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #7 on: May 06, 2006, 01:14:05 PM »

Delicious.
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

brauck

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 18
  • Posts: 572
    • http://www.hbw-webdesign.nl/
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #8 on: May 06, 2006, 02:02:17 PM »

Thanks again Bram
Logged
Confidence is reduced complexity.
brauck.nl for free css templates

David

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 7
  • Posts: 580
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #9 on: May 06, 2006, 02:05:42 PM »

Really useful this mod ! Thanks Bram!
Logged

Phil

  • Full Member
  • ***
  • Karma: 1
  • Posts: 138
    • http://www.ckt.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #10 on: May 06, 2006, 09:35:39 PM »

Very nice Bram, thanks!
Logged

Rod

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 78
    • http://www.rjs-custom.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #11 on: May 07, 2006, 03:57:08 AM »

Very nice Bram, only my typo was the issue when trying, hehe, ;)

will be really useful on a few upcoming projects that I am working on.
Logged
Whatever went wrong, I am pretty sure I didn't do it!  Well atleast I think I didn't do it...

bryn

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 2
  • Posts: 939
    • http://www.cssugly.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #12 on: May 07, 2006, 09:51:35 AM »

thanks very much Bram..this is a really useful Mod and until a better solution is found permanently then this is going to be so handy for so many..

great work again :)
Logged
Over 1,000 posts of joy, sNews is not only brilliant, but fun too! thanks guys :D

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #13 on: May 07, 2006, 08:08:25 PM »

Installed this and it seem just freaking great. Bram, my man - Whan I go to spain next time, hide or I'll kiss you, hehe ;)
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

bramsyuur

  • sNews Dude
  • Hero Member
  • *****
  • Karma: 23
  • Posts: 900
    • http://snews.vietbee.net
[MOD] Comment box anti spammers v.0.1 (sNews 1.4)
« Reply #14 on: May 07, 2006, 08:33:20 PM »

@Patric:
I'll wait you with my "lips wide shut"! :P
Thanks, mate! ;)
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Español
Pages: [1] 2 3 ... 5