Recent Changes - Search:

Presto 23-Quart Pressure Cooker/Canner Hoffman Vermiculite Kerr 0500 wide mouth mason jar half pint, 8oz Brown Rice Flour Mushroom Cultivator: A Practical Guide to Growing Mushrooms at Home Growing Gourmet and Medicinal Mushrooms Mycelium Running: How Mushrooms Can Help Save the World
Random avatar script

Random avatar script

This script chooses a random image out of all the images in the directory where the script resides, and displays it.

The result is a different image on every reload.

The image in the right is generated this way, its URL is

Script source and directions:

////// script source start //////

How to use:
1. Place suitable images in the same folder as the script resides.
The images should have a .jpg, .gif or a .png ending.

2. Copy the source of this script in a textfile, rename it avatar.php
(or any other name, as you please) and save it in the same directory as the images.

3. Call the script by appending a random name with the filetype ending.

avatar.php is the name of the script

example.jpg is a random name, you could also use asasd.jpg or qwfpoa.jpg, the name doesn't matter,
what is important is the ending. The ending determines which files from the folder are used.
So, if you use example.gif, then the gif files in this folder will be used.

$filetype end(explode(".",$_SERVER['REQUEST_URI']));
$filetype != "jpg" && $filetype != "gif" && $filetype != "png") exit;
if (
$handle opendir('.')) {
   while (
false !== ($file readdir($handle))) {
       if (
$file != "." && $file != ".." && stristr($file".".$filetype)) $files[]=$file;
if (
$files) {
$imagenr rand(0sizeof($files)-1);
$filetype == "jpg"$filetype "jpeg";
$fp fopen($files[$imagenr], 'rb');
header("Content-Type: image/$filetype");
header("Content-Length: " filesize($files[$imagenr]));

////// script source end //////

1 vistors are currently browsing this page, 14 total.

Edit - History - Print - Recent Changes - Search
Page last modified on April 15, 2008, at 03:48 PM