@@ -16,7 +16,7 @@ |
||
16 | 16 | "protocol" => $type, |
17 | 17 | "username" => isset($parsedUrl["user"]) ? $parsedUrl["user"] : "", |
18 | 18 | "hostname" => isset($parsedUrl["host"]) ? $parsedUrl["host"] : "", |
19 | - "port" => isset($parsedUrl["port"]) ? $parsedUrl["port"]: "", |
|
19 | + "port" => isset($parsedUrl["port"]) ? $parsedUrl["port"] : "", |
|
20 | 20 | "params" => $params, |
21 | 21 | "hash" => isset($parsedUrl["fragment"]) ? $parsedUrl["fragment"] : "", |
22 | 22 | ]; |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | function getFlags($country_code) |
3 | 3 | { |
4 | - $flag = mb_convert_encoding( '&#' . ( 127397 + ord( $country_code[0] ) ) . ';', 'UTF-8', 'HTML-ENTITIES'); |
|
5 | - $flag .= mb_convert_encoding( '&#' . ( 127397 + ord( $country_code[1] ) ) . ';', 'UTF-8', 'HTML-ENTITIES'); |
|
4 | + $flag = mb_convert_encoding('&#' . (127397 + ord($country_code[0])) . ';', 'UTF-8', 'HTML-ENTITIES'); |
|
5 | + $flag .= mb_convert_encoding('&#' . (127397 + ord($country_code[1])) . ';', 'UTF-8', 'HTML-ENTITIES'); |
|
6 | 6 | return $flag; |
7 | 7 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | // Extract the title and image URL using regular expressions |
11 | 11 | $title_pattern = '#<meta property="twitter:title" content="(.*?)">#'; |
12 | 12 | $image_pattern = '#<meta property="twitter:image" content="(.*?)">#'; |
13 | - preg_match($image_pattern, $html , $image_match); |
|
14 | - preg_match($title_pattern, $html , $title_match); |
|
13 | + preg_match($image_pattern, $html, $image_match); |
|
14 | + preg_match($title_pattern, $html, $title_match); |
|
15 | 15 | |
16 | 16 | // Save the image file to local storage |
17 | 17 | file_put_contents("modules/channels/" . $channel . ".jpg", file_get_contents($image_match[1])); |
@@ -23,4 +23,4 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | // Save the channel data array as JSON |
26 | -file_put_contents("modules/channels/channels_assets.json", json_encode($channel_array , JSON_PRETTY_PRINT)); |
|
26 | +file_put_contents("modules/channels/channels_assets.json", json_encode($channel_array, JSON_PRETTY_PRINT)); |
@@ -30,29 +30,29 @@ discard block |
||
30 | 30 | return $a_time > $b_time ? -1 : 1; |
31 | 31 | } |
32 | 32 | |
33 | -function point_array($input){ |
|
33 | +function point_array($input) { |
|
34 | 34 | $usernames = array_column(array_column($input, "channel"), "username"); |
35 | 35 | $point_array = array_count_values($usernames); |
36 | 36 | return $point_array; |
37 | 37 | } |
38 | 38 | |
39 | -function lowest_ping($input){ |
|
39 | +function lowest_ping($input) { |
|
40 | 40 | return array_reduce($input, function($min, $item) { |
41 | 41 | return ($item['ping'] < $min) ? $item['ping'] : $min; |
42 | 42 | }, PHP_FLOAT_MAX); |
43 | 43 | } |
44 | -function time_coefficient($config_time){ |
|
44 | +function time_coefficient($config_time) { |
|
45 | 45 | $time_diff = strtotime(tehran_time()) - strtotime($config_time); |
46 | 46 | $time_coefficient = 1 / ($time_diff + 1); |
47 | 47 | return $time_coefficient; |
48 | 48 | } |
49 | -function ping_coefficient($config_ping, $lowest_ping){ |
|
49 | +function ping_coefficient($config_ping, $lowest_ping) { |
|
50 | 50 | $ping_diff = $config_ping - $lowest_ping; |
51 | 51 | $ping_coefficient = 1 / ($ping_diff + 1); |
52 | 52 | return $ping_coefficient; |
53 | 53 | } |
54 | 54 | |
55 | -function process_rank_file($type){ |
|
55 | +function process_rank_file($type) { |
|
56 | 56 | $last_point_array = []; |
57 | 57 | if (file_exists("ranking/channel_ranking_" . $type . ".json")) { |
58 | 58 | $last_point_array = json_decode( |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | true |
61 | 61 | ); |
62 | 62 | $last_rank_date = $last_point_array['date']; |
63 | - if (same_date($last_rank_date) === false){ |
|
63 | + if (same_date($last_rank_date) === false) { |
|
64 | 64 | unlink("ranking/channel_ranking_" . $type . ".json"); |
65 | 65 | $last_point_array['points'] = []; |
66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | return $last_point_array; |
71 | 71 | } |
72 | 72 | |
73 | -function process_points($point_array, $last_point_array){ |
|
73 | +function process_points($point_array, $last_point_array) { |
|
74 | 74 | if (!empty(array_diff_assoc($point_array, $last_point_array['points']))) { |
75 | 75 | foreach ($point_array as $channel => $point) { |
76 | 76 | if (array_key_exists($channel, $last_point_array['points'])) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $point_array = point_array($input); |
89 | 89 | $lowest_ping = lowest_ping($input); |
90 | 90 | |
91 | - foreach ($input as $key => $config){ |
|
91 | + foreach ($input as $key => $config) { |
|
92 | 92 | |
93 | 93 | $username_ch = $config['channel']['username']; |
94 | 94 | |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | $ping_coefficient = ping_coefficient($config['ping'], $lowest_ping); |
99 | 99 | $point_array[$username_ch] += $ping_coefficient; |
100 | 100 | |
101 | - switch ($config['type']){ |
|
101 | + switch ($config['type']) { |
|
102 | 102 | case "reality": |
103 | - $point_array[$username_ch] += 1 ; |
|
103 | + $point_array[$username_ch] += 1; |
|
104 | 104 | break; |
105 | 105 | } |
106 | 106 | } |
@@ -104,7 +104,7 @@ |
||
104 | 104 | // Handle the error here, e.g. by logging it |
105 | 105 | $attempts++; |
106 | 106 | if ($attempts == $max_attempts) { |
107 | - // Reached max attempts, so throw an exception to indicate failure |
|
107 | + // Reached max attempts, so throw an exception to indicate failure |
|
108 | 108 | throw new Exception('Failed to retrieve data after ' . $max_attempts . ' attempts.'); |
109 | 109 | } |
110 | 110 | sleep(1); // Wait for 1 second before retrying |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | include "modules/ranking.php"; // Include the ranking module |
7 | 7 | include "modules/singbox.php"; // Include the singbox module |
8 | 8 | |
9 | -function addHeader ($subscription, $subscriptionName) { |
|
9 | +function addHeader($subscription, $subscriptionName) { |
|
10 | 10 | $headerText = "#profile-title: base64:" . base64_encode($subscriptionName) . " |
11 | 11 | #profile-update-interval: 1 |
12 | 12 | #support-url: https://t.me/v2raycollector |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | rmdir($folder); |
28 | 28 | } |
29 | 29 | |
30 | -function seprate_by_country($configs){ |
|
30 | +function seprate_by_country($configs) { |
|
31 | 31 | $configsArray = explode("\n", $configs); |
32 | 32 | $configLocation = ""; |
33 | 33 | $output = []; |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | |
37 | 37 | if ($configType === "vmess") { |
38 | 38 | $configName = parse_config($config, "vmess", true)['ps']; |
39 | - } elseif ($configType === "vless" || $configType === "trojan" ){ |
|
39 | + } elseif ($configType === "vless" || $configType === "trojan") { |
|
40 | 40 | $configName = parse_config($config, $configType)['hash']; |
41 | - } elseif ($configType === "ss"){ |
|
41 | + } elseif ($configType === "ss") { |
|
42 | 42 | $configName = parse_config($config, "ss")['name']; |
43 | 43 | } |
44 | 44 | |
45 | - if (stripos($configName, "RELAY |
@@ -377,7 +377,7 @@ |
||
377 | 377 | $final_data[$key]["time"] = convert_to_iran_time( |
378 | 378 | $matches[1][$key] |
379 | 379 | ); |
380 | - $config_number ++ ; |
|
380 | + $config_number ++ ; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $configs = get_config_items($type, $get); |
329 | 329 | |
330 | 330 | $final_data = []; |
331 | - if ($channel === "v2raycollectordonate" ) { |
|
331 | + if ($channel === "v2raycollectordonate") { |
|
332 | 332 | $key_limit = count($configs[1]) - 20; |
333 | 333 | } else { |
334 | 334 | $key_limit = count($configs[1]) - 3; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | $final_data[$key]["time"] = convert_to_iran_time( |
380 | 380 | $matches[1][$key] |
381 | 381 | ); |
382 | - $config_number ++ ; |
|
382 | + $config_number++; |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | $array_helper_trojan = 0; |
423 | 423 | $config_number = 1; |
424 | 424 | $i = 0; |
425 | - $channel = $channel . " | Donated" ; |
|
425 | + $channel = $channel . " | Donated"; |
|
426 | 426 | foreach ($configs as $config) { |
427 | 427 | $type = detect_type($config); |
428 | 428 | $is_reality = is_reality($config, $type); |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | |
462 | 462 | $key++; |
463 | 463 | ${"array_helper_$type"} = $key; |
464 | - $config_number ++; |
|
464 | + $config_number++; |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | } |
468 | - $i ++ ; |
|
468 | + $i++; |
|
469 | 469 | return $final_data; |
470 | 470 | } |
@@ -113,16 +113,16 @@ |
||
113 | 113 | sleep($accuracy); |
114 | 114 | } |
115 | 115 | |
116 | -function filtered_or_not($input, $accuracy = 3){ |
|
116 | +function filtered_or_not($input, $accuracy = 3) { |
|
117 | 117 | $request_id = check_the_host($input); |
118 | 118 | accuracy($accuracy); |
119 | 119 | $pings = check_the_ping($request_id); |
120 | 120 | $check_host_data = json_decode($pings, true); |
121 | 121 | $ping_count = 0; |
122 | 122 | $precent = [100, 66, 33, 0]; |
123 | - if (!is_null($check_host_data)){ |
|
123 | + if (!is_null($check_host_data)) { |
|
124 | 124 | $ping_count = count($check_host_data); |
125 | - $output = $precent[$ping_count] >= 66 ? true : false ; |
|
125 | + $output = $precent[$ping_count] >= 66 ? true : false; |
|
126 | 126 | } |
127 | 127 | return $output; |
128 | 128 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function ParseTuic ($config_str) { |
|
3 | +function ParseTuic($config_str) { |
|
4 | 4 | $parsedUrl = parse_url($config_str); |
5 | 5 | |
6 | 6 | // Extract the parameters from the query string |
@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | header("Content-type: application/json;"); |
4 | 4 | |
5 | 5 | function create_tehran_timestamp_tomorrow() { |
6 | - date_default_timezone_set('Asia/Tehran'); |
|
7 | - $dateTomorrow = new DateTime('tomorrow'); |
|
8 | - $timestampTomorrow = strtotime($dateTomorrow->format('Y-m-d H:i:s')); |
|
9 | - return $timestampTomorrow; |
|
6 | + date_default_timezone_set('Asia/Tehran'); |
|
7 | + $dateTomorrow = new DateTime('tomorrow'); |
|
8 | + $timestampTomorrow = strtotime($dateTomorrow->format('Y-m-d H:i:s')); |
|
9 | + return $timestampTomorrow; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | function isEvenLength($str) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | function extract_names($input){ |
23 | 23 | foreach($input as $config){ |
24 | 24 | if ($config['tag'] !== ""){ |
25 | - $locationNames[] = $config['tag']; |
|
25 | + $locationNames[] = $config['tag']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | return $locationNames; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | "authenticated_length"=> true, |
46 | 46 | "packet_encoding"=> "", |
47 | 47 | "multiplex"=> array( |
48 | - "enabled"=> false, |
|
49 | - "protocol"=> "smux", |
|
50 | - "max_streams"=> 32 |
|
48 | + "enabled"=> false, |
|
49 | + "protocol"=> "smux", |
|
50 | + "max_streams"=> 32 |
|
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | "utls"=> array( |
61 | 61 | "enabled"=> true, |
62 | 62 | "fingerprint"=> "chrome" |
63 | - ) |
|
63 | + ) |
|
64 | 64 | ); |
65 | 65 | } |
66 | 66 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | if ( |
151 | 151 | !isEvenLength($decoded_vless["params"]["sid"]) && |
152 | 152 | !is_null($decoded_vless["params"]["sid"]) |
153 | - ) { |
|
153 | + ) { |
|
154 | 154 | return null; |
155 | 155 | } |
156 | 156 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | "server_port"=> intval($decoded_trojan['port']), |
200 | 200 | "password"=> $decoded_trojan['username'], |
201 | 201 | "multiplex"=> array( |
202 | - "enabled"=> false, |
|
203 | - "protocol"=> "smux", |
|
204 | - "max_streams"=> 32 |
|
202 | + "enabled"=> false, |
|
203 | + "protocol"=> "smux", |
|
204 | + "max_streams"=> 32 |
|
205 | 205 | ) |
206 | 206 | ); |
207 | 207 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | "headers"=> array( |
225 | 225 | "Host"=> $decoded_trojan['params']["host"] |
226 | 226 | ) |
227 | - ), |
|
228 | - "grpc" => array( |
|
227 | + ), |
|
228 | + "grpc" => array( |
|
229 | 229 | "type" => $decoded_trojan['params']["type"], |
230 | 230 | "service_name" => $decoded_trojan['params']["serviceName"], |
231 | 231 | "idle_timeout" => "15s", |
232 | 232 | "ping_timeout" => "15s", |
233 | 233 | "permit_without_stream" => false |
234 | - ) |
|
234 | + ) |
|
235 | 235 | ); |
236 | 236 | if (isset($decoded_trojan['params']["type"])){ |
237 | 237 | if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){ |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | return $length % 2 == 0; |
15 | 15 | } |
16 | 16 | |
17 | -function process_jsons($input, $locationNames){ |
|
17 | +function process_jsons($input, $locationNames) { |
|
18 | 18 | $input[0]['outbounds'] = array_merge($input[0]['outbounds'], array_filter($locationNames)); |
19 | 19 | return $input; |
20 | 20 | } |
21 | 21 | |
22 | -function extract_names($input){ |
|
23 | - foreach($input as $config){ |
|
24 | - if ($config['tag'] !== ""){ |
|
22 | +function extract_names($input) { |
|
23 | + foreach ($input as $config) { |
|
24 | + if ($config['tag'] !== "") { |
|
25 | 25 | $locationNames[] = $config['tag']; |
26 | 26 | } |
27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | function VmessSingbox($VmessUrl) { |
32 | 32 | $decode_vmess = decode_vmess($VmessUrl); |
33 | - if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === ""){ |
|
33 | + if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === "") { |
|
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | $configResult = array( |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | return $configResult; |
188 | 188 | } |
189 | 189 | |
190 | -function TrojanSingbox($TrojanUrl){ |
|
190 | +function TrojanSingbox($TrojanUrl) { |
|
191 | 191 | $decoded_trojan = parseProxyUrl($TrojanUrl); |
192 | - if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === ""){ |
|
192 | + if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === "") { |
|
193 | 193 | return null; |
194 | 194 | } |
195 | 195 | $configResult = array( |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ) |
206 | 206 | ); |
207 | 207 | |
208 | - if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls"){ |
|
208 | + if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls") { |
|
209 | 209 | $configResult['tls'] = array( |
210 | 210 | "enabled"=> true, |
211 | 211 | "server_name"=> !is_null($decoded_trojan['params']['sni']) ? $decoded_trojan['params']['sni'] : "", |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | "permit_without_stream" => false |
234 | 234 | ) |
235 | 235 | ); |
236 | - if (isset($decoded_trojan['params']["type"])){ |
|
237 | - if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){ |
|
236 | + if (isset($decoded_trojan['params']["type"])) { |
|
237 | + if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc") { |
|
238 | 238 | $configResult["transport"] = $transportTypes[$decoded_trojan['params']["type"]]; |
239 | 239 | } |
240 | 240 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | function ShadowsocksSingbox($ShadowsocksUrl) { |
245 | 245 | $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl); |
246 | - if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){ |
|
246 | + if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") { |
|
247 | 247 | return null; |
248 | 248 | } |
249 | 249 | $configResult = [ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | return $configResult; |
260 | 260 | } |
261 | 261 | |
262 | -function GenerateConfig($input, $output, $theType){ |
|
262 | +function GenerateConfig($input, $output, $theType) { |
|
263 | 263 | $outbound = []; |
264 | 264 | $v2ray_subscription = str_replace(" ", "%20", $input); |
265 | 265 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($configArray as $config) { |
268 | 268 | $configType = detect_type($config); |
269 | 269 | $config = str_replace("%20", " ", $config); |
270 | - switch($configType) { |
|
270 | + switch ($configType) { |
|
271 | 271 | case "vmess": |
272 | 272 | $configSingbox = VmessSingbox($config); |
273 | 273 | break; |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | $configSingbox = ShadowsocksSingbox($config); |
282 | 282 | break; |
283 | 283 | } |
284 | - if (!is_null($configSingbox)){ |
|
284 | + if (!is_null($configSingbox)) { |
|
285 | 285 | $configName = $configSingbox['tag']; |
286 | - if (stripos($configName, "RELAY |