Location: PHPKode > scripts > Hercules - image, banner rotator > hercules/scripts/hercules_rotator.php
<?php
error_reporting(E_ALL);
ini_set("display_errors", "1");
#################################################
#        Hercules - image  rotator v.9.0        #
#################################################
#
#Copyright (C) 2005  Karma Wangchuk Sonam 
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#Check http://www.phoenixphp.net for newer version
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
############################################################################
$hpath = $_SERVER['DOCUMENT_ROOT'];
$hpath2 = "http://" . $_SERVER['SERVER_NAME'];
$setTime = @$_GET['sec']; 
$data = @$_GET['data'];
$width = @$_GET['width'];
$height = @$_GET['height'];
$order = @$_GET['order'];
$newID = @$_GET['newID'];


if($newID == "") {
	$current = 0;
} else {
	$current = $newID;
}

$banners = file($hpath . $data);

if($order == 'r') {
	$currentR = @$_GET['current'];
	shuffle(@$banners); 
	$newCurrent = $banners[0]; 
	if(strpos($newCurrent, $currentR) !== FALSE) {
		$newCurr = $banners[1];
	    list($img, $url, $alt) = explode("|", $newCurr);
	    $alt = trim($alt);
	    $newURL = "data=$data&amp;sec=$setTime&amp;width=$width&amp;height=$height&amp;order=r&amp;current=$img"; 
    } else {
	    $newCurr = $banners[0];
	    list($img, $url, $alt) = explode("|", $newCurr);
	    $alt = trim($alt);
	    $newURL = "data=$data&amp;sec=$setTime&amp;width=$width&amp;height=$height&amp;order=r&amp;current=$img"; 
    }
	if($url =="") {
	         $href = "";
	         $href2 = "";
         } else {
	         $href = '<a href="' . $url . '"  target="_top">';
	         $href2 = "</a>";
         }
} else {
   $count = count($banners);
   if(empty($current) && $current != 0) {
      list($img, $url, $alt) = explode("|", $banners[0]); 
      $alt = trim($alt);
      $newURL = "data=$data&amp;sec=$setTime&amp;width=$width&amp;height=$height&amp;newID=0";
         if($url =="") {
	         $href = "";
	         $href2 = "";
         } else {
	         $href = '<a href="' . $url . '" target="_top">';
	         $href2 = "</a>";
         }
   } elseif($current >= '0' && $current < $count-1) {
      $key = $current+1;
      list($img, $url, $alt) = explode("|", $banners[$key]);
      $alt = trim($alt);
      $newURL = "data=$data&amp;width=$width&amp;height=$height&amp;sec=$setTime&amp;newID=$key";
      if($url =="") {
	         $href = "";
	         $href2 = "";
         } else {
	         $href = '<a href="' . $url . '" target="_top">';
	         $href2 = "</a>";
         }
   } else  {
      list($img, $url, $alt) = explode("|", $banners[0]);
      $alt = trim($alt);
      $newURL = "data=$data&amp;sec=$setTime&amp;width=$width&amp;height=$height&amp;newID=0";
      if($url =="") {
	         $href = "";
	         $href2 = "";
         } else {
	         $href = '<a href="' . $url . '" target="_top">';
	         $href2 = "</a>";
         }
   }
}
if(strpos($img, 'http') !== FALSE) {
	$img = $img;
} else {
	$img = $hpath2 . $img;
}

$banner = $href . '<img src="' . $img . '"alt="' . $alt . '" title="' . $alt . '" width="' . $width . '" height="' . $height . '" />' . $href2;

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META HTTP-EQUIV=Refresh CONTENT="' .  $setTime .'; URL=?' . $newURL . '" />
<title>Phoenix PHP - Hercules image/banner rotator</title>
<link rel="stylesheet" href="'. $hpath2 . '/hercules/css/hercules_style.css" type="text/css" />
</head>
<body>' . $banner . '
</body>
</html>'; 
?>
Return current item: Hercules - image, banner rotator