Shoutbox

Changing Avatars - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: General (/forumdisplay.php?fid=11)
+---- Forum: Forum & Website (/forumdisplay.php?fid=13)
+----- Thread: Changing Avatars (/showthread.php?tid=24264)

Changing Avatars by twobluestripes on 04-25-2004 at 09:53 PM

I noticed that some members have avatars that change each time the page is refreshed. I also saw a sig banner like this. I think this is really cool, and was wondering how it is done. Is it exclusive to higher up members? Or does it only work on this board? And is it like a code, for the sig banner? Let me know. :)


RE: Changing Avatars by .blade// on 04-25-2004 at 09:56 PM

It's a PHP code hsoted on a site other than the forums. There are some sites that offer changing sig.s and av.s for free off of their site, but members such as Keystorm coded their own.


RE: Changing Avatars by KeyStorm on 04-25-2004 at 10:10 PM

Yeah, right:

MPavatar.php: (with slight modifications)

code:
<?PHP
$pics["pic"] = array (
'avatar1.jpg',
'avatar2.jpg' ,
'avatar3.jpg'     //and so on
);

$pics["title"] = array (
'Bill Gates showing the latest Messenger Plus! Technologies',
'Vitto Corleone, the Godfather, proud of his MP! pin, as new member of the forum family',
'George W. Bush revealing the existance of evil code in MP! capable to destruct CIA\'s infrastructure'  //and so on
);


$pics["date"] = array (
'2004-01-17',
'2004-01-17',
'2004-01-19'    //and so on
);


$pics["author"] = array (
'KeyStorm' ,
'KeyStorm' ,
'KeyStorm'    //and so on
);




if($view=="gui"){
if(empty($i))$i=1;
$id=$i-1;

echo"
<html>
<head>
<title>KeyStorm's Dynamic Messenger Plus! Avatars - Showing $i of ".sizeof($pics["pic"])."</title>
</head>
<html>
<body bgcolor='#38688B' text='#CCCCCC'>
<basefont face='Geneva, Arial, Helvetica, sans-serif' color='#CCCCCC' size='2'>
<center>
<h2>
Keystorm's Messenger Plus! Dynamic Avatar Collection
</h2>
<h4>User Interface Environment</h4>
<hr>
<h3>Image $i of ".sizeof($pics["pic"])."</h3>
<br>
<img src='MPavatar.php?i=$i' alt='$pics[title][$id]'> 
<br><br>
Title: <b>".$pics[title][$id]."</b><br>
Author: <b>".$pics[author][$id]."</b><br>
Added: <b>".$pics[date][$id]."</b><br><br>
<hr>";

for($a=1;$a<=sizeof($pics["pic"]);$a++){
if($a==$i)echo "<font color=white>".($a)."</font> ";
else echo "<a href='MPavatar.php?view=gui&i=".($a)."' style='color:#CCCCCC; text-decoration:none'>".($a)."</a> ";
if($a!=sizeof($pics["pic"])) echo "| ";
}

echo "
<hr>
<font size=-1>
<b>Terms and Conditions:</b><br>
All images shown here are property of their respective authors (in this case: ".$pics[author][$id]."). You may freely use them under following conditions:<br>
Written permission of ".$pics[author][$id].", the author. (webmaster&nbsp;&part;&nbsp;keystorm&bull;net)<br>
Other terms and conditions will be notified thereafter.<br>
All images have a .psd (or equivalent) source-file that can prove the ownership of the image and the owner has therefore authority over it.

</font>

</center>
</body>
</html>
";


}else{
if(empty($i)) $i = time()%sizeof($pics["pic"]);
else $i--;
$filename = $pics["pic"][$i];

header ('Content-type: image/jpeg');
header( 'Content-Disposition: attachment; filename=avatar');
$f = fopen ($filename, 'rb');
fpassthru ($f); }

?>


This way I have a nice dynamic avatar when address is:  http://funmail.keystorm.net/MP!/MPavatar.php
And a nice GUI for browsing the avatars with comments, dates and authors when the address is:
http://funmail.keystorm.net/MP!/MPavatar.php?view=gui

Hope this helps all people wanting to have a dynamic avatar.
RE: Changing Avatars by twobluestripes on 04-25-2004 at 10:25 PM

oooooh...

fascinating. mind-boggling, but fascinating. I'm going to have to figure this out. so, is all that html there optional? and you can write the program in notepad and save it as a php to upload, right? gah, and i though cgi webforms were hard.


RE: Changing Avatars by KeyStorm on 04-25-2004 at 10:30 PM

right, you'll only have to change the data where I put "//and so on". There you can add more or leave less items. The HTML is for the GUI thing.
Without GUI it would be:

code:
<?PHP
$pics["pic"] = array (
'avatar1.jpg',
'avatar2.jpg' ,
'avatar3.jpg'     //and so on
);


if(empty($i)) $i = time()%sizeof($pics["pic"]);
else $i--;
$filename = $pics["pic"][$i];

header ('Content-type: image/jpeg');
header( 'Content-Disposition: attachment; filename=avatar');
$f = fopen ($filename, 'rb');
fpassthru ($f); }

?>

It's not exactly a webform, but it's CGI, though. I also though PHP was hard before :P.
RE: Changing Avatars by twobluestripes on 04-25-2004 at 10:35 PM

so can you use this kind of thing to say, have a random changing photo on a webpage? or a sig banner?


RE: Changing Avatars by KeyStorm on 04-25-2004 at 10:39 PM

A pseudo-randomly changing sig banner, yeah.
(It's pseudo, because it's virtually changed each milisecond)


RE: Changing Avatars by twobluestripes on 04-25-2004 at 10:49 PM

sorry, one last question: do all the pictures need to be the same size?


RE: Changing Avatars by .blade// on 04-25-2004 at 10:57 PM

No - it has nothing to do with the size or file size of the pictures.


RE: Changing Avatars by twobluestripes on 04-25-2004 at 11:14 PM

oh, shizzle, i got another question...i host my images on a seperate server than my other stuff...if i host the php on my server and put the full urls for my photobucket images, will it work? or do they all need to be on the same server? thanks mucho.


RE: Changing Avatars by lizard.boy on 04-25-2004 at 11:40 PM

full urls should work :)


RE: Changing Avatars by twobluestripes on 04-25-2004 at 11:59 PM

oh geeze, thanks you guys. you've been a big help. for some reason i can't get it to work. (i was trying it out on my sig)

i'll try again some other time. but thanks very much!


RE: Changing Avatars by bach_m on 04-26-2004 at 12:05 AM

u DO have PHP installed on the server, right?


RE: Changing Avatars by twobluestripes on 04-26-2004 at 12:08 AM

uh, i wouldn't know. i have a CGI bin, if that helps. i don't know hardly anything about my server. :S


RE: Changing Avatars by .blade// on 04-26-2004 at 12:38 AM

o.O
personaly owned server, free server, or paid server?


RE: Changing Avatars by twobluestripes on 04-26-2004 at 12:40 AM

uh, free bandwidth from my ISP, sonic.net


RE: Changing Avatars by bach_m on 04-26-2004 at 12:41 AM

upload this file to ur server and then access it through a web browser. what do u see?

[edit]

quote:
Originally posted by twobluestripes
uh, free bandwidth from my ISP, sonic.net


prolly not, then
RE: Changing Avatars by twobluestripes on 04-26-2004 at 12:43 AM

am i supposed to see something when i click on it?


RE: Changing Avatars by bach_m on 04-26-2004 at 12:46 AM

no. u need to right click and save it to ur cmputer. then upload it to ur ISPs web host. then access it from through ur webbrowser


RE: Changing Avatars by twobluestripes on 04-26-2004 at 01:07 AM

*sigh* I see white. I'm assuming that this means it's not installed. Can't say I didn't try.


RE: Changing Avatars by bach_m on 04-26-2004 at 01:27 AM

its wierd. u shudn't get white, u shud get giberish. what happened when u tried to run the changing image script?


RE: Changing Avatars by twobluestripes on 04-26-2004 at 01:34 AM

what do you mean "run"?


RE: Changing Avatars by KeyStorm on 04-26-2004 at 12:53 PM

To access it from your browser, like in http://funmail.keystorm.net/MP!/MPavatar.php ;)

Btw, if you store your images anywhere else, you might want to do a slight change to the script to avoid doeuble bandwidth usage.
The script as it is now avoids people to know what the real name of your single avatars is, ie avoids them to steal the pics (use them from your server).
The other way I suggest for if you are using another server to store the avatars is to create a redirecting script.

instead of:

code:
...

header ('Content-type: image/jpeg');
header( 'Content-Disposition: attachment; filename=avatar');
$f = fopen ($filename, 'rb');
fpassthru ($f); }
...

use:
code:
...
header("Location: http://www.example.com/exampledir/$filename");
...

Btw, I really don't know if this HTTP-header would open the URL in the whole browser or inside the script, because I never used it for that purpose :$. But you may try, nevertheless. :)