Reject all malicious URL requests functions.php
this might not be the right place as it's a question about a function snippet that relates also to the server and log files.
I have been trying to block access to my site from bad query attempts which show up on my server logs attempting to access pages that don't exist. I found a snippet online with claims that it may stop these kinds of requests, but with very little explanation as to what it exactly does.
So can anyone advise me as to what this snippet would do and if it should be placed (as is) into the function.php or if it should have a function before hand:
global $user_ID;
if($user_ID) {
if(!current_user_can('administrator')) {
if (strlen($_SERVER['REQUEST_URI']) 255 ||
stripos($_SERVER['REQUEST_URI'], eval() ||
stripos($_SERVER['REQUEST_URI'], CONCAT) ||
stripos($_SERVER['REQUEST_URI'], UNION+SELECT) ||
stripos($_SERVER['REQUEST_URI'], base64)) {
@header(HTTP/1.1 414 Request-URI Too Long);
@header(Status: 414 Request-URI Too Long);
@header(Connection: Close);
@exit;
}
}
}