-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.php
More file actions
71 lines (53 loc) · 1.93 KB
/
json.php
File metadata and controls
71 lines (53 loc) · 1.93 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
<?php
/**
* Created by PhpStorm.
* User: samfaunt
* Date: 11/08/2016
* Time: 10:06 PM
*/
function stations($ip, $username, $password) {
$fields = [
'username' => $username,
'password' => $password,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, sprintf('https://%s/login.cgi', $ip));
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch); // Login
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_URL, sprintf('https://%s/sta.cgi', $ip));
$stations = curl_exec($ch); // Get Statons
curl_close($ch);
return json_decode($stations);
}
function sizeFilter( $bytes )
{
$label = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB' );
for( $i = 0; $bytes >= 1024 && $i < ( count( $label ) -1 ); $bytes /= 1024, $i++ );
return( round( $bytes, 2 ));
}
function clientInfo($ipaddress,$username,$password)
{
$clients = stations($ipaddress, $username, $password);
foreach ($clients as $i => $client) {
$clientname = $clients[$i]->remote->hostname;
$signal = $clients[$i]->remote->signal;
$devicetype = $clients[$i]->remote->platform;
$firmware = $clients[$i]->remote->version;
$uplinkcapacity = $clients[$i]->airmax->uplink_capacity;
$uplinkcapacity = sizeFilter($uplinkcapacity);
$downlinkcapacity = $clients[$i]->airmax->downlink_capacity;
$downlinkcapacity = sizeFilter($downlinkcapacity);
$apclients[$i] = array
(
array($clientname, $signal, $devicetype, $firmware, $uplinkcapacity, $downlinkcapacity)
);
return $apclients;
}
}