-
Notifications
You must be signed in to change notification settings - Fork 66
/
sort.php
44 lines (38 loc) · 1.54 KB
/
sort.php
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
<?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";
// Read the config.txt file and split it into an array by newline
$configsArray = explode("\n", file_get_contents("config.txt"));
// Initialize an empty array to hold the sorted configurations
$sortArray = [];
// Loop through each configuration in the configsArray
foreach ($configsArray as $config) {
// Detect the type of the configuration
$configType = detect_type($config);
// Add the configuration to the corresponding array in sortArray
$sortArray[$configType][] = urldecode($config);
// If the configuration is of type "vless" and is a reality, add it to the "reality" array
if ($configType === "vless" && is_reality($config)) {
$sortArray["reality"][] = urldecode($config);
}
}
// Loop through each type of configuration in sortArray
foreach ($sortArray as $type => $sort) {
// If the type is not empty
if ($type !== "") {
// Join the configurations into a string, encode it to base64, and write it to a file
$tempConfigs = hiddifyHeader("TVC | " . strtoupper($type)) . implode("\n", $sort);
$base64TempConfigs = base64_encode($tempConfigs);
file_put_contents("subscriptions/xray/normal/" . $type, $tempConfigs);
file_put_contents(
"subscriptions/xray/base64/" . $type,
$base64TempConfigs
);
}
}
// Print "done!" to the console
echo "Sorting Done!";