Hide Page by Country

Dazed
Dazed
@dazed
5 years ago
1,022 posts
I do not want to set this in the .htaccess file but I would like to be able to hide the signup page by ip range. I do not want to block these countries from listening or even me creating the user profile myself but I want to remove the option of signing up completely.

Right now every signup is approved. I get several signups a day I have to research before I delete them. I used to block the country in my .htaccess which worked great however I have listeners in that country so I want them to be able to navigate the site but not signup. My site is ranked very high in India sadly for all the wrong reasons lol.


updated by @dazed: 07/18/19 04:22:21AM
michael
@michael
5 years ago
7,750 posts
So you need to fine tune:
* You dont want to block the whole ip range from VISITING the site, just from visiting the /user/signup /user/login pages

right?

My first thought is a module that listens for those pages and blocks using "Events and Listeners"

Docs: "Events and Listeners"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1011/events-and-listeners

That would be the cleanest. Put a switch in a listener and it would be easy to add any additional pages you liked.

This is the listener from the jrBanned module:
/**
 * Parse URL check for auto-banning
 * @param array $_data incoming data array
 * @param array $_user current user info
 * @param array $_conf Global config
 * @param array $_args additional info about the module
 * @param string $event Event Trigger name
 * @return array
 */
function jrBanned_parse_url_listener($_data, $_user, $_conf, $_args, $event)
{ if (jrCore_get_config_value('jrBanned', 'auto_block', 'off') === 'on') { // We are auto blocking... is this a honeypot page? if (jrBanned_is_honeypot_url($_data['_uri'])) { header('HTTP/1.0 403 Forbidden'); jrCore_notice('error', 'You do not have permission to access this server', false); exit; } } return $_data; }

You could use the same inner code if the IP matches your range.

The code to get their ip is
$ip = jrCore_get_ip();
Dazed
Dazed
@dazed
5 years ago
1,022 posts
Thanks Michael. I will take a look at it this weekend. This approach should work fine.
michael
@michael
5 years ago
7,750 posts
get stuck, post here, I'll help.