Skip to content

Instantly share code, notes, and snippets.

@CeoFred
Created June 4, 2019 02:29
Show Gist options
  • Select an option

  • Save CeoFred/32fc6832bb89557921302f3be989e70f to your computer and use it in GitHub Desktop.

Select an option

Save CeoFred/32fc6832bb89557921302f3be989e70f to your computer and use it in GitHub Desktop.
An algorithm to check for request parameters with _urls and validate them
foreach ($_REQUEST as $key => $value) {
$ex = explode('_',$key);
foreach ($ex as $k => $v) {
if($v == 'url'){
$url = filter_var($value,FILTER_VALIDATE_URL,FILTER_FLAG_HOST_REQUIRED);
if(!$url){
http_response_code(403);
echo $Job->validationFailed('Website must be valid',$key . ' should match http://www.examplesite.com, attach protocol');
return;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment