The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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! |
#2
|
|||
|
|||
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). |
Благодарность от: | ||
findingpeace |
#3
|
||||
|
||||
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:
Code:
function verify_ip_ban() { // make sure we can contact the admin if (THIS_SCRIPT == 'sendmessage' AND (empty($_REQUEST['do']) OR $_REQUEST['do'] == 'contactus' OR $_REQUEST['do'] == 'docontactus')) { return; } global $vbulletin; $user_ipaddress = IPADDRESS . '.'; $user_alt_ipaddress = ALT_IP . '.'; if ($vbulletin->options['enablebanning'] == 1 AND $vbulletin->options['banip'] = trim($vbulletin->options['banip'])) { $addresses = preg_split('#\s+#', $vbulletin->options['banip'], -1, PREG_SPLIT_NO_EMPTY); foreach ($addresses AS $banned_ip) { if (strpos($banned_ip, '*') === false AND $banned_ip{strlen($banned_ip) - 1} != '.') { $banned_ip .= '.'; } $banned_ip_regex = str_replace('\*', '(.*)', preg_quote($banned_ip, '#')); // Check both IP addresses, it doesnt really matter if they are the same. if (preg_match('#^' . $banned_ip_regex . '#U', $user_ipaddress) OR preg_match('#^' . $banned_ip_regex . '#U', $user_alt_ipaddress)) { header('X-LiteSpeed-Cache-Control: no-cache'); eval(standard_error(fetch_error('banip', $vbulletin->options['contactuslink']))); } } } } |
#4
|
||||
|
||||
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. |
#5
|
||||
|
||||
Block them using htaccess instead of relying on vbulletin to do it for you.
|
#6
|
||||
|
||||
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! |
#7
|
||||
|
||||
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.
|
Благодарность от: | ||
ozzy47 |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|