Page 8 of 8 FirstFirst ... 678
Results 71 to 78 of 78

Thread: How can i redirect bad traffic?

  1. #71
    Now I only want to block few countries instead of allowing few countries. I used the following but it doesn't work

    // Redirect Bad Visitor
    require_once 'includes/geoip.inc';

    function
    getLocation($remoteurl) {
    $remoteurl = str_replace("http://", "", $remoteurl);
    $remoteip = gethostbyname($remoteurl);

    $gi = geoip_open("GeoIP/GeoIP.dat",GEOIP_STANDARD);

    $country = geoip_country_code_by_addr($gi, $remoteip);
    geoip_close($gi);

    $country = strtolower($country);


    return
    $country;
    }
    $addr = getenv('REMOTE_ADDR');

    $country = getLocation($addr);

    $badcountry = array('ir','cn','ng');

    if(
    in_array($country, $badcountry))
    header('Location: https://www.redirected-pages.com');

  2. #72
    Quote Originally Posted by Chuman View Post
    Now I only want to block few countries instead of allowing few countries. I used the following but it doesn't work
    <snip>
    This works for me, just make sure your file paths are correct (includes/), put this at the top of index.php and browse.php (keeps out hotlinkers too) for glype:
    Code:
    // THIS IS THE GEOIP COUNTRY BLOCKING CODE
    include('includes/geoip.inc'); //this file must exist in your directory
    // Uncomment if querying against GeoIP/Lite City.
    // include('includes/geoip.inc');
    $gi = geoip_open('includes/GeoIP.dat',GEOIP_STANDARD);
    // get the ip of the visitor
    $addr = getenv('REMOTE_ADDR');
    // translate his ip to a country code
    $country = geoip_country_code_by_addr($gi, $addr);
    // close the geo database
    geoip_close($gi);
    $badcountry = array('IR', 'CN', 'NG') // redirect them if they suck
    if(in_array($country, $badcountry))
    header('Location: http://www.youarebanned.info'); //enter a url or page on your site
    // END OF COUNTRY BLOCKING CODE
    It was posted on another thread somewhere before (maybe even this one).
    If I can't be a good example, I'll just have to be a terrible warning...

  3. #73
    The above code gives me 500 Internal Server error. The code that allowed few countries worked perfectly. The following is what I used, i have the geoip.inc and GeoIP.dat in the includes folder.

    <?php
    // THIS IS THE GEOIP COUNTRY BLOCKING CODE
    include('includes/geoip.inc'); //this file must exist in your directory
    // Uncomment if querying against GeoIP/Lite City.
    // include('includes/geoip.inc');
    $gi = geoip_open('includes/GeoIP.dat',GEOIP_STANDARD);
    // get the ip of the visitor
    $addr = getenv('REMOTE_ADDR');
    // translate his ip to a country code
    $country = geoip_country_code_by_addr($gi, $addr);
    // close the geo database
    geoip_close($gi);
    $badcountry = array('IR', 'CN', 'NG', 'NP') // redirect them if they suck
    if(in_array($country, $badcountry))
    header('Location: http://www.youarebanned.info'); //enter a url or page on your site
    // END OF COUNTRY BLOCKING CODE
    ?>

  4. #74

    Question Need some help with code modification

    I would like to implement a modification. Instead of redirecting visitors from $badcountry I would like to show them certain ads, while for visitors not belonging to $badcountry there would be other ads shown.


    ...
    if(in_array($country, $badcountry))
    {
    <show ad code1>
    }

    else
    {
    <show ad code2>
    }


    Does anybody know how to code/implement the red part properly?

    Thanks!

  5. #75
    Quote Originally Posted by Habaku View Post
    I would like to implement a modification. Instead of redirecting visitors from $badcountry I would like to show them certain ads, while for visitors not belonging to $badcountry there would be other ads shown.


    ...
    if(in_array($country, $badcountry))
    {
    <show ad code1>
    }

    else
    {
    <show ad code2>
    }


    Does anybody know how to code/implement the red part properly?

    Thanks!
    I think the <show ad code1> & <show ad code2> part is the actual ad code itself, you need to replace those with the proper ad code. Aussie has something similar on his proxy list here: Uncensors - Guide to Geo Targeting Ad Code it looks a bit different but could be what you're looking for.
    If I can't be a good example, I'll just have to be a terrible warning...

  6. #76
    That was excatly what I have been looking for. Thanks, much appreciated!
    H.

    Quote Originally Posted by UncleP View Post
    I think the <show ad code1> & <show ad code2> part is the actual ad code itself, you need to replace those with the proper ad code. Aussie has something similar on his proxy list here: Uncensors - Guide to Geo Targeting Ad Code it looks a bit different but could be what you're looking for.

  7. #77
    You must set up an internal DNS server and create a domain lookup zones you want to check and record the names of the hosts to the destination host.

  8. #78
    mod_security rules com in handy on Apache web servers that have the module compiled in. There are some good rules floating around for free on gotroot.org to stop common exploits, code injections, bad useragents and other nasty things. They can also block hosts listed in RBL's (spammer lists) from accessing Apache. That means the same spammer lists used to protect mail servers can protect websites, too. It keeps them off of comment forms and contact forms. Rules can be set in .htaccess. Exclusions can be set for specific things if it interferes with functionality. There is also a set of default rules in WHM which can be implemented in a few clicks. I have recently added a lot of global mod_security rules to my hosting servers to protect everyone.

Page 8 of 8 FirstFirst ... 678

Similar Threads

  1. Non www to www redirect
    By tetrapak in forum Managing
    Replies: 8
    Last Post: 31 May, 2010, 18:19 PM
  2. [WTS] Traffic | Traffic | Traffic | Dont forget to check inside
    By squintoo in forum Services
    Replies: 2
    Last Post: 16 October, 2009, 15:12 PM
  3. 301 redirect all to all
    By Hellas in forum Managing
    Replies: 0
    Last Post: 27 August, 2009, 12:25 PM
  4. How to redirect traffic with CSF?
    By ProxySites.ca in forum Web Hosting
    Replies: 1
    Last Post: 5 August, 2009, 23:47 PM
  5. Non-www. to www. 301 redirect
    By Dr. Stavros in forum Managing
    Replies: 8
    Last Post: 29 July, 2009, 18:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •