|
|
|
|
@@ -428,7 +428,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (12 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attributes = [
|
|
|
|
|
'bytes',
|
|
|
|
|
@@ -463,7 +463,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attributes = [
|
|
|
|
|
'bytes',
|
|
|
|
|
@@ -536,7 +536,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (12 * 3600 * 1000) : intval($start);
|
|
|
|
|
$json = ['attrs' => ['bytes', 'num_sta', 'time'], 'start' => $start, 'end' => $end];
|
|
|
|
|
if (!is_null($mac)) {
|
|
|
|
|
@@ -567,7 +567,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$json = ['attrs' => ['bytes', 'num_sta', 'time'], 'start' => $start, 'end' => $end];
|
|
|
|
|
if (!is_null($mac)) {
|
|
|
|
|
@@ -597,7 +597,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$json = ['attrs' => ['bytes', 'num_sta', 'time'], 'start' => $start, 'end' => $end];
|
|
|
|
|
if (!is_null($mac)) {
|
|
|
|
|
@@ -634,7 +634,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (12 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attribs = is_null($attribs) ? ['time', 'rx_bytes', 'tx_bytes'] : array_merge(['time'], $attribs);
|
|
|
|
|
$json = ['attrs' => $attribs, 'start' => $start, 'end' => $end, 'mac' => strtolower($mac)];
|
|
|
|
|
@@ -666,7 +666,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attribs = is_null($attribs) ? ['time', 'rx_bytes', 'tx_bytes'] : array_merge(['time'], $attribs);
|
|
|
|
|
$json = ['attrs' => $attribs, 'start' => $start, 'end' => $end, 'mac' => strtolower($mac)];
|
|
|
|
|
@@ -698,7 +698,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attribs = is_null($attribs) ? ['time', 'rx_bytes', 'tx_bytes'] : array_merge(['time'], $attribs);
|
|
|
|
|
$json = ['attrs' => $attribs, 'start' => $start, 'end' => $end, 'mac' => strtolower($mac)];
|
|
|
|
|
@@ -732,7 +732,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (12 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attribs = is_null($attribs) ? ['time', 'mem', 'cpu', 'loadavg_5'] : array_merge(['time'], $attribs);
|
|
|
|
|
$json = json_encode(['attrs' => $attribs, 'start' => $start, 'end' => $end]);
|
|
|
|
|
@@ -762,7 +762,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (7 * 24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$attribs = is_null($attribs) ? ['time', 'mem', 'cpu', 'loadavg_5'] : array_merge(['time'], $attribs);
|
|
|
|
|
$json = json_encode(['attrs' => $attribs, 'start' => $start, 'end' => $end]);
|
|
|
|
|
@@ -818,7 +818,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? ((time()) * 1000) : intval($end);
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$json = ['attrs' => ['xput_download', 'xput_upload', 'latency', 'time'], 'start' => $start, 'end' => $end];
|
|
|
|
|
$json = json_encode($json);
|
|
|
|
|
@@ -827,6 +827,35 @@ class Client
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method to fetch IPS/IDS event
|
|
|
|
|
* ----------------------------------
|
|
|
|
|
* returns an array of IPS/IDS event objects
|
|
|
|
|
* optional parameter <start> = Unix timestamp in milliseconds
|
|
|
|
|
* optional parameter <end> = Unix timestamp in milliseconds
|
|
|
|
|
* optional parameter <limit> = Maximum number of events to return, defaults to 10000
|
|
|
|
|
*
|
|
|
|
|
* NOTES:
|
|
|
|
|
* - defaults to the past 24 hours
|
|
|
|
|
* - requires a USG
|
|
|
|
|
* - supported in UniFi controller versions 5.9.X and higher
|
|
|
|
|
*/
|
|
|
|
|
public function stat_ips_events($start = null, $end = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$end = is_null($end) ? (time() * 1000) : intval($end);
|
|
|
|
|
$start = is_null($start) ? $end - (24 * 3600 * 1000) : intval($start);
|
|
|
|
|
$limit = is_null($limit) ? 10000 : intval($limit);
|
|
|
|
|
$json = ['start' => $start, 'end' => $end, '_limit' => $limit];
|
|
|
|
|
$json = json_encode($json);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/stat/ips/event', 'json=' . $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show all login sessions
|
|
|
|
|
* -----------------------
|
|
|
|
|
@@ -1068,12 +1097,12 @@ class Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->request_type = 'POST';
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'name' => $group_name,
|
|
|
|
|
'qos_rate_max_down' => intval($group_dn),
|
|
|
|
|
'qos_rate_max_up' => intval($group_up)
|
|
|
|
|
]);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/usergroup', $json);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/usergroup', $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
@@ -1095,7 +1124,7 @@ class Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->request_type = 'PUT';
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'_id' => $group_id,
|
|
|
|
|
'name' => $group_name,
|
|
|
|
|
'qos_rate_max_down' => intval($group_dn),
|
|
|
|
|
@@ -1103,7 +1132,7 @@ class Client
|
|
|
|
|
'site_id' => $site_id
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/usergroup/' . trim($group_id), $json);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/usergroup/' . trim($group_id), $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
@@ -1129,15 +1158,16 @@ class Client
|
|
|
|
|
/**
|
|
|
|
|
* List firewall groups (using REST)
|
|
|
|
|
* ----------------------------------
|
|
|
|
|
* returns an array containing the current firewall groups on success
|
|
|
|
|
* returns an array containing the current firewall groups or the selected firewall group on success
|
|
|
|
|
* optional parameter <group_id> = id of the single firewall group to list
|
|
|
|
|
*/
|
|
|
|
|
public function list_firewallgroups()
|
|
|
|
|
public function list_firewallgroups($group_id = null)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup');
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup/' . trim($group_id));
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
@@ -1162,12 +1192,12 @@ class Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->request_type = 'POST';
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'name' => $group_name,
|
|
|
|
|
'group_type' => $group_type,
|
|
|
|
|
'group_members' => $group_members
|
|
|
|
|
]);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup', $json);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup', $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
@@ -1197,14 +1227,14 @@ class Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->request_type = 'PUT';
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'_id' => $group_id,
|
|
|
|
|
'name' => $group_name,
|
|
|
|
|
'group_type' => $group_type,
|
|
|
|
|
'group_members' => $group_members,
|
|
|
|
|
'site_id' => $site_id
|
|
|
|
|
]);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup/' . trim($group_id),
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallgroup/' . trim($group_id),
|
|
|
|
|
$json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
@@ -1228,6 +1258,22 @@ class Client
|
|
|
|
|
return $this->process_response_boolean($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List firewall rules (using REST)
|
|
|
|
|
* ----------------------------------
|
|
|
|
|
* returns an array containing the current firewall rules on success
|
|
|
|
|
*/
|
|
|
|
|
public function list_firewallrules()
|
|
|
|
|
{
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/rest/firewallrule');
|
|
|
|
|
|
|
|
|
|
return $this->process_response($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List health metrics
|
|
|
|
|
* -------------------
|
|
|
|
|
@@ -2274,7 +2320,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'radio_table' => [
|
|
|
|
|
'radio' => $radio,
|
|
|
|
|
'channel' => $channel,
|
|
|
|
|
@@ -2344,7 +2390,7 @@ class Client
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$json = [
|
|
|
|
|
$json = [
|
|
|
|
|
'portal_enabled' => $portal_enabled,
|
|
|
|
|
'portal_customized' => $portal_customized,
|
|
|
|
|
'redirect_enabled' => $redirect_enabled,
|
|
|
|
|
@@ -2365,7 +2411,7 @@ class Client
|
|
|
|
|
* ------------------------------------------
|
|
|
|
|
* return true on success
|
|
|
|
|
* required parameter <network_settings> = stdClass object or associative array containing the configuration to apply to the guestlogin, must be a (partial)
|
|
|
|
|
* object/array structured in the same manner as is returned by list_settings() for the guest_access.
|
|
|
|
|
* object/array structured in the same manner as is returned by list_settings() for the "guest_access" section.
|
|
|
|
|
*/
|
|
|
|
|
public function set_guestlogin_settings_base($guestlogin_settings)
|
|
|
|
|
{
|
|
|
|
|
@@ -2379,6 +2425,25 @@ class Client
|
|
|
|
|
return $this->process_response_boolean($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update IPS/IDS settings, base
|
|
|
|
|
* ------------------------------------------
|
|
|
|
|
* return true on success
|
|
|
|
|
* required parameter <ips_settings> = stdClass object or associative array containing the IPS/IDS settings to apply, must be a (partial)
|
|
|
|
|
* object/array structured in the same manner as is returned by list_settings() for the "ips" section.
|
|
|
|
|
*/
|
|
|
|
|
public function set_ips_settings_base($ips_settings)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$json = json_encode($ips_settings, JSON_UNESCAPED_SLASHES);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/set/setting/ips', 'json=' . $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response_boolean($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rename access point
|
|
|
|
|
* -------------------
|
|
|
|
|
@@ -2725,7 +2790,7 @@ class Client
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$json = [
|
|
|
|
|
$json = [
|
|
|
|
|
'_sort' => '-time',
|
|
|
|
|
'within' => intval($historyhours),
|
|
|
|
|
'type' => null,
|
|
|
|
|
@@ -3117,6 +3182,28 @@ class Client
|
|
|
|
|
return $this->process_response_boolean($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute specific command
|
|
|
|
|
* ------------------------
|
|
|
|
|
* return true on success
|
|
|
|
|
* required parameter <command> = string; command to execute, known valid values
|
|
|
|
|
* 'reset-dpi': reset all DPI counters for the current site
|
|
|
|
|
*
|
|
|
|
|
* NOTE:
|
|
|
|
|
* the provided <command> parameter isn't validated so make sure you're using a correct value
|
|
|
|
|
*/
|
|
|
|
|
public function cmd_stat($command)
|
|
|
|
|
{
|
|
|
|
|
if (!$this->is_loggedin) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$json = json_encode(['cmd' => trim($command)]);
|
|
|
|
|
$response = $this->exec_curl('/api/s/' . $this->site . '/cmd/stat', 'json=' . $json);
|
|
|
|
|
|
|
|
|
|
return $this->process_response_boolean($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
* "Aliases" for deprecated functions from here, to support
|
|
|
|
|
* backward compatibility:
|
|
|
|
|
|