SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Ransom Note

  1. #1
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ransom Note

    I've never used the GD library or imagemagic (sp?). Anyway, I'm getting ahead of myself. I think I need a ransom note type of script for new user accounts. You know, where the user has to enter the "ransom note" code into a form on a new account confirmation page. Now I've seen the one used by altavista and I noticed an ASCII version of the same concept in use by fortunecity.

    Well, I need a script to do this. I've had a look around at hotscripts.com but didn't find anything. Has anyone implemented something similar? Got a script or class you can share? Or some tips?

  2. #2
    We are vigilant icehousedesigns's Avatar
    Join Date
    Dec 2000
    Location
    Io
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this might get you started? You can see what the output looks like here. Hope this helps

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is how you create images and put text on them, it might help you get started:

    PHP Code:
    <?php

        $string 
    "Ransom Note";

        
    $height 23;
        
    $width 105;
        
    $im ImageCreate($width$height);
        
    $white ImageColorAllocate ($im255255255);
        
    $black ImageColorAllocate ($im000);

        
    ImageFill ($im00$black);

        
    ImageString ($im533$string$white);

        
    Header ("Content-type: image/png");
        
    ImagePng ($im);

        
    ImageDestroy($im);

    ?>
    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if this is vague, my book is at hame.

    You can use fonts with GD. The best part is it is completely server-side, so you don't have to worry if the vistor has the font. Just upload the font of your choice to your website and point GD to it in your PHP script.

    I found a great Ransom font at Font Freak . It's called Ransom.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2000
    Location
    Seattle, WA area
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there,

    I haven't used this system, but I've seen it used on Yahoo. It requires that you have The Gimp installed on your system, but it comes with sample Perl code, which should be fairly easy to translate over to PHP.

    http://www.captcha.net/gimpy.html

    Let me know if that helps you out at all.

    --David
    David Baxter
    Freelance PHP/MySQL Developer
    Contact me for more information: [ Email ] [ICQ: 47136518]

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for those tips and snippets.

    icehousedesigns - there is one major flaw that
    I can see with the code you have linked to. It includes the text message in the javascript sent to
    the browser:
    Code:
    document.write("This is the kidnapper of your child.  Please send one million dollars immediately!".ransomNote())
    So I think its usefullness is limited beyond simply
    providing an asthetic effect. But thank you none the
    less.

    I am considering two approaches:

    1) Create a montage from random gifs
    - For each letter and numeral, create half a dozen png
    images (different fonts with a bit of noise/distortion
    added in) on my mac using photoshop and upload them to
    the server.

    To generate the montage image:
    - create a string of random characters,
    - save that string in the database,
    - for each character in the string, randomly select an
    image from its set and add that into the montage image
    - serve up the montage image. Perhaps rotate the image
    a few degrees clockwise or counterclockwise before adding it into the montage.

    *While this is not as elegent as completly automating
    the image creation on the server - I don't even have a
    clue what fonts are available on my maching - I'm such a linux newbie!

    2) Generate everything from scratch including
    selecting random fonts along the lines of seanf's
    sample code.

    - If anyone could give me some tips on the font side
    of things, that would help
    Last edited by freakysid; Sep 18, 2001 at 00:23.

  7. #7
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is some sample code for using fonts with GD
    PHP Code:
    <?php
    header 
    ("Content-type: image/gif");
    $image imagecreate(400200);
    $red imagecolorallocate($image255,0,0);
    $blue imagecolorallocate($image0,0,255);
    $font "/root/path/to/font/laaswfte.TTF";
    imageTTFtext($image50020100$blue$font"Welcome!");
    imagegif($image);
    ?>
    You can see the output here:
    Code Output

    The above code is from the book "PHP in 24 Hours".


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
  •