| @@ -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 | } | 
| @@ -329,7 +329,7 @@ discard block | ||
| 329 | 329 | $configs = get_config_items($type, $get); | 
| 330 | 330 | |
| 331 | 331 | $final_data = []; | 
| 332 | -    if ($channel === "v2raycollectordonate" ) { | |
| 332 | +    if ($channel === "v2raycollectordonate") { | |
| 333 | 333 | $key_limit = count($configs[1]) - 20; | 
| 334 | 334 |      } else { | 
| 335 | 335 | $key_limit = count($configs[1]) - 3; | 
| @@ -381,7 +381,7 @@ discard block | ||
| 381 | 381 | $final_data[$key]["time"] = convert_to_iran_time( | 
| 382 | 382 | $matches[1][$key] | 
| 383 | 383 | ); | 
| 384 | - $config_number ++ ; | |
| 384 | + $config_number++; | |
| 385 | 385 | } | 
| 386 | 386 | } | 
| 387 | 387 | } | 
| @@ -463,10 +463,10 @@ discard block | ||
| 463 | 463 | |
| 464 | 464 | $key++; | 
| 465 | 465 |                  ${"array_helper_$type"} = $key; | 
| 466 | - $config_number ++; | |
| 466 | + $config_number++; | |
| 467 | 467 | } | 
| 468 | 468 | } | 
| 469 | 469 | } | 
| 470 | - $i ++ ; | |
| 470 | + $i++; | |
| 471 | 471 | return $final_data; | 
| 472 | 472 | } | 
| @@ -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 | 
| @@ -17,7 +17,7 @@ discard block | ||
| 17 | 17 | rmdir($folder); | 
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | -function seprate_by_country($configs){ | |
| 20 | +function seprate_by_country($configs) { | |
| 21 | 21 |      $configsArray = explode("\n", $configs); | 
| 22 | 22 | $configLocation = ""; | 
| 23 | 23 | $output = []; | 
| @@ -26,13 +26,13 @@ discard block | ||
| 26 | 26 | |
| 27 | 27 |          if ($configType === "vmess") { | 
| 28 | 28 | $configName = parse_config($config, "vmess", true)['ps']; | 
| 29 | -        } elseif ($configType === "vless" || $configType === "trojan" ){ | |
| 29 | +        } elseif ($configType === "vless" || $configType === "trojan") { | |
| 30 | 30 | $configName = parse_config($config, $configType)['hash']; | 
| 31 | -        } elseif ($configType === "ss"){ | |
| 31 | +        } elseif ($configType === "ss") { | |
| 32 | 32 | $configName = parse_config($config, "ss")['name']; | 
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | - if (stripos($configName, "RELAY | |
| @@ -7,14 +7,14 @@ discard block | ||
| 7 | 7 | return $length % 2 == 0; | 
| 8 | 8 | } | 
| 9 | 9 | |
| 10 | -function process_jsons($input, $locationNames){ | |
| 10 | +function process_jsons($input, $locationNames) { | |
| 11 | 11 | $input[0]['outbounds'] = array_merge($input[0]['outbounds'], array_filter($locationNames)); | 
| 12 | 12 | return $input; | 
| 13 | 13 | } | 
| 14 | 14 | |
| 15 | -function extract_names($input){ | |
| 16 | -    foreach($input as $config){ | |
| 17 | -        if ($config['tag'] !== ""){ | |
| 15 | +function extract_names($input) { | |
| 16 | +    foreach ($input as $config) { | |
| 17 | +        if ($config['tag'] !== "") { | |
| 18 | 18 | $locationNames[] = $config['tag']; | 
| 19 | 19 | } | 
| 20 | 20 | } | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 | |
| 24 | 24 |  function VmessSingbox($VmessUrl) { | 
| 25 | 25 | $decode_vmess = decode_vmess($VmessUrl); | 
| 26 | -    if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === ""){ | |
| 26 | +    if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === "") { | |
| 27 | 27 | return null; | 
| 28 | 28 | } | 
| 29 | 29 | $configResult = array( | 
| @@ -180,9 +180,9 @@ discard block | ||
| 180 | 180 | return $configResult; | 
| 181 | 181 | } | 
| 182 | 182 | |
| 183 | -function TrojanSingbox($TrojanUrl){ | |
| 183 | +function TrojanSingbox($TrojanUrl) { | |
| 184 | 184 | $decoded_trojan = parseProxyUrl($TrojanUrl); | 
| 185 | -    if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === ""){ | |
| 185 | +    if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === "") { | |
| 186 | 186 | return null; | 
| 187 | 187 | } | 
| 188 | 188 | $configResult = array( | 
| @@ -198,7 +198,7 @@ discard block | ||
| 198 | 198 | ) | 
| 199 | 199 | ); | 
| 200 | 200 | |
| 201 | -    if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls"){ | |
| 201 | +    if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls") { | |
| 202 | 202 | $configResult['tls'] = array( | 
| 203 | 203 | "enabled"=> true, | 
| 204 | 204 | "server_name"=> !is_null($decoded_trojan['params']['sni']) ? $decoded_trojan['params']['sni'] : "", | 
| @@ -226,8 +226,8 @@ discard block | ||
| 226 | 226 | "permit_without_stream" => false | 
| 227 | 227 | ) | 
| 228 | 228 | ); | 
| 229 | -    if (isset($decoded_trojan['params']["type"])){ | |
| 230 | -        if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){ | |
| 229 | +    if (isset($decoded_trojan['params']["type"])) { | |
| 230 | +        if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc") { | |
| 231 | 231 | $configResult["transport"] = $transportTypes[$decoded_trojan['params']["type"]]; | 
| 232 | 232 | } | 
| 233 | 233 | } | 
| @@ -236,7 +236,7 @@ discard block | ||
| 236 | 236 | |
| 237 | 237 |  function ShadowsocksSingbox($ShadowsocksUrl) { | 
| 238 | 238 | $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl); | 
| 239 | -    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){ | |
| 239 | +    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") { | |
| 240 | 240 | return null; | 
| 241 | 241 | } | 
| 242 | 242 | $configResult = [ | 
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | return $configResult; | 
| 253 | 253 | } | 
| 254 | 254 | |
| 255 | -function GenerateConfig($input, $output){ | |
| 255 | +function GenerateConfig($input, $output) { | |
| 256 | 256 | $outbound = []; | 
| 257 | 257 |      $v2ray_subscription = str_replace(" ", "%20", $input); | 
| 258 | 258 | |
| @@ -260,7 +260,7 @@ discard block | ||
| 260 | 260 |      foreach ($configArray as $config) { | 
| 261 | 261 | $configType = detect_type($config); | 
| 262 | 262 |          $config = str_replace("%20", " ", $config); | 
| 263 | -        switch($configType) { | |
| 263 | +        switch ($configType) { | |
| 264 | 264 | case "vmess": | 
| 265 | 265 | $configSingbox = VmessSingbox($config); | 
| 266 | 266 | break; | 
| @@ -274,9 +274,9 @@ discard block | ||
| 274 | 274 | $configSingbox = ShadowsocksSingbox($config); | 
| 275 | 275 | break; | 
| 276 | 276 | } | 
| 277 | -        if (!is_null($configSingbox)){ | |
| 277 | +        if (!is_null($configSingbox)) { | |
| 278 | 278 | $configName = $configSingbox['tag']; | 
| 279 | - if (stripos($configName, "RELAY | |