| Conditions | 7 |
| Paths | 24 |
| Total Lines | 28 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | function remove_duplicate_vmess($input) |
||
| 17 | { |
||
| 18 | $array = explode("\n", $input); |
||
| 19 | $result = []; |
||
| 20 | foreach ($array as $item) { |
||
| 21 | $parts = decode_vmess($item); |
||
| 22 | if ($parts !== NULL) { |
||
| 23 | $part_ps = $parts["ps"]; |
||
| 24 | unset($parts["ps"]); |
||
| 25 | if (count($parts) >= 3) { |
||
| 26 | ksort($parts); |
||
| 27 | $part_serialize = base64_encode(serialize($parts)); |
||
| 28 | $result[$part_serialize][] = $part_ps ?? ""; |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | $finalResult = []; |
||
| 33 | foreach ($result as $serial => $ps) { |
||
| 34 | $partAfterHash = $ps[0] ?? ""; |
||
| 35 | $part_serialize = unserialize(base64_decode($serial)); |
||
| 36 | $part_serialize["ps"] = $partAfterHash; |
||
| 37 | $finalResult[] = encode_vmess($part_serialize); |
||
| 38 | } |
||
| 39 | $output = ""; |
||
| 40 | foreach ($finalResult as $config) { |
||
| 41 | $output .= $output == "" ? $config : "\n" . $config; |
||
| 42 | } |
||
| 43 | return $output; |
||
| 44 | } |
||
| 45 |