Got this slideshow script from a third party and made some modifcations to work with php 4.3. No php error has came up, but no "slideshow" images have come up. I'm still new to php stuff and I gather that the problem may lies with the glob function since it seems not sending the image paths to other functions to process the slideshow. Am I right?
In case the glob function is right, other functions below:Code:<?php // open the folder and locate the files end with .jpg $dh = glob( "blah/blah" ); $files = array(); foreach( $dh as $file ) { if ( preg_match( "/[.]jpg$/", $file ) ) $files []= "$file"; } ?>
html output:Code:<script> // list images var image_list = [ <?php $first = true; foreach( $files as $image ) { ?> <?php echo( $first ? "" : ", " ); ?>"<?php echo( $image ); ?>" <?php $first = false; } ?> ]; var curimage = 0; // grab and resize image function switchimg( ind ) { var image = image_list[ind]; var obj = document.getElementById( "selimg" ); obj.src = "scale.php?image="+image+"&y=230"; curimage = ind; } // next image function nextimage() { curimage++; if ( curimage >= image_list.length ) curimage = 0; switchimg( curimage ); } // timer window.setInterval( "nextimage()", 3000 ); </script>
scale.php:Code:<img id="selimg" height="230" src="scale.php?image=<?php echo($files[0]); ?>&y=230" />
Code:// get current image and resize <?php $image = $_GET["image"]; $maxy = $_GET["y"]; $im = @imagecreatefromjpeg( "blah/blah/".$image ); $curx = imagesx( $im ); $cury = imagesy( $im ); $ratio = $maxy / $cury; $newx = $curx * $ratio; $newy = $cury * $ratio; $oim = imagecreatetruecolor( $newx, $newy ); imageantialias( $oim, true ); imagecopyresized( $oim, $im, 0, 0, 0, 0, $newx, $newy, $curx, $cury ); header( "content-type: image/jpeg" ); imagejpeg( $oim ); ?>
jace





Bookmarks