2012-01-25, 07:02 PM
I've gone over this what seems like a million times. I'm using the Alphagaming skin on my boards, and I'm trying to get the #mainpic to randomize the banners I have upon page changes or refreshes.
I've tried javascripting it in, but that puts the images above the div table messing everything up.
Then I tried going with a PHP file and it comes up blank. I think the PHP is my best option but I'm not sure what I'm missing...here is the code I'm using...oh and I even made the PHP so it has 755 permissions on the server side.
PHP
And for the #mainpic I'm simply changing the background to: url(/images/alphagaming/banners/random.php)
If anyone has any hint, tricks, thoughts about what I'm doing wrong please let me know.
I've tried javascripting it in, but that puts the images above the div table messing everything up.
Then I tried going with a PHP file and it comes up blank. I think the PHP is my best option but I'm not sure what I'm missing...here is the code I'm using...oh and I even made the PHP so it has 755 permissions on the server side.
PHP
<?php
$folder = '.';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?>
And for the #mainpic I'm simply changing the background to: url(/images/alphagaming/banners/random.php)
If anyone has any hint, tricks, thoughts about what I'm doing wrong please let me know.