fixed bug caused by typo with "if (in_array()..."

This commit is contained in:
malle-pietje 2017-10-19 11:53:04 +02:00
parent 449baa70a3
commit e3e70cce72
2 changed files with 52 additions and 2 deletions

50
examples/disable_device.php Executable file
View File

@ -0,0 +1,50 @@
<?php
/**
* PHP API usage example
*
* contributed by: Art of WiFi
* description: example basic PHP script to disable/enable a device, returns true upon success
*/
/**
* using the composer autoloader
*/
require_once('vendor/autoload.php');
/**
* include the config file (place your credentials etc. there if not already present)
* see the config.template.php file for an example
*/
require_once('config.php');
/**
* the 24 character id of the device to disable/enable
*/
$device_id = '<enter the id of your device here>';
/**
* the site to which the device belongs
*/
$site_id = '<enter your site id here>';
/**
* 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);

View File

@ -1275,7 +1275,7 @@ class Client
*/
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 @@ class Client
*/
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;