Hi!
With this Modifikation can captcha mathematics, for a little bit more spammbot protection.
Captcha mathematics for Register, - Comments, and Postcards.
Demo 1.) search in includes/captcha_utils.php:
function captcha_get_code() {
global $captcha_path, $captcha_chars, $captcha_wordfile, $captcha_length;
replace:
//###################### captcha mathematics start #######################
function calculation(){
global $site_sess;
$math = range(0,9);
shuffle($math);
$code = "$math[0]+$math[1]+$math[2]";
$sum = $math[0]+$math[1]+$math[2];
$site_sess->set_session_var('result', $sum);
return $code;
}
function captcha_validate_sum($result) {
global $site_sess, $captcha_enable, $user_info;
if (!$captcha_enable || $user_info['user_level'] == ADMIN) {
return true;
}
$sess_sum = trim($site_sess->get_session_var('result'));
$valid_result = $sess_sum != '' && $sess_sum == $result;
$site_sess->drop_session_var('result');
return $valid_result;
}
//###################### captcha mathematics end #########################
function captcha_get_code() {
global $captcha_path, $captcha_chars, $captcha_wordfile, $captcha_length,$captcha_calculation;
//###################### captcha mathematics start #######################
if($captcha_calculation){
return calculation();
}
//###################### captcha mathematics end #########################
2.) search in root/global.php:
$captcha_ttf = 1;insert below:
$captcha_calculation = 1; // "0" turn off captcha mathematics3.) search in your Template/style.css:
.input{
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
width: 230px;
}
insert below:
.input_res{
font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
color: #0f5475;
font-size: 11px;
width: 30px;
}
4.) search in lang/deutsch/main.php:
$lang['captcha_required'] = 'Das Feld mit dem Bestätigungs-Code muss ausgefüllt werden.';
insert below:
$lang['captcha_result'] = "Ihr Ergebnis stimmt nicht, bitte versuchen Sie es noch einmal !";
$lang['captcha_desc_result'] = "Bitte tragen Sie die Rechnung aus dem Bild in das Textfeld darunter ein, und schreiben das Ergebnis rechts davon hinein.<br>Wenn Sie Probleme haben den Code zu erkennen, klicken Sie auf das Bild um ein neues zu erhalten.";
4.1.) search in lang/english/main.php:
$lang['captcha_required'] = 'Please enter the verification code.';
insert below:
$lang['captcha_result'] = "Your result is wrong, please try again !";
$lang['captcha_desc_result'] = "Please enter the code from the image into the text field below, and write the result right inside of it.<br>If you have problems identifying the image, click on it to get a new one..";
5.) For Register: search in root/register.php:
$captcha = (isset($_POST['captcha'])) ? un_htmlspecialchars(trim($_POST['captcha'])) : "";
insert below:
//###################### captcha mathematics start #######################
$result = (isset($_POST['result'])) ? intval(trim($_POST['result'])):"";
//###################### captcha mathematics end #######################
search:
if ($captcha_enable_registration && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
insert below:
//###################### captcha mathematics start #######################
if ($captcha_enable_registration && $captcha_calculation && !captcha_validate_sum($result)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_result'];
$error = 1;
}
//###################### captcha mathematics end #######################
search:
"lang_captcha_desc" => $lang['captcha_desc'],
and replace:
//###################### captcha mathematics start #######################
"captcha_calculation" => (bool)$captcha_calculation,
"lang_captcha_desc" => ($captcha_calculation) ? $lang['captcha_desc_result'] : $lang['captcha_desc'],
//###################### captcha mathematics end #########################
5.1) search in your templatet/register_form.html:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />
and replace:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />{if captcha_calculation} = <input class="input_res" name="result" type="text" >{endif captcha_calculation}
6.) For Comments: search in root/details.php:
$captcha = (isset($_POST['captcha'])) ? un_htmlspecialchars(trim($_POST['captcha'])) : "";
insert below:
//###################### captcha mathematics start #######################
$result = (isset($_POST['result'])) ? intval(trim($_POST['result'])):"";
//###################### captcha mathematics end #######################
search:
if ($captcha_enable_comments && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
insert below:
//###################### captcha mathematics start #######################
if ($captcha_enable_comments && $captcha_calculation && !captcha_validate_sum($result)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_result'];
$error = 1;
}
//###################### captcha mathematics end #######################
search:
"lang_captcha_desc" => $lang['captcha_desc'],and replace:
//###################### captcha mathematics start #######################
"captcha_calculation" => (bool)$captcha_calculation,
"lang_captcha_desc" => ($captcha_calculation) ? $lang['captcha_desc_result'] : $lang['captcha_desc'],
//###################### captcha mathematics end #########################
6.1) search in your templatet/comment_form.html:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />
and replace:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />{if captcha_calculation} = <input class="input_res" name="result" type="text" >{endif captcha_calculation}</td>
7.) For Postcards: search in root/postcards.php:
$captcha = (isset($_POST['captcha'])) ? un_htmlspecialchars(trim($_POST['captcha'])) : "";
insert below:
//###################### captcha mathematics start #######################
$result = (isset($_POST['result'])) ? intval(trim($_POST['result'])):"";
//###################### captcha mathematics end #######################
search:
if ($captcha_enable_postcards && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$action = "previewcard";
$main_template = "postcard_preview";
}
insert above:
//###################### captcha mathematics start #######################
if ($captcha_enable_postcards && $captcha_calculation && !captcha_validate_sum($result)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_result'];
$action = "previewcard";
$main_template = "postcard_preview";;
}
//###################### captcha mathematics end #######################
search:
"lang_captcha_desc" => $lang['captcha_desc'],and replace:
//###################### captcha mathematics start #######################
"captcha_calculation" => (bool)$captcha_calculation,
"lang_captcha_desc" => ($captcha_calculation) ? $lang['captcha_desc_result'] : $lang['captcha_desc'],
//###################### captcha mathematics end #########################
7.1) search in your template/postcard_preview.html:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />
and replace:
<input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input" />{if captcha_calculation} = <input class="input_res" name="result" type="text" >{endif captcha_calculation}</td>
mfg Andi