-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathduplicate.php
More file actions
81 lines (69 loc) · 2.73 KB
/
duplicate.php
File metadata and controls
81 lines (69 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
// Enable error reporting
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
error_reporting(E_ERROR | E_PARSE);
// Include the functions file
require "functions.php";
// Define the hash for each config type
$configsHash = [
"vmess" => "ps",
"vless" => "hash",
"trojan" => "hash",
"tuic" => "hash",
"hy2" => "hash",
"ss" => "name",
];
// Read the config file and split it into an array by newline
$configsArray = explode("\n", file_get_contents("config.txt"));
// Initialize arrays to store deduplicated configs and their names
$deduplicateArray = [];
$namesArray = [];
// Loop through each config in the configsArray
foreach ($configsArray as $config) {
// Detect the type of the config
$configType = detect_type($config);
// Get the hash for the config type
$configHash = $configsHash[$configType];
// Parse the config
$decodedConfig = configParse($config);
// Store the hash temporarily
$tempHash = $decodedConfig[$configHash];
// Remove the hash from the config
unset($decodedConfig[$configHash]);
// Reparse the config without the hash
$encodedConfig = reparseConfig($decodedConfig, $configType);
// If the config is not already in the deduplicateArray, add it
if (!in_array($encodedConfig, $deduplicateArray)) {
$namesArray[] = $tempHash;
$deduplicateArray[] = $encodedConfig;
}
}
// Initialize an array to store the final output
$finalOutput = [];
// Loop through each deduplicated config
foreach ($deduplicateArray as $key => $deduplicate) {
// Detect the type of the config
$configType = detect_type($deduplicate);
// Get the hash for the config type
$configHash = $configsHash[$configType];
// Parse the config
$decodedConfig = configParse($deduplicate);
// Replace the hash with the name
$decodedConfig[$configHash] = $namesArray[$key];
// Reparse the config with the name
$encodedConfig = reparseConfig($decodedConfig, $configType);
// Add the config to the final output
$finalOutput[] = $encodedConfig;
$sourceUsername = str_replace(["%20", "@"], ["", ""], explode("|", $namesArray[$key])[2]);
}
// Write the final output to the config file
file_put_contents("config.txt", implode("\n", $finalOutput));
$tempConfig = hiddifyHeader("SiNAVM | MIX") . urldecode(implode("\n", $finalOutput));
$base64TempConfig = base64_encode($tempConfig);
// Write the final output to the subscriptions/xray/normal/mix file
file_put_contents("subscriptions/xray/normal/mix", $tempConfig);
// Write the final output to the subscriptions/xray/base64/mix file, encoded in base64
file_put_contents("subscriptions/xray/base64/mix", $base64TempConfig);
// Print "done!" to the console
echo "Removing Duplicates Done!\n";