Redirect Your traffic from specific countries.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cooldude7
    Confirmed User
    • Nov 2009
    • 4306

    #1

    Redirect Your traffic from specific countries.

    Okie, i was getting traffic from malaysia and site was using full resources of cpu so host told me to do something about it.,

    so i used this

    Code:
    <script src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
    <script type="text/javascript">
        switch(geoplugin_countryCode()){
            case "MY" :
                document.location.href = "http://www.xxxtreme.com/blocked.html";
                break;
        }
    </script>
    
    
    </head>
    will c how it goes.

    thanks to you all for all ur useless reply's j/k. GFY.. not kidding.
  • Seth Manson
    Please dont fuck animals
    • Jul 2010
    • 3988

    #2
    Its better to use php and redirect them from there before your html page even loads. You can still do it for free, maxmind gives away the database for it and even tells you how to do it on their website.

    Comment

    • Barry-xlovecam
      It's 42
      • Jun 2010
      • 18083

      #3
      This does? Count/convert the money in my wallet?

      Code:
      function geoplugin_city() { return '**';} 
      function geoplugin_region() { return '**';} 
      function geoplugin_regionCode() { return '**';} 
      function geoplugin_regionName() { return '**';} 
      function geoplugin_areaCode() { return '**';} 
      function geoplugin_dmaCode() { return '**';} 
      function geoplugin_countryCode() { return 'US';} 
      function geoplugin_countryName() { return 'United States';} 
      function geoplugin_continentCode() { return 'NA';} 
      function geoplugin_latitude() { return '42.**';} 
      function geoplugin_longitude() { return '-83.**';} 
      function geoplugin_currencyCode() { return 'USD';} 
      function geoplugin_currencySymbol() { return '$';} 
      function geoplugin_currencyConverter(amt, symbol) { 
      	if (!amt) { return false; } 
      	var converted = amt * 1; 
      	if (converted <0) { return false; } 
      	if (symbol === false) { return Math.round(converted * 100)/100; } 
      	else { return '$'+(Math.round(converted * 100)/100);} 
      	return false; 
      }
      The ** were omitted but the values were close
      Last edited by Barry-xlovecam; 06-03-2011, 11:12 PM.

      Comment

      • ThatOtherGuy - BANNED FOR LIFE
        So Fucking Banned
        • Apr 2011
        • 1241

        #4
        Interesting. I'll take it.

        Comment

        • Barry-xlovecam
          It's 42
          • Jun 2010
          • 18083

          #5
          Just add these to the root .htaccess file

          http://www.ipdeny.com/ipblocks/data/countries/my.zone

          Code:
          <Files 403.shtml>
          order allow,deny
          allow from all
          </Files>
          
          #then all the malaysia ips on the above URL
          This not stopping the traffic to the server but the IPs will get a 403 - Forbidden 57 bytes?

          Blocking entire countries is best done with mod_geoip for Apache2 (Debian) Google for mod_geoip

          Comment

          • cooldude7
            Confirmed User
            • Nov 2009
            • 4306

            #6
            Originally posted by Barry-xlovecam
            Just add these to the root .htaccess file

            http://www.ipdeny.com/ipblocks/data/countries/my.zone

            Code:
            <Files 403.shtml>
            order allow,deny
            allow from all
            </Files>
            
            #then all the malaysia ips on the above URL
            This not stopping the traffic to the server but the IPs will get a 403 - Forbidden 57 bytes?

            Blocking entire countries is best done with mod_geoip for Apache2 (Debian) Google for mod_geoip
            i dont want surfers to view some 403 error, i wanna give them specific reason ....

            Comment

            • cooldude7
              Confirmed User
              • Nov 2009
              • 4306

              #7
              Originally posted by Barry-xlovecam
              This does? Count/convert the money in my wallet?

              Code:
              function geoplugin_city() { return '**';} 
              function geoplugin_region() { return '**';} 
              function geoplugin_regionCode() { return '**';} 
              function geoplugin_regionName() { return '**';} 
              function geoplugin_areaCode() { return '**';} 
              function geoplugin_dmaCode() { return '**';} 
              function geoplugin_countryCode() { return 'US';} 
              function geoplugin_countryName() { return 'United States';} 
              function geoplugin_continentCode() { return 'NA';} 
              function geoplugin_latitude() { return '42.**';} 
              function geoplugin_longitude() { return '-83.**';} 
              function geoplugin_currencyCode() { return 'USD';} 
              function geoplugin_currencySymbol() { return '$';} 
              function geoplugin_currencyConverter(amt, symbol) { 
              	if (!amt) { return false; } 
              	var converted = amt * 1; 
              	if (converted <0) { return false; } 
              	if (symbol === false) { return Math.round(converted * 100)/100; } 
              	else { return '$'+(Math.round(converted * 100)/100);} 
              	return false; 
              }
              The ** were omitted but the values were close
              i dont get it , what are u saying ??

              Comment

              • Barry-xlovecam
                It's 42
                • Jun 2010
                • 18083

                #8
                http://www.geoplugin.net/javascript.gp run your script in a browser its looks like a currency converter ...

                it doesnt do anything

                if function geoplugin_countryCode() {return MY} then?

                if (!amt) { return false; } amt is the amount from the shopping cart?

                Where did you find this?


                Edit: From here http://www.geoplugin.com/quickstart

                this does not redirect or block with geo-ip
                Last edited by Barry-xlovecam; 06-04-2011, 12:14 AM.

                Comment

                • cooldude7
                  Confirmed User
                  • Nov 2009
                  • 4306

                  #9
                  Originally posted by Barry-xlovecam
                  http://www.geoplugin.net/javascript.gp run your script in a browser its looks like a currency converter ...

                  it doesnt do anything

                  if function geoplugin_countryCode() {return MY} then?

                  if (!amt) { return false; } amt is the amount from the shopping cart?

                  Where did you find this?


                  Edit: From here http://www.geoplugin.com/quickstart

                  this does not redirect or block with geo-ip
                  lol, thanks for the info.,

                  but what it does is give the country code., and then


                  i use

                  switch(geoplugin_countryCode()){
                  case "MY" :
                  document.location.href = "http://www.xxxtreme.com/blocked.html";
                  break;

                  to check if the country code is MY , and then it redirects it to given url.

                  thanks for your time.

                  Comment

                  • Barry-xlovecam
                    It's 42
                    • Jun 2010
                    • 18083

                    #10
                    OK that is one way to do it ...
                    "Visitors from this country are currently blocked, Sorry for the inconvenience. " LOL that is better?

                    Should work ...

                    You only posted part of the code ...

                    The difference is the server resource usage.
                    I don't like using services they have a way of disappearing or starting to charge for services. Better to run this sort of thing yourself IMHO.

                    Comment

                    • cooldude7
                      Confirmed User
                      • Nov 2009
                      • 4306

                      #11
                      Originally posted by Barry-xlovecam
                      OK that is one way to do it ...
                      "Visitors from this country are currently blocked, Sorry for the inconvenience. " LOL that is better?

                      Should work ...

                      You only posted part of the code ...

                      The difference is the server resource usage.
                      I don't like using services they have a way of disappearing or starting to charge for services. Better to run this sort of thing yourself IMHO.
                      i posted the complete code in my 1st post,

                      anyways i just checked server stats and memory usage are overheating..,
                      i guess traffic coming to the index.php and then redirecting also causing issues...so i m gonna try 403 htaccess method.

                      will c if server resource goes down.

                      Comment

                      Working...