Jump to content
wickzzz

Salut

Recommended Posts

Salut am si eu nevoie de putin ajutor , nu reusesc sa sortez hostname`urile care nu dorect sa-mi acceseze pagina web de cele care imi dorect sa acceseze pagina web.

 

<?php
function check_ban() {
    if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
    else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
    else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
    else $ip = "0.0.0.0";
    $host = gethostbyaddr($ip);

    $ip_ban_array = array( // banned ip address list
    '0.0.0.0'
    );

    $hostname_ban_array = array( // banned hostname list
    'eu.tachyon.net',
    'ttnet.net.tr',
    'meteksan.net.tr',
    'metu.edu.tr',
    'doruk.net.tr',
    'belbone.be',
    'skylogicnet.com',
    'telsim.com.tr',
    'titannetworks.nl'
    );

    if (is_array($ip_ban_array)) {
        if (in_array($ip, $ip_ban_array)) {
            die("Site not available at the moment");
        }
    }

    if (is_array($hostname_ban_array)) {

        foreach ($hostname_ban_array as $ban_host) {

            if (preg_match("/".$ban_host."\b/i", $host)) {
            die("Site not available at the moment");
            }
        }
    }

}
check_ban();
?>

 

as dori la acest script hostname`urile care sunt banate sa fie redirectionate pe un alt site exemplu (www.google.com) , iar cele care nu sunt mentionate in banlist sa fie redirectionate pe (www.mysite.com).

Ma poate ajuta cineva? Multumesc

Share this post


Link to post
Share on other sites

de ce nu incerci din .htaccess?

RewriteEngine On
RewriteCond     %{HTTP_HOST}   sub\.tachyon\.net [NC]
RewriteRule     ^(.*)$  https://google.com$1 [R=302]

 

Edited by Fi8sVrs

Share this post


Link to post
Share on other sites
mult mai usor este in .htaccess  siti faci o lista cu cele pe care vrei redirectionate!
RewriteEngine On
        RewriteCond %{HTTP_HOST} !hostname.com$ [NC]
        RewriteRule ^(.*)$ http://www.google.com/$1 [L,R=301]
  • Upvote 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×