Ok, one of the most requests I get is a script for random signature images.
The second most frequent request I get is for random avatar images
Well lets cover the first one
As always this script can be downloaded here
Note for internode customers: if you’re using your node space it’s important to chmod 0755 you’ll need to check with your ftp client on how to do this. If you don’t you will get an ‘Internal Server Error’
One tip I can give you tho is to use the console ftp client included with windows to chmod after you’ve uploaded the file.
Example for Internode users
ftp users.on.netcd /pathtoscript/lit site chmod 0755 randomimage.phpThat should fix your ‘Internal Server Error’
<?php/* PHP Rotate 1.00 By Freman--------------------------------------------------Due to the large number of requests I get forthis (and similar) script, I'm making it availiblefor all to see and useConfiguration Options:$PathToImages = The path to your image filesExample:$PathToImages = "images/"*/$PathToImages='images/';// !!!!! Don't edit below here or I won't smack you.!!!!!// Open a directory object$Dir = dir($PathToImages) or die("Oops, it's broken - are you sure you've got the right PathToImages?\n");// Read the dirwhile (false !== ($DirEntry = $Dir->read())) {// Look for imagesif (preg_match('/\.(jpe?g|gif|png)$/',$DirEntry)) { // Keep track of the images we've found $Images[] = $DirEntry;}}// Get a random image$Image = $Images[array_rand($Images,1)];if ($fp = fopen("$PathToImages/$Image",'rb')) {// Helps to know how big the file is we want to read$FileSize = filesize("$PathToImages/$Image"); // Get the file extensionpreg_match('/\.(jpe?g|gif|png)$/',strtolower($Image),$Match);// Work out what our content type isif (in_array($Match[1],array('jpg','jpeg'))) { $ContentType = 'image/jpeg';} elseif (in_array($Match[1],array('gif','png'))) { $ContentType = 'image/'.$Match[1];}// Print out some headers to satisfy the browsersheader("Content-type: $ContentType");header("Content-length: $FileSize");// Print out some headers to keep the random image from being cachedheader("Cache-Control: no-cache, must-revalidate");header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");// Output our image (Long process huh)print fread($fp,$FileSize);// Always clean up after yourselffclose($fp);}?>Now to make it work as an avatar you need to trick apache into serving up your php script as a jpg/gif or png file due to the way the forums limit the extensions on files.
Best way to use this file is to make it htaccess.txt on your windows machine, upload it, then rename it to .htaccess
RewriteEngine onRewriteRule randomimage.jpg /~<YOUR USERNAME>/<PATH>/randomimage.php [L]Commenting is closed for this article.