The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
when a user logs in to the forum, where is the $userinfo array built?
Hi Just a quick question to save me some time of looking around really
The title says it all really - but when a member logs in successfully, where is the sql that builds the $vbulletin->userinfo array executed (which php file) - I want to change something in the way one of the array variables is set cheers Rich |
#2
|
|||
|
|||
I think it's fetch_userinfo() in includes/class_core.php.
|
#3
|
||||
|
||||
@kh99
Thanks again for a reply I had a look at the code you suggested and didn't really see what I hoped to see Code:
/** * Returns appropriate user info for the owner of this session. * * @return array Array of user information. */ function &fetch_userinfo() { if ($this->userinfo) { // we already calculated this return $this->userinfo; } else if ($this->vars['userid'] AND !defined('SKIP_USERINFO')) { // user is logged in $useroptions = (defined('IN_CONTROL_PANEL') ? FETCH_USERINFO_ADMIN : 0) + (defined('AVATAR_ON_NAVBAR') ? FETCH_USERINFO_AVATAR : 0); $this->userinfo = fetch_userinfo($this->vars['userid'], $useroptions, $this->vars['languageid']); return $this->userinfo; } else { // guest setup $this->userinfo = array( 'userid' => 0, 'usergroupid' => 1, 'username' => (!empty($_REQUEST['username']) ? htmlspecialchars_uni($_REQUEST['username']) : ''), 'password' => '', 'email' => '', 'styleid' => $this->vars['styleid'], 'languageid' => $this->vars['languageid'], 'lastactivity' => $this->vars['lastactivity'], 'daysprune' => 0, 'timezoneoffset' => $this->registry->options['timeoffset'], 'dstonoff' => $this->registry->options['dstonoff'], 'showsignatures' => 1, 'showavatars' => 1, 'showimages' => 1, 'showusercss' => 1, 'dstauto' => 0, 'maxposts' => -1, 'startofweek' => 1, 'threadedmode' => $this->registry->options['threadedmode'], 'securitytoken' => sha1(sha1(COOKIE_SALT) . USER_AGENT) ); Prob is here my php knowledge ain't quite good enough function &fetch_userinfo() - what's the & for? I did do a bit of a google on this '&function' stuff but non of it seems to make much sense to me. In fact the info I found on php forms seems to say it doesn't really do anything much useful - or at least I couldn't find a sensible example. $this->userinfo = fetch_userinfo($this->vars['userid'], $useroptions, $this->vars['languageid']); Now the fetch_userinfo() function them seems to call itself with some arguments (constants) here, even though fetch_userinfo() doesn't seem to be declared to have any arguments - or at least I can't see it doing anything with arguments in the code - hence the empty () I can see the stuff where it builds the userinfo array for a guest, thats easy enough to follow. I was rather expecting to see some SQL here that reads various tables and builds the userinfo array if you are logged in Your php is a lot better than mine m8 - I think I just hit the limit of my understanding so far. Help! --------------- Added [DATE]1301768461[/DATE] at [TIME]1301768461[/TIME] --------------- OK I have managed to do what I needed to do by adding some code to login.php to rebuild a couple of the counters in userinfo array the way I want them. I still didn't find the SQL that initialises them on log in but what the hell it works the way I want it to now - and a couple extra SQL on login ain't gonna effect performance much I would (for my own understanding) still like to know how the php above works though. Rich |
#4
|
|||
|
|||
Sorry, you did say you were looking for where the sql is built. There's another function called fetch_userinfo (with parameters) that's in includes/functions.php.
The & means the function returns a reference (you might want to look at this: http://us2.php.net/manual/en/language.references.php if you haven't already). Without that the returned value would be a copy. Say you had, for instance, an array somewhere that was being used to cache user info (to avoid doing the sql for a particular user more than once). If a function returned a value from that array, any changes to the returned userinfo wouldn't change the cached value. But if the function returns a reference, then any changes *would* change the cached value. I hope that makes some sense. |
#5
|
||||
|
||||
Cheers kh99 - I probably don't need to read the link you gave now - as that succinct little explanation that makes perfect sense to me.
In my mind I now see the & operator used in this way as returning the address of the userinfo array rather making a copy of the array (or array value) and returning the copy Rich |
#6
|
|||
|
|||
Yeah, pretty much. I would just have said something like that but I wasn't sure what kind of background you have in programming.
|
#7
|
||||
|
||||
Ahh not your average programmer i guess - I come from machine code and assembly language (i loved my spectrum/C64/commodore Amiga too lol) it's just higher level languages I struggle with sometimes lol at least with assembly language you could see exactly how it all works
Used to work in industrial electronics in the 80s/90s(when things were actually worth repairing that was) we'd sometimes have to reverse engineer microprocessor based boards blow our own eprom to create some test routines that actually made the board do something - then you could figure out what was going wrong with a logic analyser or at least a scope. Of course then they invented MICE (micro in circuit emulator) you could have a lot of fun with one of those Rich |
#8
|
|||
|
|||
Sounds great, I always wanted to do that kind of thing but never managed to get hired without experience in it.
Anyway, I know what you mean, kind of - my first 7 years of programming was in C and I was used to doing things using pointers extensively, then when I switched to C++ it took me a while to understand the point of adding references to the language when it seemed like using pointers was good enough. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|