|
|
|
<?php
/* banner.phtml
Banner rotation script for PHP3 by Anton Olsen (aolsen@graphweb.com)
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 -1 );
$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 is a script that list all image files on a given directory, and displays
the thumbnails nicely formated within an HTML table. It also make use of
JavScript to open pop up windows when the users want to see the full photo. Categories : Graphics, PHP, Complete Programs, Java Script | | | This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs | | | a little counter-script for PHP. Needs the gd-library and Colors.php Categories : Graphics, PHP, Complete Programs | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality. Categories : PHP, GD image library, Graphics | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Searches through a local INN server's discussions Categories : Search, Complete Programs, PHP | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | | | Parses HTTP_USER_AGENT so that you can customize your site to different browsers Categories : HTML, PHP, Complete Programs | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection. Categories : Complete Programs, Content Management, Filesystem, PHP | | | PHPCatalog Categories : Ecommerce, PHP, Complete Programs | | | GuestBook Light - a plug and play application for any website. Categories : PHP, Complete Programs, Filesystem, Sessions | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | |
| | | | Vincent Kruger wrote :405
Could any one maybe modify this script to select
random html code from a mysql database instead of
selecting a random gif froma directory.
I have tried to modify it myself, but have no come
through.
I off to try again !
Vince
| |
|
|
|