PHP code edit

Results 1 to 11 of 11
  1. #1
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    information PHP code edit

    Hello,

    I got this PHP code

    Code:
                                <?php
    $ip = $_SERVER['REMOTE_ADDR']; // the IP address to query
    $query = @unserialize(file_get_contents('http://ip-api.com/php/'.$ip));
    if($query && $query['status'] == 'success') {
        if ($query['country'] !== 'Denmark') {
    echo 'Du er online fra et andet sted end Danmark.';
    header('Location: blocked');
    
    
        } else {
            echo 'Du er online fra Danmark!';
        }
    } else {
      echo 'Unable to get location';
      header('Location: blocked');
    }
    ?>
    I'm trying to edit
    Code:
    if ($query['country'] !== 'Denmark') {
    so i also can get Sweden, Norway in... Is it possible?


  2. #2
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: PHP code edit

    Quote Originally Posted by ThomasRBang View Post
    Jeg ville foretrække at bruge en "PHP Switch"
    Sorry, i'm not the best to PHP.

  3. #3
    ☮TAKU???? seanrom is offline
    MemberRank
    Nov 2009 Join Date
    1,004Posts

    Re: PHP code edit

    What is the point in this?

  4. #4
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: PHP code edit

    Quote Originally Posted by oleaa View Post
    What is the point in this?
    Blocking users. Alot of users come with VPN / Proxy and spam the hotel with ads for other hotels.

  5. #5
    Enthusiast EmielJ is offline
    MemberRank
    Aug 2012 Join Date
    a HouseLocation
    44Posts

    Re: PHP code edit

    Code:
    			if ($query['country'] !== 'Denmark') 
    			{
    				header('Location: blocked');
    			} 
    			elseif ($query['country'] !== 'Sweden')
    			{
    				header('Location: blocked');
    			}
    			elseif ($query['country'] !== 'Norway')
    			{
    				header('Location: blocked');
    			}
    			else 
    			{
    				
    			}

  6. #6
    ☮TAKU???? seanrom is offline
    MemberRank
    Nov 2009 Join Date
    1,004Posts

    Re: PHP code edit

    Quote Originally Posted by UartigZone View Post
    Blocking users. Alot of users come with VPN / Proxy and spam the hotel with ads for other hotels.
    You should implement this system (only one connection per IP) on emulator side, not website. I can think of atleast one way to avoid your little protection. Client is authenticated by SSO, so i can spawn a ton of SSO tickets and then connect trough a html page on another web server.

    There are also other ways to fight advertisement bots, just think out of the box.
    -Create a spam detection system based on repeated messages
    -Create a system that requires manual approval to active the user account based on username.
    -Use cookies stored on the clients computer to track frequent registrations
    -Think outside of the box

    I wish you goodluck on the journey on defeating the spam bots :-)

    - - - Updated - - -

    I am also going to answer your question very specifically

    If you want to block specific countries trough PHP, not that I can recommend this at all, because there are better ways todo this. You can use this piece of code i just made. However, this requires you to use CloudFlare. Because it uses the CF-IPCountry HTTP Header provioded by CloudFlare. I guess you're already using CloudFlare as it is very common for people to use now-a-days.

    PHP Code:
    <?php
        
    // Block some countries from seeing this page

    switch($_SERVER["HTTP_CF_IPCOUNTRY"])
    {

        
    // Norway
        
    case 'BV'// (Bouvet Island) apperently according to Wikipedia, it belongs to Norway?
        
    case 'NO'// (Norway) Mainland
        
    case 'SJ'// (Svalbard and Jan Mayen) also belongs to Norway, according to Wikipedia

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

        
    // Denmark
        
    case 'DK'// (Denmark) Mainland

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

        
    // Sweden
        
    case 'SE'// (Sweden) Mainland

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

    }
    If you want to add more countries
    CloudFlare's CF-IPCountry HTTP Header is in a ISO 3166-1 Alpha 2 format

  7. #7
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: PHP code edit

    Quote Originally Posted by oleaa View Post
    You should implement this system (only one connection per IP) on emulator side, not website. I can think of atleast one way to avoid your little protection. Client is authenticated by SSO, so i can spawn a ton of SSO tickets and then connect trough a html page on another web server.

    There are also other ways to fight advertisement bots, just think out of the box.
    -Create a spam detection system based on repeated messages
    -Create a system that requires manual approval to active the user account based on username.
    -Use cookies stored on the clients computer to track frequent registrations
    -Think outside of the box

    I wish you goodluck on the journey on defeating the spam bots :-)

    - - - Updated - - -

    I am also going to answer your question very specifically

    If you want to block specific countries trough PHP, not that I can recommend this at all, because there are better ways todo this. You can use this piece of code i just made. However, this requires you to use CloudFlare. Because it uses the CF-IPCountry HTTP Header provioded by CloudFlare. I guess you're already using CloudFlare as it is very common for people to use now-a-days.

    PHP Code:
    <?php
        
    // Block some countries from seeing this page

    switch($_SERVER["HTTP_CF_IPCOUNTRY"])
    {

        
    // Norway
        
    case 'BV'// (Bouvet Island) apperently according to Wikipedia, it belongs to Norway?
        
    case 'NO'// (Norway) Mainland
        
    case 'SJ'// (Svalbard and Jan Mayen) also belongs to Norway, according to Wikipedia

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

        
    // Denmark
        
    case 'DK'// (Denmark) Mainland

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

        
    // Sweden
        
    case 'SE'// (Sweden) Mainland

            
    header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
            exit;
            break;

    }
    If you want to add more countries
    CloudFlare's CF-IPCountry HTTP Header is in a ISO 3166-1 Alpha 2 format
    Thanks and i can't code in the emulator because Auzre Team update it every month...

    Btw, the code you maked does not work... And yes, i use Cloudflare

  8. #8
    Evil Italian Overlowrd Droppy is offline
    [Internal Coder]Rank
    Feb 2012 Join Date
    /home/droppyLocation
    2,080Posts

    Re: PHP code edit

    Quote Originally Posted by UartigZone View Post
    Thanks and i can't code in the emulator because Auzre Team update it every month...

    Btw, the code you maked does not work... And yes, i use Cloudflare
    Can you create a PHP file, with any name you want, and use var_dump($_SERVER); for us?

    Code:

    PHP Code:
    <?php
    var_dump
    ($_SERVER);
    ?>
    Open the page with the PHP file you want (normal url please, like http://yourhotel.com/ ), give ctrl + u (for showing with indentation), ctrl a (for selecting all), and paste it on pastebin.com ,and link us.

  9. #9
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: PHP code edit

    Quote Originally Posted by Droppy View Post
    Can you create a PHP file, with any name you want, and use var_dump($_SERVER); for us?

    Code:

    PHP Code:
    <?php
    var_dump
    ($_SERVER);
    ?>
    Open the page with the PHP file you want (normal url please, like http://yourhotel.com/ ), give ctrl + u (for showing with indentation), ctrl a (for selecting all), and paste it on pastebin.com ,and link us.
    This is my code right now.
    No idea how i can make so Denmark, Sweden and Norway can come into it... Right now only danish Ips can come into the hotel.

    http://pastebin/bh92Luq9

    - - - Updated - - -

    Quote Originally Posted by UartigZone View Post
    This is my code right now.
    No idea how i can make so Denmark, Sweden and Norway can come into it... Right now only danish Ips can come into the hotel.

    http://pastebin/bh92Luq9
    The page says: NULL

  10. #10
    Evil Italian Overlowrd Droppy is offline
    [Internal Coder]Rank
    Feb 2012 Join Date
    /home/droppyLocation
    2,080Posts

    Re: PHP code edit

    Quote Originally Posted by UartigZone View Post
    This is my code right now.
    No idea how i can make so Denmark, Sweden and Norway can come into it... Right now only danish Ips can come into the hotel.

    http://pastebin/bh92Luq9
    Do as I said, do the php file with var_dump on it, and send me the logs in anyway you want, so I can see how you can fix it. If you want you can remove informations like proccessors etc, or simply search your real ip on it and send us the line (remove the ip if you want)

  11. #11
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: PHP code edit

    Quote Originally Posted by Droppy View Post
    Do as I said, do the php file with var_dump on it, and send me the logs in anyway you want, so I can see how you can fix it. If you want you can remove informations like proccessors etc, or simply search your real ip on it and send us the line (remove the ip if you want)
    array(55) { ["REDIRECT_MIBDIRS"]=> string(24) "C:/xampp/php/extras/mibs" ["REDIR - Pastebin.com

    Here you go... I have removed the server IP and called it SERVER IP HERE



Advertisement