You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 54 guest(s) and 0 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - Randomly rotate logo [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
dsnail2000
Site Admin
Site Admin


Joined: Mar 17, 2003
Posts: 331

Location: Northern VA

PostPosted: Sat Apr 12, 2003 1:03 pm Reply with quoteBack to top

I have 5 images that I want to randomly rotate as the logo and they are all the same size. The code as to go in the theme.php file. Does anybody know how to do this?
Find all posts by dsnail2000View user's profileSend private messageVisit poster's website
dsnail2000
Site Admin
Site Admin


Joined: Mar 17, 2003
Posts: 331

Location: Northern VA

PostPosted: Sat Apr 12, 2003 2:13 pm Reply with quoteBack to top

Code:
<?php

  //Edit this line to the url of your image folder to randomize
  //Must be a relative URL in your server, do not put in a forward
  //or trailing slash for it to work.
  $url='images/logos';
  //Stop editing, that is all. Call the image with <img src=url/filename.php> That's all, enjoy. :D

  $files=array();
  if ($handle=opendir("$url")) {
      while(false !== ($file = readdir($handle))) { 
      if ($file != "." && $file != "..") {
      if(substr($file,-3)=='gif' || substr($file,-3)=='jpg' || substr($file,-3)=='png' || substr($file,-3)=='bmp') $files[count($files)] = $file;
      }
      }
  }
  closedir($handle);

  $random=rand(0,count($files)-1);
  if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
  elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
  elseif(substr($files[$random],-3)=='png') header("Content-type: image/png");
  elseif(substr($files[$random],-3)=='bmp') header("Content-type: image/bmp");
  readfile("$url/$files[$random]");

?>


I can't figure out exactly where to put this code and how to make it work.
Find all posts by dsnail2000View user's profileSend private messageVisit poster's website
sixonetonoffun
Major
Major


Joined: Jan 13, 2003
Posts: 892


PostPosted: Sat Apr 12, 2003 2:21 pm Reply with quoteBack to top

Put your file in the includes directory then use the code as you posted. Replace the logo.gif with filename.php see if that works.
//Stop editing, that is all. Call the image with <img src=url/filename.php> That's all, enjoy. Very Happy

_________________
www.netflake.com
www.glowoptics.com
Find all posts by sixonetonoffunView user's profileSend private message
dsnail2000
Site Admin
Site Admin


Joined: Mar 17, 2003
Posts: 331

Location: Northern VA

PostPosted: Sat Apr 12, 2003 2:43 pm Reply with quoteBack to top

That didn't work, does anybody have any original code or code that they made work?

I want to be able to call a random image function from anywhere on the site, I would need to send the function the absolute URL of the images so it can choose the images from that directory.

ex: I call the function with the parameter of an absolute URL

the function then randomly chooses an image from that directory and sends back the file name and extension

Anybody know how to make an include file that will do this?

P.S. can this be called from inside an echo command?
Find all posts by dsnail2000View user's profileSend private messageVisit poster's website
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.183 Seconds - 282 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::