-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.php
46 lines (33 loc) · 1.12 KB
/
reset.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
45
46
<?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");
}
// Execute the systemctl command to get the V2Ray status
exec('systemctl status v2ray', $output, $returnVar);
// Check if the command executed successfully
if ($returnVar === 0) {
// Output the command output
foreach ($output as $line) {
echo $line . "<br>";
}
} else {
echo "Failed to retrieve V2Ray status";
}
// Execute the systemctl restart command
//exec('systemctl restart v2ray', $output, $returnCode);
$command = '/var/www/v2ray_restart.sh';
$output = exec($command, $outputArray, $returnCode);
// Check the return code to determine if the restart was successful
if ($returnCode === 0) {
echo 'v2ray service restarted successfully.';
} else {
echo 'Failed to restart v2ray service. Error code: ' . $returnCode;
}
?>