vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Custom Avatars as Files (updated for vBulletin 2.2.2) (https://vborg.vbsupport.ru/showthread.php?t=11760)

MaSTaKiLLaH 02-09-2002 08:29 PM

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 ?

eva2000 02-10-2002 07:54 PM

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 :D

thanks Kier :)

Kier 02-11-2002 08:33 AM

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.

Jawelin 02-13-2002 08:20 AM

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

Kier 02-13-2002 03:12 PM

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...

Jawelin 02-13-2002 06:00 PM

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.

Jawelin 02-13-2002 08:22 PM

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.

Erwin 02-16-2002 12:32 PM

This is a revolutionary hack!

Thanks!!!

Erwin 02-17-2002 09:29 AM

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?

Erwin 02-17-2002 09:39 AM

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.


All times are GMT. The time now is 01:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01365 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete