Renamed check_domain_blocklist to blocked_url
- Remove debug
This commit is contained in:
parent
8d469c155a
commit
188d3a6f5e
4 changed files with 11 additions and 13 deletions
|
@ -82,7 +82,7 @@ function new_contact($uid,$url,$interactive = false) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! check_domain_blocklist($url)) {
|
if (blocked_url($url)) {
|
||||||
$result['message'] = t('Blocked domain');
|
$result['message'] = t('Blocked domain');
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) {
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (! check_domain_blocklist($url)) {
|
if (blocked_url($url)) {
|
||||||
logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
logger('z_fetch_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) {
|
||||||
function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0) {
|
function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0) {
|
||||||
$stamp1 = microtime(true);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
if (!check_domain_blocklist($url)) {
|
if (blocked_url($url)) {
|
||||||
logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
logger('post_url: domain of ' . $url . ' is blocked', LOGGER_DATA);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -522,34 +522,33 @@ function allowed_url($url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the provided url domain isn't on the domain blacklist.
|
* Checks if the provided url domain is on the domain blocklist.
|
||||||
* Return true if the check passed (not on the blacklist), false if not
|
* Returns true if it is or malformed URL, false if not.
|
||||||
* or malformed URL
|
|
||||||
*
|
*
|
||||||
* @param string $url The url to check the domain from
|
* @param string $url The url to check the domain from
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function check_domain_blocklist($url) {
|
function blocked_url($url) {
|
||||||
$h = @parse_url($url);
|
$h = @parse_url($url);
|
||||||
|
|
||||||
if (! $h) {
|
if (! $h) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain_blocklist = get_config('system', 'blocklist', array());
|
$domain_blocklist = get_config('system', 'blocklist', array());
|
||||||
if (! $domain_blocklist) {
|
if (! $domain_blocklist) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$host = strtolower($h['host']);
|
$host = strtolower($h['host']);
|
||||||
|
|
||||||
foreach ($domain_blocklist as $domain_block) {
|
foreach ($domain_blocklist as $domain_block) {
|
||||||
if (strtolower($domain_block['domain']) == $host) {
|
if (strtolower($domain_block['domain']) == $host) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -272,7 +272,6 @@ function admin_content(App $a) {
|
||||||
*/
|
*/
|
||||||
function admin_page_blocklist(App $a) {
|
function admin_page_blocklist(App $a) {
|
||||||
$blocklist = Config::get('system', 'blocklist');
|
$blocklist = Config::get('system', 'blocklist');
|
||||||
var_dump($blocklist);
|
|
||||||
$blocklistform = array();
|
$blocklistform = array();
|
||||||
if (is_array($blocklist)) {
|
if (is_array($blocklist)) {
|
||||||
foreach($blocklist as $id => $b) {
|
foreach($blocklist as $id => $b) {
|
||||||
|
|
|
@ -514,7 +514,7 @@ function dfrn_request_post(App $a) {
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! check_domain_blocklist($url)) {
|
if (blocked_url($url)) {
|
||||||
notice( t('Blocked domain') . EOL);
|
notice( t('Blocked domain') . EOL);
|
||||||
goaway(App::get_baseurl() . '/' . $a->cmd);
|
goaway(App::get_baseurl() . '/' . $a->cmd);
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
|
|
Loading…
Reference in a new issue