-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregenerate_uuid.php
44 lines (35 loc) · 1.13 KB
/
regenerate_uuid.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
include 'inc/func.php';
include 'settings.php';
$valid_users = array_keys($valid_passwords);
$user = $_SERVER['PHP_AUTH_USER'];
$pass = $_SERVER['PHP_AUTH_PW'];
$validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);
if (!$validated) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
die("Not authorized");
}
$configFile = $dir.'/config.json';
// Load the JSON configuration file
$config = json_decode(file_get_contents($configFile), true);
// Find the client with the specified UUID and update only the UUID value
$idToUpdate = $_GET['uuid'];
if (!$idToUpdate) {
echo "UUID is not provided.";
exit;
}
$newUUID = generateUUID();
$clients = &$config['inbound']['settings']['clients'];
foreach ($clients as &$client) {
if ($client['id'] === $idToUpdate) {
// $client['id'] = 'NEW_UUID_VALUE';
$client['id'] = generateUUID();
break;
}
}
// Save the updated configuration back to the file
file_put_contents($configFile, json_encode($config, JSON_PRETTY_PRINT));
// Redirect to client.php
header('Location: client.php');
exit;