Results 1 to 6 of 6

Thread: GumCha simple captcha, no mysql no sessions, flatfile captch

  1. #1
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,494
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default GumCha simple captcha, no mysql no sessions, flatfile captch

    here is a captcha code which i have developed for wap sites.

    1. create a new file image.php and put the next code code to it:
    PHP Code:
    <?php

    @exec("find ./gumcha/ -maxdepth 1 -type f -mtime +1 -exec rm -f {} \;");


    $code rand_string(5);
    file_put_contents('./gumcha/'.$code$code);


    function 
    rand_string$length ) {
        
    $chars "abcdefghijklmnopqrstuvwxyz123456789";    

        
    $size strlen$chars );
        for( 
    $i 0$i $length$i++ ) {
            
    $str .= $charsrand0$size ) ];
        }

        return 
    $str;
    }


    /* YOU CAN MODIFY THE IMAGE CODE FROM HERE TO CREATE MORE COOL CAPTCHA IMAGES, eg. with different backgrounds */
    header("Content-type: image/gif");
    $im = @imagecreate(6025)
        or die(
    "Cannot Initialize new GD image stream");
    $background_color imagecolorallocate($im000);
    $text_color imagecolorallocate($im2331491);
    imagestring($im355,  $code$text_color);
    imagegif($im);
    imagedestroy($im);

    ?>
    create folder gumcha where the captcha image script is and chmod 777 it.


    and then use this peace of code which will check if the gumcha generated code is correct:

    PHP Code:
    if($_POST){
                
    $gumcha_code $_POST['code'];

        if(
    gumcha_check($gumcha_code) == true)
        {


                           
    // HERE GOES THE CONTENT AFTER THE CAPTCHA VALIDATION


        
    }else echo 'WRONG CAPTCHA CODE';
    }

    function 
    gumcha_check($code)
    {
        
    $code trim($code);
        
    $code str_replace('.','',$code);
        
    $code strtolower($code);
        if (
    preg_match("/[^\da-z]+/"$code)) return false;
        elseif(
    strlen($code)<2)return false;
        elseif(
    file_exists('./gumcha/'.$code))
        {
            @
    unlink('./gumcha/'.$code);
            return 
    true;
        }
        else return 
    false;

    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  2. The Following 2 Users Say Thank You to GumSlone For This Useful Post:

    metulj (23-06-10), something else (23-06-10)

  3. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    5
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    0

    Default

    Nice, but what if someone evil would pass $_POST['code']= "../index.php"?
    this is kinda dangerous....
    it would be better to generate a numeric random code and use something like
    @unlink('./gumcha/'.intval($gumcha_code));


    I hope i explained myself

    Cheers

  4. The Following User Says Thank You to Sora101 For This Useful Post:

    GumSlone (23-06-10)

  5. #3
    Administrator GumSlone's Avatar
    Join Date
    Mar 2005
    Location
    Mars, GumCity
    Posts
    1,494
    Thanks
    125
    Thanked 573 Times in 201 Posts
    Blog Entries
    2
    Rep Power
    10

    Default

    Quote Originally Posted by Sora101 [Only registered and activated users can see links. Click Here To Register...]
    Nice, but what if someone evil would pass $_POST['code']= "../index.php"?
    this is kinda dangerous....
    it would be better to generate a numeric random code and use something like
    @unlink('./gumcha/'.intval($gumcha_code));


    I hope i explained myself

    Cheers
    PHP Code:
    $gumcha_code str_replace('.','',$gumcha_code); 
    will do the thing

    or
    PHP Code:
    if (preg_match("/[^\da-zA-Z]+/"$gumcha_code)))
                
    $error 'Wrong code.'
    code updated
    Advertise your mobile site for FREE with [Only registered and activated users can see links. Click Here To Register...]

    [Only registered and activated users can see links. Click Here To Register...]


  6. #4
    Senior Member
    Join Date
    Apr 2009
    Location
    Lipa City, Batangas, Philippines
    Posts
    386
    Thanks
    0
    Thanked 14 Times in 11 Posts
    Rep Power
    5

    Default

    I can do it w/o session, sql or txt file..just submit the answer of the user and the correct answer to the 2nd page and then compare if equal..as easy as that..

  7. #5
    Senior Member wapmetal's Avatar
    Join Date
    Mar 2009
    Location
    guam, USA
    Posts
    616
    Thanks
    82
    Thanked 22 Times in 22 Posts
    Rep Power
    5

    Default

    lol there are many tuts out there on web thats why u just modify codes LOL...
    com site: [Only registered and activated users can see links. Click Here To Register...]
    download site: [Only registered and activated users can see links. Click Here To Register...]
    fb: [Only registered and activated users can see links. Click Here To Register...]

  8. #6
    Senior Member
    Join Date
    Apr 2009
    Location
    Lipa City, Batangas, Philippines
    Posts
    386
    Thanks
    0
    Thanked 14 Times in 11 Posts
    Rep Power
    5

    Default

    You don't need tut if u use head or common sense..Be wise..Trust urself u can do it with ur own and learn with urself..If not, you don't deserve to be a good coder..
    Last edited by kiLLeR-eyEd_14; 23-06-10 at 21:26.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Captcha ?!
    By Malka1 in forum Coding Forum
    Replies: 7
    Last Post: 10-04-10, 13:17
  2. Hidden sessions
    By kiLLeR-eyEd_14 in forum Coding Forum
    Replies: 25
    Last Post: 14-01-10, 07:02
  3. Replies: 2
    Last Post: 28-06-09, 17:24
  4. Captcha
    By tkrocks in forum Coding Forum
    Replies: 1
    Last Post: 21-02-09, 17:32
  5. Sessions
    By naveen-PHP LEARNER in forum Coding Forum
    Replies: 11
    Last Post: 18-07-06, 08:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19