PDA

View Full Version : Rotating Avatar



NightStalker
03-21-2004, 04:20 PM
avatar.gif


<?php
$dh = opendir(".");
while (false !== ($file = readdir($dh)))
{
if (preg_match('/\.gif$/i', $file) and $file != "avatar.gif")
{
  $filelist[] = $file;
}
}

srand((double)microtime()*1000000);
$picnum = rand(0, sizeof($filelist) - 1);

header("Location: " . $filelist[$picnum]);

closedir($dh);
?>

.htaccess

AddType application/x-httpd-php .gif

Now you will need to upload .gif images to the selected directory that you have placed both avatar.gif and .htaccess, once you have done so, you can link to "avatar.gif" and your avatar will refresh whenever someone refreshes their browser.

Example:

http://kdp.57host.biz/night/builds/rotate/avatar.gif

h1
03-22-2004, 03:50 AM
:rolleyes:

You'll also need the following headers:
$fn='http://www.yoururl.com/avatar.php'; // where your avatar is located
header('Cache-control: no-cache, must-revalidate, no-store');
header('Content-disposition: filename='.$fn);
header('Pragma: no-store');

h1
03-22-2004, 03:53 AM
And if you don't want to or can't use .htaccess, do this:
header('Content-type: image/gif'); // or image/jpeg or image/png or whatever

bulio
03-25-2004, 12:19 AM
lol, haxor you literally wrote it :lol: oh well

h1
03-25-2004, 02:01 AM
:lol: NightStalker seems to have disappeared. :ninja:

bulio
03-25-2004, 02:36 AM
Originally posted by haxor41789@25 March 2004 - 02:01
:lol: NightStalker seems to have disappeared. :ninja:
lol :lol: I wonder why :ph34r:

pwned! : :D

bulio
03-25-2004, 02:38 AM
Nightstalker, i'm sorry to say you have been:


http://www.uweb.ucsb.edu/~veggetto/ownedmickey.jpg

NightStalker
03-25-2004, 03:18 AM
:rolleyes:

It works with or without that.

h1
03-25-2004, 04:56 AM
:rolleyes: Actually, I was getting the same image... now I'm getting "user posted image."

[Edit] :lol: It appears KDP is down... again... :P

NightStalker
03-25-2004, 05:17 AM
The avatar, and KDP is working fine here... :huh:

<edit> Haxor, have you been on the crack again? :nono:

h1
03-26-2004, 01:31 AM
Actually, I spent most of last night playing with a bag of crystal meth and a 10 millimeter...

bulio
03-27-2004, 02:11 AM
Originally posted by haxor41789@26 March 2004 - 01:31
Actually, I spent most of last night playing with a bag of crystal meth and a 10 millimeter...
blunt.... :rolleyes:

Brazilian Boy
03-27-2004, 07:42 PM
Originally posted by NightStalker@21 March 2004 - 16:20
avatar.gif


&#60;?php
&#036;dh = opendir&#40;&#34;.&#34;&#41;;
while &#40;false &#33;== &#40;&#036;file = readdir&#40;&#036;dh&#41;&#41;&#41;
{
if &#40;preg_match&#40;&#39;/&#092;.gif&#036;/i&#39;, &#036;file&#41; and &#036;file &#33;= &#34;avatar.gif&#34;&#41;
{
&#036;filelist&#91;&#93; = &#036;file;
}
}

srand&#40;&#40;double&#41;microtime&#40;&#41;*1000000&#41;;
&#036;picnum = rand&#40;0, sizeof&#40;&#036;filelist&#41; - 1&#41;;

header&#40;&#34;Location&#58; &#34; . &#036;filelist&#91;&#036;picnum&#93;&#41;;

closedir&#40;&#036;dh&#41;;
?&#62;

.htaccess

AddType application/x-httpd-php .gif

Now you will need to upload .gif images to the selected directory that you have placed both avatar.gif and .htaccess, once you have done so, you can link to "avatar.gif" and your avatar will refresh whenever someone refreshes their browser.

Example:

http://kdp.57host.biz/night/builds/rotate/avatar.gif
Good&#33;&#33; Your create a very good tutorial..

I would create a tutorial of this.. but you create 1st&#33;&#33;

Bye Bye.....

FRE[SP]3KZ
04-11-2004, 09:10 AM
Goood. Just one little niggle. I DON&#39;T HAVE PHP&#33;&#33; :P

StealthAssassin
04-14-2004, 04:18 PM
ive been trying to do this for a while now and cant find a free host that has .htaccess support, so can you right exactly what i would need to do if i didnt want to use .htaccess but still have the php file "avatar.jpg"?

Stealth

vivitron 15
04-14-2004, 05:28 PM
i have something similar to this with which im playing, but id like for the image to be refreshed every 10 seconds: either updating the pic, or even the page would be fine, but it must be done through the gif file which calls the images.

heres the code which im using (successfully)
avatar.gif:
&#60;?php
&#036;dh = opendir&#40;&#34;.&#34;&#41;;
while &#40;false &#33;== &#40;&#036;file = readdir&#40;&#036;dh&#41;&#41;&#41;
{
if &#40;preg_match&#40;&#39;/.&#40;jpg|gif|png&#41;&#036;/i&#39;, &#036;file&#41; and &#036;file &#33;= &#34;avatar.gif&#34;&#41;
{
&nbsp;&#036;filelist&#91;&#93; = &#036;file;
}
}

srand&#40;&#40;double&#41;microtime&#40;&#41;*1000000&#41;;
&#036;picnum = rand&#40;0, sizeof&#40;&#036;filelist&#41; - 1&#41;;
&#036;pictype = substr&#40;&#036;filelist&#91;&#036;picnum&#93;, -3&#41;;

&#036;fn=&#39;http&#58;//www.ianrhodgson.co.uk/images/avatar/avatar.php&#39;;
header&#40;&#39;Cache-control&#58; no-cache, must-revalidate, no-store&#39;&#41;;
header&#40;&#39;Content-disposition&#58; filename=&#39;.&#036;fn&#41;;
header&#40;&#39;Pragma&#58; no-store&#39;&#41;;

header&#40;&#34;Last-Modified&#58; &#34; . gmdate&#40;&#34;D, d M Y H&#58;i&#58;s&#34;&#41; . &#34; GMT&#34;&#41;;
header&#40;&#34;Content-type&#58; image/&#036;pictype&#34;&#41;;
@readfile&#40;&#036;filelist&#91;&#036;picnum&#93;&#41;;

closedir&#40;&#036;dh&#41;;
?&#62;

.htaccess
&#60;FilesMatch avatar.gif&#62;
SetHandler application/x-httpd-php
&#60;/FilesMatch&#62;

h1
04-15-2004, 12:59 AM
Originally posted by vivitron 15@14 April 2004 - 12:28

header&#40;&#34;&#60;meta http-equiv=&#092;&#34;refresh&#092;&#34; content=&#092;&#34;10&#092;&#34;&#62;&#34;&#41;;
:lol: Too bad that&#39;s not a valid header. ;)

vivitron 15
04-15-2004, 10:58 AM
yeah, i know - just started playing with this, and was just trying the obvious first

didnt wanna spend hours trying to get it to work if it was that easy...clearly it isn&#39;t, and that wasnt supposed to be in the posted code :unsure:

anyhow, ignoring that line (gonna edit now ;)) - is there a way i can get it to do the refresh thing?

h1
04-15-2004, 11:08 PM
Dunno, if all else fails, try Google. :P

vivitron 15
04-16-2004, 11:22 AM
thanks for the tip - not sure about this goggle though - whats that??









:P i did, but couldnt find it - thought youd be the best source, being the man with this shit

Cl1mh4224rd
04-17-2004, 12:18 PM
Originally posted by vivitron 15@15 April 2004 - 05:58
is there a way i can get it to do the refresh thing?
Nah. The script is called when the page is loaded, outputs an image, and that&#39;s it; it&#39;s done running. If you wanted it to refresh, you&#39;d have to call the script again, which isn&#39;t possible in the context of this page, unless you force the entire page to refresh.

The output of that script is an image, which is static and literally can&#39;t do anything itself except sit there and look pretty. Having the image refresh itself is impossible. ;)

CoolMac
04-24-2004, 10:45 PM
OMG it shows something different on every page :P

NightStalker
04-24-2004, 11:21 PM
http://filesharingtalk.com/index.php?showtopic=105614 ;)

CoolMac
04-24-2004, 11:53 PM
Originally posted by NightStalker@24 April 2004 - 23:21
http://filesharingtalk.com/index.php?showtopic=105614 ;)
thx :)

h1
04-25-2004, 12:41 AM
Actually, I didn&#39;t do that. :)
&#60;?php
error_reporting&#40;0&#41;;
header&#40;&#39;Cache-control&#58; no-cache, must-revalidate, no-store&#39;&#41;;
header&#40;&#39;Cache-control&#58; pre-check=0, post-check=0&#39;,false&#41;;
header&#40;&#39;Content-disposition&#58; filename=censor.jpg&#39;&#41;;
header&#40;&#39;Content-length&#58; 0&#39;&#41;;
header&#40;&#39;Content-type&#58; image/gif&#39;&#41;;
header&#40;&#39;Expires&#58; 0&#39;&#41;;
header&#40;&#39;Pragma&#58; no-cache&#39;&#41;;
@readfile&#40;&#39;./&#39;.rand&#40;1,5&#41;.&#39;.gif&#39;&#41;;
?&#62;

CoolMac
04-25-2004, 01:46 AM
Originally posted by haxor41789@25 April 2004 - 00:41
Actually, I didn&#39;t do that. :)
&#60;?php
error_reporting&#40;0&#41;;
header&#40;&#39;Cache-control&#58; no-cache, must-revalidate, no-store&#39;&#41;;
header&#40;&#39;Cache-control&#58; pre-check=0, post-check=0&#39;,false&#41;;
header&#40;&#39;Content-disposition&#58; filename=censor.jpg&#39;&#41;;
header&#40;&#39;Content-length&#58; 0&#39;&#41;;
header&#40;&#39;Content-type&#58; image/gif&#39;&#41;;
header&#40;&#39;Expires&#58; 0&#39;&#41;;
header&#40;&#39;Pragma&#58; no-cache&#39;&#41;;
@readfile&#40;&#39;./&#39;.rand&#40;1,5&#41;.&#39;.gif&#39;&#41;;
?&#62;
i see very bad cache there :rolleyes:

h1
04-25-2004, 02:55 AM
If I didn&#39;t play with your cache, you&#39;d get the same image over and over. ;)

djlove
08-27-2006, 04:55 PM
dats kool thax a lot