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.

Author Topic: Easy ways to add Captcha in sNews  (Read 2047 times)

daus

  • Newbie
  • *
  • Karma: 1
  • Posts: 7
Easy ways to add Captcha in sNews
« on: June 18, 2008, 08:41:12 am »

Tested with sNews16

Captcha source  : http://gscripts.net

Preview of mod in sNews  :


 
Download Support files first ( http://www.daoush.net/download/captcha_support_files.zip ) :
- captcha.php
- fonts\arialbd.ttf
- fonts\VeraBd.ttf
- fonts\verdanab.ttf


1. Copy all support files to snews-root

2. Modified mathCaptcha function with :
Code: [Select]
function mathCaptcha($input='', $sum='') {

if ( isset($_REQUEST['inputcode'])) {
if (md5($_REQUEST['inputcode']) == $_SESSION['__vimg_code__']) {  // Check Captcha
$math = true;
}else{
$math = false;
} //endif check captcha
}else {
$sum = time();
        $math = '<p><label for="calc">* '.l('math_captcha').':</label><br />';
$math .= '<img id="__code__" src="captcha.php?id=".$sum." style="border:1px solid #000000" /><br/>';
$math .= 'Captcha code ( case sensitive ) <input type="text" name="inputcode" size="5" maxlength="5" /></p>';
    } //endif $_REQUEST

    return $math;
}


3. Remove is_numeric function under //COMMENTS and $doublecheck = retrieve('id',  ..... with :
Code: [Select]
if ($ip == $_SERVER['REMOTE_ADDR'] && (time() - $now) > 4 && $comment && $name && $post_article_id && mathCaptcha($_POST['calc'], $_POST['sum']) && !isset($doublecheck)) {
4.Change captcha related variable under #SITE LANGUAGE VARIABLES with
Code: [Select]
$l['math_captcha'] = 'Perform Captcha code to avoid spam';
$l['err_Login'] = 'Wrong username and/or password and/or Captcha.';

* You can also remove all parameters when called mathCaptcha function if you want.

Its a very simple , isn't it ?  ;)
« Last Edit: June 18, 2008, 08:45:01 am by daus »
Logged