1
BenG1
Random Images
  • 2004/9/25 17:13

  • BenG1

  • Just popping in

  • Posts: 16

  • Since: 2004/8/30


I was wondering if someone could help me out. I would like to be able to add a random image to the logo of xoops. I am using the <? include("filename.php") ?> in the themes "theme.html" file. But it doesn't work. I also made a test.html page and loaded the same script on that page. And it STILL wont load. Is there something I am doing wrong?

2
CiberEspia
Re: Random Images

use
<{php}> include("filename.php") <{/php}>



also this works:
I in my theme use a script logo_izquierdo.php:

<?php  

function rnd($min$max){//mt_rand wrapper, seeds automatically, once per page

    
global $rnd_seeded;

    if (
$rnd_seeded!=1){//seed if not seeded

        
$mtime=microtime();

        list(
$usec,$sec)=explode(" ",$mtime);

        
mt_srand($usec*$sec);

        
$rnd_seeded=1;

        }

    return 
mt_rand($min$max);

    }

    

$def_img_url="http://unruly.homeunix.net/images/misc/macos_x_ua.png";

    
//default image to redirect to if no images exist in random dir





//read folder 

$folder=opendir(".");



while (
$file readdir($folder)){

    
$ext=strtolower(substr(trim($file),-4));

    if (
$ext==".jpg"||$ext==".gif"||$ext=="jpeg"||$ext==".png")$imgs[]=$file;

}

closedir($folder); 



if (
is_array($imgs)){

    
header ("location: ".$imgs[rnd(0count($imgs)-1)]);

}else{

    
header ("location: $def_img_url");

}

?>

http://ciberespia.adictoshp.org/themes/ce6_/logo/logo_izquierdo.php
in my theme:
<img border="0" src="http://adictoshp.org/ciberespia/themes/ce6_/logo/logo_izquierdo.php" width="169" height="90">

Random Images upload in folder-> logo .
to see it work in www.ciberespia.com

3
evylrat
Re: Random Images
  • 2005/2/2 21:24

  • evylrat

  • Not too shy to talk

  • Posts: 164

  • Since: 2004/2/25


I would like to have a random THEME. I'd like to use a number of images from a particular set and have the page pick a SET at random.

Like;
header1.jpg, menu1.jpg and table1.jpg
OR
header2.jpg, menu2.jpg and table2.jpg

Can anyone give my a function that just assigns a random number to a variable to make this work?

4
evylrat
Re: Random Images
  • 2005/2/2 21:30

  • evylrat

  • Not too shy to talk

  • Posts: 164

  • Since: 2004/2/25


Found a perfectly good solution here

Login

Who's Online

225 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 225


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits