Block foreigners [Any CMS]

Results 1 to 19 of 19
  1. #1
    YOLO <3 DutchenL is offline
    MemberRank
    Jul 2013 Join Date
    543Posts

    Block foreigners [Any CMS]

    Hello,

    Use this code to block foreigners on your retro, it's made with PHP. It allows only Dutch and Belgium IP adresses.
    Code:
    <?php
        $ip=$_SERVER['REMOTE_ADDR'];
    
    $landCodes=array(
    "nl"=>"nederland",
    "be"=>"belgie",
        );
    $gethostbyaddr=gethostbyaddr($ip);
    if($gethostbyaddr==$ip)
        {
    exit("forbidden");
        }
    $explode=explode(".",$gethostbyaddr);
    foreach($explodeas$key)
        {
    $ext=$key;
        }
    $land=$landCodes[$ext];
    if(empty($land))
        {
    $land="onbekend";
        }
    if($land=='nederland'||$land=='belgie')
        {
            
        }
    else
    {
    exit("forbidden");
        }
    ?>


    Cheers!


  2. #2
    Apprentice superjason is offline
    MemberRank
    Nov 2011 Join Date
    21Posts

    Re: Block foreigners [Any CMS]

    Thank you, I am belgium, belgium block why?

  3. #3
    No, Just no. Matthew is offline
    MemberRank
    Jul 2008 Join Date
    United KingdomLocation
    1,408Posts

    Re: Block foreigners [Any CMS]

    This is not an accurate way to block people. You're going to cause a lot of issues for your self and loose a lot of potential members.

  4. #4
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,608Posts

    Re: Block foreigners [Any CMS]

    And the reason why you want to block foreigners is....?

  5. #5
    Hakuna Matata Matata is offline
    MemberRank
    Sep 2012 Join Date
    DenmarkLocation
    807Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by tdid View Post
    And the reason why you want to block foreigners is....?
    If you're running a Dutch hotel, you don't want Swedish players.
    Just an example.

    I once had something like this on my site.
    Then I found out a lot of users got blocked, even tho they were Danish. :P

  6. #6
    YOLO <3 DutchenL is offline
    MemberRank
    Jul 2013 Join Date
    543Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by neto737 View Post
    You are stupid!
    I'm sorry for my comment but I hope you know what I mean.. When it's night in our timezone, and day in your timezone they come to my hotel really often and I don't want that.

    Again, sorry for that comment I hope you understand it now..

  7. #7
    C# Developer neto737 is offline
    MemberRank
    Oct 2010 Join Date
    Environment.csLocation
    274Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by DutchenL View Post
    I'm sorry for my comment but I hope you know what I mean.. When it's night in our timezone, and day in your timezone they come to my hotel really often and I don't want that.

    Again, sorry for that comment I hope you understand it now..
    Okay, I understand that ..

  8. #8
    No, Just no. Matthew is offline
    MemberRank
    Jul 2008 Join Date
    United KingdomLocation
    1,408Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by Matata View Post
    If you're running a Dutch hotel, you don't want Swedish players.
    Just an example.

    I once had something like this on my site.
    Then I found out a lot of users got blocked, even tho they were Danish. :P
    Why would you not want extra players on your hotel? Isn't that what hotels compete on, members online, size of community etc..?

  9. #9
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,608Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by Matata View Post
    If you're running a Dutch hotel, you don't want Swedish players.
    Just an example.

    I once had something like this on my site.
    Then I found out a lot of users got blocked, even tho they were Danish. :P
    Why will swedish people join a dutch hotel? Why would english people join a german hotel. Why would danish people join a turkish hotel?

    Makes no sense..

  10. #10
    YOLO <3 DutchenL is offline
    MemberRank
    Jul 2013 Join Date
    543Posts

    Re: Block foreigners [Any CMS]

    Anyways, if you like it, feel free to use the script, I share it with all of you. If you don't like it, don't use it. Maybe you could make a better one? Would be great though..

  11. #11
    YOLO <3 DutchenL is offline
    MemberRank
    Jul 2013 Join Date
    543Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by Matthew View Post
    This is not an accurate way to block people. You're going to cause a lot of issues for your self and loose a lot of potential members.
    How then?

  12. #12
    Hakuna Matata Matata is offline
    MemberRank
    Sep 2012 Join Date
    DenmarkLocation
    807Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by tdid View Post
    Why will swedish people join a dutch hotel? Why would english people join a german hotel. Why would danish people join a turkish hotel?

    Makes no sense..
    I've had Swedish people on my hotel who just wanted to troll.

  13. #13
    Apprentice opp is offline
    MemberRank
    Dec 2012 Join Date
    24Posts

    Re: Block foreigners [Any CMS]

    This makes no sense at all. . .

  14. #14
    Account Upgraded | Title Enabled! Chapo is offline
    MemberRank
    Jul 2010 Join Date
    United StatesLocation
    944Posts

    Re: Block foreigners [Any CMS]

    Hai i'm a foreigner plz block me

    Anyway, its useless.

  15. #15
    No, Just no. Matthew is offline
    MemberRank
    Jul 2008 Join Date
    United KingdomLocation
    1,408Posts

    Re: Block foreigners [Any CMS]

    If you're using CloudFlare:

    PHP Code:

    $allowedCountries 
    = array('NL''BE''LX');

    if(!
    in_array($_SERVER["HTTP_CF_IPCOUNTRY"], $allowedCountries)) 
    {
      
    //Some error message here, echo 'You cant register here', header("Location: google.nl") etc..
      
    exit;


  16. #16
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,372Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by Matthew View Post
    Why would you not want extra players on your hotel? Isn't that what hotels compete on, members online, size of community etc..?
    Well to be honest, i'd rather not let mexicans mingle with my english players. I pride myself on having next to no foreigners on my hotel. Fuck'em. English or get out.

  17. #17
    Proficient Member BeastFC is offline
    MemberRank
    Dec 2012 Join Date
    160Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by Jonteh View Post
    Well to be honest, i'd rather not let mexicans mingle with my english players. I pride myself on having next to no foreigners on my hotel. Fuck'em. English or get out.
    How do you block them? With Cloudfare?

  18. #18
    :joy: Jonteh is offline
    MemberRank
    Apr 2007 Join Date
    New York, USALocation
    3,372Posts

    Re: Block foreigners [Any CMS]

    Quote Originally Posted by BeastFC View Post
    How do you block them? With Cloudfare?
    I ban them manually. I find it fun and entertaining.

  19. #19
    Member Finley7 is offline
    MemberRank
    Feb 2013 Join Date
    In tha NedzLocation
    61Posts

    Re: Block foreigners [Any CMS]

    Looks a lot like a script I've seen already.. Glybe ->/includes/inc.bootstrap.php -> line 21
    PHP Code:
    function checkIfIsNlOrBe($ip)
    {
        
    $landCodes = array (
            
    "be" => "belgie",
            
    "nl" => "nederland",
        );
        
    $gethostbyaddr gethostbyaddr($ip);
        if(
    $gethostbyaddr == $ip)
        {
            return 
    "onbekend";
        }
        
    $explode explode("."$gethostbyaddr);
        foreach(
    $explode as $key)
        {
            
    $ext $key;
        }
        
    $land $landCodes[$ext];
        if(
    $land == "")
        {
            
    $land "onbekend";
        }
        if(
    $land == 'nederland' || $land == 'belgie')
        {
            if(
    stristr($gethostbyaddr"nuspelen.nl"))
                return 
    false;
            return 
    true;
        }
        else
        {
            return 
    false;
        }




Advertisement