Version: , by Kier
Developer Last Online: May 2011
Version: 2.2.x
Rating:
Released: 03-18-2001
Last Update: Never
Installs: 52
No support by the author.
Updated for vBulletin 2.2.2, 5th February 2002
Since there has been so much demand for this, I wrote a hack that will allow you to store all your custom avatars as files, rather than in the mySQL database.
Doing this will have the following benefits:
Avatars folder can be protected by .htaccess (Apache only) to prevent bandwidth stealing
No SQL queries or PHP code required to display custom avatars - server load decreases
No cacheing issues with Internet Explorer 5.5, so server bandwidth use should decrease
The install script will make the necessary modifications to your database, install a control panel option to switch the file-based avatars on, and convert your existing custom avatars from the database into files.
All avatar options that are present when using the standard mySQL avatar system are still present, and users will not notice a difference in the interface.
Full instructions for altering your PHP files are included in the zip file.
Once you have made the necessary modifications to the PHP scripts, you should run the enclosed install_favatar.php script from your admin/ folder.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
So here's a bit of the problem:
admin/functions.php as per instructions:
PHP Code:
function getavatarurl($userid) {
global $DB_site,$session;
if ($avatarinfo=$DB_site->query_first("SELECT user.avatarid,avatarpath,NOT ISNULL(avatardata) AS hascustom FROM user LEFT JOIN avatar ON avatar.avatarid=user.avatarid LEFT JOIN customavatar ON customavatar.userid=user.userid WHERE user.userid='$userid'")) {
if ($avatarinfo[avatarpath]!="") {
return $avatarinfo[avatarpath];
} else if ($avatarinfo['hascustom']) {
return "avatar.php?s=$session[sessionhash]&userid=$userid";
admin/functions.php in vB2.0.0 Final Release:
PHP Code:
function getavatarurl($userid) {
global $DB_site,$session;
if ($avatarinfo=$DB_site->query_first("SELECT user.avatarid,avatarpath,NOT ISNULL(avatardata) AS hascustom,customavatar.dateline
FROM user
LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid
WHERE user.userid='$userid'")) {
if ($avatarinfo[avatarpath]!="") {
return $avatarinfo[avatarpath];
} else if ($avatarinfo['hascustom']) {
return "avatar.php?userid=$userid&dateline=$avatarinfo[dateline]";
} else {
return '';
}
}
}
You see that tiny differences?
So is there anyone out there who could tell me what to do?
function getavatarurl($userid) {
global $DB_site,$session;
if ($avatarinfo=$DB_site->query_first("SELECT user.avatarid,avatarpath,NOT ISNULL(avatardata) AS hascustom,customavatar.dateline
FROM user
LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid
WHERE user.userid='$userid'")) {
if ($avatarinfo[avatarpath]!="") {
return $avatarinfo[avatarpath];
} else if ($avatarinfo['hascustom']) {
return "avatar.php?userid=$userid&dateline=$avatarinfo[dateline]";
} else {
return '';
}
}
}
replace with:
PHP Code:
function getavatarurl($userid) {
global $DB_site,$session,$usefileavatar;
if ($avatarinfo=$DB_site->query_first("SELECT user.avatarid,avatarpath,avatarrevision,NOT ISNULL(avatardata) AS hascustom,customavatar.dateline
FROM user
LEFT JOIN avatar ON avatar.avatarid=user.avatarid
LEFT JOIN customavatar ON customavatar.userid=user.userid
WHERE user.userid='$userid'")) {
if ($avatarinfo[avatarpath]!="") {
return $avatarinfo[avatarpath];
if ($usefileavatar) return "custom_avatars/avatar$userid"."_$avatarinfo[avatarrevision].gif";
else return "avatar.php?userid=$userid";
}
}
}
Originally posted by freddie sven the code looks the same .. it just appears I got to it and broke the sql up into multiple lines which I have a habit of doing.
Only because it is a lot easier to read and comprehend.
Well, that's almost the same question I have.... what about the &dateline=$post[avatardateline]" thing?
Do I have to add this at the appropriate places or is it not mandatory?
I got the Avatar_as_files option working on my local testinstallation with the replacements from the instructions but I'm not sure if I can use this on the production environment w/o causing bugs due to the changes.
I edited all of the files now to add the "dateline"...
It's in all files but member.php, in most of them you just need to add the
&dateline=$post[avatardateline]"
but in user.php it's different, take care of that one!
In my local installation it seems to work - after I changed the files