ionux's Forum Posts

  • Hey guys, I wrote my own custom CAPTCHA image generator using PHP & the GD library and wanted to share it with you, in case you need something like this on your own sites or apps. It's a really simple implementation which you can see an example output here: 10b.us/captchar.php

    This PHP script generates a 150x80 PNG image consisting of a few random geometric shapes along with a CAPTCHA text string of 5 characters consisting of the numbers 0-9 and letters a-f. If you needed more characters or different colors, you could easily extend this script. The correct CAPTCHA value is stored in a session variable named "captchaval". The font I'm using is called "aescrawl.ttf" which has a handwriting feel to it. Substitute whatever font you'd like but it will need to be in the same directory as this script.

    Implementation: Think of this file as just any other image that you'd insert into your HTML as an img src. You would include this script inside that tag like this:

    <img src="captchar.php" alt="CAPTCHA image" />

    Here's the CAPTCHA PHP code itself:

    <?php
    
    /********************************************************
     *
     *    CAPTCHA generator v0.01, 2013
     *    Written by ionux (help@10b.us)
     *
     *    This is free software released into the 
     *    public domain. No warranty is implied or provided.
     *
     ********************************************************/
    
    ob_start();
    session_start();
    
    $string = substr(md5(mt_rand(0,55)),5,5);
    $spook = ':::::::::::';
    $shape1_x = rand(0,145);
    $shape1_y = rand(0,75);
    $shape2_x = rand(0,145);
    $shape2_y = rand(0,75);
    
    $_SESSION['captchaval'] = $string;
    
    header('Content-Type: image/png');
    
    $im = @imagecreate(150, 80) or die('Cannot Initialize new GD image stream');
    
    $background_color = imagecolorallocate($im, 0, 0, 0);
    $text_color = imagecolorallocate($im, 233, 233, 233);
    $strange_color = imagecolorallocate($im, 101, 101, 101);
    $shape1_color = imagecolorallocate($im, 191, 77, 224);
    $shape2_color = imagecolorallocate($im, 200, 111, 43);
    
    imagestring($im, 5, rand(3,100), rand(10,75), $spook, $strange_color);
    imagestring($im, 5, rand(3,100), rand(10,75), $spook, $strange_color);
    imageellipse($im, $shape1_x, $shape1_y, rand(46,100), rand(30,100), $shape1_color);
    imageellipse($im, $shape2_x, $shape2_y, rand(46,100), rand(30,100), $shape2_color);
    imagettftext($im, 34, rand(0,15), 10, 75, $text_color, 'aescrawl.ttf', $string);
    
    imagepng($im);
    imagedestroy($im);
    

    If this help anyone else, great! I appreciate all the help you guys have given me with C2 so far. :D

  • Just brainstorming here, but you could have a pre-simulation page where you upload a CSV file, parse it and perform any needed variable substitution with php. I've used php a lot over the years to assign values in javascript code.

  • Yep, my first console was an Atari 2600. :) It's been a lot of fun watching games evolve over the years.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Nope, not a noob. Happens to me about 50% of the time.

  • That's so awesome! It inspired me to apply to their program! :D

  • Yeah, that's what I thought but just wanted to make sure.

    (Technically speaking, minification is just the removal of unecessary characters like newlines, extra spaces, etc., so that the file itself is smaller. It's not encrypted, per se...)

  • Please correct me if I'm wrone here, but C2 only minifies the javascript. I don't think there's any obfuscation going on. But anyway, yeah I was hoping there might be some additional options. Thanks for your reply, though!

  • Hey guys/gals, given the nature of these web apps, how do you go about keeping your game property from being stolen or copied? I'm a small time developer so I don't necessarily have a lawyer on retainer. What are your recommendations?

    Thanks! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Wow, thank you so much!!

  • Merry Christmas to you, as well! This is a great community and I'm glad to have discovered it this year. All the best to everyone and I wish you a happy 2014!

  • Ah, hmmm... Ok. I think my best option in this case would be to have the pausescreen on the same layout. Thank you for the tip! :D

  • Hey guys, I've got a puzzle app that I'm added a pause screen to. When I click the pause button, the action is System -> Go to Layout 3. On layout 3, I have an unpause button that is just System -> Go to Layout 1. But, when I do that, it restarts the puzzle. What am I doing wrong here?

  • szymek

    Thanks for pointing that out - you're right. Didn't see that before but it's fixed now. When you generate a font, it will automatically download that image.

    Cheers!

  • szymek

    thanks for the feedback! I could not reproduce that empty file behavior using Firefox 24.0 or 25.0. Is it breaking on a specific font & color combination? I'm getting an image no matter which browser I use on OS X or Windows...

    The PHP code behind the scenes creates a transparent png and outputs that only. Maybe you have an image blocker preventing it from showing?

  • Really love the retro graphics. Awesome idea having two characters played at once! :D