+ Reply to Thread
Results 1 to 3 of 3

Thread: Random Signature

  1. #1
    Join Date
    Apr 2009
    Location
    Trapped in my own little world.
    Posts
    2,487
    Rep Power
    33

    Random Signature

    Random Signature Generator:

    For this tutorial I will simply show you a few ways to do each part and put one way together for you. It will be a simple random signature generator. First of all you will need some signatures I will be using these listed below. Something to note remember is that the default forum sig: 400x100

    Now to start off we need to be able to find them when we need them we can either put them into an array or put them into a local directory and scan for them.

    Code:
    <?PHP
    //array of images
    $sig[] = "http://i44.tinypic.com/9fqwb9.gif";
    $sig[] = "http://i44.tinypic.com/ip4f8m.gif";
    $sig[] = "http://i41.tinypic.com/2d5t1t.gif";
    Code:
    $files scandir("/homepages/blainesch/htdocs/signatures/");
    $ext "gif"//extension you want - change to anything!
    $start strlen($ext) - (strlen($ext)*2); //gets the negative number
    $end strlen($ext);
    foreach(
    $files as $file) {
        if(
    substr($file$start$end) == $ext) {
            
    $sig[] = "http://yoursite.com/signatures/".$file;
        }

    Now we should all have an array of $sigs! Now to display or not to display - that is the question!

    We can either go about this by forwarding the user to the address which is probably the cheaper way of doing it but will work in most forum signatures I would assume. It worked when I tried it on codecall. Or we can actually generate the page.

    Code:
    header('Location: '.$sig[mt_rand(0count($sig)-1)]); 
    Code:
    header('Content-type: image/gif');
    $im imagecreatefromgif($sig[mt_rand(0,count($sig)-1)]);
    imagegif($im); 
    So to sum it all up...

    Code:
    <?PHP
    //array of images
    $folder "/homepages/blainesch/htdocs/siggys/";
    $files scandir($folder);
    $ext "gif";
    $start strlen($ext) - (strlen($ext)*2);
    $end strlen($ext);
    foreach(
    $files as $file) {
        if(
    substr($file$start$end) == $ext) {
            
    $sig[] = $folder.$file;
        }
    }
    header('Content-type: image/gif');
    $im imagecreatefromgif($sig[mt_rand(0,count($sig)-1)]);
    imagegif($im);
    ?>

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Random Signature

    Very cool, +rep!

  4. #3
    Join Date
    Aug 2007
    Location
    Gizeh, Al Jizah, Egypt, Egypt
    Posts
    8,675
    Blog Entries
    12
    Rep Power
    81

    Re: Random Signature

    awesome dude
    i really like this kind of tutorials good work
    ++rep
    yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
    Code:
    eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
    www.amrosama.com | the unholy methods of javascript

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using a random function to generate another random funtion
    By Roger in forum General Programming
    Replies: 11
    Last Post: 08-23-2010, 08:07 AM
  2. My New Signature! Tell me what you think
    By Donovan in forum The Lounge
    Replies: 5
    Last Post: 07-07-2010, 03:06 PM
  3. "random" number generator is not random?
    By schwza in forum PHP Development
    Replies: 1
    Last Post: 06-04-2010, 01:58 AM

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