Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-2006, 10:38 PM
ShortCircuit ShortCircuit is offline
Learning Programmer
 
Join Date: Jun 2006
Posts: 34
Rep Power: 9
ShortCircuit is on a distinguished road
Default PHP Image rotation

My client wants some images on their site that rotate, to keep the site looking fresh.
I was going to use javascript but I dont like it and want to use PHP but unsure where to really start with a script like this.

Is it simple to build?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-24-2006, 11:30 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

here is a script that i made as a sig rotator...it does exactly what you want done.

Notes:
1) Make sure you change the image directory in the script.
2) Make sure you use the php script as the image... <img src="banner_rotator.php"></img>
3) i havnt used it in a while, so im not sure if this is even the right script, but give it a try and see if it works.

PHP Code:
<?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( 
$extListstrtolower$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( 
$extListstrtolower$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 (100100)
           or die (
"Cannot initialize new GD image stream");
       
$background_color imagecolorallocate ($im255255255);
       
$text_color imagecolorallocate ($im0,0,0);
       
imagestring ($im255,  "IMAGE ERROR"$text_color);
       
imagepng ($im);
       
imagedestroy($im);
   }
}

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-26-2006, 09:20 PM
ShortCircuit ShortCircuit is offline
Learning Programmer
 
Join Date: Jun 2006
Posts: 34
Rep Power: 9
ShortCircuit is on a distinguished road
Default

Thanks, I take it this script will pull all images from a directory rather than me having to go in and manually type in each file name?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-29-2006, 09:42 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

yes
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-06-2006, 01:45 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

Nice script. I may use this once I develop one for one of my websites.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 4 end of life announcement Jordan Programming News 4 08-30-2007 10:55 AM
PHP Image NeedHelp JavaScript and CSS 1 04-20-2007 10:00 AM


All times are GMT -5. The time now is 05:27 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads