Tutorial on how to make your avatar rotate using php.
2 posters
Page 1 of 1
Tutorial on how to make your avatar rotate using php.
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 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:
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.
You might have noticed that my avatars changes each time the page loads. Refresh now and you'll see it change 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.
Re: Tutorial on how to make your avatar rotate using php.
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?
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?
Re: Tutorial on how to make your avatar rotate using php.
I've never tried it, but think it would work. Use <img src="FILEURL">, just like you would if it was a graphic.
Re: Tutorial on how to make your avatar rotate using php.
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?
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?
Re: Tutorial on how to make your avatar rotate using php.
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
Re: Tutorial on how to make your avatar rotate using php.
That's ok, I'll try to find stuffs like that. Maybe I'll find some interesting things.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|