Captcha Class.

Gestart doorErik46 reacties196 weergaven

47 berichten · pagina 1 van 4

Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,
Ik heb een captcha class, alleen hij errort:

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 57

Warning: imageline(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 50

Warning: Cannot modify header information - headers already sent by (output started at /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php:57) in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 69

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 31

Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 63

Warning: imagestring(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 71

Warning: imagepng(): supplied argument is not a valid Image resource in /home/menatwar/domains/menatwar.one2xs.com/public_html/cls/captcha.cls.php on line 73


En het script is:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
 * @Author: Erik
 * @Version 1.0
 * @Copy 2009
 * @Package Captcha Class
*/[/COLOR]
[URL="http://www.php.net/class"]class[/URL] captcha
[COLOR= #007700]{[/COLOR]
    [COLOR= #FF8000]/*
     * @Var int
     * @Access public
    */[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #0000BB]$font[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #FF8000]// De constructor[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De captcha maken[/COLOR]
        [COLOR= #0000BB]$cap[/COLOR] [COLOR= #007700]=[/COLOR] imagecreate[COLOR= #007700]([/COLOR][COLOR= #0000BB]200[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [COLOR= #FF8000]// De achtergrond kleur functie[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] createbg[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De achtergrond kleur maken[/COLOR]
        [COLOR= #0000BB]$bg[/COLOR] [COLOR= #007700]=[/COLOR] imagecolorallocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]255[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]255[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]255[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [COLOR= #FF8000]// De code generator[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] code[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De letters en cijfers in een variabel zetten[/COLOR]
        [COLOR= #0000BB]$chars[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array_merge"]array_merge[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]a[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]z[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]A[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Z[/COLOR][COLOR= #007700]) &&[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]9[/COLOR][COLOR= #007700]));[/COLOR]
        [COLOR= #FF8000]// De letters en cijfers weergeven[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$chars[/COLOR][COLOR= #007700];
    }[/COLOR]
    [COLOR= #FF8000]// De lijnen functie[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] line[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// Een for[/COLOR]
        [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]<[/COLOR][COLOR= #0000BB]10[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++)
        {[/COLOR]
            [COLOR= #FF8000]// X Start[/COLOR]
            [COLOR= #0000BB]$xs[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]200[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #FF8000]// X Eind[/COLOR]
            [COLOR= #0000BB]$xe[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]200[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #FF8000]// Y Start[/COLOR]
            [COLOR= #0000BB]$ys[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #FF8000]// Y Eind[/COLOR]
            [COLOR= #0000BB]$ye[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700]);[/COLOR]
            [COLOR= #FF8000]// De lijnen tekenen[/COLOR]
            imageline[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$xs[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$ys[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$xe[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$ye[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]colorl[COLOR= #007700]());
        }
    }[/COLOR]
    [COLOR= #FF8000]// De lijn kleur[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] colorl[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De lijn een kleur geven[/COLOR]
        [COLOR= #0000BB]$colorl[/COLOR] [COLOR= #007700]=[/COLOR] imagecolorallocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [COLOR= #FF8000]// De tekst kleur[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] colort[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De tekst een kleur geven[/COLOR]
        [COLOR= #0000BB]$colort[/COLOR] [COLOR= #007700]=[/COLOR] imagecolorallocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [COLOR= #FF8000]// De weergeef functie[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] view[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De headers[/COLOR]
        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Content-Type: image/png[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #FF8000]// De tekst erop zetten[/COLOR]
        imagestring[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]code[COLOR= #007700](),[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]colort[COLOR= #007700]());[/COLOR]
        [COLOR= #FF8000]// De weergever[/COLOR]
        imagepng[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700]);
    }[/COLOR]
    [COLOR= #FF8000]// De vernietiger[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] __destroy[COLOR= #007700]()
    {[/COLOR]
        [COLOR= #FF8000]// De captcha vernietingen[/COLOR]
        imagedestroy[COLOR= #007700]([/COLOR][COLOR= #0000BB]$cap[/COLOR][COLOR= #007700]);
    }
}[/COLOR]
?>
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$cap op regel 25 bestaat niet
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat moet t dan worden?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$this->cap
Ook op regel 50 e.v.

Edit:
En hem definieren net als je op regel 14 doet.

Edit2:
En die $cap op regel 19 vervangen door $this->cap emo
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oke

verander op regel 14 $font; naar $font, $cap;
verander op regel 19: $cap naar $this->cap
verander op regel 25: $cap naar $this->cap
verander op regel 50: $cap naar $this->cap
verander op regel 57: $cap naar $this->cap
verander op regel 63: $cap naar $this->cap
verander op regel 71: $cap naar $this->cap
verander op regel 73: $cap naar $this->cap
verander op regel 79: $cap naar $this->cap
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu krijg ik dit:

Warning: array_merge() [function.array-merge]: Argument #1 is not an array in leuk. on line 36
PNG  IHDR:o!PLTEmHIDAT8c``Q0 FpJ IENDB`
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$chars = array_merge(range(a, z) && range(A, Z) && range(0, 9));
vervangen door
$chars = array_merge(range(a, z), range(A, Z), range(0, 9));
t Zijn gewoon verschillende parameters, dus een komma drtussen.
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
op regel 31 de &&s vervangen met ,
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu werkt hij, maar alles word zwart.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Erik schreef:
Nu werkt hij, maar alles word zwart.
waar staat hij online?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
$this->colorl() geeft geen kleur, dat klopt sowieso niet.

Onthoud wel dat de eerste imagecolorallocate() de achtergrondkleur wordt, dus als je $this->colorl() als eerste aanroept dan wordt de achtergrondkleur zwart.
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Aha. En hoe maak je em dan wit? emo
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
door createbg() aan te roepen in je __construct()
0
Erik

Lid · Topicstarter

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nu is ie wit, en me tekstkleur denk ik ook.. emo
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja, als je colorl() zo aanpast dat hij die waarde van imagecolorallocate() returnt dan moet het werken denk ik.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren