Advertisement
setty7

Untitled

Jan 21st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 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. //echo "script start ";
  8.  
  9. require 'vendor/autoload.php';
  10. require_once 'TorDetect.php';
  11. use GeoIp2\Database\Reader;
  12.  
  13.  
  14.  
  15.  
  16. $url = "";
  17. $host = 'localhost';
  18. $db   = 'testtest';
  19. $user = 'root';
  20. $pass = 'flsGxvQTxT';
  21. $charset = 'utf8';
  22.  
  23. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  24. $opt = [
  25.     PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
  26.     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  27.     PDO::ATTR_EMULATE_PREPARES   => false,
  28. ];
  29. $pdo = new PDO($dsn, $user, $pass, $opt);
  30.  
  31. $ip = getIP();
  32.  
  33. if (strpos($ip, ',') !== false) {
  34.    $ip_arr = explode(",", $ip);
  35.    $ip = $ip_arr[0];
  36.    
  37. }
  38.  
  39. if($ip == "67.137.36.66")
  40. {exit;}
  41.  
  42.  
  43. $sng_codes = [
  44. 'RU',
  45. 'UA',
  46. 'BY',
  47. 'KZ'
  48. ];
  49.  
  50.  
  51.  
  52.  $instance = \TorDetect\TorDetect::getInstance();
  53.  
  54.  
  55. //$host= gethostname(); $serv_ip = gethostbyname($host);
  56.  
  57. //$is_tor = $tor_detector->check($ip, 80, $serv_ip);
  58.  
  59.  
  60.  
  61.  
  62.  
  63. //echo "tor check start ";
  64. $is_tor = $instance->isTorActive();
  65.  
  66.  
  67. //echo "tor check end ";
  68.  
  69. try{
  70.  
  71. $reader = new Reader('GeoIP2-City.mmdb');
  72.  
  73. $record = $reader->city($ip);
  74. $country = $record->country->name;
  75. $cc  =   $record->country->isoCode;
  76. //add to db info
  77.  
  78. }
  79. catch (GeoIp2\Exception\AddressNotFoundException $e ){
  80. $country = "Not found";
  81. $cc = "NotF";
  82. }
  83.  
  84. //echo "sng check start ";
  85. if(in_array($cc, $sng_codes))
  86. {
  87.     exit;
  88. }
  89. //echo "sng check end ";
  90. $date = date('Y-m-d H:i:s');
  91. $q =  $pdo->prepare('insert into `hits` (ip, country, date) values (:ip, :country, :date) ');
  92.             $q->bindParam(':ip', $ip);
  93.             $q->bindParam(':country', $country);
  94.             $q->bindParam(':date', $date);
  95.             $q->execute();
  96.             echo "";
  97.              echo file_get_contents("caa.txt");
  98. echo $url;
  99.  
  100.  
  101.  
  102.  
  103. function getIP()
  104. {
  105.     if (isset($_SERVER["HTTP_X_REAL_IP"]))
  106.         return $_SERVER["HTTP_X_REAL_IP"];
  107.     else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
  108.         return $_SERVER ["HTTP_X_FORWARDED_FOR"];
  109.     return $_SERVER['REMOTE_ADDR'];
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement