Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2017, 11:18 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 07-21-2017, 12:00 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #3  
Old 07-21-2017, 12:20 AM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #4  
Old 07-21-2017, 12:28 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Glad to help out!
Reply With Quote
  #5  
Old 07-22-2017, 03:16 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

?>
Reply With Quote
Благодарность от:
MarkFL
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04126 seconds
  • Memory Usage 2,210KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (1)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete