vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Vb4 user option bitfields, how to extract (https://vborg.vbsupport.ru/showthread.php?t=325422)

Medi0cr3 07-20-2017 11:18 PM

Vb4 user option bitfields, how to extract
 
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":

Code:

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:

PHP Code:

$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 [DATE]1500743867[/DATE] at [TIME]1500743867[/TIME] ---------------

To build upon this post I've included the following in case people were curious:
PHP Code:

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

?>



All times are GMT. The time now is 04:00 AM.

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.10108 seconds
  • Memory Usage 1,726KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete