mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-27 07:49:27 +00:00
Created a function to check posted URLs
This commit is contained in:
parent
cc909ebf7a
commit
d909b2a29e
@ -260,6 +260,27 @@ function check_post_file(string $name) : bool {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the validity of a URL specified in a request
|
||||
*
|
||||
* @param string $name The name of the $_POST field containing the URL
|
||||
* @return bool True if the url is valid / false else
|
||||
*/
|
||||
function check_post_url(string $name) : bool {
|
||||
|
||||
//Check if image exists
|
||||
if(!isset($_POST[$name]))
|
||||
return false;
|
||||
$url = $_POST[$name];
|
||||
|
||||
//Check URL
|
||||
if(!filter_var($url, FILTER_VALIDATE_URL))
|
||||
return false;
|
||||
|
||||
//The URL seems to be valid
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the validity of a Youtube video ID
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user