ERLEDIGT
NEIN
NEIN
ANTWORTEN
3
3
ZUGRIFFE
243
243
EMPFEHLEN
-
Hallo,
ich hab (mal wieder
) ein Problem mit einem Captcha_Script.
Ich habe schon versucht,das Bild ohne Header zu senden aber da sah es für mich nach einem Einwandfreiem PNG aus.
Hier mein Code:
Alle Dateien sind auch Da,aber ich kriege wenn ich den Header sende nur "Das Bild kann nich gezeigt werden weil es Fehler enthält."PHP-Code:<?php
/*
Copyright (c) 2008 Tristan Seifert<seiferttristan@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/
// ERROR_REPORTING(E_ALL);
// ERROR_REPORTING(E_NONE);
session_start();
unset($_SESSION['captcha_spam']);
function randomString($len) {
function make_seed(){
list($usec , $sec) = explode (' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
//Der String $possible enthält alle Zeichen, die verwendet werden sollen
$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789";
$str="";
while(strlen($str)<$len) {
$str.=substr($possible,(rand()%(strlen($possible))),1);
}
return($str);
}
$text = randomString(5); //Die Zahl bestimmt die Anzahl stellen
$_SESSION['captcha_spam'] = $text;
header('Content-type: image/png');
$rand_bg=rand(1,6);
$rand_font=rand(1,6);
$img = ImageCreateFromPNG("captcha".$rand_bg.".PNG"); //Backgroundimage
$color = ImageColorAllocate($img, rand(180,255), rand(175,245), rand(180,255)); //Farbe
$ttf = "font".$rand_font."f"; //Schriftart
$ttfsize = 18; //Schriftgrösse
$angle = rand(-20,20);
$t_x = rand(5,30);
$t_y = 35;
imagettftext($img, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
imagepng($img);
imagedestroy($img);
?>
Ich benutze Firefox 1.9.0.4 (Die war tazächlich bei Ubuntu 8.10 dabei!).
Außerdem ist GD Und PNG-Support enabled.
gd
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.5
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XPM Support enabled
XBM Support enabled
JIS-mapped Japanese Font Support enabled
Ich kann deisen doofen Fehler einfach nicht finden
!
Danke für alle Antworten im Voraus!Geändert von ts230 (20.12.08 um 18:21 Uhr)
-
21.12.08 04:15 #2
- Registriert seit
- Feb 2008
- Beiträge
- 522
Hi
ich hatte den Fehler auch immer. Ich weiß nicht ob meine Lösung dafür jetzt gut ist, aber ich glaube ich habe es so geschafft:
Den Header natürlich dann nicht mehr auf image/png stellenPHP-Code:imagepng($img, 'captcha.png');
echo '<img src="captcha.png">';
Napoleon trug rote Kleidung, damit seine Soldaten nicht sahen, dass er verwundet war.
Die Naz!s trugen braune Hosen ...
-
ja aber das Bild soll ja statisch generiert werden.
Ich kanns ja auch als PHP einbinden.
-
21.12.08 13:49 #4
- Registriert seit
- Feb 2008
- Beiträge
- 522
Dann hab ich leider keine Ahnung.
Du könntest das Script mit meiner Lösung als include an die gewünschte Stelle schreiben.Napoleon trug rote Kleidung, damit seine Soldaten nicht sahen, dass er verwundet war.
Die Naz!s trugen braune Hosen ...
Ähnliche Themen
-
Captcha in ein schon existierendes Script einfügen
Von IcomY im Forum PHPAntworten: 7Letzter Beitrag: 27.02.09, 13:21 -
1. Wordpress - Eintragfelder erweitern 2. Sehr einfaches Script mit Captcha schützen
Von greendog im Forum Stellenangebote (unentgeltlich)Antworten: 0Letzter Beitrag: 15.11.06, 13:54 -
Problem bei meinem Bilder Script!
Von Froschh im Forum PHPAntworten: 7Letzter Beitrag: 04.03.06, 16:34 -
Problem bei meinem Script
Von Grashupfaa im Forum PHPAntworten: 4Letzter Beitrag: 28.09.03, 10:00 -
Problem mit meinem login script
Von cctnt im Forum PHPAntworten: 3Letzter Beitrag: 11.09.02, 08:22





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren