Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 23 Sep 2014, 16:30
findingpeace's Avatar
findingpeace findingpeace is offline
 
Join Date: Nov 2011
Question Hook for IP Blocked guests?

What hook would I use to create a plugin where the guest's IP is blocked under User Banning Options?

My problem is that I've implemented a cache for guest users that works great, unless an IP blocked guest views the site when logged out, in which case two bad things can happen:

1) They see the cached version of the site, like they aren't blocked
2) They happen to be the cache changer, in which case everyone else sees "Your IP has been blocked" for two minutes, which is obviously really bad.

As a solution, I thought I'd use a plugin to set a cookie for the IP blocked page, and then have .htaccess never cache when that cookie is present.

Thanks!

Last edited by findingpeace; 23 Sep 2014 at 16:41.
Reply With Quote
  #2  
Old 23 Sep 2014, 21:09
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
The ip banning check is done in verify_ip_ban() which is in includes/functions.php. Unfortunately there's no hook in that function. But maybe you could modify the source code of that function, or if you want to use plugins you might be able to work out something else. If a user is banned it calls standard_error() to show an error message, and that has an "error _generic" hook. So you could check the message to see if it's the "you are banned" message, or maybe look at the call stack to see if verify_ip_ban() called standard_error, and do something there.

Also, verify_ip_ban is called just before the "global_state_check" hook (and before the "archive_global" hook if you have the archive enabled), so maybe you could do something like disable the ip banning option and do your own check in a plugin on those hooks (maybe copy the code from verify_ip_ban).
Reply With Quote
  #3  
Old 23 Sep 2014, 22:35
findingpeace's Avatar
findingpeace findingpeace is offline
 
Join Date: Nov 2011
Thanks very much kh99! I just tried putting the no-cache header in the function but it's still caching IP block messages for everyone. I highlighted the line I added below:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Any idea why this ban page would still be getting cached? I know this header works in other areas (such as for all logged-in users). But in this specific area, it doesn't seem to work.

Last edited by findingpeace; 23 Sep 2014 at 22:46.
Reply With Quote
  #4  
Old 23 Sep 2014, 23:05
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Check the actual banned user page output, and make sure that header is being sent.

You might want to modify the standard_error function to just always send that header, since I can't think of a good reason you would want that data cached.
__________________
Looking for ImpEx?
Reply With Quote
  #5  
Old 24 Sep 2014, 13:01
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Real name: Paul M
Block them using htaccess instead of relying on vbulletin to do it for you.
__________________
Former vBulletin.org Staff Member


Cable Forum
Please do not PM me about custom work - I no longer undertake any.
Note: I will not answer support questions via e-mail or PM - please use the relevant thread or forum.
Reply With Quote
  #6  
Old 25 Sep 2014, 16:02
findingpeace's Avatar
findingpeace findingpeace is offline
 
Join Date: Nov 2011
We have multiple admins banning IP addresses, so we wouldn't be able to do .htaccess (only site owner has access). Thank you though!

Zachery, do you know where I would put it in the standard_error function? I tried up top after the globals, but it still does not apply. Does it need to go into a specific part of the function?

Thanks!
Reply With Quote
  #7  
Old 25 Sep 2014, 18:06
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
No, also, stop banning ips in the vBulletin AdminCP, its generally not the best idea and IP's are so easy to change or get around you're more likely to ban legitimate users.
__________________
Looking for ImpEx?
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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


New To Site? Need Help?

All times are GMT. The time now is 23:18.

Layout Options | Width: Wide Color: