******************************* Intention ******************************* This script is a script desigend to display random banner images in jpg, gif and png formates. This script can also be modified to display any other file type by altering the $image_ext_array array bellow. Notice that the ARRAY_RAND function may choose the same file many times before selecting a different file.
******************************* System Requirments. ******************************* 1. PHP 4.2.0 or higher. 2. A Unix based Opertating System. 3. A Web Server (Apache Perphered). 4. Executable priviages on your server. Even in Safe Mode the PWD command is available provided that the executable directory has the same UID as this script.
******************************* Author. ******************************* This script was designed by Sulaiman Aleem of FreshSoftware.net. Send questions to webmaster@freshsoftware.net
To watch this script in action visit http://www.freshsoftware.net/images/advertisments/freshsoftware/index.php
******************************* HOW TO INSTALL *******************************
1) Copy this file to a directory that is accessbile by a HTTP server. 2) Copy banner images to the same directory containg this file. 3) Use the HEADER, ECHO or FPASSTHRU (recommended)function to display the banner image in a browser window. */
$dir = exec('pwd');
$open_dir = opendir("$dir");
//Add or remove files extensions to suit your needs. //Notice that the extensions are in upper and lower case. $image_ext_array = array( "jpg", "jpeg", "gif", "png",
//If the PHP server is less that 4.2.0 the SRAND function is needed. //srand((float) microtime() * 10000000); $show_img = array_rand($image_files);
//Optional: use the HEADER function to prevent the browser from caching the html content and image. //This is most use full when using the HEADER function to display the image //header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //header ("Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0, proxy-revalidate, no-transform"); //header ("Pragma: no-cache"); //header("Vary: User-Agents");
//Edit the image ALT field to suit your needs. $image_alt = "FreshSoftware 1-866-343-3343";
//USE the ECHO function to display HTML Code. //echo "<img src=\"$image_files[$show_img]\" width=\"$image_width[0]\" height=\"$image_height[1]\" alt=\"$image_alt\">";
//The HEADER function often times fails to rotate an image when refreshing a browser. //header("location: http://freshsoftware-internal.net/images/advertisments/freshsoftware/$image_files[$show_img]");
//Recommended. These three lines make use of the FPASSTHRUE function. $open_image = fopen($image_location, 'rb'); fpassthru($open_image); fclose($open_image);
closedir($open_dir); } ?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.