Jump to content

How to include a script to block countries by IP


Recommended Posts

Posted

I am trying to install a country ip blocking script to our forum to prevent access to countries like Cuba, Iran, North Korea, etc.

I have tried including the php script with (include, require, require_once) but I cannot get it working on forum.altair.com without it throwing a 500 Internal Server Errors. It was attempting to load the file more than once despite that it was only being called out once. 

What would be the best practices for including php files that load first?

Thank you for your help.

Posted

Something like blocking IPs would be more beneficial on the server or network level. Have you contacted your hosting provider to see if they have a solution?

Posted
43 minutes ago, Christine Barrett said:

Well we are trying to block countries like Iran, North Korea, Cuba using an IP lookup service. So we are not blocking a known IP. How would the server do that without loading files in the www root?

Various firewalls may have rules that you could take advantage of. CSF does allow you to block countries. Your hosting provider may have a better solution which is why I suggested getting in contact.

Posted

While I fundamentally agree with Jim's recommendation, if you are forced to include a script in the manner you are describing, your best bet would be to use a require_once() call from either conf_global.php or constants.php.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...