Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default Dynamic Random Image Tutorial

    Ok, some people may have been wondering how my image in my sig changed. When you cant put a randomize script in your sig.

    Well its actly quite simple as the randomiser is actly in the image.

    so isnetd of banner.gif
    you have banner.php

    It then genirates the headers to tell the computer loading it, that it is an image, and not a php script.

    the script below only works with .gif 's athogh you could cahnge this.

    to ad more images, simply ad to the array, and chnage the currant image in the array to the images you want in the randomize.

    hope this helps some one
    PHP Code:
    <?php

    // tells it its a gif image
    Header("Content-type: image/gif");

    // dates back a bit (so dosnt go in cache, so peeps actaly see chnages)
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

    // ye be modifed always (so dosnt go in cache, so peeps actaly see chnages)
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");

    // HTTP/1.1 - no (so dosnt go in cache, so peeps actaly see chnages)
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);

    // HTTP/1.0 - no (so dosnt go in cache, so peeps actaly see chnages)
    header("Pragma: no-cache");

    //image arrays
    // just ad decres it to remove images, also chnage image1.gif etc to images you wnat to dimainc image to randomize "/
    $stuff = array (
                    
    => "image1.gif",
                    
    => "image2.gif",
                    
    => "image3.gif",
                    );
    $display=rand(0sizeof($stuff)-1);

    //include it and done
    include($stuff[$display]);

      
    ?>

    Exstendered

    Ok you have a dinamic image, but you want to use it on a forum. BUT the forum only supports valide image types, gif, jpg, png etc?

    Well with a bit of help from .htaccss files its possible to run file types as other file types.

    Heres an exsample of a finshed part
    http://www.thybag.co.uk/php/speacal/myimage.png

    The file type in PNG. yet refresh it, and it chnages like the php exsample

    OK how do i do this. Well its axtly quite simple if your host supports .htaccess

    As a htaccess effects all files below it, its best to creat a new directy for this, then put the script and the images in it.
    Next choose what image typed youd like the php genirator to be, for my exsample i choose png.

    creat a new file, called .htaccess

    now htaccess can over ride both the apachi handlers and the MIME Types, as well as adding new ones, if you wanted a .pie files for exsample

    Anyway to ad the MIME Type, use this format
    Code:
    AddType application/x-httpd-php .png
    The bit that says add MIME type is
    Code:
    AddType
    The middle is what type to add
    Code:
    application/x-httpd-php
    Above ive used the php file type

    and the last bit is what exsention to apply it to
    Code:
    .png
    This can be used for ANY exstention, and aply any file type.

    Say if i was just renaime a .html document this would be all i need. But as im doing this for a php document, the apachi server needs to genrate the php on it, or there would be an error

    we add a apchi handler in the same way, exspt with one diffence
    [code]
    AddHandler application/x-httpd-php .png
    [code]
    that is we use the ad handler command insted of the addtype command.

    so in your .htaccess file you should have

    Code:
    AddType application/x-httpd-php .png
    AddHandler application/x-httpd-php .png
    Now save this. and then chnage the exstention on the php file with the random banner script on it, to in this exsampe .png .

    Now due to the .htaccess all .png file in this directory will be treated as php, and are therefore the script will genriate succefuly and give you the random image.


    The only flaw in this is some versions of IE (helpfuly) decide to ignore the information there given, and attempt to treat the file on its own mime file type database, wich can cause errors.
    Last edited by Mentor; 28-06-2005 at 09:15 PM.

  2. #2
    Join Date
    Nov 2004
    Location
    Daventry, Northants
    Posts
    1,510
    Tokens
    0

    Latest Awards:

    Default

    Ah cool

    I thaught it was done by a Java image rotator script

  3. #3
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    Quote Originally Posted by Anderman
    Ah cool

    I thaught it was done by a Java image rotator script
    javascript.

    Old thybag did, then i upgraded to php, but i coulnt use that in a sig, or on forum, so i then made the image itself dinaimic, as ye can see above

  4. #4
    Join Date
    Apr 2005
    Location
    MrsHabbo Offices Construction
    Posts
    710
    Tokens
    0

    Default

    lol, never noticed that before. nice...

  5. #5
    Join Date
    Sep 2004
    Location
    USA (was UK)
    Posts
    334
    Tokens
    50
    Habbo
    Kroziun

    Default

    Good one - I too wondered how it was done.
    Remember Hobbas and MODs? Join my "Bring Back Hobbas!" group if you miss them!

  6. #6
    Join Date
    Oct 2004
    Location
    Scotland
    Posts
    2,280
    Tokens
    1,075

    Latest Awards:

    Default

    Quote Originally Posted by Anderman
    Ah cool

    I thaught it was done by a Java image rotator script

    i wish people would stop calling javascript JAVA, two different things!!

    http://www.stupidian.com
    (contains mild swearing)

  7. #7
    Join Date
    Nov 2004
    Location
    Daventry, Northants
    Posts
    1,510
    Tokens
    0

    Latest Awards:

    Default

    I know now,
    I didnt know when i made that post

  8. #8
    Join Date
    Jun 2004
    Location
    The Great White North™
    Posts
    2,320
    Tokens
    0

    Latest Awards:

    Default

    I was wondering, can you show like a tutorial with pictures, because I dunno how to do this.. so confusing..
    Habbo [CA] Username: Dave
    Habbo [US] Username: Dave.
    Habbo [UK] Username: :-Mystical.Dave-
    Habbo [SG] Username: Lenin
    Habbo [AU] Username: STALlN

    6th Registered Member of HabboxForum | Join Date: 23-06-2004
    http://www.habboxforum.com/member.php?u=6

  9. #9
    Join Date
    Jul 2005
    Posts
    143
    Tokens
    0

    Default

    nice tutorial

  10. #10
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Post

    nice Tutorial
    +rep if i can :rolleyes:
    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

Page 1 of 2 12 LastLast

Posting Permissions

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