vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Rotate your logos (https://vborg.vbsupport.ru/showthread.php?t=38320)

Sparkz 05-06-2002 03:36 PM

Rotate your logos
 
This template mod randomly picks an image from a specified folder to be used as the forum logo.

In your phpinclude-template, add this code:
PHP Code:

$logos = array();
$logodir "images/";

function 
make_seed() {
    list(
$usec$sec) = explode(' 'microtime());
    return (float) 
$sec + ((float) $usec 100000);
}
srand(make_seed());

if (
$handle opendir($logodir)) {
    while (
false !== ($file readdir($handle))) { 
        if (
$file != "." && $file != "..") { 
            
array_push ($logos$logodir $file); 
        } 
    }
    
closedir($handle);
    
// $logo = rand(0, count ($logos));
    
$logo rand(0count ($logos) - 1); // Corrected a small bug
    
$titleimage $logos[$logo];


Change the value of $logodir to the directory where you have your logos.

and in your header-template, change { titleimage} to $titleimage

That should be it, really.

tkieffer 05-06-2002 07:43 PM

Thanks again Sparkz. It's installed and working great.

tkieffer 05-06-2002 07:55 PM

Hmm. I've noticed that it occasionally pushes a null to the client (img src=""). I'm thinking this could either be because the random function goes beyond the bounds of the array or the directory read is actually picking up a blank. I'm afraid to just go fooling around with coding languages I haven't learned yet so I'm going to stay away from modifying your code.

Please help.

Crazy Mofo 05-07-2002 01:26 AM

Nice but maybe need some work on it as when u refresh a few times a blank image wit the red cross appears ;)

Sparkz 05-07-2002 07:40 AM

Hmm, sorry about that.
Change
PHP Code:

$logo rand(0count ($logos)); 

to

PHP Code:

$logo rand(0count ($logos) - 1); 

Didn't check it properly before I posted, I guess :)

geniuscrew 05-07-2002 11:52 AM

You can also use DHTML by putting the code in the head bit :-/

Sparkz 05-07-2002 12:08 PM

There are probably tons of way to do this.
I just happen to know and like PHP, so that's why I chose to do it like this.

Sparkz 05-07-2002 12:09 PM

Besides, this saves bandwidth, as it is server side.

Using DHTML, you'd have to pass the whole list if images to the client, plus the code to actually do the pick which image to show.

Crazy Mofo 05-07-2002 03:39 PM

nice work sparkz very impressive :D

Crazy Mofo 05-07-2002 03:42 PM

well works like a charm i gave this 10 outta 10 m8 well done :) nice simple and very effective :D


All times are GMT. The time now is 02:30 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02216 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete