|
111 | 111 | $userName = $info['name']; |
112 | 112 |
|
113 | 113 | if($match[1] == "Plan"){ |
| 114 | + $offset = 0; |
| 115 | + $limit = 20; |
| 116 | + |
114 | 117 | $condition = array_values(array_keys(json_decode($info['discount_percent'],true)['plans']??array())); |
115 | 118 | $condition = count($condition) > 0? "WHERE `id` NOT IN (" . implode(",", $condition) . ")":""; |
116 | | - $stmt = $connection->prepare("SELECT * FROM `server_plans` $condition"); |
| 119 | + $stmt = $connection->prepare("SELECT * FROM `server_plans` $condition LIMIT ? OFFSET ?"); |
| 120 | + $stmt->bind_param("ii", $limit, $offset); |
117 | 121 | $stmt->execute(); |
118 | 122 | $list = $stmt->get_result(); |
119 | 123 | $stmt->close(); |
|
130 | 134 | $keys[] = [['text'=>$row['title'] . " " . $catInfo['title'],'callback_data'=>"editAgentDiscountPlan" . $match[2] . "_" . $row['id']]]; |
131 | 135 | } |
132 | 136 |
|
| 137 | + if($list->num_rows >= $limit){ |
| 138 | + $keys[] = [['text'=>"▶️",'callback_data'=>"nextAgentDiscountPlan" . $match[2] . "_" . ($offset + $limit)]]; |
| 139 | + } |
133 | 140 | $keys[] = [['text' => $buttonValues['back_button'], 'callback_data' => "agentPercentDetails" . $match[2]]]; |
134 | 141 | $keys = json_encode(['inline_keyboard'=>$keys]); |
135 | 142 |
|
|
156 | 163 | }else alert("سروری باقی نمانده است"); |
157 | 164 | } |
158 | 165 | } |
| 166 | +if(preg_match('/^nextAgentDiscountPlan(?<agentId>\d+)_(?<offset>\d+)/',$data,$match)){ |
| 167 | + $stmt = $connection->prepare("SELECT * FROM `users` WHERE `userid` = ?"); |
| 168 | + $stmt->bind_param('i',$match['agentId']); |
| 169 | + $stmt->execute(); |
| 170 | + $info = $stmt->get_result()->fetch_assoc(); |
| 171 | + $stmt->close(); |
| 172 | + $userName = $info['name']; |
| 173 | + |
| 174 | + $offset = $match['offset']; |
| 175 | + $limit = 20; |
| 176 | + |
| 177 | + $condition = array_values(array_keys(json_decode($info['discount_percent'],true)['plans']??array())); |
| 178 | + $condition = count($condition) > 0? "WHERE `id` NOT IN (" . implode(",", $condition) . ")":""; |
| 179 | + $stmt = $connection->prepare("SELECT * FROM `server_plans` $condition LIMIT ? OFFSET ?"); |
| 180 | + $stmt->bind_param("ii", $limit, $offset); |
| 181 | + $stmt->execute(); |
| 182 | + $list = $stmt->get_result(); |
| 183 | + $stmt->close(); |
| 184 | + |
| 185 | + if($list->num_rows > 0){ |
| 186 | + $keys = array(); |
| 187 | + while($row = $list->fetch_assoc()){ |
| 188 | + $stmt = $connection->prepare("SELECT * FROM `server_categories` WHERE `id` = ?"); |
| 189 | + $stmt->bind_param("i", $row['catid']); |
| 190 | + $stmt->execute(); |
| 191 | + $catInfo = $stmt->get_result()->fetch_assoc(); |
| 192 | + $stmt->close(); |
| 193 | + |
| 194 | + $keys[] = [['text'=>$row['title'] . " " . $catInfo['title'],'callback_data'=>"editAgentDiscountPlan" . $match['agentId'] . "_" . $row['id']]]; |
| 195 | + } |
| 196 | + |
| 197 | + if($list->num_rows >= $limit && $offset == 0){ |
| 198 | + $keys[] = [['text'=>"▶️",'callback_data'=>"nextAgentDiscountPlan" . $match['agentId'] . "_" . ($offset + $limit)]]; |
| 199 | + } |
| 200 | + elseif($list->num_rows >= $limit && $offset != 0){ |
| 201 | + $keys[] = [ |
| 202 | + ['text'=>"◀️️",'callback_data'=>"nextAgentDiscountPlan" . $match['agentId'] . "_" . ($offset - $limit)], |
| 203 | + ['text'=>"▶️",'callback_data'=>"nextAgentDiscountPlan" . $match['agentId'] . "_" . ($offset + $limit)] |
| 204 | + ]; |
| 205 | + } |
| 206 | + elseif($offset != 0){ |
| 207 | + $keys[] = [ |
| 208 | + ['text'=>"◀️️",'callback_data'=>"nextAgentDiscountPlan" . $match['agentId'] . "_" . ($offset - $limit)] |
| 209 | + ]; |
| 210 | + } |
| 211 | + $keys[] = [['text' => $buttonValues['back_button'], 'callback_data' => "agentPercentDetails" . $match['agentId']]]; |
| 212 | + $keys = json_encode(['inline_keyboard'=>$keys]); |
| 213 | + |
| 214 | + editText($message_id,"لطفا سرور مورد نظر را برای افزودن تخفیف به نماینده $userName انتخاب کنید",$keys); |
| 215 | + }else alert("سروری باقی نمانده است"); |
| 216 | +} |
159 | 217 | if(preg_match('/^removePercentOfAgent(?<type>Server|Plan)(?<agentId>\d+)_(?<serverId>\d+)/',$data,$match)){ |
160 | 218 | $stmt = $connection->prepare("SELECT * FROM `users` WHERE `userid` = ?"); |
161 | 219 | $stmt->bind_param('i',$match['agentId']); |
|
329 | 387 | $stmt->bind_param("s", $newData); |
330 | 388 | $stmt->execute(); |
331 | 389 | $stmt->close(); |
332 | | - } |
| 390 | + } |
333 | 391 | editText($message_id,$mainValues['change_bot_settings_message'],getBotSettingKeys()); |
334 | 392 | } |
335 | 393 | if($data=="changeUpdateConfigLinkState" && ($from_id == $admin || $userInfo['isAdmin'] == true)){ |
|
1418 | 1476 | delMessage(); |
1419 | 1477 |
|
1420 | 1478 | $price = $payInfo['price']; |
1421 | | - $rate = json_decode(file_get_contents("https://api.changeto.technology/api/rate"),true)['result']; |
1422 | | - $priceInTrx = round($price / $rate['TRX'],2); |
| 1479 | + $priceInTrx = round($price / $botState['TRXRate'],2); |
1423 | 1480 |
|
1424 | 1481 | $stmt = $connection->prepare("UPDATE `pays` SET `tron_price` = ? WHERE `hash_id` = ?"); |
1425 | 1482 | $stmt->bind_param("ds", $priceInTrx, $match[1]); |
|
1518 | 1575 |
|
1519 | 1576 |
|
1520 | 1577 | $price = $payInfo['price']; |
1521 | | - $rate = json_decode(file_get_contents("https://api.changeto.technology/api/rate"),true)['result']; |
1522 | | - $priceInUSD = round($price / $rate['USD'],2); |
1523 | | - $priceInTrx = round($price / $rate['TRX'],2); |
| 1578 | + $priceInUSD = round($price / $botState['USDRate'],2); |
| 1579 | + $priceInTrx = round($price / $botState['TRXRate'],2); |
1524 | 1580 | $pay = NOWPayments('POST', 'payment', [ |
1525 | 1581 | 'price_amount' => $priceInUSD, |
1526 | 1582 | 'price_currency' => 'usd', |
|
2693 | 2749 | } |
2694 | 2750 | if($price == 0 or ($from_id == $admin)){ |
2695 | 2751 | $keyboard[] = [['text' => '📥 دریافت رایگان', 'callback_data' => "freeTrial$id"]]; |
| 2752 | + setUser($remark, 'temp'); |
2696 | 2753 | }else{ |
2697 | 2754 | $token = base64_encode("{$from_id}.{$id}"); |
2698 | 2755 |
|
|
5429 | 5486 | $portType = $stmt->get_result()->fetch_assoc()['port_type']; |
5430 | 5487 | $stmt->close(); |
5431 | 5488 |
|
5432 | | - if($botState['remark'] == "digits"){ |
5433 | | - $rnd = rand(10000,99999); |
5434 | | - $remark = "{$srv_remark}-{$rnd}"; |
| 5489 | + if($from_id == $admin && !empty($userInfo['temp'])){ |
| 5490 | + $remark = $userInfo['temp']; |
| 5491 | + setUser('','temp'); |
5435 | 5492 | }else{ |
5436 | | - $rnd = rand(1111,99999); |
5437 | | - $remark = "{$srv_remark}-{$from_id}-{$rnd}"; |
| 5493 | + if($botState['remark'] == "digits"){ |
| 5494 | + $rnd = rand(10000,99999); |
| 5495 | + $remark = "{$srv_remark}-{$rnd}"; |
| 5496 | + }else{ |
| 5497 | + $rnd = rand(1111,99999); |
| 5498 | + $remark = "{$srv_remark}-{$from_id}-{$rnd}"; |
| 5499 | + } |
5438 | 5500 | } |
5439 | 5501 |
|
5440 | 5502 | if($portType == "auto"){ |
|
5705 | 5767 | $remark = $email; |
5706 | 5768 | } |
5707 | 5769 | else{ |
5708 | | - $upload = sumerize($list[$keys]->up); |
5709 | | - $download = sumerize($list[$keys]->down); |
| 5770 | + $clientUpload = $clientState[$emailKey]->up; |
| 5771 | + $clientDownload = $clientState[$emailKey]->down; |
| 5772 | + $clientTotal = $clientState[$emailKey]->total; |
| 5773 | + $clientExpTime = $clientState[$emailKey]->expiryTime; |
| 5774 | + |
| 5775 | + $up = $list[$keys]->up; |
| 5776 | + $down = $list[$keys]->down; |
| 5777 | + $total = $list[$keys]->total; |
| 5778 | + $expiry = $list[$keys]->expiryTime; |
| 5779 | + |
| 5780 | + if(($clientTotal != 0 || $clientTotal != null) && ($clientExpTime != 0 || $clientExpTime != null)){ |
| 5781 | + $up = $clientUpload; |
| 5782 | + $down = $clientDownload; |
| 5783 | + $total = $clientTotal; |
| 5784 | + $expiry = $clientExpTime; |
| 5785 | + } |
| 5786 | + |
| 5787 | + $upload = sumerize($up); |
| 5788 | + $download = sumerize($down); |
5710 | 5789 | $configLocation = ["uuid" => $text, "remark"=>$list[$keys]->remark]; |
5711 | | - $leftMb = $list[$keys]->total!=0?($list[$keys]->total - $list[$keys]->up - $list[$keys]->down):"نامحدود"; |
| 5790 | + $leftMb = $total!=0?($total - $up - $down):"نامحدود"; |
5712 | 5791 | if(is_numeric($leftMb)){ |
5713 | 5792 | if($leftMb<0){ |
5714 | 5793 | $leftMb = 0; |
5715 | 5794 | }else{ |
5716 | | - $leftMb = sumerize($list[$keys]->total - $list[$keys]->up - $list[$keys]->down); |
| 5795 | + $leftMb = sumerize($total - $up - $down); |
5717 | 5796 | } |
5718 | 5797 | } |
5719 | | - $totalUsed = sumerize($list[$keys]->up + $list[$keys]->down); |
5720 | | - $total = $list[$keys]->total!=0?sumerize($list[$keys]->total):"نامحدود"; |
5721 | | - $expiryTime = $list[$keys]->expiryTime != 0?jdate("Y-m-d H:i:s",substr($list[$keys]->expiryTime,0,-3)):"نامحدود"; |
5722 | | - $expiryDay = $list[$keys]->expiryTime != 0? |
| 5798 | + $totalUsed = sumerize($up + $down); |
| 5799 | + $total = $total!=0?sumerize($total):"نامحدود"; |
| 5800 | + |
| 5801 | + |
| 5802 | + $expiryTime = $expiry != 0?jdate("Y-m-d H:i:s",substr($expiry,0,-3)):"نامحدود"; |
| 5803 | + $expiryDay = $expiry != 0? |
5723 | 5804 | floor( |
5724 | | - ((substr($list[$keys]->expiryTime,0,-3)-time())/(60 * 60 * 24)) |
| 5805 | + ((substr($expiry,0,-3)-time())/(60 * 60 * 24)) |
5725 | 5806 | ): |
5726 | 5807 | "نامحدود"; |
5727 | 5808 | if(is_numeric($expiryDay)){ |
|
9191 | 9272 | break; |
9192 | 9273 | case "Max": |
9193 | 9274 | $txt = "ظرفیت"; |
9194 | | - break; |
| 9275 | + break; |
9195 | 9276 | case "Remark": |
9196 | 9277 | $txt ="ریمارک"; |
9197 | 9278 | break; |
9198 | 9279 | case "Flag": |
9199 | | - $txt = "پرچم"; |
| 9280 | + $txt = "پرچم"; |
9200 | 9281 | break; |
9201 | 9282 | default: |
9202 | 9283 | $txt = str_replace("_", " ", $match[1]); |
|
0 commit comments