+ Reply to Thread
Results 1 to 8 of 8

Thread: Need a PHP script

  1. #1
    Woraug's Avatar
    Woraug is offline x10Hosting Member Woraug is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Only In Your Mind
    Posts
    9

    Need a PHP script

    I'm looking for a PHP script that I had a while back, and now don't remember. What it did, every time you refreshed a page, it was a different banner. As seen here:

    http://www.katbox.net/laslindas/

    Anyone know how to do this?

  2. #2
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Re: Need a PHP script

    Quote Originally Posted by Woraug
    I'm looking for a PHP script that I had a while back, and now don't remember. What it did, every time you refreshed a page, it was a different banner. As seen here:

    http://www.katbox.net/laslindas/

    Anyone know how to do this?
    Like this ;) (the script gets all images from folder it is in and randomly displays one of them):
    PHP Code:
    <?
    if ($dir opendir(".")) 

         
    $list buildimagearray($dir); 
         
    displayrandomimage($list); 

     
    function 
    buildimagearray($dir

         while (
    false !== ($file readdir($dir))) 
         { 
              if (!
    is_dir($file) && getimagesize($file)) 
              { 
                   
    $list[] = $file
              } 
         } 
         
    array_shift($list);
         return 
    $list

     
    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; 
         } 

    ?>

  3. #3
    Woraug's Avatar
    Woraug is offline x10Hosting Member Woraug is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Only In Your Mind
    Posts
    9

    Re: Need a PHP script

    How would I get it to read from a specific directory, instead of the one the script in put in?

  4. #4
    swirly's Avatar
    swirly is offline x10 Elder swirly is an unknown quantity at this point
    Join Date
    Jul 2005
    Location
    NC
    Posts
    965

    Re: Need a PHP script

    Code:
    <?
    if ($dir = opendir(".")) 
    { 
         $list = buildimagearray($dir); 
         displayrandomimage($list); 
    }
    i beleive u just change the opendir code...make it
    Code:
    <?
    if ($dir = opendir("blah/blahblah")) 
    { 
         $list = buildimagearray($dir); 
         displayrandomimage($list); 
    }
    Last edited by swirly; 07-15-2006 at 12:51 AM.
    Don't go to bed angry, stay awake and plot revenge.

  5. #5
    Woraug's Avatar
    Woraug is offline x10Hosting Member Woraug is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Only In Your Mind
    Posts
    9

    Re: Need a PHP script

    Very cool. One final question (which I didn't think to ask before) How would I implement this into my forum? I'm not sure what I would edit to make this work. Invision v1.3.1

    (BTW, thanks much for the help so far guys, you rock! :biggthump)

  6. #6
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Re: Need a PHP script

    You just have to use this where ever you want your images to show:

    Code:
    <img src="path/to/dir/where/script/is/script.php" border="0" />

  7. #7
    Woraug's Avatar
    Woraug is offline x10Hosting Member Woraug is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Only In Your Mind
    Posts
    9

    Re: Need a PHP script

    Right on! You guys have reached previously unheard of levels of badass.

  8. #8
    Torch's Avatar
    Torch is offline x10 Lieutenant Torch is an unknown quantity at this point
    Join Date
    Apr 2006
    Location
    Belgrade, Serbia
    Posts
    317

    Re: Need a PHP script

    Glad to be of help ;)

    If you need any more personalized help/scripts, check this topic out: http://www.x10hosting.com/forums/showthread.php?t=17453
    Last edited by Torch; 07-15-2006 at 06:24 PM.

+ Reply to Thread

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  4. Need a PHP Script
    By Rising in forum The Marketplace
    Replies: 16
    Last Post: 02-19-2006, 12:27 PM
  5. php Script help!
    By Vr3nuhm in forum Scripts & 3rd Party Apps
    Replies: 7
    Last Post: 04-10-2005, 07:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers