From e3e70cce72ae3c85694cf480a00cd2e47c7cfd77 Mon Sep 17 00:00:00 2001 From: malle-pietje Date: Thu, 19 Oct 2017 11:53:04 +0200 Subject: [PATCH] fixed bug caused by typo with "if (in_array()..." --- examples/disable_device.php | 50 +++++++++++++++++++++++++++++++++++++ src/Client.php | 4 +-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100755 examples/disable_device.php diff --git a/examples/disable_device.php b/examples/disable_device.php new file mode 100755 index 0000000..f0cf0f9 --- /dev/null +++ b/examples/disable_device.php @@ -0,0 +1,50 @@ +'; + +/** + * the site to which the device belongs + */ +$site_id = ''; + +/** + * initialize the UniFi API connection class and log in to the controller + */ +$unifi_connection = new UniFi_API\Client($controlleruser, $controllerpassword, $controllerurl, $site_id, $controllerversion); +$set_debug_mode = $unifi_connection->set_debug($debug); +$loginresults = $unifi_connection->login(); + +/** + * then we disable the device + */ +$disable_result = $unifi_connection->disable_ap($device_id, true); + +/** + * or we enable the device, uncomment as neccesary (then also comment the previous call) + */ +//$disable_result = $unifi_connection->disable_ap($device_id, false); + +/** + * provide feedback (the newly created voucher code, without the dash) in json format + */ +echo json_encode($disable_result, JSON_PRETTY_PRINT); diff --git a/src/Client.php b/src/Client.php index ddd6dd2..6f65053 100755 --- a/src/Client.php +++ b/src/Client.php @@ -1275,7 +1275,7 @@ public function set_ap_radiosettings($ap_id, $radio, $channel, $ht, $tx_power_mo */ public function set_ap_wlangroup($wlantype_id, $device_id, $wlangroup_id) { if (!$this->is_loggedin) return false; - if (in_array($wlantype_id, ['ng', 'na'])) return false; + if (!in_array($wlantype_id, ['ng', 'na'])) return false; $json = json_encode(['wlan_overrides' => [],'wlangroup_id_'.$wlantype_id => $wlangroup_id]); $response = $this->exec_curl('/api/s/'.$this->site.'/upd/device/'.trim($device_id),'json='.$json); return $this->process_response_boolean($response); @@ -1550,7 +1550,7 @@ public function delete_wlan($wlan_id) */ public function set_wlan_mac_filter($wlan_id, $mac_filter_policy, $mac_filter_enabled, array $macs) { - if (in_array($mac_filter_policy, ['allow', 'deny'])) return false; + if (!in_array($mac_filter_policy, ['allow', 'deny'])) return false; $payload = (object)[]; $payload->mac_filter_enabled = (bool)$mac_filter_enabled; $payload->mac_filter_policy = $mac_filter_policy;