timed header image rotation
Posted on
16th Feb 2014 07:03 pm by
admin
I have a joomla site and I was trying to setup a rotating image based on timing NOT just refreshing the page.
I found this code (i didn't write it) which works to load images but does not switch them with timing. Can someone help me so that it will rotate a new image from the folder every 8 seconds?
<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';
// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';
$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match('/.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
$files[] = $file; // it’s good
++$i;
}
}
}
closedir($handle); // We’re not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>
No comments posted yet
Your Answer:
Login to answer
245
5
Other forums
List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab
same querie, or a new one??
Hi guys,
I'm still working on this drop down list. I've got the actual drop down list to wor
Select question
Hi,
First I would like to say that php is pretty new for me..
so please don't shoot me if
xml
<?php
echo "<h1>XML Articles</h1>";
$home
What's wrong with my code
sobbing for many days, still don't know why please Help. Why my page isn't posted correctly. In a
Finding digits in variable containing text, and IDing them
$romanstock = "http://www.remoteprice.com/data.asp?storeid=123&itemcode=456&typ
Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co
MySQL Does not UPDATE- SQLString Problem
vb Syntax (Toggle Plain Text)
1.
SQL = "UPDATE sampletable SET column1 = 'C1sample1'"
my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they
Check Date/Time in PHP
What I need the code to check is that $reQuest is 24 hours in the past then return a time based on h