<?php
/***************************************************************************
* feedRollImg.php
*
* begin : October 2006
* version : 20 October 2006
* copyright : (C) 2006 grandolini.net
*
* Feed rolling images through an XMLHTTP response script
* Images MUST be placed in: [root]/skins/[skin dir]/img/rollimg
* Thumb must be already present and their filenames must start with:
* 'thumb_'.
*
***************************************************************************/
session_start();
if(!isset($_SESSION[last_rollimg]) || $_SESSION[last_rollimg]==0) { $_SESSION[last_rollimg]=-1; }
if(!file_exists($_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'skins/'.$_GET[skid].'/img/rollimg/index.html')) { die; }
#
$_ROOT=$_SERVER[DOCUMENT_ROOT].$_SESSION[misc][folder].'skins/'.$_GET[skid].'/img/rollimg';
$RRN=1;
#
if($handle=opendir($_ROOT))
{
while(($file=readdir($handle))!==false)
{
if(is_file($_ROOT.'/'.$file) && substr($file,0,6)=='thumb_')
{
if($RRN>$_SESSION[last_rollimg])
{
$_SESSION[last_rollimg]=$RRN;
#
header("Cache-Control: no-cache, must-revalidate");
header('Expires: Fri, 31 Dec 1999 23:59:59 GMT');
header('Content-type: text/xml');
echo '<rollingImages>'
.'<rrn>'.$_SESSION[last_rollimg].'</rrn>'
.'<rollimg>'.htmlspecialchars(substr($file,6)).'</rollimg>'
.'</rollingImages>';
closedir($handle);
die;
#-:-:-:-:-:-:-:-| natural end
}
$RRN++;
}
}
closedir($handle);
#
# all images were shown, reset the counter and call itself to feed the first file again
#
$_SESSION[last_rollimg]=0;
header('Location: '.$_SERVER[PHP_SELF].'?'.$_SERVER[QUERY_STRING]);
}
?>