Check Domain

<?php

/**
 * check_domain
 *
 * Check a domain name against a whitelist and blacklist.
 *
 * @version 0.1
 * @author Contributors at eXorithm
 * @link /algorithm/view/check_domain Listing at eXorithm
 * @link /algorithm/history/check_domain History at eXorithm
 * @license /home/show/license
 *
 * @param mixed $url 
 * @param array $white_list 
 * @param array $black_list 
 * @return bool
 */
function check_domain($url='',$white_list=array(0=>'*.gov',1=>'*.gov.ru'),$black_list=array(0=>'*.nk',1=>'*.ru'))
{
	foreach ($white_list as $re) {
		$re = preg_quote($re);
		$re = str_replace('\*', '.*', $re);
		
		if (preg_match('|^'.$re.'$|', $url)) {
			return true;
		}
	}
	
	foreach ($black_list as $re) {
		$re = preg_quote($re);
		$re = str_replace('\*', '.*', $re);
		
		if (preg_match('|^'.$re.'$|', $url)) {
			return false;
		}
	}
	
	return true;
}

?>