MyBB Community Forums

Full Version: DenisTT, how do u make a .php like that?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, DenisTT.

i like ur signature.
but i don't know how to make one like yours, always chaging pictures.

would u like to tell us about it?

i wonder what the php script looks like.

Thanks you,
Your MyBB fan
^^
Thanks for your compliment.

It's just a script that outputs a different image each time the script is loaded. That's all I'll say about it Smile
I've seen people do this before, it's pretty cool. Smile
<?php
srand ((float) microtime() * 10000000);
$images = array('./sig0.jpg', './sig1.jpg', './sig2.jpg', './sig3.jpg', './sig4.jpg', './sig5.jpg', './sig6.jpg');
$rand_image = array_rand($images);

header('Content-type: image/jpeg');
readfile($images["$rand_image"]);
?>
<?php
/*
 * http://www.syridium.com/
 */

/*
 * NOTES.
 * 1. Image extension Must relate to the image type.
 * 2. Images must not have a period in the filename (except to identify the extension)
 */

// Image directory.
$cImgDir = './images/'; 

// Image Array.
$images = array (
	'sig3.png',
	'dg345345.png',
);

// Random Image.
$imgCount = count($images);
$imgNo = rand(0, ($imgCount - 1));
$imgFile = $images[$imgNo];

// Image type.
$imgTypeEx = explode('.', $imgFile);
$imageType = strtolower($imgTypeEx[1]);

// Image file.
$imgContents = @file_get_contents($cImgDir.$imgFile);

// Header.
header('Content-type: image/'.$imageType);

// Output.
echo $imgContents;
?>
Well that's basically it, except mine has a bit more stuff (sync with avatar, and dynamic text generation) Wink
hello there, use the attached file, it is actually easier than any of the previous, you are only requested to upload it somewhere(./dyn/image.php) then create a folder with all the images in the same directory as the php file (./dyn/imgs).

it works for both avatars and signatures

$pic = "$folderdir/$final"; 
return $pic;

That just returns the filename. I think you need to do fpassthru/readfile or something like that Smile
You need to use img tags, and the php file as the source.

$folderdir has the path for the images folder.
$final has the file name.

So you you will get something like ./sig/one.jpg

When using it on an external server, you will need to put the full upper path.

However for the fpassthru, i guess it worth a try.
regards