Php Code For Banner Rotator!

Discussion in 'General Discussion' started by SponX, Jul 15, 2005.

  1. SponX

    SponX Well-Known Member

    Age:
    35
    Posts:
    2,332
    Likes Received:
    0
    Joined:
    Nov 30, 2004
    Location:
    HypedGaming.com
    50 credits if someone can give me the code (not a site) for a sig rotator ;)

    Thanks <3 ^_^
     
  2. Kai-WoZ

    Kai-WoZ Well-Known Member

    Posts:
    62
    Likes Received:
    0
    Joined:
    Mar 27, 2005
    Here is a better explanation of the random php tutorial

    Step one: go to http://www.100webspace.com/signup.html and fill out the form (enter fake info if u want but put real e-mail). For "Pick up a domain name" choose "use a subdomain" and it doesn't matter what you choose for payment method since its free. When you are done filling out the form click Place the order.

    Step two: They should send you an e-mail already giving your username and password. Use that information to log into your account. If you didn't recieve an e-mail check your "Spam" folder or try step one again.

    Step three: When you are logged in, click on the button "File Manager". Now click on the word "www" and now click on the only folder that should be listed and it should be your subdomain.

    Step four: At the bottom of the page you should see "New Folder", highlight it and enter "images" and click Create Folder. You have just created a new folder called "images", this is where you put all of your sigs. Click "images" to go inside the folder and start uploading your sigs by clicking "Browse...", choose your file, then click "Upload File(s)".

    Step five: After uploading all of your sigs, click "Uplevel". Then at the bottom of the page where it says "New file", highlight the text and enter "random.php" then click "Create File". Now there should be a big text editor. Copy/Paste this code into the text box:
    PHP Code:
    <?php

    // Header info, forces no cache and image type of GIF
    header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
    header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
    header("Pragma: no-cache");
    header("Content-Type: image/gif");

    // Define the subdirectory to where we store the images..
    $dir = "images";

    // Set a random seed up
    srand((double)microtime()*1000000);

    // Set our counter to 0
    $i = 0;

    // Open the images directory
    $dirHandle = opendir($dir);

    // Read in image filenames
    while(($im = readdir($dirHandle)))
    {
    // Don't read in the 2 directories ".." and "."
    if($im != ".." && $im != ".")
    {
    // Add that image filename to the array
    $image[$i] = $im;
    // Increment our counter
    $i++;
    }
    }
    // Close the directory handle
    closedir($dirHandle);
    // Create a random number from 0 to the size of the array
    $n = rand(0,(count($image)-1));

    // Read in a file and output it to the output buffer..
    if(!readfile($dir."/".$image[$n]))

    // If we can't for some reason use the error.gif file in the error directory
    readfile($dir."error/error.gif");
    ?>

    Then click "Save"

    Step six: Now everything is set up and all you have to do is enter the url: www.yourwebsite.com/random.php and it should display a random sig in your "images" folder. Go to www.starcraftdream.com, log in and click User CP -> Edit Signature and type [​IMG]
     
  3. ^Samurai^

    ^Samurai^ Senior Member

    Age:
    32
    Posts:
    2,540
    Likes Received:
    0
    Joined:
    Jul 14, 2005
    Location:
    Mexico
    hey u get the credits =P

    gj
     
  4. Kai-WoZ

    Kai-WoZ Well-Known Member

    Posts:
    62
    Likes Received:
    0
    Joined:
    Mar 27, 2005
    eh lets hope so :) lol
     
  5. ManualAce

    ManualAce Well-Known Member

    Age:
    33
    Posts:
    1,198
    Likes Received:
    0
    Joined:
    Oct 13, 2004
    Location:
    Marina, California
    or just put this in a notepad and than rename it index.php

    make a folder called mysigs and than host it. the host needs php for this to work. than when u have a host do this:

    &IMG]http://hostname.com/mysigs/index.php[/IMG]

    PUT THE INDEX.PHP in the folder with your sigs u want to rotate.

    <?php
    //////////////////////////////////////////////////////////////////////
    /* Suho1004's PHP Sig Rotator V2.0 */
    /* */
    /* This script takes an inventory of all image files in a directory */
    /* and displays one at random. All you need to do is save this code */
    /* in a directory that contains your images (name it what you will, */
    /* but make sure it has a ".php" extension). Then just link to this */
    /* script to get your random image. */
    /* */
    /* I would recommend naming this file "index.php," and then you can */
    /* just link to the directory itself (like I do in my example). */
    /* */
    /* Once you've read these instructions, feel free to delete them to */
    /* cut down on the file size. I claim no rights to this code, which */
    /* means you can do whatever you like with it. Have fun. */
    /* */
    /* Thanks to TP for the gentle nudging... */
    //////////////////////////////////////////////////////////////////////

    if ($dir = opendir("."))
    {
    $list = buildimagearray($dir);
    displayrandomimage($list);
    }

    // This function reads all the files in the current directory and adds all image files to the array $list[]
    function buildimagearray($dir)
    {
    while (false !== ($file = readdir($dir)))
    {
    if (!is_dir($file) && getimagesize($file))
    {
    $list[] = $file;
    }
    }
    return $list;
    }

    // This function selects a random image, determines the mime type, opens the file for reading,
    // and then outputs the image
    function displayrandomimage($list)
    {
    srand ((double) microtime() * 10000000);
    $sig = array_rand ($list);

    $size = getimagesize ($list[$sig]);
    $fp = fopen($list[$sig], "rb");

    if ($size && $fp)
    {
    header("Content-type: {$size['mime']}");
    fpassthru($fp);
    exit;
    }
    }
    ?>
     
  6. Kai-WoZ

    Kai-WoZ Well-Known Member

    Posts:
    62
    Likes Received:
    0
    Joined:
    Mar 27, 2005
    my way gives u a way to host it thought...and i did it first! lol
     
  7. ManualAce

    ManualAce Well-Known Member

    Age:
    33
    Posts:
    1,198
    Likes Received:
    0
    Joined:
    Oct 13, 2004
    Location:
    Marina, California
    haha dont worry nothing unfriendly against u. just for the credits XD. and if i do win ill give u 50 percent.
     
  8. Kai-WoZ

    Kai-WoZ Well-Known Member

    Posts:
    62
    Likes Received:
    0
    Joined:
    Mar 27, 2005
    lol thats cool if he likes urs better and gives to u it aint no thang ;) i gonna go to bed got up too early this morning peace bro...BTW sponx or whoever u were POST HERE!
     
  9. Xerxes

    Xerxes Senior Member

    Age:
    43
    Posts:
    540
    Likes Received:
    0
    Joined:
    Aug 3, 2004
    Location:
    K-Town, Tennessee
    This is how i do mine
     
  10. ManualAce

    ManualAce Well-Known Member

    Age:
    33
    Posts:
    1,198
    Likes Received:
    0
    Joined:
    Oct 13, 2004
    Location:
    Marina, California
    haha u knoe what's funny, i followed that so basically its the same thing XD.
     

Share This Page