Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Details »»

Version: , by Kier Kier is offline
Developer Last Online: May 2011 Show Printable Version Email this Page

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.

Comments
  #182  
Old 02-09-2002, 08:29 PM
MaSTaKiLLaH MaSTaKiLLaH is offline
 
Join Date: Oct 2001
Location: Hannover, Germany
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where did you creat the custom_avatars directory ?
I made one in every sub-directory of my board an chmod them all 777, but it doesn't work

Do I have to upgrade to 2.2.2 ?
Reply With Quote
  #183  
Old 02-10-2002, 07:54 PM
eva2000's Avatar
eva2000 eva2000 is offline
 
Join Date: Oct 2001
Location: Brisbane, Australia
Posts: 577
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Kier
A new and improved install script, together with new hacking instructions are attached to the first post in this thread.
motivation for me to upgrade

thanks Kier
Reply With Quote
  #184  
Old 02-11-2002, 08:33 AM
Kier Kier is offline
 
Join Date: Oct 2001
Posts: 131
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The custom_avatars folder needs to be created in same directory as the forumdisplay.php.

Instructions for this are in the install script, rather than the readme file.
Reply With Quote
  #185  
Old 02-13-2002, 08:20 AM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Kier
The custom_avatars folder needs to be created in same directory as the forumdisplay.php.

Instructions for this are in the install script, rather than the readme file.
Hi, Kier.
I successfully installed the hack, Great!

Just some question:
1) The avatardata in db (customavatar table) is filled the same. I guess the hack purpose is not to make a smaller db, but to unload the db itself when showing posts/threads giving a direct html link. Is it true ?

2) The filename in db (customavatar table) - the original filename - is not filled any more.... File is renamed ok, but if i would keep the original name as before ? Even, if i switched settings from file to db, again ?

3) Why the avatarrevision field is in user table and not in customavatar one ?

4) I tried to parametrize the directory name: infact I added in setting table a row with a setup instruction like this:
PHP Code:
$DB_site->query("INSERT INTO setting (settingid, settinggroupid, title, 
varname, value, description, optioncode, displayorder) VALUES 
('',26,'Custom Avatar File Directory', 'avatarpath', '/home/username/avatars/custom', 
'The directory where custom avatars will be stored.', '', 10)"
); 
but realized that the directory name (unlike the PPN's attachment as files hack from which I took the tip) has to be a relative one, not absolute. Infact the same name is used the same time for http purposes and server side ones (copy/unlink/etc.). So that $avatarpath should be valued like 'images/avatars/custom' (without leading slashes) and simply replaced to your custom_avatars directory name.
Well. The problem is how to make read that global var to php's that don't import ./global.php... ?
I though to something like
PHP Code:
$avatarpath=trim($GLOBALS['avatarpath']); 
somewhere, but it seems not working...
I haven't any idea how to manage global settings...

Thanks a lot for your attention.
Bye
Reply With Quote
  #186  
Old 02-13-2002, 03:12 PM
Kier Kier is offline
 
Join Date: Oct 2001
Posts: 131
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1) The purpose of the hack is not to reduce the size of the database, but to dramatically reduce the number of queries required to display a page showing avatars.

It's much easier to simply show an image using the webserver than to have PHP query the database and grab the avatar from there.

2) Not sure about that... it should still store the filename

3) Because storing the avatar revision in the customavatar table would mean that the custom avatar table would still need to be queried = bad.

4) Um... not sure what you are trying to do here...
Reply With Quote
  #187  
Old 02-13-2002, 06:00 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FoA, thanx for such a complete answer...

1) Agree! Will check better but seems is still a point in which avatar.php is accessed: userCP when updating avatar. I'll let you know if interested.

2) The filename isn't stored if the admin uploads a custom avatar for an user. Have no idea about the 'traditional' behavior of VB222 this case.

3) Elementar but right

4) In functions.php there's no global.php import, so the global variables aren't defined unless explicitly red. An assignment like mine just right before using the variable works fine (is the same way you read the usefileavatar global/setting var.

Thanks again.
Reply With Quote
  #188  
Old 02-13-2002, 08:22 PM
Jawelin Jawelin is offline
 
Join Date: Nov 2001
Posts: 557
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Jawelin
FoA, thanx for such a complete answer...

1) Agree! Will check better but seems is still a point in which avatar.php is accessed: userCP when updating avatar. I'll let you know if interested.

[...]
1) I think was forgotten a hack point.
Infact, I understand that'll not affect performance purposes - the first goal of this
hack - but for a complete job, I think also the getavatarulr() function should be
modified, and become as follows:
Code:
// ###################### Start getavatarurl #######################
function getavatarurl($userid) {
  global $DB_site,$session;

  if ($avatarinfo=$DB_site->query_first("SELECT user.avatarid,user.avatarrevision,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']) {
        $avatarpath=trim($GLOBALS['avatarpath']);
    	if ($GLOBALS['usefileavatar'] && $avatarpath>"") {
    		$avatarurl = "$avatarpath/avatar$userid"."_$avatarinfo[avatarrevision].gif";
    	} else {
    		$avatarurl = "avatar.php?userid=$userid&dateline=$avatarinfo[dateline]";
    	}
        return $avatarurl;
    } else {
      return '';
    }
  }
}
(I would put in bold main differences from the original... but ... )

Of course, I put my 'version' with the $avatarpath global variable. Your original, it should be replaced with the stored directory name...

What do you think ?
Thnx.
Reply With Quote
  #189  
Old 02-16-2002, 12:32 PM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is a revolutionary hack!

Thanks!!!
Reply With Quote
  #190  
Old 02-17-2002, 09:29 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works fine. I even made it work with the memberlist avatar hack.

However, I was wondering if someone could give me some advice.

I still get avatars displayed using avatar.php rather than using the custom_avatar files with the following:

1) Avatar in a member's profile (member.php/ getinfo)
2) Avatar in the Welcome Panel
3) Avatar in the vBPortal logout panel

Any suggestions?
Reply With Quote
  #191  
Old 02-17-2002, 09:39 AM
Erwin's Avatar
Erwin Erwin is offline
 
Join Date: Jan 2002
Posts: 7,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Another note: Jawelin, your fix for the Welcome Panel and the User Profile does not help - avatar.php is still being used to display the avatars.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:23 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05574 seconds
  • Memory Usage 2,321KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete