diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-09-13 17:12:54 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-09-13 17:12:54 -0700 |
commit | 38fde6672eb3d46b8b154ba2f22df99f91f64852 (patch) | |
tree | 2b66ef1aa3d6575a124e0b3cdad9c2a3042d0444 /boot.php | |
parent | 2c96ad77396b0df2be481c4f90cc61ebaa83bc75 (diff) | |
download | volse-hubzilla-38fde6672eb3d46b8b154ba2f22df99f91f64852.tar.gz volse-hubzilla-38fde6672eb3d46b8b154ba2f22df99f91f64852.tar.bz2 volse-hubzilla-38fde6672eb3d46b8b154ba2f22df99f91f64852.zip |
provide allow list of friend sites for education/corporate environments,
pattern matchable
Diffstat (limited to 'boot.php')
-rw-r--r-- | boot.php | 44 |
1 files changed, 41 insertions, 3 deletions
@@ -782,16 +782,54 @@ function get_uid() { }} if(! function_exists('validate_url')) { -function validate_url($url) { +function validate_url(&$url) { if(substr($url,0,4) != 'http') $url = 'http://' . $url; $h = parse_url($url); - if(! $h) + if(! $h) { return false; - if(! checkdnsrr($h['host'], 'ANY')) + } + if(! checkdnsrr($h['host'], 'ANY')) { return false; + } return true; }} +if(! function_exists('allowed_url')) { +function allowed_url($url) { + + $h = parse_url($url); + + if(! $h) { + return false; + } + + $str_allowed = get_config('system','allowed_sites'); + if(! $str_allowed) + return true; + + $found = false; + + $host = strtolower($h['host']); + + // always allow our own site + + if($host == strtolower($_SERVER['SERVER_NAME'])) + return true; + + $fnmatch = function_exists('fnmatch'); + $allowed = explode(',',$str_allowed); + + if(count($allowed)) { + foreach($allowed as $a) { + $pat = strtolower(trim($a)); + if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) { + $found = true; + break; + } + } + } + return $found; +}} |