PDA

View Full Version : UKBL ~ Auto Rotating Avatars


UKBusinessLive
08-11-2009, 10:00 PM
UKBL ~ Auto Rotating Avatars

https://vborg.vbsupport.ru/external/2009/08/18.gifhttps://vborg.vbsupport.ru/external/2009/08/19.gifhttps://vborg.vbsupport.ru/external/2009/08/20.gifhttps://vborg.vbsupport.ru/external/2009/08/21.gif

Heres a nice hack which will let you, your moderators, and perhaps as a treat for your members, the ability to rotate their avatars on every frefresh.

Imagine having an avatar directory and a nice collection of avatars, which will automatically refresh every time you open a new page or refresh your screen.

You can use this just for yourself, your staff and perhaps offer it as a paid item to your members.

Interested ? Lets get going............

Step 1

First step is to create a .htaccess file,add the following line to it

<Files rotate.gif>
ForceType application/x-httpd-php
</Files>

What this does is, it makes the PHP file parse as a graphic file readable by VBulletin, If you just added the rotate.php as a url in your upload avatar box it would simply come back as invaild file.

The Apache Web server provides a feature called .htaccess file, which provides commands to control a Web site. This file is simply a text file containing Apache directives. Those directives apply to the documents in the directory where the file is located, and to all subdirectories under it as well. Other .htaccess files in subdirectories may change or nullify the effects of those in parent directories.

You can use any text editor to create or make changes to .htaccess files. Keep in mind that commands in these files should be placed on one line only, so if your text editor uses word-wrap, make sure it's disabled. Be sure .htaccess file is uploaded in ASCII mode, not BINARY, or it won't work.

Your text editor or operating system may probably not allow to save file as .htaccess. The solution is to save the file as htaccess.txt and upload it to your server. After doing that, you should use your FTP client and rename the file to it's proper name.


Referance: .htaccess file - short tutorial and the most notable and useful htaccess examples. http://www.buildwebsite4u.com/advanced/htaccess-file.shtml

Ok guys, thats part one done

Now Lets get the coding done..

Step 2

Open Notebook or a similar text editor on your PC and copy the following .PHP code


<?php

Header('Cache-Control: no-cache');
Header('Pragma: no-cache');

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

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

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

closedir($dh);
?>


Save the file as rotate.gif. Once thats done, Just make a new directory on your server, called "avatar" and upload all your Avatar graphics to this directory using your FTP package or even Cpanel, whatever your comfortable with.

I have made this for Gif files only, you need to make sure the avatar files are all in gif format, any others will not load, if you want to use a diffent graphics format, you need to edit the .htaccess code as well as changing the gif referance in the php code.

Now we need to upload our rotate.gif file (the one with the php code in) Our graphics and our .htaccess file all to the avatar directory.

Then all we need to do is go to our UserCP and enter our Avatar directory url, pointing to our rotate.gif file, something like this..

http://www.myforum/avatars/rotate.gif

Just add your url to your box shown below.

https://vborg.vbsupport.ru/external/2009/08/19.png

Remember you also need to keep within the avatar rules of the site, if the rules state 70 x 70 px avatars, it won't work if you upload 80 x 80 or even a larger file file than is permissable.

Thats its, I've no screenshots, but if you would like your site to be listed as a demo site please PM me, First 3 requests only please :D

As always please click install and i'll support you 100%