I am getting a syntax error on this code. Can anyone help me? The error happens around line 60.
On this line:
<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Rotate</title>
<script src="http://www.1stnaz.com/js/dw_rotator.js" type="text/javascript"></script>
<script src="http://www.1stnaz.com/js/dw_random.js" type="text/javascript"></script>
<?php
$path_to_images = "http://www.1stnaz.com/images/Slides/"; // path to your images
$num_to_rotate = "ALL"; // number or "ALL" (to rotate all images in directory)
// returns string to echo into JavaScript images array
function getJSRandomized($path, $list, $num) {
$str = '"';
mt_srand( (double)microtime() * 1000000 );
shuffle($list);
if ( $num == "ALL" ) $num = count($list);
for ($i=0; $i<$num; $i++) {
$str .= $path . $list[$i] . '", "';
}
// remove last comma and space
$str = substr($str, 0, -3);
return $str;
}
function getImagesList($path) {
$ctr = 0;
if ( $img_dir = @opendir($path) ) {
while ( false !== ($img_file = readdir($img_dir)) ) {
// add checks for other image file types here, if you like
if ( preg_match("/(.GIF|.jpg)$/", $img_file) ) {
$images[$ctr] = $img_file;
$ctr++;
}
}
closedir($img_dir);
return $images;
} else {
return false;
}
}
?>
</head>
<body onload="dw_Rotator.start()">
<?php if ( $image_list = getImagesList($path_to_images) ) : ?>
<script type="text/javascript">
/*************************************************************************
This code is from Dynamic Web Coding at dyn-web.com
Copyright 2001-5 by Sharon Paine
See Terms of Use at dyn-web.com/bus/terms.html
regarding conditions under which you may use this code.
This notice must be retained in the code as is!
See full source code at dyn-web.com/scripts/rotate-rand/
*************************************************************************/
var imgList = [
<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>
];
var rotator1 = new dw_RandRotator(4000); // rotation speed
// images array, width and height of images, transition filter (boolean)
rotator1.setUpImage(imgList, 251, 188, true);
</script>
<?php else : ?>
<!-- image to display if directory listing fails -->
<img src="http://www.1stnaz.com/images/Slides/Slide0.jpg" width="252" height="127" alt="">
<script type="text/javascript">dw_Rotator.start = function() {};</script>
<?php endif; ?>
</body>
</html>