PDA

View Full Version : Query in plugin simply wont work?


principle_slw
05-11-2014, 10:31 AM
Hi I'm using the plugin register_addmember_complete and can not for the life of me get this to work. All i'm looking for is the users password hash

HERE are the current contents.

$uidn = $vbulletin->userinfo['userid'];
$db = $vbulletin->db;

$a = $db->query_first("SELECT password FROM user WHERE userid = '4' ");

vbsetcookie('userid', $vbulletin->userinfo['userid'], true, true, true);
vbsetcookie('password', md5($a . COOKIE_SALT''), true, true, true);
vbsetcookie('useridtmp', $a, true, true, true);

$a is empty so my password is simply set to a hash of my cookie salt?

---------------------------------------------------------------------------------
I've also tried this,

vbsetcookie('userid', $vbulletin->userinfo['userid'], true, true, true);
vbsetcookie('password', md5($vbulletin->userinfo['password'] . COOKIE_SALT), true, true, true);

Same thing $vbulletin->userinfo['password'] is blank? so once again password cookies becomes just a hash of the cookie salt

-------------------------------------------------------------------------------------

I've also tried this

$uidn = intval($vbulletin->userinfo['userid']);
$newpw = $db->query_read("SELECT password FROM user WHERE userid = $uidn");

Nothing seems capable of simply returning the users password?

Any help greatly appreciated.
Thanks

kh99
05-11-2014, 10:47 AM
$db->query_first() will return an array (even if you are selecting only one field), or else NULL if it fails. So you should check for NULL, but maybe just try using $a['password'] and see if that works.

Edit: also I don't think $vbulletin->userinfo has been updated at that point (since the user was just created), so try using $userinfo and/or $userid instead. And of course using those is probably better than doing your own query.

principle_slw
05-11-2014, 02:21 PM
Thanks very much you where correct $db->query_first() was returning an array.

Thanks for the help