View Single Post
Old 20 June, 2009, 14:44 PM   #1 (permalink)
xrvel xrvel is offline
Newbie Net Builder
 
xrvel's Avatar
 
Location: ProxyCoder.com
iTrader: (0)
Blog Entries: 1
Thanked 18 Times in 8 Posts
Posts: 37
$NetBucks: 65
Join Date: Mar 2009
Last Online: 8 January, 2010 15:46 PM
Lightbulb Code To Ban Domain (for Proxy List Owners)

You can try this. I made it pretty human readable and human friendly
If you own a proxy list, you can ban some domain, blogspot.com, *.co.cc, *.cn, *.something, etc
PHP Code:
<?php
/*
 * Author : xrvel (xrvel.com)
 */
// MAIN CODE START
function isBanned($url) {

    
// Enter banned URL here
    
$ban_reg_exp = array(
        
'blogspot.com',
        
'.cn',
        
'.co.cc',
        
'some-thing.com'
    
);

    
$ban_reg_exp '/('.friendlyRegExp(implode('|'$ban_reg_exp)).')+$/i';
    
//echo $ban_reg_exp;

    
$url urldecode($url);
    
$url preg_replace('/^http(s)?\:\/\/www\./i''http\\1://'$url);// remove "www."
    
$parsed_url parse_url($url);
    
//echo '<pre>', print_r($parsed_url, true), '</pre>';
    
$host $parsed_url['host'];
    return (bool)
preg_match($ban_reg_exp$host);
}

function 
friendlyRegExp($s) {
    
$s trim($s);
    
$s str_replace('.''\.'$s);
    
$s str_replace('-''\-'$s);
    return 
$s;
}
// MAIN CODE END

//
// Let's test our code with some URLs
//
$url 'https://www.test1.com//test.com?awioduawd';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';

$url 'https://www.test1.cn/test.com?axasa';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';

$url 'https://www.test1-something%2Ecn/test.com?axasa';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';

$url 'https://www.test1-something.blogspot.com/test.com?axasa';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';

$url 'https://www.hello.cn.more.com/test.com?axasa';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';

$url 'http://test1.cn/test.com?axasa';
echo 
$url' ::: ';
if (
isBanned($url)) {
    echo 
'IS BANNED';
} else {
    echo 
'is allowed...';
}

echo 
'<br />';
?>
The output of above example is :
Code:
https://www.test1.com//test.com?awioduawd ::: is allowed...
https://www.test1.cn/test.com?axasa ::: IS BANNED
https://www.test1-something%2Ecn/test.com?axasa ::: IS BANNED
https://www.test1-something.blogspot.com/test.com?axasa ::: IS BANNED
https://www.hello.cn.more.com/test.com?axasa ::: is allowed...
http://test1.cn/test.com?axasa ::: IS BANNED
__________________
. Xrvel . Free Proxy List Script (BETA) .
Anyone want to join open source proxy list project? Let's work with subversion. PM me for details.
Domains for sale : ihidden.com

Last edited by xrvel; 20 June, 2009 at 15:31 PM..
  Reply With Quote
Thanked by:
m42 (20 June, 2009), WebEvader (20 June, 2009), Will.Spencer (20 June, 2009)