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
Bookmarks