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 03-17-2015, 03:33 PM
apleschu apleschu is offline
 
Join Date: Aug 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Where are the banned IP addresses stored?

I have extended the spambot blocker a little bit so that it creates a log of who and when was blocked and from what IP address they came. Today I had the idea that it might be a good idea to automatically block the IP addresses they are coming from as well. That way they can try it once and then they are done.

Unfortunately, being new to vB programming I was unable to find where the banned IP addresses are stored and how to manipulate that list, but the latter is a question on where they are stored first.

Can anybody point me into the direction where I can find that ?
Reply With Quote
  #2  
Old 03-17-2015, 03:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

They are stored as the value of the setting, so they are in the setting table. But the settings are combined and put in the datastore, so after you update the setting table, you want to call build_options() which is in includes/adminfunctions.php.

So a string of the current banned ips will be in $vbulletin->options['banip'], and you can see how that's used in function verify_ip_ban(), which is in includes/functions.php, and once you add to the string it you'd want to do something like:
Code:
require_once(DIR.'/includes/adminfunctions.php');
$vbulletin->db->query_write("UPDATE ".TABLE_PREFIX."setting SET value = '".$vbulletin->db->escape_string($value)."' WHERE varname='banip' ");
build_options();
Edit: and now that I think about it, that could be a lot of db work to be doing if you have a lot of attempts. I don't know, maybe not. But one alternative would be to just update the datastore row directly by using a REPLACE in the query. But it's a serialize array of all the options so you'd have to get it right. Another way might be to implement your own ip ban using hook global_state_check, which is called right after verify_ip_ban(). You could probably copy the verify_ip_ban function and modify it.
Reply With Quote
Благодарность от:
RichieBoy67
  #3  
Old 03-17-2015, 04:43 PM
apleschu apleschu is offline
 
Join Date: Aug 2005
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for the pointer, Much appreciated. That gives me something to start looking.

--------------- Added [DATE]1426622022[/DATE] at [TIME]1426622022[/TIME] ---------------

AND ... it works. Now, if those suckers show up once their IP will be banned and instead of creating problems over and over and letting them try over and over the first time they fail their IP is gone for good.

Next thing will be to make the test for the banned IP faster. Currently that is a linear search, which for only a few IP adresses is OK, but once those become hundreds something better needs to be done.

Currently I am thinking of keeping the list of banned IPs as a sorted address then then there are only 10 comparisons for 1024 entries.
Reply With Quote
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 11:08 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.10585 seconds
  • Memory Usage 2,186KB
  • Queries Executed 13 (?)
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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (1)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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_postinfo_query
  • fetch_postinfo
  • 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