@@ -470,9 +470,13 @@ function editInboundTraffic($server_id, $remark, $volume, $days){
470470 $ expire_microdate = ($ now_microdate > $ expiryTime ) ? $ now_microdate + $ extend_date : $ expiryTime + $ extend_date ;
471471 }
472472
473- if ($ volume != 0 ) $ total = $ total + floor ($ volume * 1073741824 );
473+ if ($ volume != 0 ){
474+ $ leftGB = $ total ;// - $up - $down;
475+ $ extend_volume = floor ($ volume * 1073741824 );
476+ $ total = ($ leftGB > 0 ) ? $ leftGB + $ extend_volume : $ extend_volume ;
477+ }
474478
475- $ dataArr = array ('up ' => 0 ,'down ' => 0 ,'total ' => is_null ($ total ) ? $ row ->total : $ total ,'remark ' => $ row ->remark ,'enable ' => 'true ' ,
479+ $ dataArr = array ('up ' => $ up ,'down ' => $ down ,'total ' => is_null ($ total ) ? $ row ->total : $ total ,'remark ' => $ row ->remark ,'enable ' => 'true ' ,
476480 'expiryTime ' => is_null ($ expire_microdate ) ? $ row ->expiryTime : $ expire_microdate , 'listen ' => '' ,'port ' => $ row ->port ,'protocol ' => $ row ->protocol ,'settings ' => $ row ->settings ,
477481 'streamSettings ' => $ row ->streamSettings , 'sniffing ' => $ row ->sniffing );
478482 $ serverName = $ server_info ['username ' ];
@@ -575,10 +579,12 @@ function editClientTraffic($server_id, $inbound_id, $remark, $volume, $days){
575579 }
576580 }
577581 if ($ volume != 0 ){
578- $ client_total = $ settings ['clients ' ][$ client_key ]['totalGB ' ] - $ up - $ down ;
582+ /*if($serverType == "sanaei") $res = resetClientTraffic($server_id, $remark, $inbound_id);
583+ else $res = resetClientTraffic($server_id, $remark);*/
584+ $ client_total = $ settings ['clients ' ][$ client_key ]['totalGB ' ];
585+ //else $client_total = $settings['clients'][$client_key]['totalGB'] - $up - $down;
579586 $ extend_volume = floor ($ volume * 1073741824 );
580587 $ volume = ($ client_total > 0 ) ? $ client_total + $ extend_volume : $ extend_volume ;
581- resetClientTraffic ($ server_id , $ remark );
582588 $ settings ['clients ' ][$ client_key ]['totalGB ' ] = $ volume ;
583589 }
584590
@@ -786,7 +792,7 @@ function deleteInbound($server_id, $remark, $delete = 0){
786792 return $ oldData ;
787793
788794}
789- function resetClientTraffic ($ server_id , $ remark ){
795+ function resetClientTraffic ($ server_id , $ remark, $ inboundId = null ){
790796 global $ connection ;
791797 $ stmt = $ connection ->prepare ("SELECT * FROM server_config WHERE id=? " );
792798 $ stmt ->bind_param ("i " , $ server_id );
@@ -828,8 +834,10 @@ function resetClientTraffic($server_id, $remark){
828834 // unlink("tempCookie.txt");
829835
830836 $ phost = str_ireplace ('https:// ' ,'' ,str_ireplace ('http:// ' ,'' ,$ panel_url ));
837+ if ($ inboundId == null ) $ url = "$ panel_url/xui/inbound/resetClientTraffic/ $ remark " ;
838+ else $ url = "$ panel_url/xui/inbound/ $ inboundId/resetClientTraffic/ $ remark " ;
831839 curl_setopt_array ($ curl , array (
832- CURLOPT_URL => " $ panel_url /xui/inbound/resetClientTraffic/ $ remark " ,
840+ CURLOPT_URL => $ url ,
833841 CURLOPT_RETURNTRANSFER => true ,
834842 CURLOPT_ENCODING => '' ,
835843 CURLOPT_MAXREDIRS => 10 ,
@@ -1119,6 +1127,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
11191127 $ alpn = $ tlsSetting ->certificates ->alpn ;
11201128 }
11211129 $ serviceName = json_decode ($ row ->streamSettings )->grpcSettings ->serviceName ;
1130+ $ grpcSecurity = json_decode ($ row ->streamSettings )->security ;
11221131 }
11231132 if ($ tlsStatus == 'tls ' ){
11241133 $ serverName = $ tlsSetting ->serverName ;
@@ -1155,6 +1164,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
11551164 $ alpn = $ tlsSetting ->alpn ;
11561165 }
11571166 $ serviceName = json_decode ($ row ->streamSettings )->grpcSettings ->serviceName ;
1167+ $ grpcSecurity = json_decode ($ row ->streamSettings )->security ;
11581168 }elseif ($ netType == 'kcp ' ){
11591169 $ kcpSettings = json_decode ($ row ->streamSettings )->kcpSettings ;
11601170 $ kcpType = $ kcpSettings ->header ->type ;
@@ -1229,7 +1239,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
12291239 if ($ netType == 'grpc ' ){
12301240 if (!is_null ($ alpn ) and json_encode ($ alpn ) != '[] ' and $ alpn != '' ) $ vmessArr ['alpn ' ] = $ alpn ;
12311241 if (strlen ($ serviceName ) > 1 ) $ vmessArr ['path ' ] = $ serviceName ;
1232- $ vmessArr ['type ' ] = ' gun ' ;
1242+ $ vmessArr ['type ' ] = $ grpcSecurity ;
12331243 $ vmessArr ['scy ' ] = 'auto ' ;
12341244 }
12351245 if ($ netType == 'kcp ' ){
@@ -1284,7 +1294,7 @@ function getConnectionLink($server_id, $uniqid, $protocol, $remark, $port, $netT
12841294 if ($ netType == 'grpc ' ){
12851295 if (!is_null ($ alpn ) and json_encode ($ alpn ) != '[] ' and $ alpn != '' ) $ vmessArr ['alpn ' ] = $ alpn ;
12861296 if (strlen ($ serviceName ) > 1 ) $ vmessArr ['path ' ] = $ serviceName ;
1287- $ vmessArr ['type ' ] = ' gun ' ;
1297+ $ vmessArr ['type ' ] = $ grpcSecurity ;
12881298 $ vmessArr ['scy ' ] = 'auto ' ;
12891299 }
12901300 if ($ netType == 'kcp ' ){
@@ -1377,7 +1387,7 @@ function editInbound($server_id, $uniqid, $remark, $protocol, $netType = 'tcp',
13771387 "clients": [
13781388 {
13791389 "id": " ' .$ uniqid .'",
1380- "alterId ": 0
1390+ "flow ": "xtls-rprx-direct"
13811391 }
13821392 ],
13831393 "decryption": "none",
@@ -1461,7 +1471,7 @@ function editInbound($server_id, $uniqid, $remark, $protocol, $netType = 'tcp',
14611471 "clients": [
14621472 {
14631473 "id": " ' .$ uniqid .'",
1464- "alterId ": 0
1474+ "flow ": "xtls-rprx-direct"
14651475 }
14661476 ],
14671477 "decryption": "none",
@@ -1957,4 +1967,4 @@ function addUser($server_id, $client_id, $protocol, $port, $expiryTime, $remark,
19571967 return json_decode ($ response );
19581968}
19591969
1960- ?>
1970+ ?>
0 commit comments