-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpostback_cryptopay.php
183 lines (159 loc) · 5.24 KB
/
postback_cryptopay.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
$data_init = file_get_contents('php://input');
$data = json_decode($data_init, true);
include "config.php";
include "global.php";
$link = mysqli_connect($hostName, $userName, $password, $databaseName) or die ("Error connect to database");
mysqli_set_charset($link, "utf8");
###########SAVE DATA############
$date_time = date("j-m-Y G:i");
$results = "
=========$date_time========
";
$results .= print_r($data, true);
if($file = fopen("debug.txt", "a+")){
fputs($file, $results);
fclose($file);
} // end frite to file
###########SAVE DATA############
if($data['update_type'] == 'invoice_paid'){
$p = explode(":", $data['payload']['payload']);
$chat_id = $p[0];
$nfttype = $p[1];
$paidSumForNFT = $data['payload']['amount'];
// LANGUAGE
$str3select = "SELECT `lang` FROM `users` WHERE `chatid`='$chat_id'";
$result3 = mysqli_query($link, $str3select);
$row3 = @mysqli_fetch_object($result3);
if($row3->lang != ''){
$langcode = $row3->lang;
}else{
$langcode = 0;
}
require "lang.php";
for ($i = 0; $i < count($text); $i++) {
for ($k = 0; $k < count($text[$i]); $k++) {
$text[$i][$k] = str_replace(" ", "
", $text[$i][$k]);
$text[$i][$k] = str_replace("	", "", $text[$i][$k]);
$text[$i][$k] = str_replace("<", "<", $text[$i][$k]);
$text[$i][$k] = str_replace(">", ">", $text[$i][$k]);
$text[$i][$k] = str_replace("'", "'", $text[$i][$k]);
$text[$i][$k] = str_replace("", "", $text[$i][$k]);
} // end FOR
} // end FOR
// LANGUAGE
if(preg_match("/^([0-9])+$/", $nfttype)){
// if WIN
$case = $nfttype;
require "roulette.php";
roulette($case, $paidSumForNFT, "CryptoPayBot");
}else{
// if buy NFT
if($nfttype == "blogger") {$rate = $BloggerNFT;}
elseif($nfttype == "custom") {$rate = $Blogger3D;}
elseif($nfttype == "nude") {$rate = $NFTNude;}
$ssum = $paidSumForNFT/$rate;
$gotNFT = number_format($ssum, 2, '.', '');
$str16select = "SELECT * FROM `nft` WHERE `chatid`='$chat_id'";
$result16 = mysqli_query($link, $str16select);
if(mysqli_num_rows($result16) == 0){
if($nfttype == "blogger"){
$nfttype2 = "blogger";
}elseif($nfttype == "custom"){
$nfttype2 = "custom3d";
}elseif($nfttype == "nude"){
$nfttype2 = "nude";
}
$str2ins = "INSERT INTO `nft` (`chatid`,`".$nfttype2."`) VALUES ('$chat_id','$gotNFT')";
mysqli_query($link, $str2ins);
}else{
$row16 = @mysqli_fetch_object($result16);
if($nfttype == "blogger"){
$oldsum = $row16->blogger;
$nfttype2 = "blogger";
}elseif($nfttype == "custom"){
$oldsum = $row16->custom;
$nfttype2 = "custom3d";
}elseif($nfttype == "nude"){
$oldsum = $row16->nude;
$nfttype2 = "nude";
}
$newsum = $oldsum + $gotNFT;
$str11upd = "UPDATE `nft` SET `".$nfttype2."`='".$newsum."' WHERE `chatid`='$chat_id'";
mysqli_query($link, $str11upd);
}
########## REF FEE ##########
$str12select = "SELECT * FROM `users` WHERE `chatid`='$chat_id'";
$result12 = mysqli_query($link, $str12select);
$row12 = @mysqli_fetch_object($result12);
$earnRefNFT = $gotNFT / 100 * $NFTRefPercent * $rate;
if($row12->ref > 1){
$str10upd = "UPDATE `users` SET `refbalance`=`refbalance`+$earnRefNFT WHERE `chatid`='".$row12->ref."'";
mysqli_query($link, $str10upd);
}
########## REF FEE ##########
######## SAVE TRANSACTION ###########
if($nfttype == "blogger"){
$cat = $gotNFT;
$dog = 0;
$nude = 0;
}elseif($nfttype == "custom"){
$cat = 0;
$dog = $gotNFT;
$nude = 0;
}elseif($nfttype == "nude"){
$cat = 0;
$dog = 0;
$nude = $gotNFT;
}
$date_time = date("j-m-Y G:i");
$str2ins = "INSERT INTO `transactions` (`chatid`,`sender`,`date_time`,`blogger`,`custom`,`nude`) VALUES ('$chat_id','$senderid','$date_time','$cat','$dog','$nude')";
mysqli_query($link, $str2ins);
######## SAVE TRANSACTION ###########
$response = array(
'chat_id' => $chat_id,
'text' => "Success: your payment received!",
'parse_mode' => 'HTML');
sendit($response, 'sendMessage');
}
}
function sendit($response, $restype){
$ch = curl_init('https://api.telegram.org/bot' . TOKEN . '/'.$restype);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $response);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_exec($ch);
curl_close($ch);
}
function send($id, $message, $keyboard) {
//Удаление клавы
if($keyboard == "DEL"){
$keyboard = array(
'remove_keyboard' => true
);
}
if($keyboard){
//Отправка клавиатуры
$encodedMarkup = json_encode($keyboard);
$data = array(
'chat_id' => $id,
'text' => $message,
'reply_markup' => $encodedMarkup,
'parse_mode' => 'HTML',
'disable_web_page_preview' => True
);
}else{
//Отправка сообщения
$data = array(
'chat_id' => $id,
'text' => $message,
'parse_mode' => 'HTML',
'disable_web_page_preview' => True
);
}
$out = sendit($data, 'sendMessage');
return $out;
}
?>