captcha script

Gestart doorDaiman36 reacties96 weergaven

37 berichten · pagina 2 van 3

Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hoi,

Sorry voor het omhoog halen van dit topic.
Maar vond het ook weer zo raar om hier een nieuw topic voor te maken terwijl ik er nog 1 had.

Ik heb hem nu wat veranderd.

Hij is nu in een class gebouwd.
En je kunt het aantal lijnen en tekens wijzigen.

captcha.class.php

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/class"]class[/URL] captcha [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [URL="http://www.php.net/static"]static[/URL] [COLOR= #007700]function[/COLOR] make[COLOR= #007700]([/COLOR][COLOR= #0000BB]$lijnen[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aantal[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"content-type: image/png"[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$font[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]arial.ttf[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$me[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$tekst[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
        [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$aantal[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
            [COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700][] =[/COLOR] [URL="http://www.php.net/substr"]substr[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/microtime"]microtime[/URL][COLOR= #007700]()),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);
        }[/COLOR]
        [COLOR= #0000BB]$breedte[/COLOR] [COLOR= #007700]= (([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700])*[/COLOR][COLOR= #0000BB]15[/COLOR][COLOR= #007700])+[/COLOR][COLOR= #0000BB]5[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$image[/COLOR] [COLOR= #007700]=[/COLOR] ImageCreate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$breedte[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]30[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$achtergrond[/COLOR] [COLOR= #007700]=[/COLOR] ImageColorAllocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/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]
        [URL="http://www.php.net/foreach"]foreach[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tekst[/COLOR] [COLOR= #007700]AS[/COLOR] [COLOR= #0000BB]$tekens[/COLOR][COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$me[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$tekens[/COLOR][COLOR= #007700];
        }[/COLOR]
        [COLOR= #0000BB]$te[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$me[/COLOR][COLOR= #007700]);[/COLOR]
        [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$te[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$c[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]5[/COLOR][COLOR= #007700];[/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][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700])-[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
                ImageTTFText[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]12[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]15[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]10[/COLOR][COLOR= #007700]),[/COLOR] [COLOR= #0000BB]$c[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]25[/COLOR][COLOR= #007700],[/COLOR] ImageColorAllocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700])),[/COLOR] [COLOR= #0000BB]$font[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$tekst[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]]);[/COLOR]
            [COLOR= #0000BB]$c[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$c[/COLOR][COLOR= #007700]+[/COLOR][COLOR= #0000BB]15[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$i[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]$lijnen[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$i[/COLOR][COLOR= #007700]++) {[/COLOR]
        ImageLine[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]80[/COLOR][COLOR= #007700]),[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]360[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]360[/COLOR][COLOR= #007700]),[/COLOR] ImageColorAllocate[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700]),[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]255[/COLOR][COLOR= #007700])));
        }[/COLOR]
        ImagePng[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700]);[/COLOR]
        ImageDestroy[COLOR= #007700]([/COLOR][COLOR= #0000BB]$image[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]];
        }[/COLOR]
    [URL="http://www.php.net/public"]public[/URL] [URL="http://www.php.net/static"]static[/URL] [COLOR= #007700]function[/COLOR] check[COLOR= #007700]([/COLOR][COLOR= #0000BB]$input[/COLOR][COLOR= #007700]) {[/COLOR]
         [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]] ==[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$input[/COLOR][COLOR= #007700])) {[/COLOR]
            [URL="http://www.php.net/unset"]unset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]]);[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
         }[/COLOR]
         [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
         }
    }
}[/COLOR]
?>


Check bestand:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]captcha.class.php[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"make"[/COLOR][COLOR= #007700]])) {[/COLOR]
    captcha[COLOR= #007700]::[/COLOR]make[COLOR= #007700]([/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]])) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR]captcha[COLOR= #007700]::[/COLOR]check[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"captcha"[/COLOR][COLOR= #007700]])){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"De captcha is goed ingevuld"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"De captcha is niet goed ingevuld"[/COLOR][COLOR= #007700];
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>
<form name="form1" method="post" action="">
captcha : <a href="#" onclick="javascript:location.reload(true)"><img src="?make=1" border="0"></a><br>
<input name="captcha" type="text" id="captcha"><br>
<input type="submit" name="Submit" value="test!">
</form>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR] ?>


Om de image te maken gebruik je captcha::make(aantal lijnen, aantal tekens)
om te checken gebruik je captcha::check(plaincaptcha)
0
Berichten
5.498
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Demo?
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Mooi script hoor k ga hem zeker gebruiken!
0
Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik ben nu begonnen met een nieuwe functie dat je de captcha ook gesproken hebt

Klein voorproefje: http://daimanmeijers.nl/captcha/
Misschien kunnen jullie het even testen.
Hij werkt nu met een java applet.
Maar ik ga kijken om de letters te laten parsen en afspelen met een flash applicatie
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Het werkt niet geweldig heb ik het idee. Het loopt hier in ieder geval steeds vast.
0
Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Het werkt niet geweldig heb ik het idee. Het loopt hier in ieder geval steeds vast.
Ja,
Komt denk ik doordat ik 5 applets dan laat gebruiken voor iedere letter dus 1.
Ik ga even kijken om een wave parser te maken
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Doe gewoon geen applets maar neem google vertalen gewoon op voor elke letter/cijfer en laat dan .mp3tjes of .wavjes afspelen.
0
Berichten
181
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
kan je het voor me in in zip bestandje zetten plzz
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nice gemaakt
0
Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zo ik heb een verandering ingebouwd.
Hij werkt nu met flash en hij parsed de letters aan elkaar ook kan het mp3 bestand gedownload worden.
Zouden jullie even kunnen testen of het werkt
0
Berichten
2.517
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nice daiman, het werkt.
0
Fass

Lid

Berichten
3.771
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Eerst werkte het nog. Nu krijg ik gewoon een blokje met een rood kruisje erin als ik het geluid wil afspelen.
0
Daiman

Lid · Topicstarter

Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Fassdfds schreef:
Eerst werkte het nog. Nu krijg ik gewoon een blokje met een rood kruisje erin als ik het geluid wil afspelen.
Heb je een link waar het staat?
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