Captcha für Adv. Guestbook - Einbauprobleme

Allgemeiner Support zum phpBB 2 Board und phpBB 2 Modifikationen
Forumsregeln
Auch wenn hier der Support für phpBB 2 weiterhin aufrecht erhalten bleibt, weisen wir darauf hin, dass das phpBB 2 nicht mehr offiziell unterstützt und weiterentwickelt wird!
Antworten
Andraste
Beiträge: 103
Registriert: Di 21.Mär, 2006 20:25

Captcha für Adv. Guestbook - Einbauprobleme

Beitrag von Andraste »

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 funktioniert 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 :!:

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

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

Edit: Wirklich niemand ? :(
Zuletzt geändert von Andraste am So 21.Dez, 2008 14:08, insgesamt 1-mal geändert.
Antworten