-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVPNUsers.php
More file actions
79 lines (54 loc) · 2.45 KB
/
Copy pathVPNUsers.php
File metadata and controls
79 lines (54 loc) · 2.45 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
<?php
//Configuraton
$apikey = "<set API KEY HERE>";
$fgip = "<Set Firewall IP HERE>";
//Check if a user needs disconnected
if ($_POST) {
$kickindex = $_POST['userindex'];
$apikick = "https://" . $fgip . ":443/api/v2/monitor/vpn/ssl/delete?access_token=" . $apikey;
//$content = json_encode($fields);
$content = '{ "type": "websession", "index": ' . $kickindex . '}';
$curl = curl_init($apikick);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("accept: application/json,Content-Type: application/x-www-form-urlencoded"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
//if ( $status != 201 ) {
// die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
//}
curl_close($curl);
$response = json_decode($json_response, true);
}
//Get List of current users
$apicall = "https://" . $fgip . ":443/api/v2/monitor/vpn/ssl?access_token=" . $apikey . "";
// create curl session
$ch = curl_init();
// set user agent header
curl_setopt(CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
curl_setopt($ch, CURLOPT_HEADER, 0);
// set our url
curl_setopt($ch, CURLOPT_URL, $apicall);
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// ignore SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// $output contains the output string
$output = curl_exec($ch);
// close curl
curl_close($ch);
//echo $output;
$response = json_decode($output, true);
echo "<h1>Current VPN Users:</h1>";
echo "<table border='1'><tr><th>Disconnect</th><th>Username</th></tr>";
foreach($response[results] as $key=>$value){
$userindex = $value['index'];
$username = $value['user_name'];
echo "<tr><td> <form method='post' action='" . $_SERVER['PHP_SELF'] . "'><input type='hidden' name='userindex' value=' " . $userindex . "'><input type='submit' name='submit' value='Disconnect'></form></td><td>" . $username . "</td>$
}
?>