Das nennt sich Captcha 1.0.8
1. Dat. captcha.php
2. Dat. captcha_ausw.php
3. Dat. captcha_img.php
Und da ist das Problem, weil ich ja irgentwie wieder zurück muss.
Scripte:
captcha.php
-------------------------
<?
/*
Captcha v1.o8 - Copyright (c) 2006, Daniel Kauser aka danysahne333
This program and it's moduls are Open Source in terms of General Public License (GPL) v2.0
captcha.php (random text module)
visit
externer Link for latest version
*/
// Alle Fehler und Notices anzeigen
error_reporting(E_ALL);
session_start();
$CAPTCHA_TempString="";
// Zufallsfunktion für Zahlen und Buchstaben
function GetRandomChar() {
// Zufallszahl generieren
mt_srand((double)microtime()*1000000);
$CAPTCHA_RandVal = mt_rand(1,2);
// Buchstabensalat generieren jeh nachdem ob Randval 1 oder 2 ist
switch ($CAPTCHA_RandVal) {
case 1:
// Zahlen 0-9
$CAPTCHA_RandVal = mt_rand(48, 57);
break;
case 2:
// Grosse Buchstaben
$CAPTCHA_RandVal = mt_rand(65, 90);
break;
}
// Zufallscode ausgeben
return chr($CAPTCHA_RandVal);
}
// Zufallscode x-stellig ausgeben
for ($i = 1; $i <= 6; $i++) {
$CAPTCHA_TempString .= GetRandomChar();
}
// Text in Sessionvariable speichern
if (isset($CAPTCHA_TempString)) {
$_SESSION["CAPTCHA_RndText"] = str_replace('I','E',str_replace('0','3',str_replace('1','S',str_replace('B','F',str_replace('O','P',str_replace('4','A',str_replace('D','K',$CAPTCHA_TempString)))))));
} else {
die("Zufallscode konnte nicht generiert werden!");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="language" content="de" />
<title>captcha.php</title>
</head>
<body>
<h3>Captcha 1.0.8</h3>
<form method="post" action="captcha_ausw.php" name="sms">
<div>
<p class="abstand3">Please enter correct code here. </p>
<p class="abstand3"><img border="0" src="captcha_img.php" alt="" /></p>
<p class="abstand">Code: <input maxlength="6" name="txtCode" size="28" type="text" /></p>
<p class="abstand"><input class="button" type="submit" name="eintrag" value="eintragen" /> <input class="button" type="reset" name="reset" value="löschen" /></p>
</div>
</form>
</body>
</html>
--------------------
Dat. captcha_ausw.php
--------------------
<?
// Alle Fehler und Notices anzeigen
error_reporting(E_ALL);
session_start();
// Bei Ausgabe des eingegebenen Codes müssen html tags entfernt werden!
$CAPTCHA_RandomText = "";
if (isset($_POST['txtCode'])){
$CAPTCHA_EnteredText = str_replace("<","",str_replace(">","",str_replace("'","",str_replace("[","",str_replace("]","",$_POST['txtCode'])))));
}
if (isset($_SESSION['CAPTCHA_RndText'])) {
$CAPTCHA_RandomText = $_SESSION['CAPTCHA_RndText'];
}
if ($CAPTCHA_EnteredText == $CAPTCHA_RandomText and isset($_POST['txtCode']) == true and isset($_SESSION['CAPTCHA_RndText'])){
// Hier Code, wenn Übereinstimmung
echo "<h3>Gratulation!</h3>";
echo "Right Code!";
echo "Your Code: $CAPTCHA_EnteredText, Random Code: $CAPTCHA_RandomText";
} else {
// Hier Code wenn keine Übereinstimmung
echo "<h3>Nope!</h3>";
echo "Wrong Code!";
echo "Your Code: $CAPTCHA_EnteredText, Random Code: $CAPTCHA_RandomText";
}
echo "<br />";
echo "<a href=\"captcha.php\">do it again!</a>";
// Session unset und destroy
session_unset();
session_destroy();
?>
-------------------
captcha_img.php
-------------------
<?php
// Alle Fehler und Notices anzeigen
error_reporting(E_ALL);
/*
Captcha v1.o8 - Copyright (c) 2006, Daniel Kauser aka danysahne333
This program and it's moduls are Open Source in terms of General Public License (GPL) v2.0
captcha_img.php (image module)
visit
externer Link for latest version
*/
// Session initialisieren
session_start();
// Benötigte Files laden! Hier kann editiert werden!
$imagettftext = "1"; // Alternative Grafik-Zeichenfunktion nutzen? (bei fehlerhafter Darstellung
// oder fehlendem Truetype-support) 1=nein, 2=ja
$Welleneffekt = "1"; // Welleneffekt nutzen? 1=nein, 2=ja
$Textgroesse = "32";
$Texthoehe = "47";
$Schriftart = "captcha_files/truetype.ttf";
$bg1 = "captcha_files/background1.png";
$bg2 = "captcha_files/background2.png";
$ov1 = "captcha_files/overlay1.png";
$ov2 = "captcha_files/overlay2.png";
// Benötige Strings überprüfen
if (isset($_SESSION["CAPTCHA_RndText"])) {
$CAPTCHA_RandomText = $_SESSION["CAPTCHA_RndText"];
} else {
// Fehlermeldung ausgeben
header ("Content-type: image/png");
$im = @imagecreatetruecolor(300, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 7, "Kein Zufallscode übergeben!", $text_color);
imagepng($im);
imagedestroy($im);
exit();
}
// Auf Funktion überprüfen
if ($imagettftext == "1") {
// Benötige Files überprüfen
if (!file_exists($Schriftart)) {
// Fehlermeldung ausgeben
// header ("Content-type: image/png");
$im = @imagecreatetruecolor(300, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 7, "Schriftart nicht gefunden!", $text_color);
imagepng($im);
imagedestroy($im);
exit();
}
if (!file_exists($bg1) OR !file_exists($bg2)) {
// Fehlermeldung ausgeben
header ("Content-type: image/png");
$im = @imagecreatetruecolor(300, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 7, "Hintergrundbild nicht gefunden!", $text_color);
imagepng($im);
imagedestroy($im);
exit();
}
if (!file_exists($ov1) OR !file_exists($ov2)) {
// Fehlermeldung ausgeben
header ("Content-type: image/png");
$im = @imagecreatetruecolor(300, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 7, "Overlaybild nicht gefunden!", $text_color);
imagepng($im);
imagedestroy($im);
exit();
}
// Zufallshintergrund
mt_srand((double)microtime()*1000000);
$Bild1 = mt_rand(1, 2);
switch ($Bild1) {
case 1:
$Grafik=imagecreatefrompng($bg1);
$Grafikhilf=imagecreatefrompng($bg1);
break 1;
case 2:
$Grafik=imagecreatefrompng($bg2);
$Grafikhilf=imagecreatefrompng($bg2);
break 1;
}
// Zufallsgrafik2
mt_srand((double)microtime()*1000000);
$Bild2 = mt_rand(1, 2);
switch ($Bild2) {
case 1:
$Grafik2=imagecreatefrompng($ov1);
break 1;
case 2:
$Grafik2=imagecreatefrompng($ov2);
break 1;
}
// Textfarben ins Array speichern
$textfarbe = array(
imagecolorallocate($Grafik, 128, 128, 128),
imagecolorallocate($Grafik, 0, 0, 0),
imagecolorallocate($Grafik, 50, 171, 4),
imagecolorallocate($Grafik, 128, 0, 128),
imagecolorallocate($Grafik, 128, 128, 255),
imagecolorallocate($Grafik, 255, 128, 128),
imagecolorallocate($Grafik, 192, 122, 0),
imagecolorallocate($Grafik, 250, 94, 250),
imagecolorallocate($Grafik, 122, 146, 224),
imagecolorallocate($Grafik, 122, 155, 180)
);
// Text auf das Bild schreiben
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 10, $Texthoehe+mt_rand(-7,8), $Textfarbe1 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[0]);
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 45, $Texthoehe+mt_rand(-7,8), $Textfarbe2 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[1]);
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 80, $Texthoehe+mt_rand(-7,8), $Textfarbe3 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[2]);
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 113, $Texthoehe+mt_rand(-7,8), $Textfarbe4 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[3]);
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 150, $Texthoehe+mt_rand(-7,8), $Textfarbe5 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[4]);
imagettftext($Grafik, $Textgroesse, mt_rand(-13, 13), 191, $Texthoehe+mt_rand(-7,8), $Textfarbe6 = $textfarbe[array_rand($textfarbe)] , $Schriftart, $CAPTCHA_RandomText[5]);
if ($Welleneffekt == "2") {
$stauchung = mt_rand(0,100)/400+0.10;
$Grafikalt = $Grafik;
$Grafik = $Grafikhilf;
for ($i=1;$i<=65;$i++){
imagecopy($Grafik, $Grafikalt, round((sin($i*$stauchung)*2))+3, $i, 1, $i, 230,1);
}
}
// Transparente Grafik drüberlegen
imagecopy($Grafik, $Grafik2, 0, 0, 0, 0, 230, 65);
// Bild ausgeben
header("Content-type: image/png");
imagepng($Grafik);
imagedestroy($Grafik);
} else if ($imagettftext == "2") {
// Alternativbild ausgeben
header ("Content-type: image/png");
$im = @imagecreatetruecolor(70, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 10, 5, 7, $CAPTCHA_RandomText, $text_color);
imagepng($im);
imagedestroy($im);
} else {
// Fehlermeldung ausgeben
header ("Content-type: image/png");
$im = @imagecreatetruecolor(430, 30)
or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 10, 5, 7, "Fehlerhafte Auswahl($imagettftext)der Funktion! (1 od. 2)", $text_color);
imagepng($im);
imagedestroy($im);
exit();
}
?>
-----------------------