<?php
function urlWhitelisted($url)
{
$always_allowed = array('localhost');
$whitelisted_domains = array('fxnetworks.com') + $always_allowed;
$domain = parse_url($url, PHP_URL_HOST);
if (strpos($url, "/") === 0 || in_array($domain, $whitelisted_domains)) {
return true;
}
foreach ($whitelisted_domains as $whitelisted_domain) {
$whitelisted_domain = '.' . $whitelisted_domain;
if (strpos($domain, $whitelisted_domain) === (strlen($domain) - strlen($whitelisted_domain))) {
return true;
}
}
return false;
}
$domains = array('/user', 'localhost/user', 'http://localhost:4039', 'http://fxnetworks.com/user', 'http://google.com', 'google.com', 'fxnetworks.com.google.com');
foreach($domains as $domain) {
var_dump(urlWhitelisted($domain));
}
preferences:
41.62 ms | 402 KiB | 5 Q