vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   randomizing images (https://vborg.vbsupport.ru/showthread.php?t=74296)

AN-net 01-13-2005 01:58 AM

randomizing images
 
it seems that my code will randomize if i run the the script through the browser but it doesnt randomize if i put it in an image page
HTML Code:

<img src="$vboptions[bburl]/banners.php" />
and

the code is:
PHP Code:

<?php 
$img
= array();
$img[] = "banner1.gif"
$img[] = "banner2.gif"
$img[] = "banner3.gif";
$img[] = "banner4.gif";
$img[] = "banner5.gif";
$img[] = "banner6.gif";
$img[] = "banner7.gif";
$img[] = "banner8.gif";
$img[] = "banner9.gif";
$dir "http://dev.animationation.net/images/banners/";
$rand rand(0count($img) - 1); 
$img $img["$rand"]; 
header("Location: $dir$img");
?>


cinq 01-13-2005 02:24 AM

PHP Code:

header("Location: $dir.$img"); 


AN-net 01-13-2005 02:48 AM

that didnt work...

cinq 01-13-2005 03:01 AM

Why not do this :

in your code :
PHP Code:

<?php
$img
= array();
$img[] = "banner1.gif";
$img[] = "banner2.gif";
$img[] = "banner3.gif";
$img[] = "banner4.gif";
$img[] = "banner5.gif";
$img[] = "banner6.gif";
$img[] = "banner7.gif";
$img[] = "banner8.gif";
$img[] = "banner9.gif";
$dir "http://dev.animationation.net/images/banners/";
$rand rand(0count($img) - 1);
$img $img["$rand"];
$path "<img src=\"".$dir.$img."\">";
?>

The above is the banner.php file.

Then use an include in your main page you want to show the banner in :
PHP Code:

include('./banner.php'); 

and place :
PHP Code:

echo $path

whereever u want it to show.

rake 01-13-2005 06:29 AM

That's the wrong way to do it. You need to read the file data, set some header information and then echo it out. Look at attachment.php for an example.

deathemperor 01-13-2005 11:56 AM

if you had

HTML Code:

<img src="$vboptions[bburl]/banners.php" />
then why would you need
HTML Code:

$dir = "http://dev.animationation.net/images/banners/";
in the random script ? I mean the url for the images' location.

and if you use it in vb3 why don't we use a template ?

and (yes, and T_T) why not mt_rand ?

AN-net 01-13-2005 08:26 PM

it outputs the image but it doesnt change the image unless i visit the script directly.

my current code is:
PHP Code:

<?php 
$img
= array();
$img[] = "banner1.gif"
$img[] = "banner2.gif"
$img[] = "banner3.gif";
$img[] = "banner4.gif";
$img[] = "banner5.gif";
$img[] = "banner6.gif";
$img[] = "banner7.gif";
$img[] = "banner8.gif";
$img[] = "banner9.gif";
$img[] = "banner10.gif";
$dir "http://dev.animationation.net/images/banners/";
$rand mt_rand(0count($img));
$randimg $dir;
$randimg .= $img["$rand"]; 
header('Content-type: image/gif');
header('Location: '.$randimg.'');
?>



All times are GMT. The time now is 03:08 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.01608 seconds
  • Memory Usage 1,744KB
  • 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_html_printable
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete