Captchas klappen nicht

Hey LeutZ,
Die Captchas bei meiner Toplist klappen nicht. Wenn man seine Seite in die Toplist einfügen will muss man einen Captcha eingeben der garnicht angezeigt wird.
Seht selbst: pivot-toplist.bplaced.net/toplis … php?a=join (nach unten scroolen)

Ich habe gerade gemerkt dass wenn man über den Link oben geht werden die Captchas angezeigt :astonished: . Aber wenn ich die Seite über den Browser aufrufe und eine Seite eintragen will werden die Captchas nicht angezeigt, warum ist das so?

,DoKi

/EDIT: Jetzt klappt aufeinmal doch nicht mehr :astonished: .

Wie du auf http://pivot-toplist.bplaced.net/toplist/captcha.php sehen kannst stimmt da was in deinem script nicht.

Poste mal den PHP Code von pivot-toplist.bplaced.net/toplist/captcha.php

Hier der PHP Code von captcha.php:

[code]<?php
//===========================================================================\
// Aardvark Topsites PHP 5.2 \
// Copyright © 2000-2007 Jeremy Scheff. All rights reserved. \
//---------------------------------------------------------------------------\
// http://www.aardvarktopsitesphp.com/ http://www.avatic.com/ \
//---------------------------------------------------------------------------\
// This program is free software; you can redistribute it and/or modify it \
// under the terms of the GNU General Public License as published by the \
// Free Software Foundation; either version 2 of the License, or (at your \
// option) any later version. \
// \
// This program is distributed in the hope that it will be useful, but \
// WITHOUT ANY WARRANTY; without even the implied warranty of \
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General \
// Public License for more details. \
//===========================================================================\

// This file is based on HN Captcha 1.3 by Horst Nogajski.
// http://hn273.users.phpclasses.org/browse/package/1569.html

// Help prevent register_globals injection
define(‘ATSPHP’, 1);
$CONF = array();
$FORM = array();
$TMPL = array();

// Change the path to your full path if necessary
$CONF[‘path’] = ‘.’;

// You can change most of these settings if you want to spice up your captcha
$TTF_folder = “{$CONF[‘path’]}/fonts/”;
$chars = array(4, 5, 6); // How many chars the generated text should have (default: 6 or 7)
$minsize = 30; // The minimum size a Char should have (default: 30-50)
$maxsize = 60; // The maximum size a Char can have (default: 50-70)
$maxrotation = 30; // The maximum degrees a Char should be rotated. Set it to 30 means a random rotation between -30 and 30.
$noise = 1; // Background noise On/Off (1/0); if is Off, a grid will be created
$debug = 0; // Outputs configuration values for testing
$jpegquality = 80; // image quality
$noisefactor = 9; // this will multiplyed with number of chars

$ckey = array_rand($chars);
$chars = $chars[$ckey];

// Connect to the database
require_once("{$CONF[‘path’]}/settings_sql.php");
require_once("{$CONF[‘path’]}/sources/sql/{$CONF[‘sql’]}.php");
$DB = “sql_{$CONF[‘sql’]}”;
$DB = new $DB;
$DB->connect($CONF[‘sql_host’], $CONF[‘sql_username’], $CONF[‘sql_password’], $CONF[‘sql_database’]);

$string = mt_rand();
$string = substr(sha1($string), 0, $chars);
$string = str_replace(array(‘0’, ‘O’, ‘o’, ‘9’, ‘g’, ‘G’, ‘b’, ‘B’, ‘6’), rand(1, 5), $string);

$TTF_RANGE = array();
$dir = opendir($TTF_folder);
while (false !== ($file = readdir($dir))) {
if (is_file($TTF_folder.$file)) {
array_push($TTF_RANGE, $file);
}
}

// check TrueTypeFonts
if($debug) echo “\n
-Captcha-Debug: Check given TrueType-Array! (”.count($TTF_RANGE).")";
$temp = array();
foreach($TTF_RANGE as $key => $value) {
if (is_readable($TTF_folder.$value)) {
$temp[] = $value;
}
}
$TTF_RANGE = $temp;
if($debug) echo “\n
-Captcha-Debug: Valid TrueType-files: (”.count($TTF_RANGE).")";
if(count($TTF_RANGE) < 1) die(‘No Truetypefont available for the CaptchaClass.’);

// select first TrueTypeFont
$TTF_file = change_TTF();
if($debug) echo “\n
-Captcha-Debug: Set current TrueType-File: (”.$TTF_file.")";

// get number of noise-chars for background if is enabled
$nb_noise = $noise ? ($chars * $noisefactor) : 0;
if($debug) echo “\n
-Captcha-Debug: Set number of noise characters to: (”.$nb_noise.")";

// set dimension of image
$lx = ($chars + 1) * (int)(($maxsize + $minsize) / 1.5);
$ly = (int)(2.4 * $maxsize);
if($debug) echo “\n
-Captcha-Debug: Set image dimension to: (”.$lx." x “.$ly.”)";
$image = imagecreatetruecolor($lx, $ly);

// Set Backgroundcolor
list($r, $g, $b) = random_color(224, 256);
$back = imagecolorallocate($image, $r, $g, $b);
imagefilledrectangle($image, 0, 0, $lx, $ly, $back);
if($debug) echo “\n
-Captcha-Debug: We allocate one color for Background: (”.$r."-".$g."-".$b.")";

// fill with noise or grid
if($nb_noise > 0) {
// random characters in background with random position, angle, color
if($debug) echo “\n
-Captcha-Debug: Fill background with noise: (”.$nb_noise.")";
for($i=0; $i < $nb_noise; $i++) {
$size = intval(rand((int)($minsize / 2.3), (int)($maxsize / 1.7))); $angle = intval(rand(0, 360));
$x = intval(rand(0, $lx));
$y = intval(rand(0, (int)($ly - ($size / 5))));
list($r, $g, $b) = random_color(160, 224);
$color = imagecolorallocate($image, $r, $g, $b);
$text = chr(intval(rand(45,250)));
imagettftext($image, $size, $angle, $x, $y, $color, change_TTF(), $text);
}
}
else {
// generate grid
if($debug) echo “\n
-Captcha-Debug: Fill background with x-gridlines: (”.(int)($lx / (int)($minsize / 1.5)).")";
for($i=0; $i < $lx; $i += (int)($minsize / 1.5)) {
list($r, $g, $b) = random_color(160, 224);
$color = imagecolorallocate($image, $r, $g, $b);
imageline($image, $i, 0, $i, $ly, $color);
}
if($debug) echo “\n
-Captcha-Debug: Fill background with y-gridlines: (”.(int)($ly / (int)(($minsize / 1.8))).")";
for($i=0 ; $i < $ly; $i += (int)($minsize / 1.8)) {
list($r, $g, $b) = random_color(160, 224);
$color = imagecolorallocate($image, $r, $g, $b);
imageline($image, 0, $i, $lx, $i, $color);
}
}

// generate Text
if($debug) echo “\n
-Captcha-Debug: Fill forground with chars and shadows: (”.$chars.")";
for($i=0, $x = intval(rand($minsize,$maxsize)); $i < $chars; $i++) {
$text = $string{$i};
$angle = intval(rand(($maxrotation * -1), $maxrotation));
$size = intval(rand($minsize, $maxsize));
$y = intval(rand((int)($size * 1.5), (int)($ly - ($size / 7))));
list($r, $g, $b) = random_color(0, 127);
$color = imagecolorallocate($image, $r, $g, $b);
list($r, $g, $b) = random_color(0, 127);
$shadow = imagecolorallocate($image, $r + 127, $g + 127, $b + 127);
$TTF_file = change_TTF();
imagettftext($image, $size, $angle, $x + (int)($size / 15), $y, $shadow, $TTF_file, $text);
imagettftext($image, $size, $angle, $x, $y - (int)($size / 15), $color, $TTF_file, $text);
$x += (int)($size + ($minsize / 5));
}

$ip = $DB->escape($_SERVER[‘REMOTE_ADDR’], 1);

$DB->query(“DELETE FROM {$CONF[‘sql_prefix’]}_sessions WHERE data LIKE ‘{$ip}|%’”, FILE, LINE);
$data = “{$ip}|” . sha1(’)F*RJ@FHR^%X’.$string.’(*Ht3h7f9&^F’.$ip);

require_once("{$CONF[‘path’]}/sources/misc/session.php");
$session = new session;
$session->create(‘captcha’, $data);

header(‘Pragma: no-cache’);
header(‘Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0’);
header(‘Content-type: image/jpeg’);
imagejpeg($image);
imagedestroy($image);

// Select a new random font
function change_TTF() {
global $TTF_RANGE, $TTF_folder;
$key = array_rand($TTF_RANGE);
$TTF_file = $TTF_folder.$TTF_RANGE[$key];

return $TTF_file;
}

// Select a random color within a range
function random_color($min, $max) {
$r = intval(mt_rand($min, $max));
$g = intval(mt_rand($min, $max));
$b = intval(mt_rand($min, $max));

return array($r, $g, $b);
}
?>
[/code]

Ich hoffe ihr könnt mir helfen :slight_smile: .

,DoKi

hmm komisch bei joomla geht captcha siehe meine homepage l4a.6x.to o.O

sieht so aus als würde er die funktion change_TTF() bemängeln…

auch wenn ich nix falsches in der funktion bemerke O.o

[code]function change_TTF() {
global $TTF_RANGE, $TTF_folder;
$key = array_rand($TTF_RANGE);
$TTF_file = $TTF_folder.$TTF_RANGE[$key];

return $TTF_file;
}[/code]

oder es ist iwas generell in der zeile falsch… aber was ist dann bitte any2eucjp() ?

EDIT: google.de/search?q=any2eucjp( ahh 2 links zu bug meldungen in php die diese funktion und ImageTTFBBox betreffen…

Ich verstehs nicht :neutral_face: . Ich kenn mich mit PHP nicht aus, kann mir denn keiner helfen?

Hallo ich habe auch ein problem mit Captchas…

Bei mir wird kein Bild angeziegt…ich weiß nur das es an dem code:

[code]<?php
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’);
$img = ImageCreateFromPNG(‘captcha.PNG’); //Backgroundimage
$color = ImageColorAllocate($img, 0, 0, 0); //Farbe
$ttf = $_SERVER[‘DOCUMENT_ROOT’]."/captcha/XFILES.TTF"; //Schriftart
$ttfsize = 25; //Schriftgrösse
$angle = rand(0,5);
$t_x = rand(5,30);
$t_y = 35;
imagettftext($img, $ttfsize, $angle, $t_x, $t_y, $color, $ttf, $text);
imagepng($img);
imagedestroy($img);
?> [/code]

So habe dann mal die php datei aufgerufen nur so…

da kommt so eine fehlermeldung:

Warning: imagettftext() [function.imagettftext]: Invalid font filename in /users/burnoutastra/www/gbook/captcha/captcha.php on line 32 ‰PNG IHDRŒ(£/…‘ ¥IDATxœµšQ¶ã8Cµtîœýá¼€äTj¦Û§Î›$¶% @ÚÓ«ºWWw?žÕ]ý9ôau­µt±nìîµVãkc)}Õ•Õý¬S8¥¿ç-oŸuqÝ®ùD«gc©óÆ3ªóÞŒöëF玫kU¯ê'þu»I®r ”/ÝeÜØ²œ¿·ÍÊ¿¶îÁñK`ôFäõë€v\a|8.àReÜe²·8ŸËJkîp onV‚-Þ9‹Þ ->0¾I£ ˹>Ÿ#g±`1™çÞ(Ž@­›·_,‹²`âúÉŽ‘¾bâɈn´ÊÀ,ª†—¼bNÀÖN ÆU°/–¡%¹Ñ´¯5isÖº:aÍâèFÖ™Z V¶] …íxZÍÁ0Tá8Èa…¿!&‘1¢f†‘ÁUæ2 6% ¿Äj×cð3èÁ%KÁ‚9f r§CíVûîû®rôXè oNÝìýC3¯~CÀTEÛk ý«³ÇþÈ:»f=ÈA˜eI7eŠd¾ÚúBƒ6Ú ›¥CÓfX%¨9ãHŠ­)n§‡lãÄŠ‰àή$”˜¸7#˜Ï»®e%>P=fP§)·ñ*¬µ~»ì`è]¦9]EˆÝoÕl ø$&ÛðOztAu'™TÀ+IÌ奁E|&…UÃMÖ©XÄ×3ÃÊO.×"Š$Ì0îíøŽìxËÖ ?(6‰†øh© =×›ÆEf—ŠàecƒãŠQ‚ y;U“L†Î¶Qzk—hZD¤dÄ«€öâ,¦%4ÌîCâ.— ¾ý0»ƒmîHü=„þÙNþ„U¿pÆX£_c…ÖšÝ5^~¢4¢è.T•e("QÞlk¬÷VáL³ÚÂÅu6¤aNÍždf¥h\¶SJBP(¼O*4\ò19õ‘}àÃ)«»µ¦¤Žºƒõ§fUOþ6e•Í&‹f¯F¹èz‰i;Psn/öâoeóv[ê+]üÆàR4^ãr§±©÷á-K~m1î]ù—-þBy¡§»>nÆv‘¯ôª@Œž’Ô}»uM;Iª”/Æ81Ñ‚|¤æ"íeþ>Ò>êàÄËÄ·Q5”XÑtZ³»i8œôˆÂ)İô]¡Ô“P *(i4’AaS–Ù‚¦ìúgm!ZAè©ø#ø3ÈÎá­«¯øð)| ÍÍ_²âè}Og÷츣Å)Uiuns*fA4 ºTzk·¥=_‰š(|¯w¹Í8 oÄÃ2‰è'ƒËIº]0úÖgސÍ,ªæ5³Œùa 0•´0ÚYì©/x2‰D¥£9{äéÂn<™úBðb2‡z ;X"iŽØ¶ÿy©ùœ–z­Öµ¯wS“ˆÅ©=ÁÞ²’M˸Α´¦–)©b’ôÍšN‡ùn Ê¿¢-9ÜÕSa‰{þ ±_&F÷ÿÚt9F]–Úžß2ái»-åìUCÀہ9}&h’¶£¨e¸e=|N‚-ë' ×Ãh;ÄÁO-Ÿ=ŒKíQ¾WëT,¨Eª-˜ô·Íߨêyã0?ý~Ä[M&·Î|ZŸR=9[àF@s‹¨ÓûA• ÓÌ:¨ªÆ^Í\°ÏÞ[škšõ7(ølÜð…±©Ù9G¿±öÒ{Ìd0½LgÿW1ÂÖ·Á:ŽÖ´Ò³†^s<è1>°fÇô1V4’Òð—¬kSYü—e oV~ƒ‡Ÿ°vM•×EfJ"Ù×bxùUë™ãÝÕëb^^à˜š»sÃt4,˜z0DÛ·Míãie¶"δ%ŒbMuÊ¥bmyÄª$”zU›ïž†ŒMFaHÇk‘Žu@^w…ørLäßQg™¬ÅÕ§-Øb†4h—µ–C,“ù,ªeã9ævØ À>¾mFï–ðFÛ)©é^‘Àól'ñ¶1:1§Qddh›RªˆnÔÅïV雯ï¦?Ö;®¸ ïåÐâ}ðJ+ŽßYUì.´ƒtßeaý #ž•ʼŽÿå"¨¾”¤ãEó)¾½ŸÙˇ´>ŸbSI/-ðR×e þÑ«õ·à£×Úì€A€.e}«Àú«ÉûŠš^]xùpef;¬§³÷¥Ø½É‡ è„õâfèdu“Ž3Pâ•.öp¸V6”²Ñ< €5½¿þXJy4êº_(1ËŠWP:ê/hÓõ¼1Û6mÇm¥?f6sø¿Ñ¹¦»Ï-ûÒ¥çßeïàåB>¼~ü ÿáðÝíèɨ^`½&£…Ù—ÿwßÙ_õàŒ‡ño[¼Y£,Ì'£C_é¡Õn'µUÙWÔh©{(˜+¥YN†ÿ⡬˜$fœ¿\ö-œ¸ÖõóïãÏen°÷¥dŒe8/aM¶.kE˜†6(š¾'Ÿý¯4ºK¯÷N±ûË7 ‹ùª@¿TFž"heg¹ñ\ú,"Ö屋‚µnVͳ#Œ“’í= ±²{ý»Çï ²­"Áî1’!ì÷PýiGòúœ$DÔÖ-Ñ6CE#ñi9z ìˆÉdLØHg –«¬,„²¿‰ø+¯û¿Ž#Ù©<>ÈÿH˜—ûn@wš[‘ÎÙ§ãA¹ª¯ ‘MKÂâáµ}µ´ó¡9?È‘”ü~úîÿ˜B³utqÿ´žXžbúìñ\7uq45çÆ EÇ3«=÷ƒ« Ð>f oÆAyý"ÝrA§L¬ŸÕd¼ë¿k¿OUßv`ÕxN5¬!–‰b“ŽLÜÔ†8ÌånñSøîZ{£ wÄêÿ:8æFÕÃ¥ÅÐ%Au_ØÑ¿Èà•¶Uý{ÚÈ%$ DÊIEND®B`‚

sorry ich fange grade erst mit php an…achja habe das von stoppt-den-spam.de!!!

Ich hoffe ihr könnt mir helfen! :wink: :slight_smile:

Die Schriftart hast du auch kopiert? Groß-/Kleinschreibung beachtet?

P.S.: Die URL der Quelle ist falsch. stoppt-den-spam.info wäre richtig.

[quote=“burnoutastra”]Hallo ich habe auch ein problem mit Captchas…

Bei mir wird kein Bild angeziegt…ich weiß nur das es an dem code:

So habe dann mal die php datei aufgerufen nur so…

da kommt so eine fehlermeldung:

sorry ich fange grade erst mit php an…achja habe das von stoppt-den-spam.de!!!

Ich hoffe ihr könnt mir helfen! :wink: :slight_smile:[/quote]
Die Schriftart wurde nicht gefunden, einfach eine Schriftart hochladen (TTF), und hier den Dateinamen eintragen:

also:

vG :wink:

Klappt immer noch nicht…kommt die selbe fehlermeldung! :neutral_face:

Eine sehr einfache Captcha-klasse mit vielen Features: Captcha-klasse!

Hier, ist ein bisschen überarbeitet und getestet:

[code]<?php
session_start();
unset($_SESSION[‘captcha_spam’]);

#TTF File
$_TTF = "AnkeCalligraph.ttf";
#Hintergrundbild
$_PNG = "captcha.PNG";

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);

$_SESSION[‘captcha_spam’] = $text;

header(‘Content-type: image/png’);
$img = imagecreatefrompng($_PNG);
$color = imagecolorallocate($img, 0, 0, 0);

imagettftext($img, 25, rand(0,5), rand(5,30), 35, $color, $_TTF, $text);
imagepng($img);
imagedestroy($img);
?> [/code]
Oben in der $_TTF variable, musste noch die Schrift eintragen und den genauen Pfad genau so wie in der $_PNG variable das Hintergrundbild eingetragen werden muss.
Es muss ein .PNG Format sein!

Du bist klasse!!!

Dankeschön es hat geklappt! :hail: :hail: :hail: :slight_smile:

Hab ebenfalls ein Problem mit meinen captchas =/ nur leider ist das ein fertiges script und ich kann somit nur schlecht bis garnicht (zweites triffts wohl eher) ein anderes captcha einbaun… noch dazu das das bei weitem meine php fähigkeiten übertrifft

[code]<?php

ob_start();
session_start();
require(“includes/config.inc.php”);

class CaptchaSecurityImages {

function generateCode($characters) {
/* list all possible characters, similar looking characters and vowels have been removed */
$possible = ‘345789cfkmnpstwxyz’;
$code = ‘’;
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}
return $code;
}

function CaptchaSecurityImages($width='120',$height='40',$characters='6',$font) {
    global $font,$font_fallback;
    $code = $this->generateCode($characters);

    /* font size will be 75% of the image height */
    $font_size = $height * 0.75;
    $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
    /* set the colours */
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 100, 120, 180);
    /* generate random dots in background */
	/*
    for( $i=0; $i<($width*$height)/12; $i++ ) {
        imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
    }
	*/
    /* generate random lines in background */
    for( $i=0; $i<($width*$height)/150; $i++ ) {
        imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
    }
    $x = 4;
    $y = 5;

    if(function_exists('imagettfbbox') == true)
    {
        imagettfbbox($font_size, 0, $font, $code);
        $textbox = imagettfbbox($font_size, 0, $font, $code);
        $x = ($width - $textbox[4])/2;
        $y = ($height - $textbox[5])/2;
        imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $code);
    } 
    else 
    {
        imagestring($image, $font_fallback, $x, $y, $code, $text_color);
    }
    
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
    $_SESSION['security_code'] = $code;
}

}

$width = 90;
$height = 30;
$characters = 6;

$font = $APP_CONFIG[‘base_path’].’/resources/fonts/monofont.ttf’;
$font_fallback = imageloadfont($APP_CONFIG[‘base_path’].’/resources/fonts/captchafont.gdf’);

$captcha = new CaptchaSecurityImages($width,$height,$characters,$font);

?>[/code]

monofont.ttf sowie captchafont.gdf sind vorhanden und im korrekten pfad

Irgend jemand ne idee? hab auch schon im board der entwickler des scriptes nachgefragt, bhis jetzt zwar keine antwort aber ich dachte mri frag ich einfach auch mal hier :smiley:

[offtopic]

zdnet.de/security/news/0,390 … 9,00.htm?h

[/offtopic]