Skip to content

Commit 016f90d

Browse files
authored
Update back.php
1 parent 0f004bf commit 016f90d

File tree

1 file changed

+84
-29
lines changed

1 file changed

+84
-29
lines changed

pay/back.php

Lines changed: 84 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ function doAction($payRowId, $gateType){
291291
$server_info = $stmt->get_result()->fetch_assoc();
292292
$serverType = $server_info['type'];
293293
$portType = $server_info['port_type'];
294+
$panelUrl = $server_info['panel_url'];
294295
$stmt->close();
295296
include '../phpqrcode/qrlib.php';
296297
define('IMAGE_WIDTH',540);
@@ -325,13 +326,23 @@ function doAction($payRowId, $gateType){
325326
if(!empty($description)) $remark = $description;
326327

327328
if($inbound_id == 0){
328-
$response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid);
329-
if(! $response->success){
330-
if(strstr($response->msg, "Duplicate email")) $remark .= RandomString();
331-
elseif(strstr($response->msg, "Port already exists")) $port = rand(1111,65000);
332-
333-
$response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid);
334-
}
329+
if($serverType == "marzban"){
330+
$response = addMarzbanUser($server_id, $remark, $volume, $days, $fid);
331+
if(!$response->success){
332+
if($response->msg == "User already exists"){
333+
$remark .= rand(1111,99999);
334+
$response = addMarzbanUser($server_id, $remark, $volume, $days, $fid);
335+
}
336+
}
337+
}else{
338+
$response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid);
339+
if(! $response->success){
340+
if(strstr($response->msg, "Duplicate email")) $remark .= RandomString();
341+
elseif(strstr($response->msg, "Port already exists")) $port = rand(1111,65000);
342+
343+
$response = addUser($server_id, $uniqid, $protocol, $port, $expire_microdate, $remark, $volume, $netType, 'none', $rahgozar, $fid);
344+
}
345+
}
335346
}else {
336347
if($botState['firstUseState'] == "on" && ($serverType == "sanaei" || $serverType == "alireza")) $expire_microdate = $days * -86400000;
337348

@@ -376,10 +387,17 @@ function doAction($payRowId, $gateType){
376387
sendMessage("✅ مبلغ " . number_format($amount) . " تومان به کیف پول کاربر $user_id توسط درگاه اضافه شد میخواست کانفیگ بخره، ولی خطا داد",null,null,$admin);
377388
exit;
378389
}
379-
380-
$vraylink = getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netType, $inbound_id, $rahgozar, $customPath, $customPort, $customSni);
381-
$token = RandomString(30);
382-
$subLink = $botState['subLinkState']=="on"?$botUrl . "settings/subLink.php?token=" . $token:"";
390+
391+
if($serverType == "marzban"){
392+
$uniqid = $token = str_replace("/sub/", "", $response->sub_link);
393+
$subLink = $botState['subLinkState'] == "on"?$panelUrl . $response->sub_link:"";
394+
$vraylink = $response->vray_links;
395+
}
396+
else{
397+
$vraylink = getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netType, $inbound_id, $rahgozar, $customPath, $customPort, $customSni);
398+
$token = RandomString(30);
399+
$subLink = $botState['subLinkState']=="on"?$botUrl . "settings/subLink.php?token=" . $token:"";
400+
}
383401

384402
foreach($vraylink as $vray_link){
385403
$acc_text = "
@@ -526,10 +544,21 @@ function doAction($payRowId, $gateType){
526544
$days = $respd['days'];
527545
$volume = $respd['volume'];
528546

529-
if($inbound_id > 0)
530-
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew");
531-
else
532-
$response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew");
547+
$stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?");
548+
$stmt->bind_param("i", $server_id);
549+
$stmt->execute();
550+
$server_info = $stmt->get_result()->fetch_assoc();
551+
$stmt->close();
552+
$serverType = $server_info['type'];
553+
554+
if($serverType == "marzban"){
555+
$response = editMarzbanConfig($server_id, ['remark'=>$remark, 'days'=>$days, 'volume' => $volume]);
556+
}else{
557+
if($inbound_id > 0)
558+
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew");
559+
else
560+
$response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew");
561+
}
533562

534563
if(is_null($response)){
535564
showForm('پرداخت شما با موفقیت انجام شد ولی مشکل فنی در اتصال به سرور. لطفا به مدیریت اطلاع بدید، مبلغ ' . number_format($amount) . " تومان به کیف پول شما اضافه شد",$payDescription);
@@ -599,10 +628,21 @@ function doAction($payRowId, $gateType){
599628
$stmt->close();
600629
$volume = $res['volume'];
601630

602-
if($inbound_id > 0)
603-
$response = editClientTraffic($server_id, $inbound_id, $uuid, 0, $volume);
604-
else
605-
$response = editInboundTraffic($server_id, $uuid, 0, $volume);
631+
$stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?");
632+
$stmt->bind_param("i", $server_id);
633+
$stmt->execute();
634+
$server_info = $stmt->get_result()->fetch_assoc();
635+
$stmt->close();
636+
$serverType = $server_info['type'];
637+
638+
if($serverType == "marzban"){
639+
$response = editMarzbanConfig($server_id, ['remark'=>$remark, 'plus_day'=>$volume]);
640+
}else{
641+
if($inbound_id > 0)
642+
$response = editClientTraffic($server_id, $inbound_id, $uuid, 0, $volume);
643+
else
644+
$response = editInboundTraffic($server_id, $uuid, 0, $volume);
645+
}
606646

607647
if($response->success){
608648
$stmt = $connection->prepare("UPDATE `orders_list` SET `expire_date` = `expire_date` + ?, `notif` = 0 WHERE `uuid` = ?");
@@ -673,12 +713,22 @@ function doAction($payRowId, $gateType){
673713
$volume = $res['volume'];
674714

675715
$acctxt = '';
676-
677716

678-
if($inbound_id > 0)
679-
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, 0);
680-
else
681-
$response = editInboundTraffic($server_id, $uuid, $volume, 0);
717+
$stmt = $connection->prepare("SELECT * FROM server_config WHERE id=?");
718+
$stmt->bind_param("i", $server_id);
719+
$stmt->execute();
720+
$server_info = $stmt->get_result()->fetch_assoc();
721+
$stmt->close();
722+
$serverType = $server_info['type'];
723+
724+
if($serverType == "marzban"){
725+
$response = editMarzbanConfig($server_id, ['remark'=>$remark, 'plus_volume'=>$volume]);
726+
}else{
727+
if($inbound_id > 0)
728+
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, 0);
729+
else
730+
$response = editInboundTraffic($server_id, $uuid, $volume, 0);
731+
}
682732
if($response->success){
683733
$stmt = $connection->prepare("UPDATE `orders_list` SET `notif` = 0 WHERE `uuid` = ?");
684734
$stmt->bind_param("s", $uuid);
@@ -743,14 +793,19 @@ function doAction($payRowId, $gateType){
743793
$configInfo = json_decode($payParam['description'],true);
744794
$uuid = $configInfo['uuid'];
745795
$remark = $configInfo['remark'];
746-
796+
$isMarzban = $configInfo['marzban'];
797+
747798
$uuid = $payParam['description'];
748799
$inbound_id = $payParam['volume'];
749800

750-
if($inbound_id > 0)
751-
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew");
752-
else
753-
$response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew");
801+
if(isset($isMarzban)){
802+
$response = editMarzbanConfig($server_id, ['remark'=>$remark, 'days'=>$days, 'volume' => $volume]);
803+
}else{
804+
if($inbound_id > 0)
805+
$response = editClientTraffic($server_id, $inbound_id, $uuid, $volume, $days, "renew");
806+
else
807+
$response = editInboundTraffic($server_id, $uuid, $volume, $days, "renew");
808+
}
754809

755810
if(is_null($response)){
756811
alert('🔻مشکل فنی در اتصال به سرور. لطفا به مدیریت اطلاع بدید',true);

0 commit comments

Comments
 (0)