Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing avatar script
#1
Found it on the net,just wanted to share

PHP Code:
<?php
/*
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.
Example:
http://www.fungifun.org/rotate/avatar.php/example.jpg

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']));
if(
$filetype != "jpg" && $filetype != "gif" && $filetype != "png") exit;
if (
$handle opendir('.')) {
   while (
false !== ($file readdir($handle))) {
       if (
$file != "." && $file != ".." && stristr($file".".$filetype)) $files[]=$file;
   }
   
closedir($handle);
}
if (
$files) {
    
$imagenr rand(0sizeof($files)-1);
    if(
$filetype == "jpg"$filetype "jpeg";
    
$fp fopen($files[$imagenr], 'rb');
    
header("Content-Type: image/$filetype");
    
header("Content-Length: " filesize($files[$imagenr]));
    
fpassthru($fp);
    exit;
}
?>
Reply


Messages In This Thread
Changing avatar script - by Brainless Control - 12-19-2009, 10:09 AM
RE: Changing avatar script - by Gaijin - 01-14-2010, 05:39 AM
RE: Changing avatar script - by Drake™ - 04-05-2010, 01:26 PM
RE: Changing avatar script - by burnt - 04-05-2010, 01:30 PM
RE: Changing avatar script - by Drake™ - 04-05-2010, 01:31 PM
RE: Changing avatar script - by Nyx- - 04-05-2010, 02:21 PM
RE: Changing avatar script - by Drake™ - 04-05-2010, 02:24 PM
RE: Changing avatar script - by Nyx- - 04-05-2010, 02:31 PM
RE: Changing avatar script - by Drake™ - 04-05-2010, 02:34 PM
RE: Changing avatar script - by Support - 04-05-2010, 01:32 PM
RE: Changing avatar script - by Kewlz - 04-06-2010, 07:51 AM
RE: Changing avatar script - by php - 04-06-2010, 08:22 AM
RE: Changing avatar script - by Kewlz - 04-06-2010, 08:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  php form script with upload script help andrewjs18 4 2,872 10-07-2010, 11:46 AM
Last Post: JMK940

Forum Jump:


Users browsing this thread: 1 Guest(s)