Advertisement:

Image Rotation?

Aloittaja ShadowStriker, kesäkuu 17, 2007, 02:03:22 IP

« edellinen - seuraava »

ShadowStriker

I have seen this before, but I don't know how they did it. I think they put a link to a folder (on the internet) or something with all their sigs in, and then every couple seconds (when you refresh) it switches sigs to a different one in that folder. How do you do this?

Alan S

Okay , heres how you do it.

Create a Php file named "random_image.php" with this code

<?php

// print a random image. Don't forget ending slash!
// setting $type to 'all' will return all images.

function getRandomImage($dir,$type='random')
{
global 
$errors,$seed;

if (
is_dir($dir)) {

$fd opendir($dir);
$images = array();

while ((
$part = @readdir($fd)) == true) {

if ( 
eregi("(gif|jpg|png|jpeg)$",$part) ) {
$images[] = $part;
}
}

// adding this in case you want to return the image array
if ($type == 'all') return $images;

if (
$seed !== true) {
mt_srand ((double) microtime() * 1000000);
$seed true;
}

$key mt_rand (0,sizeof($images)-1);

return 
$dir $images[$key];

} else {
$errors[] = $dir.' is not a directory';
return 
false;
}
}

?>



Create a folder on your site called something like "sigimages" and place it in there.

Then create another php file called "images.php" with this code

<?php
require_once("random_image.php");
$pic getRandomImage('path/to/images/');
?>



replace path/to/images/' with the path to the folder the images are in.

Place the "images.php" in the same folder as "random_image.php" and also place all your pictures in there.

Then in your bbc sig code use this code

[img]http://yoursite.com/sigimages/image.php[/img]


Obviously replace the  link to your image.php address.
Lainaus käyttäjältä: Eliana Tamerin - elokuu 23, 2008, 04:10:10 IP
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P



Alan S

Hmmm , Okay Give me a hour or so to get some personal stuff out of the way and then i'll look into it further.
Lainaus käyttäjältä: Eliana Tamerin - elokuu 23, 2008, 04:10:10 IP
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P


Alan S

Hmmm okay , I dont know what the problem is but a quick google search turned up this , Take a look

http://alistapart.com/articles/randomizer/
Lainaus käyttäjältä: Eliana Tamerin - elokuu 23, 2008, 04:10:10 IP
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P

Bulakbol

Lainaus käyttäjältä: Alan S - kesäkuu 21, 2007, 12:39:45 IP
Hmmm okay , I dont know what the problem is but a quick google search turned up this , Take a look

http://alistapart.com/articles/randomizer/

Thanks. I got this thing working. It's great.  ;)
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Advertisement: