Seite 1 von 1

Captcha für Adv. Guestbook - Hilfe beim Einbau

Verfasst: 11.12.2008 19:38
von Tommy_65428
Moin Moin. Ich bin scheinbar zu doof für den Einbau eines Captchas in das AGB. Hier mal die kurze Textanleitung:
Der Einbau ins bestehende Script ist sehr einfach, es braucht nur eine if-Schleife um das bisherige Script, welche überprüft ob das Ergebnis das eingegeben wurde, der generierten Captcha Rechnung entspricht. Optional kann auch noch ein else Teil angefügt werden, welche den Fehler ausgibt, dass das Ergebnis falsch war.
Damit ist folgender Code gemeint:

Code: Alles auswählen

<?php
session_start();
function encrypt($string, $key) {
$result = '';
for($i=0; $i<strlen($string); $i++) {
   $char = substr($string, $i, 1);
   $keychar = substr($key, ($i % strlen($key))-1, 1);
   $char = chr(ord($char)+ord($keychar));
   $result.=$char;
}
return base64_encode($result);
}
$sicherheits_eingabe = encrypt($_POST["sicherheitscode"], "29jfkd921");
$sicherheits_eingabe = str_replace("=", "", $sicherheits_eingabe);
if(isset($_SESSION['rechen_captcha_spam']) AND $sicherheits_eingabe == $_SESSION['rechen_captcha_spam']){
unset($_SESSION['rechen_captcha_spam']);

//
//
//Hier kommt das ursprüngliche Script hin.
//
//

}
?> 
Und das alles soll hier rein (Hoffe Ich):

Code: Alles auswählen

<?php
$include_path = dirname(__FILE__);
include_once $include_path."/admin/config.inc.php";
include_once $include_path."/lib/$DB_CLASS";
include_once $include_path."/lib/image.class.php";
include_once $include_path."/lib/template.class.php";


include_once $include_path."/lib/vars.class.php";
include_once $include_path."/lib/add.class.php";

$gb_post = new addentry($include_path);

if (isset($HTTP_POST_VARS["gb_action"])) {
	$gb_post->name = (isset($HTTP_POST_VARS["gb_name"])) ? $HTTP_POST_VARS["gb_name"] : '';
	$gb_post->email = (isset($HTTP_POST_VARS["gb_email"])) ? $HTTP_POST_VARS["gb_email"] : '';
	$gb_post->url = (isset($HTTP_POST_VARS["gb_url"])) ? $HTTP_POST_VARS["gb_url"] : '';
	$gb_post->comment = (isset($HTTP_POST_VARS["gb_comment"])) ? $HTTP_POST_VARS["gb_comment"] : '';
	$gb_post->location = (isset($HTTP_POST_VARS["gb_location"])) ? $HTTP_POST_VARS["gb_location"] : '';
	$gb_post->icq = (isset($HTTP_POST_VARS["gb_icq"])) ? $HTTP_POST_VARS["gb_icq"] : '';
	$gb_post->aim = (isset($HTTP_POST_VARS["gb_aim"])) ? $HTTP_POST_VARS["gb_aim"] : '';
	$gb_post->gender = (isset($HTTP_POST_VARS["gb_gender"])) ? $HTTP_POST_VARS["gb_gender"] : '';
	$gb_post->userfile = (isset($HTTP_POST_FILES["userfile"]["tmp_name"]) && $HTTP_POST_FILES["userfile"]["tmp_name"] != "") ? $HTTP_POST_FILES : '';
	$gb_post->user_img = (isset($HTTP_POST_VARS["gb_user_img"])) ? $HTTP_POST_VARS["gb_user_img"] : '';
	$gb_post->preview = (isset($HTTP_POST_VARS["gb_preview"])) ? 1 : 0;
	$gb_post->private = (isset($HTTP_POST_VARS["gb_private"])) ? 1 : 0;
	echo $gb_post->process($HTTP_POST_VARS["gb_action"]);
} else {
	echo $gb_post->process();

	exit;
}

?>
Der Rest des Captchas funzt einwandfrei. Die Zahlen werden angezeigt und variieren auch nach jedem Refresh der Seite. Ich bekomme den Code nur nicht an die richtige Stelle im Script eingebaut. Habe da einen geistigen Hänger :oops:

Danke schonmal im vorraus an denjenigen der mich und meinen geistiges tief erlöst :oops:

PS: Wer Zeit hat kann mir beim Teil mit der Else Bedingung auch mal helfen, hinsichtlich auf Fehlerausgabe XD

Verfasst: 23.12.2008 12:47
von Tommy_65428
*mal anschubs*