Skip to content

Commit

Permalink
fixed bug caused by typo with "if (in_array()..."
Browse files Browse the repository at this point in the history
  • Loading branch information
malle-pietje committed Oct 19, 2017
1 parent 449baa7 commit e3e70cc
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
50 changes: 50 additions & 0 deletions examples/disable_device.php
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e3e70cc

Please sign in to comment.