Alicia MX Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Tutorial on how to make your avatar rotate using php.

2 posters

Go down

Tutorial on how to make your avatar rotate using php. Empty Tutorial on how to make your avatar rotate using php.

Post  BeastInRepose Sat Feb 23, 2008 1:00 pm

I haven't a clue if i'm posting this in the right place, but I thought some people might be interested in this.

You might have noticed that my avatars changes each time the page loads. Refresh now and you'll see it change Very Happy At the moment they're all random, i'll get around to making a matching set when I get around to it. To make this work you'll need a host that supports php to upload a file to. I suggest http://ripway.com if you don't already have a host.

Firstly create a folder with the icons you want to use in it. Name this folder whatever you want. My folder is called faves. Then upload this folder to your sever. For example, I uploaded mine to http://thinkyouneedtosmile.net/icon/categories/fave/.

Next create a text file and save it as FILENAME.php. Change filename to whatever you want, but make sure it ends in .php NOT .html or .tx. Paste in the following code:

Code:
<?php
$dir = '.'; // '.' means: the current directory this script resides
$array = array(); // nothing

mt_srand((double)microtime()*1000000);
$handle = opendir($dir);

while (false !== ($file = readdir($handle))) {
$extention = strtolower(substr(strrchr($file,"."),1));
if($extention == 'jpg' || $extention == 'jpeg' || $extention == 'jpe' || $extention == 'gif' || $extention == 'png' || $extention ==
'bmp'){
$array[] = $file;
}
}

$count = count($array);
$num = mt_rand(0, ($count-1));

if($count > 0){
$size = getimagesize($array[$num]);
$stream = fopen($dir.'/'.$array[$num], "rb");
if($size && $stream){
header("Content-type: ".$size['mime']);
fpassthru($stream); //fpassthru closes the stream by itself
exit();
}
}else{
echo 'no images';
}
?>

Upload this file to your icons folder you made before. So mine would be uploaded to thinkyouneedtosmile.net/icon/categories/fave.

Now click on profile, click the sub tab avatar and in the Link to off-site Avatar box paste in the URL of your php file. So if your folder URL is http://h1.badwaresite.www/YOURUSERNAME/icons and you named the file avatar.php, paste in http://h1.badwaresite.www/YOURUSERNAME/icons/avatar.php.

I hope this all made sense, if it didn't just reply and i'll help.
BeastInRepose
BeastInRepose

Posts : 13
Join date : 2008-02-23
Age : 32
Location : Leeds

http://thinkyouneedtosmile.net

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  Admin Cullen Sat Feb 23, 2008 1:06 pm

wow that's awsome!!! As soon as I have a few minutes I'll try that!!

This is awsome I didn't even know this was possible!

This is soo cool!

So this works for avatars but then would it work for a signature for exemple?
Admin Cullen
Admin Cullen
Admin

Posts : 37
Join date : 2008-01-02
Age : 35
Location : In Edward's arms ... DO NOT DISTURB

http://aliciamx.site.voila.fr

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  BeastInRepose Sat Feb 23, 2008 1:12 pm

I've never tried it, but think it would work. Use <img src="FILEURL">, just like you would if it was a graphic.
BeastInRepose
BeastInRepose

Posts : 13
Join date : 2008-02-23
Age : 32
Location : Leeds

http://thinkyouneedtosmile.net

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  Admin Cullen Sat Feb 23, 2008 1:17 pm

right now I'm doing a hundred things at the same time but as soon as I can I'll try it.

That would be wicked if it was working for the signature too :d

Thanks again for posting the code!

Where do you find codes like that?
Admin Cullen
Admin Cullen
Admin

Posts : 37
Join date : 2008-01-02
Age : 35
Location : In Edward's arms ... DO NOT DISTURB

http://aliciamx.site.voila.fr

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  BeastInRepose Sat Feb 23, 2008 1:17 pm

I saved that one about a year ago when I wanted to try and modifiy it to randomnise CSS. I'm not too sure about where its from Question
BeastInRepose
BeastInRepose

Posts : 13
Join date : 2008-02-23
Age : 32
Location : Leeds

http://thinkyouneedtosmile.net

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  Admin Cullen Sat Feb 23, 2008 1:21 pm

That's ok, I'll try to find stuffs like that. Maybe I'll find some interesting things.
Admin Cullen
Admin Cullen
Admin

Posts : 37
Join date : 2008-01-02
Age : 35
Location : In Edward's arms ... DO NOT DISTURB

http://aliciamx.site.voila.fr

Back to top Go down

Tutorial on how to make your avatar rotate using php. Empty Re: Tutorial on how to make your avatar rotate using php.

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum