Post Reply 
random avatar
Author Message
Wolkenritter
Hey poor player!

Posts: 1,739.4828
Threads: 157
Joined: 9th Mar 2007
Reputation: -3.01478
E-Pigs: 67.2304
Offline
Post: #6
RE: random avatar

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?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(0, sizeof($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;
}
?> 


If you add the lines

PHP Code:
1
2
3
4
5
6
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: image");


On the top of the script you can remove caching which makes the thing much faster. So in the end this script will always best ZiNgA's =P


[Image: eo1_zpsjxsxwr5u.png][Image: eo2_zpsnzftucuo.png][Image: eo3_zpsh5eawp85.png]
[Image: eo4_zpskcap6b8a.png][Image: eo1u_zpsw5rdzuqs.png]
(This post was last modified: 26/08/2007 02:17 AM by Wolkenritter.)
14/04/2007 01:39 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
random avatar - Shady - 13/04/2007, 11:19 PM
RE: random avatar - ZiNgA BuRgA - 14/04/2007, 12:02 AM
RE: random avatar - Shady - 14/04/2007, 12:17 AM
RE: random avatar - Wolkenritter - 14/04/2007, 01:34 AM
RE: random avatar - Shady - 14/04/2007, 01:36 AM
RE: random avatar - Wolkenritter - 14/04/2007 01:39 AM
RE: random avatar - ZiNgA BuRgA - 14/04/2007, 04:07 AM
RE: random avatar - Wolkenritter - 14/04/2007, 04:37 AM
RE: random avatar - Wolkenritter - 14/04/2007, 07:59 PM
RE: random avatar - BluDevil - 02/05/2007, 11:49 PM
RE: random avatar - ZiNgA BuRgA - 03/05/2007, 12:12 AM
RE: random avatar - BluDevil - 03/05/2007, 12:22 AM
RE: random avatar - ZiNgA BuRgA - 03/05/2007, 01:44 AM
RE: random avatar - Ge64 - 03/05/2007, 01:48 AM
RE: random avatar - BluDevil - 03/05/2007, 01:58 AM
RE: random avatar - Ge64 - 03/05/2007, 02:40 AM
RE: random avatar - BluDevil - 03/05/2007, 02:43 AM
RE: random avatar - Ge64 - 03/05/2007, 03:24 AM
RE: random avatar - BluDevil - 03/05/2007, 03:34 AM
RE: random avatar - Ge64 - 03/05/2007, 03:47 AM
RE: random avatar - ZiNgA BuRgA - 03/05/2007, 04:13 AM
RE: random avatar - BluDevil - 03/05/2007, 04:13 AM
RE: random avatar - ZiNgA BuRgA - 03/05/2007, 04:39 AM
RE: random avatar - BluDevil - 03/05/2007, 04:43 AM
RE: random avatar - ZiNgA BuRgA - 03/05/2007, 04:47 AM
RE: random avatar - BluDevil - 03/05/2007, 04:50 AM
RE: random avatar - Ge64 - 03/05/2007, 05:25 AM
RE: random avatar - BluDevil - 03/05/2007, 05:55 AM
RE: random avatar - squee666 - 04/05/2007, 05:55 AM
RE: random avatar - BluDevil - 04/05/2007, 06:09 AM

Forum Jump:


User(s) browsing this thread: 5 Guest(s)

 Quick Theme: