Link Farm Code

  Home arrow Link Farm Code arrow FreshSoftware Banner Image Rotater
LINK FARM CODE

FreshSoftware Banner Image Rotater
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2004-09-24

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    A PHP script that automatically rotates randomally selected banner images.

    By : thebomani

    <?
    /*
    *******************************
    FreshSoftware Banner Image Rotater
    Version: 1.0
    *******************************

    *******************************
    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",

    "JPG",
    "JPEG",
    "GIF",
    "PNG",
    );

    $image_files = array();

    if(!$open_dir){
    die("can not $dir");
    }
    else{
    while(false !== ($file = readdir($open_dir))){

    $ext = explode(".", "$file");

    if(in_array($ext[1], $image_ext_array)){
    $image = "$ext[0]" . "." . "$ext[1]";
    array_push($image_files, $image);
    }

    }

    //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";

    $image_location = $dir . "/" . $image_files[$show_img];

    $image_width = getimagesize($image_location);
    $image_height = getimagesize($image_location);

    //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.

    More Link Farm Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    LINK FARM CODE ARTICLES

    - FreshSoftware Banner Image Rotater
    - LinkMachine
    - Pagination
    - Ask and Receive version 2.0
    - MyLinks Version 1.1
    - Flexphplink Pro
    - Flexphplink
    - Please remove
    - Simple Outgoing Links/Url Hit Counter
    - PHP-LINKS

    Developer Shed Affiliates

     



    © 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap