Geschrieben von lucas9991 am 22.01.2005, 23:35

So ich hab ein kleines script geschrieben, das ein bild mit zahlen erzeut, diese müsst ihr in einem formular feld eingeben, dann werden diese geprüft und falls richtig wird "richtig" ausgegeben.
Wenn ihr ein wenig PHP könnt, könnt ihr das in eurer login script reinpacken, damit kein bot einen account hackt!

also hier zuerst die datei zum erstellen des bildes (bild.php):

<?php
header("Content-type:image/png");
$bild = imagecreatetruecolor(120, 50); // bild mit auflösung 120x50

$weiss = imagecolorallocate($bild, 255, 255, 255); // hintergrundfarbe 255, 255, 255 = weiss
imagefilledrectangle($bild, 0, 0, 120, 50, $weiss);
// erste zahl
$color1 = rand(1, 255);
$color3 = rand(1, 255);
$color = imagecolorallocate($bild, $color1, 0, $color3);
$zahl = rand(1, 9);
$entfernung = rand(2, 19);
$hoehe = rand(-2, 30);
imagestring($bild, 5, $entfernung, $hoehe, $zahl, $color);
$zahltoput = $zahl;

// zweite zahl
$color1 = rand(1, 255);
$color3 = rand(1, 255);
$color = imagecolorallocate($bild, $color1, 0, $color3);
$zahl = rand(1, 9);
$entfernung = rand(22, 39);
$hoehe = rand(-2,30);
imagestring($bild, 5, $entfernung, $hoehe, $zahl, $color);
$zahltoput .= $zahl;

// dritte zahl
$color1 = rand(1, 255);
$color3 = rand(1, 255);
$color = imagecolorallocate($bild, $color1, 0, $color3);
$zahl = rand(1, 9);
$entfernung = rand(42, 59);
$hoehe = rand(-2,30);
imagestring($bild, 5, $entfernung, $hoehe, $zahl, $color);
$zahltoput .= $zahl;

// vierte zahl
$color1 = rand(1, 255);
$color3 = rand(1, 255);
$color = imagecolorallocate($bild, $color1, 0, $color3);
$zahl = rand(1, 9);
$entfernung = rand(62, 79);
$hoehe = rand(-2,30);
imagestring($bild, 5, $entfernung, $hoehe, $zahl, $color);
$zahltoput .= $zahl;

// fünfte zahl
$color1 = rand(1, 255);
$color3 = rand(1, 255);
$color = imagecolorallocate($bild, $color1, 0, $color3);
$zahl = rand(1, 9);
$entfernung = rand(82, 99);
$hoehe = rand(-2,30);
imagestring($bild, 5, $entfernung, $hoehe, $zahl, $color);
$zahltoput .= $zahl;

imagepng($bild); // bild ausgeben
imagedestroy($bild); // bild aus dem speicher löschen

$text = "<?php \$zahl = \"$zahltoput\"; ?>"; // text für die zahl.php, wo die zahl im bild gespeichert wird
$write = fopen("zahl.php", "w"); // zahl.php ggf. erstellen und die zahl reinschreiben
fputs($write, $text);
fclose ($write); // datei wieder schliessen
?>

wenn ihr diese datei aufruft seht ihr ein bild ^^
diese könnt ihr über <img src="bild.php"> auch aufrufen!
so hier die login.php:

<img src="text.php"> <!-- das bild ausgegeben danach ein kleines formular //-->
<form method="get" action="">
<input name="zahlen">
<input type="submit">
</form>

<?php
if(isset($zahlen)) // falls das formular abgeschickt wurde
{
include("zahl.php"); // dann füge zahl.php ein
if($zahl==$zahlen) // wenn $zahl aus zahl.php gleich der eingegebenen zahlen ist dann gebe richtig aus
{ echo "richtig"; }
else { echo "falsch"; } // ansonsten falsch
?>

So das wars schon
Ich hoffe ihr könnt damit was anfangen, wenn nich pn an mich oder icq 192853407.

mfg Lucas

Bewertung Anzahl
6
63,6 %
7 Bewertungen
4
18,2 %
2 Bewertungen
3
18,2 %
2 Bewertungen