Nieuw lid |
|
Ik ben zojuist eenzelfde iets aan het schrijven. Ten eerste filter ik het met filter_var:
$url = een link of zo;
function cleanURL($raw_input){
var $host;
//Make sure this url is an url
$this->clean = filter_var($raw_input, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED);
if ($this->clean == true)
{
//Get the hostname from the url
$this->host = parse_url($url, PHP_URL_HOST);
//check if the domain really exists:
// If it exists, the URL is oke and can be returned.
if(checkdnsrr($this->host,"A")) { return $raw_input; }
else { return false; }
}
else { return false; } // This was not a valid url
}
function cleanURL($raw_input){ var $host; //Make sure this url is an url $this->clean = filter_var($raw_input, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED, FILTER_FLAG_HOST_REQUIRED); if ($this->clean == true) { //Get the hostname from the url //check if the domain really exists: // If it exists, the URL is oke and can be returned. if(checkdnsrr($this->host,"A")) { return $raw_input; } else { return false; } } else { return false; } // This was not a valid url }
Werkt nog niet helemaal (checkdnsrr werkt nog niet goed) maar misschien heb je hier in ieder geval al wat aan |