Free web development scripts for the webmasterDevelopment Scripts


 
 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 5 users online
 o Most users online: 67
 o Home
  o PHP
   o Random
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o OxyScripts
 o Wedding Vendor Directory
 o Free Online Invoices
 o designplace
 o Free Wedding Websites

Random Signatures/Avatars (Rated 5)

Description:

This will pick a random image (GIF) from a directory, and display it to the browser.
Its good for having a rolling signature that changes each time you load up the page.
In vBulletin you could call it like this
[IMG]http://www.yourserver/signature.php[/IMG]
Where you called the file below signature.php

Code starts here


<?php
Header
("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
Header("Pragma: no-cache");
Header("Content-Type: image/gif");
// Header info, forces no cache and image type of GIF

$dir = "sigs" ; // Define the subdirectory to where we store the images..

srand((double)microtime()*1000000); // Set a random seed up
$i = 0; // Set our counter to 0
$dirHandle = opendir($dir); // Open the images directory
while(($im = readdir($dirHandle))) // Read in image filenames
{
if(
$im != ".." && $im != ".") // Don't read in the 2 directories ".." and "."
{
$image[$i] = $im; // Add that image filename to the array
$i++; // Increment our counter
}
}
closedir($dirHandle); // Close the directory handle
$n = rand(0,(count($image)-1)); // Create a random number from 0 to the size of the array

if(!readfile($dir."/".$image[$n])) // Read in a file and output it to the output buffer..
readfile($dir."error/error.gif"); // If we can't for some reason use the error.gif file in the error directory
?>


Submitted by Devscripts on 13-02-2003 23:34


Rate This Script

User Contributed Comments

Registered Members login
© Copyright 2003 - Devscripts.net