vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   vBulletin and datastore (https://vborg.vbsupport.ru/showthread.php?t=191368)

Marco 09-19-2008 10:29 PM

vBulletin and datastore
 
Through a custom script (which runs outside of vBulletin), I am adding IP addresses to the vBulletin ban list. First I add it to the setting table, like so:

PHP Code:

$banlist mysql_fetch_array(mysql_query("SELECT value FROM setting WHERE varname = 'banip'"));
$addban $banip " " $banlist['value'];
$updatebanlist mysql_query("UPDATE setting SET value = '$addban' WHERE varname = 'banip'"); 

($banip is the IP address I am adding)

Because vBulletin also saves a cached copy of the options in the datastore table, I then refresh the options in the datastore like so:

PHP Code:

$q mysql_query("
    SELECT varname,value
    FROM setting"
);

while (
$setting mysql_fetch_array($q))
{
    
$newsetting[$setting['varname']] = $setting['value'];
}

$new_ds serialize($newsetting);

mysql_query("
    UPDATE datastore
    SET data = '
$new_ds'
    WHERE title = 'options'
"
); 

Up until recently (I have no idea what broke it), this was working great. Actually it still works; when I add an IP address, it gets added to the setting table, I can see it in the Admin CP - User Banning options and I can see through phpMyAdmin that it gets added to the datastore too. However, the IP ban still isn't effective until I manually save the User Banning options in the Admin CP.

This is driving me nuts and majorly pissing me off by now. Can anyone see what's wrong? I mean, the correct information is in the database, in both places ('setting' and 'datastore') yet vBulletin (3.7.3) doesn't seem to care. Is there maybe another place this information is cached?

(And no, I cannot use the build_options() function from vB, since I'm running a standalone script.)

Lynne 09-20-2008 03:10 AM

Are you using datastore_cache? It needs to get added into there also (I think - I'm a total n00b when it comes to datastore_cache).

Marco 09-20-2008 08:55 AM

We are not, but your post did put me on the right track! It turns out we are using APC now (we upgraded to PHP5 a few days ago) and that was the culprit. I put the following code at the end of my "datastore-update" code:

PHP Code:

apc_delete("options");
apc_store("options"$new_ds); 

It works great now. :)

oegis 09-20-2008 12:08 PM

thanks.. very helpful

Lynne 09-20-2008 02:15 PM

Quote:

Originally Posted by Marco (Post 1626191)
It works great now. :)

I'm glad I was able to trigger that lightbulb to go off in your head. :)


All times are GMT. The time now is 08:56 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.01040 seconds
  • Memory Usage 1,728KB
  • 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
  • (3)bbcode_php_printable
  • (1)bbcode_quote_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