|
37 | 37 | require_once("shortcuts.inc"); |
38 | 38 | require_once("service-utils.inc"); |
39 | 39 |
|
| 40 | +$servers = openvpn_get_active_servers(); |
| 41 | +$sk_servers = openvpn_get_active_servers("p2p"); |
| 42 | +$clients = openvpn_get_active_clients(); |
| 43 | + |
40 | 44 | /* Handle AJAX */ |
41 | 45 | if ($_POST['action']) { |
42 | 46 | if ($_POST['action'] == "kill") { |
43 | | - $port = $_POST['port']; |
44 | | - $remipp = $_POST['remipp']; |
45 | | - $client_id = $_POST['client_id']; |
46 | | - if (!empty($port) and !empty($remipp)) { |
| 47 | + $port = $_POST['port']; |
| 48 | + $remipp = $_POST['remipp']; |
| 49 | + $client_id = $_POST['client_id']; |
| 50 | + $error = false; |
| 51 | + |
| 52 | + /* Validate remote IP address and port. */ |
| 53 | + if (!is_ipaddrwithport($remipp)) { |
| 54 | + $error = true; |
| 55 | + } |
| 56 | + /* Validate submitted server ID */ |
| 57 | + $found_server = false; |
| 58 | + foreach ($servers as $server) { |
| 59 | + if ($port == $server['mgmt']) { |
| 60 | + $found_server = true; |
| 61 | + } else { |
| 62 | + continue; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + if (!$error && $found_server) { |
47 | 67 | $retval = openvpn_kill_client($port, $remipp, $client_id); |
48 | 68 | echo htmlentities("|{$port}|{$remipp}|{$retval}|"); |
49 | 69 | } else { |
|
64 | 84 | } |
65 | 85 | } |
66 | 86 |
|
67 | | -$servers = openvpn_get_active_servers(); |
68 | | -$sk_servers = openvpn_get_active_servers("p2p"); |
69 | | -$clients = openvpn_get_active_clients(); |
70 | | - |
71 | 87 | include("head.inc"); ?> |
72 | 88 |
|
73 | 89 | <form action="status_openvpn.php" method="get" name="iform"> |
74 | 90 | <script type="text/javascript"> |
75 | 91 | //<![CDATA[ |
76 | 92 | function killClient(mport, remipp, client_id) { |
77 | | - var busy = function(index,icon) { |
78 | | - $(icon).bind("onclick",""); |
79 | | - $(icon).attr('src',$(icon).attr('src').replace("\.gif", "_d.gif")); |
80 | | - $(icon).css("cursor","wait"); |
| 93 | + if (client_id === '') { |
| 94 | + $('a[id="i:' + mport + ":" + remipp + '"]').first().children('i').removeClass().addClass('fa-solid fa-cog fa-spin text-danger'); |
| 95 | + } else { |
| 96 | + $('a[id="i:' + mport + ":" + remipp + '"]').last().children('i').removeClass().addClass('fa-solid fa-cog fa-spin text-danger'); |
81 | 97 | } |
82 | 98 |
|
83 | | - $('img[name="i:' + mport + ":" + remipp + '"]').each(busy); |
84 | | - |
85 | 99 | $.ajax( |
86 | 100 | "<?=$_SERVER['SCRIPT_NAME'];?>", |
87 | 101 | { |
|
0 commit comments