Feed on Posts or Comments

Personal Daantje on 11 Oct 2006 10:40 pm

submitThroughImage

A small but usefull spam/flood form submit protection that uses CAPTCHA. This class can produce a image with a random string and a form input. When the form is submitted, the string from the form input can be matched against generated string in the image. When they match, the submition can proceed. The random generated image string will be matched against a session var or against a file on the server disk, depanding on the backend you’ve choosed. Default backend is the session backend.

VERSION 0.2:

  • Did a small security bugfix with the session backend.
  • Added a new example with seperate CAPTCHA input check.
  • The new example 4 is better for newbe’s to implement.

FEATURES:

Here are the features of the current version 0.2:

  • One or more random colors.
  • One or more random TTF fonts.
  • Random rotation.
  • Custom background color or image.
  • Transparent background with anti-alias of string.
  • Hardcoded or variable (liquid) dimentions of the image.
  • Colors can be filled as HEX or as RGB values.
  • String/code type can be only numbers, only letters or both.
  • Backend by session or server disk space.

For a first version it can do a lot, at least I do think so! ;)

LICENSE:

GPL (http://www.gnu.org/licenses/gpl.txt)

SUPPORT:

Please report any bugs to me at daantje dot nl

DONATE:

Please support this project by paypal donations, (my email is my paypal address)

Help me develop this and other projects. Donate to the good cause.
donation button

DOWNLOAD:

Download and untar the file (tar -zxvf submitTroughImage.tgz), upload it and point your browser to one of the examples. Windows users can use WinRAR to decompress the file.

EXAMPLE

More examples are included in the package.

captcha
code:
(can’t read code?)

28 Responses to “submitThroughImage”

  1. on 19 Feb 2007 at 1:34 pm 1.Jurriaan said …

    Hoi, ik heb em draaiende. http://trimsalonpluto.nl/het_gastenboek/?functie=formulier

    is het toch nog gelukt ondanks mijn beperkte kennis van php. Hij geeft overigens niet aan of de code goed of fout is maar hij doet het gewoon wel of niet zonder melding. opzich wel vervelend maar dat soort dingen kan ik toch niet veranderen. Ben in ieder geval van de spam af.

    Bedankt :)

  2. on 20 Feb 2007 at 12:49 am 2.Lex said …

    Thank you, they mached!????

  3. on 20 Feb 2007 at 12:57 am 3.Daantje said …

    Bad English, I know ;) Will change it in the next update ;)

  4. on 22 Feb 2007 at 5:18 pm 4.pondokiklan.com said …

    Waw ….. Thank you for the scripts….

    Best Regard’s
    www.pondokiklan.com

  5. on 22 Feb 2007 at 6:15 pm 5.Daantje said …

    Oh no! You’ve got the vista wow feeling! Go to your doctor!

  6. on 27 Feb 2007 at 11:34 pm 6.Lody said …

    Zeer bruikbaar script, heb er al een guestbooks en mailform spam-vrij mee kunnen maken… thanx!

    Klopt het alleen dat je de $sti->parseStringInput(); niet in een user-defined function kan aanroepen? (ook al wordt ie pas defined nadat je de class al hebt ge-include) Of ben ik nog iets te php-n00b? ;)

    Anyway, thanx en groet’n uut Hengelooo.

  7. on 27 Feb 2007 at 11:50 pm 7.Daantje said …

    Kan je een voorbeeld geven? En heb je in je functie dan wel $sti global gemaakt?

    function foobar(){
    global $sti;
    $sti->parseStringInput();
    }

    en dan aanroepen met…
    foobar();

    Of het doorgeven van het object via een variable:

    function foobar($sti){
    $sti->parseStringInput();
    }

    en dan aanroepen met…
    foobar($sti);

  8. on 28 Feb 2007 at 12:02 am 8.Lody said …

    global $sti; in de function setten >>>

    Ik wist dat ik iets over het hoofd had gezien! Stom stom stom… That did the trick, my friend :) Alles werkt nu inderdaad zoals het moet.

    Wederom hartstikke bedankt!

  9. on 01 Mar 2007 at 6:12 pm 9.Lorenzo said …

    Everything looks great, however I havent managed to make your code work when being processed within included files.

    Setting the paths works fine, but when it comes to show the image, although the path is right the image is never shown. Any way around this?

  10. on 01 Mar 2007 at 7:56 pm 10.Daantje said …

    What gives the image when you point your browser to the image path directly? Is the class giving any errors with the error function?

  11. on 01 Mar 2007 at 10:27 pm 11.Lorenzo said …

    All the errors have been sorted out. No errors!

    What happens is that it only shows the cached image all the time, refresh doesn’t update the image. By doing it with the backend_dir as well, doesn’t solve the problem.

    The image is like that with or without the key it doesnt update. All the includes are correct but the session doesn’t seem to update :(

  12. on 01 Mar 2007 at 10:34 pm 12.Daantje said …

    And when you empty your cache you see a new one? If not, may be your server has an caching accelerator installed on it?

    Try to call the image with a time stamp behind the url. Like: foobar/image.php?< ?php echo time();? ?>

  13. on 01 Mar 2007 at 11:31 pm 13.Lorenzo said …

    yeah that’s probably the problem since i have e-accelerator installed. Also as I was trying to mess around with the sessions there, it seemed to have caused a problem, where now, none of the pages load.

    In short, really advanced php pages, wont load, a simple echo or print_r works fine. Online, it said something about the accelerator cache. Any idea how this could be solved?

    Basically everything inside that folder(that has .htaccess) doesnt load, let’s just say cached pages. If you have any idea how this could be fixed, I would really appreciate it!

    Thank! ;)

  14. on 02 Mar 2007 at 10:18 am 14.Daantje said …

    No, if the problem is not my script, but your server configuration, I can’t help you… Sorry.

    Check if the accelerator app has some issues on there support forum…

  15. on 20 Mar 2007 at 11:14 am 15.Sven said …

    This is a great tool, thanks a lot.

    If you would make it better and easier, my suggestions are:

    1. The script should hold (buffer) all submitted data while checking if entered code is identical to captcha

    2. If the code is correct, all data should be sent to original “receiver”

    or

    3. If errors, the script should offer user to enter a new code from a new captcha (this way the user does not lose all submitted data, like they do when they go back)

    I dont know if this could be done with the same procedure as now, if not a “middle station” (seperate script page) could be used

    Also, it is a shame that when generating a new captchapicture, the entered data is lost :(

    Well, thanks again for a nice script!

    PS: I am starting to learn php and are still not able to do these things myself.

  16. on 20 Mar 2007 at 11:57 am 16.Daantje said …

    That part you’ll have to program your self ;) The class handles only the captcha part… The rest of the functionality is your own concern.

    But I’m a programmer, so if you want to hire me? ;)

  17. on 27 Mar 2007 at 5:54 am 17.Dave said …

    This is exactly what I need…I am a newby, so please excuse a stupid question: I don\’t understand how this
    piece of code works:

    code: parseStringInput();?>

    There is no and no , so how does the input value get inserted into the $sti variable?

    I am using the example1.php with PHP5…everything works fine except that the variable is not getting posted…Thanks for any help you can give me!

  18. on 27 Mar 2007 at 6:00 am 18.Dave said …

    This is exactly what I need…I am a newby, so please excuse a stupid question: I dont understand how this
    can work…

    There is input type=text or name=inputname , so how does the string get inserted into the $sti variable and posted with the form?

    I am using example1.php with PHP5…everything works fine except that the variable is not getting posted…Thanks for any help you can give me!

  19. on 27 Mar 2007 at 6:08 am 19.Dave said …

    Forgot to mention that you can see the result of using the example1.php script on my site here:

    http://www.pelletbase.com/example1.php

    I am struggling with the fact there is no input type=text or name=inputname

    Thanks!

  20. on 27 Mar 2007 at 9:20 am 20.Daantje said …

    You don’t understand objects… $sti is not a variable, but an object… Please check the PHP manual for more info about objects and classes. http://www.php.net/class

  21. on 27 Mar 2007 at 9:24 am 21.Daantje said …

    And if the GET vars are not loaded, you don’t have REGISTER_GLOBALS=On in your php.ini or virtual host settings. I should check/fix that in my code, so the class is not depending on that setting…

  22. on 30 Apr 2007 at 1:03 pm 22.stiUser said …

    On the current page, the EXAMPLE captcha is never shown until we click (can’t read the code?).

    What do we have to change in the code to have the image initially loaded?

  23. on 01 May 2007 at 9:09 am 23.Daantje said …

    I don’t know what the bug is, but it appears only in XHTML strict documents. Have to look in to it.

  24. on 02 May 2007 at 11:59 pm 24.tom said …

    hello, I\’m only beginer on php.. and there are no extension of the file in package, so I don\’t know how to open it, tryed with notepad++, but there are many unrecognizable symbols, so could you write example 3 apart from others, or email me?

    respectfully tom

  25. on 03 May 2007 at 9:40 am 25.Daantje said …

    One file? (you are a windows user I think…) You’ve uncompressed the file the wrong way or with the wrong software. Use winRAR to uncompress the file. The .tgz file has a .tar and the tar (tape archive) you have to uncompress again with winRAR.

    Or use a normal OS and do on the commandline:
    tar -zxvf submitTroughImage.tgz
    Or just dubble click the file in your favorite window manager…

  26. on 06 May 2007 at 2:53 pm 26.tom said …

    thanks, I’v extracted these files but I receive such an errors (I use EasyPHP):

    Notice: Undefined variable: str in \submitTroughImage.class.php on line 293

    Notice: Undefined variable: rotate in \submitTroughImage.class.php on line 394

    Fatal error: Call to undefined function: imagettfbbox() in \submitTroughImage.class.php on line 405

  27. on 07 May 2007 at 12:14 am 27.Daantje said …

    The notices are not relevant at this time, the fatal error on imagettfbbox is… It looks like your server does not have TrueType support. Check your phpinfo() for details on your PHP installation/configuration.

  28. on 21 Feb 2009 at 4:25 pm 28.Jawa said …

    Hi, I have a question while I use this file to include with other page and it could not work till i refresh the page then i could see the image.

    Please tell me what happens with this. Or we could not use this file to include with other page?

    Many thanks,

Trackback | Comments RSS Feed

Leave a Reply

You must be logged in to post a comment.