aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-25 18:27:32 -0700
committerzotlabs <mike@macgirvin.com>2016-10-25 18:27:32 -0700
commit88a68b941ff2c8295ac5a6f221855bc4940ddb40 (patch)
treefc45ca754d0bfb82ecef6e1179adffb41c119d87 /include/network.php
parent084b41fc2c0e8abeec1da5c792ec552b5ae1ce8f (diff)
downloadvolse-hubzilla-88a68b941ff2c8295ac5a6f221855bc4940ddb40.tar.gz
volse-hubzilla-88a68b941ff2c8295ac5a6f221855bc4940ddb40.tar.bz2
volse-hubzilla-88a68b941ff2c8295ac5a6f221855bc4940ddb40.zip
put all dns checking into one function, allow it to be ignored
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/include/network.php b/include/network.php
index 6411d6ddf..8c118eff3 100644
--- a/include/network.php
+++ b/include/network.php
@@ -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
// 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
@@ -494,7 +511,7 @@ function validate_url(&$url) {
$url = 'http://' . $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 false;
@@ -512,7 +529,7 @@ function validate_email($addr) {
return false;
$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 false;