Fubar Simple Program I cant get to work lol

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian
    Senior Member
    • Apr 2000
    • 252

    Fubar Simple Program I cant get to work lol

    I am trying to use the following simple image rotator program I found and am having problems getting it to work. What I am trying to do is just get a random image when called via url, however it is not working.

    I believe it is a php3 legacy issue as I am trying to use this on a php4 server.

    Anyhow if some one can see what might be wrong I would appreciate it a million

    -Brian

    PHP Code:
    <?php
    /* banner.phtml
       Banner rotation script for PHP3 by Anton Olsen ([email protected])
       Please feel free to do with this script what you want, all I ask is
       that if you make significant changes, please e-mail them to me.

       I tried to use a number of different methods, the image functions
       of PHP do not appear to understand animated GIFs and the file
       handling features (fopen, fpassthru, and fclose) were causing
       apache to crash on me.  I settled on using passthru.  Although
       possibly not as portable, it appears to work faster than either
       method mentioned above.

       Assumptions:
       You have a directory for all your banners.
       All banners are GIF files.
       The filenames of the banners all start with banner.
       There are no other files in the directory starting with banner.

       Installation:
       Place this script in the banners directory.
       Place all your banner*gif files in the same directory.
       Add the following HTML code to your web pages :
         <a href="wherever.you.want.com">
         <img src="http://www.yourserver.com/bannerdir/banner.phtml" alt="Random Banner Here" border=0>
         </a>

    */

    /* random( $max integer )
       Returns a random number between 0 and $max-1;
    */
    function random$max )
    {
            
    $x rand();
            
    $y getrandmax();

            
    $r $x $y * ($max -);

            
    $r round$r++ );
            return 
    $r;
    }

    /* Read the directory, add all "banner*" files with to the array
    */
    $i 0;
    $d   dir(".");
    while(
    $entry=$d->read())
            if (
    substr($entry,0,6) == "banner")
                    
    $array[$i++] = $entry;
    $d->close();
                    

    /* pick a banner at random
    */
    $r random$i );

    /* Send a no-cache header, and the gif type header, and output the file.
    */
    Header"Pragma: no-cache" );
    Header"Expires: Monday 01-Jan-80 12:00:00 GMT" );
    Header"Content-type:  image/gif");
    passthru"cat $array[$r]);

    ?>
    << This Space Intentionally Left Blank >>
  • krs-one
    Senior Member
    • Jun 2001
    • 285

    #2
    Any specific problems you are having? That code in PHP3 would work the exact same in PHP4, I don't think it is a legacy issue.

    And are you following the instructions? Perhaps your server doesn't recognize .phtml files as PHP files.

    -Vic

    Comment

    • Brian
      Senior Member
      • Apr 2000
      • 252

      #3
      PHP 4 no longer recognizes .phmtl thus I named script simply .php but it does not work :/

      -Brian
      << This Space Intentionally Left Blank >>

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...