Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $host = $config['db']['host'];
  2. $user = $config['db']['username'];
  3. $pass = $config['db']['password'];
  4. $database = $config['db']['name'];
  5.  
  6. $ua = $_SERVER['HTTP_USER_AGENT'];
  7. if(stristr($ua, 'msnbot') || stristr($ua, 'googlebot') || stristr($ua, 'Ask Jeeves') || stristr($ua, 'Yahoo! Slurp')){
  8. //it's pretending to be MSN's bot or Google's bot or yahoo slurp
  9. $ip = $_SERVER['REMOTE_ADDR'];
  10.  
  11. $hostname = gethostbyaddr($ip);
  12. if(!preg_match("/\.googlebot\.com$/", $hostname) && !preg_match("/\.search\.msn\.com$/", $hostname) && !preg_match("/\.crawl\.yahoo\.net$/", $hostname) && !preg_match("/\.ask\.com$/", $hostname)){
  13. //the hostname does not belong to either msn.com or googlebot.com or crawl yahoo.
  14. //Remember the UA already said it is either MSNBot or Googlebot.
  15. //Fake.
  16. //echo "Not Allowed";
  17. //Optional php header 404 page
  18. header("HTTP/1.1 403 Forbidden");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement