put all dns checking into one function, allow it to be ignored
This commit is contained in:
parent
084b41fc2c
commit
88a68b941f
@ -54,8 +54,7 @@ class Regdir extends \Zotlabs\Web\Controller {
|
|||||||
if ($url) {
|
if ($url) {
|
||||||
$m = parse_url($url);
|
$m = parse_url($url);
|
||||||
|
|
||||||
if ((! $m) || ((! @dns_get_record($m['host'], DNS_A + DNS_CNAME + DNS_PTR)) && (! filter_var($m['host'], FILTER_VALIDATE_IP) ))) {
|
if ((! $m) || (! z_dns_check($m['host']))) {
|
||||||
|
|
||||||
$result['message'] = 'unparseable url';
|
$result['message'] = 'unparseable url';
|
||||||
json_return_and_die($result);
|
json_return_and_die($result);
|
||||||
}
|
}
|
||||||
|
@ -414,8 +414,8 @@ function visible_activity($item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_edit_activity($item))
|
// if(is_edit_activity($item))
|
||||||
return false;
|
// return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ abstract class dba_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1') && (! strpbrk($server,':;'))) {
|
if(strlen($server) && ($server !== 'localhost') && ($server !== '127.0.0.1') && (! strpbrk($server,':;'))) {
|
||||||
if((! dns_get_record($server, DNS_A + DNS_CNAME + DNS_PTR)) && (! filter_var($server, FILTER_VALIDATE_IP))) {
|
if(! z_dns_check($server)) {
|
||||||
$this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
|
$this->error = sprintf( t('Cannot locate DNS info for database server \'%s\''), $server);
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
$this->db = null;
|
$this->db = null;
|
||||||
|
@ -4522,15 +4522,12 @@ function item_create_edit_activity($post) {
|
|||||||
$new_item['body'] .= "\n\n";
|
$new_item['body'] .= "\n\n";
|
||||||
$new_item['body'] .= $update_item['body'];
|
$new_item['body'] .= $update_item['body'];
|
||||||
|
|
||||||
$new_item['title'] = $update_item['title'];
|
|
||||||
|
|
||||||
$new_item['verb'] = ACTIVITY_UPDATE;
|
$new_item['verb'] = ACTIVITY_UPDATE;
|
||||||
$new_item['item_thread_top'] = 0;
|
$new_item['item_thread_top'] = 0;
|
||||||
|
$new_item['created'] = $new_item['edited'] = datetime_convert();
|
||||||
|
|
||||||
$x = post_activity_item($new_item);
|
$x = post_activity_item($new_item);
|
||||||
|
|
||||||
logger('posted edit activity');
|
|
||||||
|
|
||||||
$post_id = $x['id'];
|
$post_id = $x['id'];
|
||||||
if($post_id) {
|
if($post_id) {
|
||||||
$r = q("select * from item where id = %d",
|
$r = q("select * from item where id = %d",
|
||||||
|
@ -480,6 +480,23 @@ function convert_xml_element_to_array($xml_element, &$recursion_depth=0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function z_dns_check($h,$check_mx = 0) {
|
||||||
|
|
||||||
|
// dns_get_record() has issues on some platforms
|
||||||
|
// so allow somebody to ignore it completely
|
||||||
|
|
||||||
|
if(get_config('system','do_not_check_dns'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$opts = DNS_A + DNS_CNAME + DNS_PTR;
|
||||||
|
if($check_mx)
|
||||||
|
$opts += DNS_MX;
|
||||||
|
return((@dns_get_record($h, $opts) || filter_var($h, FILTER_VALIDATE_IP)) ? true : false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Take a URL from the wild, prepend http:// if necessary
|
// Take a URL from the wild, prepend http:// if necessary
|
||||||
// and check DNS to see if it's real (or check if is a valid IP address)
|
// and check DNS to see if it's real (or check if is a valid IP address)
|
||||||
// return true if it's OK, false if something is wrong with it
|
// return true if it's OK, false if something is wrong with it
|
||||||
@ -494,7 +511,7 @@ function validate_url(&$url) {
|
|||||||
$url = 'http://' . $url;
|
$url = 'http://' . $url;
|
||||||
$h = @parse_url($url);
|
$h = @parse_url($url);
|
||||||
|
|
||||||
if(($h) && (@dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
|
if(($h) && z_dns_check($h['host'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -512,7 +529,7 @@ function validate_email($addr) {
|
|||||||
return false;
|
return false;
|
||||||
$h = substr($addr,strpos($addr,'@') + 1);
|
$h = substr($addr,strpos($addr,'@') + 1);
|
||||||
|
|
||||||
if(($h) && (@dns_get_record($h, DNS_A + DNS_CNAME + DNS_PTR + DNS_MX) || filter_var($h, FILTER_VALIDATE_IP) )) {
|
if(($h) && z_dns_check($h,true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user