Thanks for sending me the above script but I have the idea that the script is not safe because it doesn’t test for Cross Site Scripting (XSS).
Try adding XSS protection into your .htaccess file.
## Reflected XSS protection
Header set X-XSS-Protection "1; mode=block"
Hope that works for you. 😉