|
110 | 110 | $stmt = $connection->prepare("SELECT * FROM `server_config` WHERE `id`=?"); |
111 | 111 | $stmt->bind_param("i", $server_id); |
112 | 112 | $stmt->execute(); |
113 | | - $portType = $stmt->get_result()->fetch_assoc()['port_type']; |
| 113 | + $serverConfig = $stmt->get_result()->fetch_assoc(); |
| 114 | + $serverType = $serverConfig['type']; |
| 115 | + $portType = $serverConfig['port_type']; |
| 116 | + $panelUrl = $serverConfig['panel_url']; |
114 | 117 | $stmt->close(); |
115 | 118 | include '../phpqrcode/qrlib.php'; |
116 | 119 | define('IMAGE_WIDTH',540); |
|
146 | 149 | if(!empty($description)) $remark = $description; |
147 | 150 |
|
148 | 151 | if($inbound_id == 0){ |
149 | | - $response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid); |
150 | | - if(! $response->success){ |
151 | | - $response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid); |
152 | | - } |
| 152 | + if($serverType == "marzban"){ |
| 153 | + $response = addMarzbanUser($server_id, $remark, $volume, $days, $fid); |
| 154 | + if(!$response->success){ |
| 155 | + if($response->msg == "User already exists"){ |
| 156 | + $remark .= rand(1111,99999); |
| 157 | + $response = addMarzbanUser($server_id, $remark, $volume, $days, $fid); |
| 158 | + } |
| 159 | + } |
| 160 | + }else{ |
| 161 | + $response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid); |
| 162 | + if(! $response->success){ |
| 163 | + if(strstr($response->msg, "Duplicate email")) $remark .= RandomString(); |
| 164 | + elseif(strstr($response->msg, "Port already exists")) $port = rand(1111,65000); |
| 165 | + |
| 166 | + $response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid); |
| 167 | + } |
| 168 | + } |
153 | 169 | }else { |
154 | 170 | $response = addInboundAccount($server_id, $uniqid, $inbound_id, $expire_microdate, $remark, $volume, $limitip, null, $fid); |
155 | 171 | if(! $response->success){ |
| 172 | + if(strstr($response->msg, "Duplicate email")) $remark .= RandomString(); |
| 173 | + |
156 | 174 | $response = addInboundAccount($server_id, $uniqid, $inbound_id, $expire_microdate, $remark, $volume, $limitip, null, $fid); |
157 | 175 | } |
158 | 176 | } |
|
188 | 206 | exit; |
189 | 207 | } |
190 | 208 |
|
191 | | - $vraylink = getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netType, $inbound_id, $rahgozar, $customPath, $customPort, $customSni); |
192 | | - $token = RandomString(30); |
193 | | - $subLink = $botState['subLinkState']=="on"?$botUrl . "settings/subLink.php?token=" . $token:""; |
| 209 | + if($serverType == "marzban"){ |
| 210 | + $uniqid = $token = str_replace("/sub/", "", $response->sub_link); |
| 211 | + $subLink = $botState['subLinkState'] == "on"?$panelUrl . $response->sub_link:""; |
| 212 | + $vraylink = $response->vray_links; |
| 213 | + } |
| 214 | + else{ |
| 215 | + $vraylink = getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netType, $inbound_id, $rahgozar, $customPath, $customPort, $customSni); |
| 216 | + $token = RandomString(30); |
| 217 | + $subLink = $botState['subLinkState']=="on"?$botUrl . "settings/subLink.php?token=" . $token:""; |
| 218 | + } |
194 | 219 |
|
195 | 220 | foreach($vraylink as $vray_link){ |
196 | 221 | $acc_text = " |
|
336 | 361 | $name = $respd['title']; |
337 | 362 | $days = $respd['days']; |
338 | 363 | $volume = $respd['volume']; |
339 | | - |
340 | | - if($inbound_id > 0) |
341 | | - $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew"); |
342 | | - else |
343 | | - $response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew"); |
344 | | - |
| 364 | + global $connection; |
| 365 | + |
| 366 | + $stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?"); |
| 367 | + $stmt->bind_param("i", $server_id); |
| 368 | + $stmt->execute(); |
| 369 | + $server_info = $stmt->get_result()->fetch_assoc(); |
| 370 | + $stmt->close(); |
| 371 | + $serverType = $server_info['type']; |
| 372 | + |
| 373 | + if($serverType == "marzban"){ |
| 374 | + $response = editMarzbanConfig($server_id, ['remark'=>$remark, 'days'=>$days, 'volume' => $volume]); |
| 375 | + }else{ |
| 376 | + if($inbound_id > 0) |
| 377 | + $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew"); |
| 378 | + else |
| 379 | + $response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew"); |
| 380 | + } |
| 381 | + |
345 | 382 | if(is_null($response)){ |
346 | 383 | $stmt = $connection->prepare("UPDATE `users` SET `wallet` = `wallet` + ? WHERE `userid` = ?"); |
347 | 384 | $stmt->bind_param("ii", $price, $user_id); |
|
408 | 445 | $stmt->close(); |
409 | 446 | $volume = $res['volume']; |
410 | 447 |
|
411 | | - if($inbound_id > 0) |
412 | | - $response = editClientTraffic($server_id, $inbound_id, $uuid, 0, $volume); |
413 | | - else |
414 | | - $response = editInboundTraffic($server_id, $uuid, 0, $volume); |
| 448 | + |
| 449 | + $stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?"); |
| 450 | + $stmt->bind_param("i", $server_id); |
| 451 | + $stmt->execute(); |
| 452 | + $server_info = $stmt->get_result()->fetch_assoc(); |
| 453 | + $stmt->close(); |
| 454 | + $serverType = $server_info['type']; |
| 455 | + |
| 456 | + if($serverType == "marzban"){ |
| 457 | + $response = editMarzbanConfig($server_id, ['remark'=>$remark, 'plus_day'=>$volume]); |
| 458 | + }else{ |
| 459 | + if($inbound_id > 0) |
| 460 | + $response = editClientTraffic($server_id, $inbound_id, $uuid, 0, $volume); |
| 461 | + else |
| 462 | + $response = editInboundTraffic($server_id, $uuid, 0, $volume); |
| 463 | + } |
415 | 464 |
|
416 | 465 | if($response->success){ |
417 | 466 | $stmt = $connection->prepare("UPDATE `orders_list` SET `expire_date` = `expire_date` + ?, `notif` = 0 WHERE `uuid` = ?"); |
|
482 | 531 |
|
483 | 532 | $acctxt = ''; |
484 | 533 |
|
485 | | - |
486 | | - if($inbound_id > 0) |
487 | | - $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, 0); |
488 | | - else |
489 | | - $response = editInboundTraffic($server_id, $uuid, $volume, 0); |
| 534 | + $stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?"); |
| 535 | + $stmt->bind_param("i", $server_id); |
| 536 | + $stmt->execute(); |
| 537 | + $server_info = $stmt->get_result()->fetch_assoc(); |
| 538 | + $stmt->close(); |
| 539 | + $serverType = $server_info['type']; |
| 540 | + |
| 541 | + if($serverType == "marzban"){ |
| 542 | + $response = editMarzbanConfig($server_id, ['remark'=>$remark, 'plus_day'=>$volume]); |
| 543 | + }else{ |
| 544 | + if($inbound_id > 0) |
| 545 | + $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, 0); |
| 546 | + else |
| 547 | + $response = editInboundTraffic($server_id, $uuid, $volume, 0); |
| 548 | + } |
490 | 549 | if($response->success){ |
491 | 550 | $stmt = $connection->prepare("UPDATE `orders_list` SET `notif` = 0 WHERE `uuid` = ?"); |
492 | 551 | $stmt->bind_param("s", $uuid); |
|
549 | 608 | $configInfo = json_decode($payParam['description'],true); |
550 | 609 | $uuid = $configInfo['uuid']; |
551 | 610 | $remark = $configInfo['remark']; |
552 | | - |
| 611 | + $isMarzban = $configInfo['marzban']; |
| 612 | + |
553 | 613 | $uuid = $payParam['description']; |
554 | 614 | $inbound_id = $payParam['volume']; |
555 | 615 |
|
556 | | - if($inbound_id > 0) |
557 | | - $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew"); |
558 | | - else |
559 | | - $response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew"); |
| 616 | + if($isMarzban){ |
| 617 | + $response = editMarzbanConfig($server_id, ['remark'=>$remark, 'days'=>$days, 'volume' => $volume]); |
| 618 | + }else{ |
| 619 | + if($inbound_id > 0) |
| 620 | + $response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew"); |
| 621 | + else |
| 622 | + $response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew"); |
| 623 | + } |
560 | 624 |
|
561 | 625 | if(is_null($response)){ |
562 | 626 | sendMessage('🔻مشکل فنی در اتصال به سرور. لطفا به مدیریت اطلاع بدید',null,null,$user_id); |
|
0 commit comments