View Full Version : Vb4 user option bitfields, how to extract
Medi0cr3
07-20-2017, 11:18 PM
How in the world do you extract the bitfields on individual users. I'm really only looking for daylight savings time on, off, and auto dst.
If anybody could help me I'd be greatly appreciative.
MarkFL
07-21-2017, 12:00 AM
What I typically do is on my dev site I take a look at the bitfield in question via phpMyAdmin and convert them to binary, noting the choice made. In this case, we are interested in the "options" column of the "user table. Here is what I found regarding the "DST Correction Option":
10101100000100110011010111 (auto-detect)
10101100000100110000010111 (always off)
10101100000100110010010111 (always on)
Counting from the right, and beginning with zero in our count, we see that we are interested in the 6th and 7th bits (2^6+2^7 = 192), so we want to mask off all the other bits by performing a bitwise AND on the options value and 192 then divide that by 2^6 = 64 to move the unmasked bits all the way to the right.
So, a PHP statement like:
$dst_option = ($vbulletin->userinfo['options'] & 192)/64
will store in that variable for the browsing user the following values:
0 - always off
2 - always on
3 - auto detect
Does this make sense? :)
Medi0cr3
07-21-2017, 12:20 AM
dude, that was like way above my brain power to figure out on my own, thanks dude!
I tried it, but no luck. I couldn't get the dst_option to return anything.
a var_dump returns int(1), but its literally NULL
MarkFL
07-21-2017, 12:28 AM
Glad to help out! :)
Medi0cr3
07-22-2017, 03:16 PM
never mind. its inherent. thanks dude. I had it practically, just global spam was needed
--------------- Added 1500743867 at 1500743867 ---------------
To build upon this post I've included the following in case people were curious:
<?php
error_reporting(E_ALL & ~E_NOTICE);
require_once('./global.php');
global $vbulletin;
$vbulletin->userinfo = $vbulletin->db->query_first("SELECT * FROM ".TABLE_PREFIX."user WHERE username = 'somerandomdude'");
echo "<pre>", print_r($vbulletin->userinfo['options']), "</pre>";
$dstauto = ($vbulletin->userinfo['options'] & 192)/64;
echo $dstauto."<br>";
var_dump($dstonoff);
// 0 = always off
// 2 = always on
// 3 = auto detect
?>
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.