Advertisement
MikFoxi

ipscore.biz - Checking the visitor's IP address for spam, scam, bot activity, scraping

Nov 4th, 2022 (edited)
5,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | Software | 0 0
  1. <?php
  2. $ip = '123.123.123.123'; // for test
  3. //$ip = isset($_SERVER['REMOTE_ADDR']) ? strip_tags($_SERVER['REMOTE_ADDR']) : die('IP'); // Most often the real IP is here
  4. //$ip = isset($_SERVER['HTTP_CF_CONNECTING_IP']) ? strip_tags($_SERVER['HTTP_CF_CONNECTING_IP']) : die('IP'); // Real IP if using CloudFlare
  5. $apikey = ''; // Your API Key
  6.  
  7. $ch = curl_init();
  8. curl_setopt($ch, CURLOPT_URL, 'https://ipscore.biz/api/'.$apikey.'/'.$ip.'/score.json');
  9. curl_setopt($ch, CURLOPT_HEADER, false);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11. curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 600);
  12. curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  13. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
  14. curl_setopt($ch, CURLOPT_USERAGENT, 'ipscoreclient'); // Do NOT change user-agent
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  17. curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
  18. curl_setopt($ch, CURLOPT_FTP_SSL, CURLFTPSSL_TRY);
  19. $outch = curl_exec($ch);
  20. curl_close($ch);
  21. $outch = json_decode($outch, true);
  22. ?>
  23.  
  24. <?php if (isset($outch['score']) AND $outch['score'] == 1) { ?>
  25. <p style="color:green;">Content for human. Good IP address.</p>
  26. <?php } ?>
  27.  
  28. <?php if (isset($outch['score']) AND $outch['score'] == 0) { ?>
  29. <p style="color:blue;">Content for Bad Bot. Bad IP address.</p>
  30. <?php } ?>
  31.  
  32. <?php if (isset($outch['error'])) { ?>
  33. <p style="color:red;">Error Message: <?php echo $outch['error']; ?></p>
  34. <?php } ?>
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement