While I have been working on a server problem for another customer I came up with this little script for rotating content on that bulletin board I previously posted about. The customer has decided to stick with powerpoint because he knows powerpoint but I went ahead and made this anyhow.
<?php
// auto refresh page every 10 seconds
header("Refresh: 10;");
// init variables
$content="";
$contentcount=0;
// read directory for htm and html files
$dir_handle = @opendir(".") or die("Unable to open .");
while (false !== ($file = readdir($dir_handle))) {
if (preg_match('@().htm(l)?$@',$file)) {
$content = $content . "," . $file;
++$contentcount;
}
}
closedir($dir_handle);
// convert file list into array
$test = preg_split('/[,]/',$content, -1, PREG_SPLIT_NO_EMPTY);
// grab contents of a random file from the array
$page = file_get_contents($test[(rand()%$contentcount)]);
// echo the contents of the file to the browser
echo "$page";
?>
I am showing the content that I used to test the script. To make it easier you have to run the script in the directory with the files that you want to rotate through but using some preg_replace and whatnot you could technically make any directory work. I also tested it with using pages saved by firefox and it works just fine. so you can either put in your own html files or use firefox, etc and save a page to the directory and it will host them up just as well. Very simple script and I put the comments in there to explain what all it was doing. enjoy.

Current Mood: tired