From 9b8fdc7531ca8f042bd4ccf1a167a4e3115088ee Mon Sep 17 00:00:00 2001 From: malle-pietje Date: Mon, 6 Feb 2017 15:20:33 +0100 Subject: [PATCH] API Browser version 1.0.9, API client class version 1.0.13 - API Browser: added list_admins endpoint - API client class: added adopt_device() function/method to adopt a device (access point, switch or router), contributed by nelsencd - API client class: added delete_site() function/method to delete a site - API client class: added list_admins() function/method to list the administrators for the current site - API client class: added led_override() function/method to toggle LED mode for individual devices - minor code cleanup --- README.md | 1 + index.php | 13 +- phpapi/class.unifi.php | 594 ++++++++++++++++++++++++++--------------- 3 files changed, 387 insertions(+), 221 deletions(-) diff --git a/README.md b/README.md index bd4bed0..1aba4c9 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ The UniFi API browser tool offers the following features: - Configuration - list sites on this controller - list site settings + - list admins for current site - sysinfo - self - wlan config diff --git a/index.php b/index.php index 15fd0df..448da01 100644 --- a/index.php +++ b/index.php @@ -10,7 +10,7 @@ * the currently supported data collections/API endpoints in the README.md file * - this tool currently supports versions 4.x and 5.x of the UniFi Controller software * - * VERSION: 1.0.8 + * VERSION: 1.0.9 * * ------------------------------------------------------------------------------------ * @@ -20,7 +20,7 @@ * with this package in the file LICENSE.md * */ -define('API_BROWSER_VERSION', '1.0.8'); +define('API_BROWSER_VERSION', '1.0.9'); /** * in order to use the PHP $_SESSION array for temporary storage of variables, session_start() is required @@ -57,7 +57,7 @@ $objects_count = ''; $alert_message = ''; $cookietimeout = '1800'; -$debug = FALSE; +$debug = false; $detected_controller_version = ''; /** @@ -401,6 +401,10 @@ $selection = 'all site stats'; $data = $unifidata->stat_sites(); break; + case 'list_admins': + $selection = 'list_admins'; + $data = $unifidata->list_admins(); + break; default: break; } @@ -669,6 +673,7 @@ function sites_sort($a, $b)
  • self
  • list site settings
  • +
  • list admins for current site
  • list wlan configuration
  • @@ -718,7 +723,7 @@ function sites_sort($a, $b)
  • United
  • Yeti
  • -
  • Reset PHP session
  • +
  • Reset PHP session
  • About UniFi API Browser
  • diff --git a/phpapi/class.unifi.php b/phpapi/class.unifi.php index 4543316..ea55b46 100644 --- a/phpapi/class.unifi.php +++ b/phpapi/class.unifi.php @@ -9,7 +9,7 @@ * and the API as published by Ubiquiti: * https://www.ubnt.com/downloads/unifi/5.3.8/unifi_sh_api * - * VERSION: 1.0.12 + * VERSION: 1.0.13 * * NOTES: * - this Class will only work with UniFi Controller versions 4.x and 5.x. There are no checks to prevent @@ -26,20 +26,22 @@ * with this package in the file LICENSE.md * */ -define('API_CLASS_VERSION', '1.0.12'); +define('API_CLASS_VERSION', '1.0.13'); -class unifiapi { +class unifiapi +{ public $user = ''; public $password = ''; public $site = 'default'; public $baseurl = 'https://127.0.0.1:8443'; public $version = '4.8.20'; - public $is_loggedin = FALSE; - public $debug = FALSE; + public $is_loggedin = false; + public $debug = false; private $cookies = ''; private $request_type = 'POST'; - function __construct($user = '', $password = '', $baseurl = '', $site = '', $version = '') { + function __construct($user = '', $password = '', $baseurl = '', $site = '', $version = '') + { if (!empty($user)) $this->user = $user; if (!empty($password)) $this->password = $password; if (!empty($baseurl)) $this->baseurl = $baseurl; @@ -47,7 +49,8 @@ function __construct($user = '', $password = '', $baseurl = '', $site = '', $ver if (!empty($version)) $this->version = $version; } - function __destruct() { + function __destruct() + { if ($this->is_loggedin) { $this->logout(); } @@ -56,7 +59,8 @@ function __destruct() { /** * Login to UniFi Controller */ - public function login() { + public function login() + { $this->cookies = ''; $ch = $this->get_curl_obj(); @@ -66,15 +70,15 @@ public function login() { curl_setopt($ch, CURLOPT_URL, $this->baseurl.'/api/login'); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('username' => $this->user, 'password' => $this->password))); - if ($this->debug === TRUE) { - curl_setopt($ch, CURLOPT_VERBOSE, TRUE); + if ($this->debug === true) { + curl_setopt($ch, CURLOPT_VERBOSE, true); } - if (($content = curl_exec($ch)) === FALSE) { + if (($content = curl_exec($ch)) === false) { error_log('curl error: ' . curl_error($ch)); } - if ($this->debug === TRUE) { + if ($this->debug === true) { print '
    ';
                 print PHP_EOL.'-----------LOGIN-------------'.PHP_EOL;
                 print_r (curl_getinfo($ch));
    @@ -95,8 +99,8 @@ public function login() {
                 $this->cookies = implode(';', $results[1]);
                 if (!empty($body)) {
                     if (($code >= 200) && ($code < 400)) {
    -                    if (strpos($this->cookies,'unifises') !== FALSE) {
    -                        $this->is_loggedin = TRUE;
    +                    if (strpos($this->cookies,'unifises') !== false) {
    +                        $this->is_loggedin = true;
                         }
                     }
                     if ($code === 400) {
    @@ -112,18 +116,19 @@ public function login() {
         /**
          * Logout from UniFi Controller
          */
    -    public function logout() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function logout()
    +    {
    +        if (!$this->is_loggedin) return false;
             $content           = $this->exec_curl($this->baseurl.'/logout');
    -        $this->is_loggedin = FALSE;
    +        $this->is_loggedin = false;
             $this->cookies     = '';
    -        return TRUE;
    +        return true;
         }
     
         /**
          * Authorize a client device
          * -------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter      = client MAC address
          * required parameter  = minutes (from now) until authorization expires
          * optional parameter       = upload speed limit in kbps
    @@ -131,24 +136,25 @@ public function logout() {
          * optional parameter   = data transfer limit in MB
          * optional parameter   = AP MAC address to which client is connected, should result in faster authorization
          */
    -    public function authorize_guest($mac, $minutes, $up = NULL, $down = NULL, $MBytes = NULL, $ap_mac = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function authorize_guest($mac, $minutes, $up = null, $down = null, $MBytes = null, $ap_mac = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $mac    = strtolower($mac);
    -        $return = FALSE;
    +        $return = false;
             $json   = array('cmd' => 'authorize-guest', 'mac' => $mac, 'minutes' => $minutes);
     
             /**
              * if we have received values for up/down/MBytes we append them to the payload array to be submitted
              */
    -        if (isset($up))     $json['up'] = $up;
    -        if (isset($down))   $json['down'] = $down;
    -        if (isset($MBytes)) $json['bytes'] = $MBytes;
    +        if (isset($up))     $json['up']     = $up;
    +        if (isset($down))   $json['down']   = $down;
    +        if (isset($MBytes)) $json['bytes']  = $MBytes;
             if (isset($ap_mac)) $json['ap_mac'] = $ap_mac;
             $json            = json_encode($json);
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/stamgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -158,18 +164,19 @@ public function authorize_guest($mac, $minutes, $up = NULL, $down = NULL, $MByte
         /**
          * Unauthorize a client device
          * ---------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = client MAC address
          */
    -    public function unauthorize_guest($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function unauthorize_guest($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $mac             = strtolower($mac);
             $json            = json_encode(array('cmd' => 'unauthorize-guest', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/stamgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -179,18 +186,19 @@ public function unauthorize_guest($mac) {
         /**
          * Reconnect a client device
          * -------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = client MAC address
          */
    -    public function reconnect_sta($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function reconnect_sta($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $mac             = strtolower($mac);
             $json            = json_encode(array('cmd' => 'kick-sta', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/stamgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -200,18 +208,19 @@ public function reconnect_sta($mac) {
         /**
          * Block a client device
          * ---------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = client MAC address
          */
    -    public function block_sta($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function block_sta($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $mac             = strtolower($mac);
             $json            = json_encode(array('cmd' => 'block-sta', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/stamgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -221,18 +230,19 @@ public function block_sta($mac) {
         /**
          * Unblock a client device
          * -----------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = client MAC address
          */
    -    public function unblock_sta($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function unblock_sta($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $mac             = strtolower($mac);
             $json            = json_encode(array('cmd' => 'unblock-sta', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/stamgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -242,22 +252,23 @@ public function unblock_sta($mac) {
         /**
          * Add/modify a client device note
          * -------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = id of the user device to be modified
          * optional parameter     = note to be applied to the user device
          *
          * NOTES:
    -     * - when note is empty or not set, the existing note for the user will be removed and "noted" attribute set to FALSE
    +     * - when note is empty or not set, the existing note for the user will be removed and "noted" attribute set to false
          */
    -    public function set_sta_note($user_id, $note = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    -        $noted           = (is_null($note)) || (empty($note)) ? FALSE : TRUE;
    +    public function set_sta_note($user_id, $note = null)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
    +        $noted           = (is_null($note)) || (empty($note)) ? false : true;
             $json            = json_encode(array('note' => $note, 'noted' => $noted));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/user/'.$user_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -267,21 +278,22 @@ public function set_sta_note($user_id, $note = NULL) {
         /**
          * Add/modify a client device name
          * -------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = id of the user device to be modified
          * optional parameter     = name to be applied to the user device
          *
          * NOTES:
          * - when name is empty or not set, the existing name for the user will be removed
          */
    -    public function set_sta_name($user_id, $name = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function set_sta_name($user_id, $name = null)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = json_encode(array('name' => $name));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/user/'.$user_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -299,8 +311,9 @@ public function set_sta_name($user_id, $name = NULL) {
          * - defaults to the past 52*7*24 hours
          * - bytes" are no longer returned with controller version 4.9.1 and later
          */
    -    public function stat_daily_site($start = NULL, $end = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_daily_site($start = null, $end = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $end             = is_null($end) ? ((time()-(time() % 3600))*1000) : $end;
             $start           = is_null($start) ? $end-(52*7*24*3600*1000) : $start;
    @@ -330,8 +343,9 @@ public function stat_daily_site($start = NULL, $end = NULL) {
          * - defaults to the past 7*24 hours
          * - "bytes" are no longer returned with controller version 4.9.1 and later
          */
    -    public function stat_hourly_site($start = NULL, $end = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_hourly_site($start = null, $end = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $end             = is_null($end) ? ((time())*1000) : $end;
             $start           = is_null($start) ? $end-(7*24*3600*1000) : $start;
    @@ -361,8 +375,9 @@ public function stat_hourly_site($start = NULL, $end = NULL) {
          * - defaults to the past 7*24 hours
          * - UniFi controller does not keep these stats longer than 5 hours with versions < 4.6.6
          */
    -    public function stat_hourly_aps($start = NULL, $end = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_hourly_aps($start = null, $end = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $end             = is_null($end) ? ((time())*1000) : $end;
             $start           = is_null($start) ? $end-(7*24*3600*1000) : $start;
    @@ -392,8 +407,9 @@ public function stat_hourly_aps($start = NULL, $end = NULL) {
          * NOTES:
          * - defaults to the past 7*24 hours
          */
    -    public function stat_sessions($start = NULL, $end = NULL, $mac = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_sessions($start = null, $end = null, $mac = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $end             = is_null($end) ? time() : $end;
             $start           = is_null($start) ? $end-(7*24*3600) : $start;
    @@ -421,8 +437,9 @@ public function stat_sessions($start = NULL, $end = NULL, $mac = NULL) {
          * required parameter    = client MAC address
          * optional parameter  = maximum number of sessions to get (defaults to 5)
          */
    -    public function stat_sta_sessions_latest($mac, $limit = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_sta_sessions_latest($mac, $limit = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $limit           = is_null($limit) ? 5 : $limit;
             $json            = json_encode(array('mac' => $mac, '_limit' => $limit, '_sort'=> '-assoc_time'));
    @@ -450,8 +467,9 @@ public function stat_sta_sessions_latest($mac, $limit = NULL) {
          * NOTES:
          * - defaults to the past 7*24 hours
          */
    -    public function stat_auths($start = NULL, $end = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_auths($start = null, $end = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $end             = is_null($end) ? time() : $end;
             $start           = is_null($start) ? $end-(7*24*3600) : $start;
    @@ -480,8 +498,9 @@ public function stat_auths($start = NULL, $end = NULL) {
          * -  is only used to select clients that were online within that period,
          *    the returned stats per client are all-time totals, irrespective of the value of 
          */
    -    public function stat_allusers($historyhours = 8760) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_allusers($historyhours = 8760)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $json            = json_encode(array('type' => 'all', 'conn' => 'all', 'within' => $historyhours));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/alluser','json='.$json));
    @@ -504,8 +523,9 @@ public function stat_allusers($historyhours = 8760) {
          * returns an array of guest device objects with valid access
          * optional parameter  = time frame in hours to go back to list guests with valid access (default = 24*365 hours)
          */
    -    public function list_guests($within = 8760) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_guests($within = 8760)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $json            = json_encode(array('within' => $within));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/guest','json='.$json));
    @@ -528,8 +548,9 @@ public function list_guests($within = 8760) {
          * returns an array of online client device objects, or in case of a single device request, returns a single client device object
          * optional parameter  = the MAC address of a single online client device for which the call must be made
          */
    -    public function list_clients($client_mac = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_clients($client_mac = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/sta/'.$client_mac));
             if (isset($content_decoded->meta->rc)) {
    @@ -551,9 +572,10 @@ public function list_clients($client_mac = NULL) {
          * returns an object with the client device information
          * required parameter  = client device MAC address
          */
    -    public function stat_client($client_mac) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function stat_client($client_mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
     	    $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/user/'.$client_mac));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    @@ -573,8 +595,9 @@ public function stat_client($client_mac) {
          * ----------------
          * returns an array of user group objects
          */
    -    public function list_usergroups() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_usergroups()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/usergroup'));
             if (isset($content_decoded->meta->rc)) {
    @@ -593,18 +616,19 @@ public function list_usergroups() {
         /**
          * Assign user device to another group
          * -----------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter   = id of the user device to be modified
          * required parameter  = id of the user group to assign user to
          */
    -    public function set_usergroup($user_id, $group_id) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function set_usergroup($user_id, $group_id)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = json_encode(array('usergroup_id' => $group_id));
     	    $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/user/'.$user_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -616,8 +640,9 @@ public function set_usergroup($user_id, $group_id) {
          * -------------------
          * returns an array of health metric objects
          */
    -    public function list_health() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_health()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/health'));
             if (isset($content_decoded->meta->rc)) {
    @@ -638,8 +663,9 @@ public function list_health() {
          * ----------------------
          * returns an array of dashboard metric objects (available since controller version 4.9.1.alpha)
          */
    -    public function list_dashboard() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_dashboard()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/dashboard'));
             if (isset($content_decoded->meta->rc)) {
    @@ -660,8 +686,9 @@ public function list_dashboard() {
          * -----------------
          * returns an array of known user device objects
          */
    -    public function list_users() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_users()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/user'));
             if (isset($content_decoded->meta->rc)) {
    @@ -683,8 +710,9 @@ public function list_users() {
          * returns an array of known device objects (or a single device when using the  parameter)
          * optional parameter  = the MAC address of a single device for which the call must be made
          */
    -    public function list_aps($device_mac = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_aps($device_mac = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/device/'.$device_mac));
             if (isset($content_decoded->meta->rc)) {
    @@ -706,8 +734,9 @@ public function list_aps($device_mac = NULL) {
          * returns an array of known rogue access point objects
          * optional parameter  = hours to go back to list discovered "rogue" access points (default = 24 hours)
          */
    -    public function list_rogueaps($within = '24') {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_rogueaps($within = '24')
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $json            = json_encode(array('within' => $within));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/rogueap','json='.$json));
    @@ -729,8 +758,9 @@ public function list_rogueaps($within = '24') {
          * ----------
          * returns a list sites hosted on this controller with some details
          */
    -    public function list_sites() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_sites()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/self/sites'));
             if (isset($content_decoded->meta->rc)) {
    @@ -752,8 +782,9 @@ public function list_sites() {
          * returns statistics for all sites hosted on this controller
          * NOTE: this endpoint was introduced with controller version 5.2.9
          */
    -    public function stat_sites() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_sites()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/stat/sites'));
             if (isset($content_decoded->meta->rc)) {
    @@ -776,9 +807,10 @@ public function stat_sites() {
          * required parameter  = the long name for the new site
          * NOTE: immediately after being added, the new site will be available in the output of the "list_sites" function
          */
    -    public function add_site($description) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function add_site($description)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = json_encode(array('desc' => $description, 'cmd' => 'add-site'));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/sitemgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
    @@ -794,13 +826,59 @@ public function add_site($description) {
             return $return;
         }
     
    +    /**
    +     * Delete a site
    +     * -------------
    +     * return true on success
    +     * required parameter  = _id (24 char string) of the site to delete
    +     */
    +    public function delete_site($site_id)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
    +        $json            = json_encode(array('site' => $site_id, 'cmd' => 'delete-site'));
    +        $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/sitemgr','json='.$json));
    +        if (isset($content_decoded->meta->rc)) {
    +            if ($content_decoded->meta->rc == 'ok') {
    +                $return = true;
    +            }
    +        }
    +
    +        return $return;
    +    }
    +
    +    /**
    +     * List admins
    +     * -----------
    +     * returns an array containing administrator objects for selected site
    +     */
    +    public function list_admins($description)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
    +        $json            = json_encode(array('cmd' => 'get-admins'));
    +        $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/sitemgr','json='.$json));
    +        if (isset($content_decoded->meta->rc)) {
    +            if ($content_decoded->meta->rc == 'ok') {
    +                if (is_array($content_decoded->data)) {
    +                    foreach ($content_decoded->data as $admin) {
    +                        $return[]= $admin;
    +                    }
    +                }
    +            }
    +        }
    +
    +        return $return;
    +    }
    +
         /**
          * List wlan_groups
          * ----------------
    -     * returns an array of known wlan_groups
    +     * returns an array containing known wlan_groups
          */
    -    public function list_wlan_groups() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_wlan_groups()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/wlangroup'));
             if (isset($content_decoded->meta->rc)) {
    @@ -821,8 +899,9 @@ public function list_wlan_groups() {
          * ------------
          * returns an array of known sysinfo data
          */
    -    public function stat_sysinfo() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_sysinfo()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/sysinfo'));
             if (isset($content_decoded->meta->rc)) {
    @@ -843,8 +922,9 @@ public function stat_sysinfo() {
          * ---------
          * returns an array of information about the logged in user
          */
    -    public function list_self() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_self()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/self'));
             if (isset($content_decoded->meta->rc)) {
    @@ -865,8 +945,9 @@ public function list_self() {
          * ----------------
          * returns an array of network configuration data
          */
    -    public function list_networkconf() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_networkconf()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/networkconf'));
             if (isset($content_decoded->meta->rc)) {
    @@ -888,10 +969,11 @@ public function list_networkconf() {
          * returns an array of hotspot voucher objects
          * optional parameter  = Unix timestamp in seconds
          */
    -    public function stat_voucher($create_time = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_voucher($create_time = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return = array();
    -        if (trim($create_time) != NULL) {
    +        if (trim($create_time) != null) {
                 $json = json_encode(array('create_time' => $create_time));
             } else {
                 $json = json_encode(array());
    @@ -917,10 +999,11 @@ public function stat_voucher($create_time = NULL) {
          * returns an array of hotspot payments
          * optional parameter  = number of hours to go back to fetch payments
          */
    -    public function stat_payment($within = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function stat_payment($within = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return = array();
    -        if ($within != NULL) {
    +        if ($within != null) {
               $url_suffix = '?within='.$within;
             } else {
               $url_suffix = '';
    @@ -943,14 +1026,15 @@ public function stat_payment($within = NULL) {
         /**
          * Create hotspot operator
          * -----------------------
    -     * return TRUE upon success
    +     * return true upon success
          * required parameter        = name for the hotspot operator
          * required parameter  = clear text password for the hotspot operator
          * optional parameter        = note to attach to the hotspot operator
          */
    -    public function create_hotspotop($name, $x_password, $note = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return = FALSE;
    +    public function create_hotspotop($name, $x_password, $note = null)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return = false;
             $json   = array('name' => $name, 'x_password' => $x_password);
             /**
              * if we have received a value for note, we append it to the payload array to be submitted
    @@ -960,7 +1044,7 @@ public function create_hotspotop($name, $x_password, $note = NULL) {
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/rest/hotspotop','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -972,8 +1056,9 @@ public function create_hotspotop($name, $x_password, $note = NULL) {
          * ----------------------
          * returns an array of hotspot operators
          */
    -    public function list_hotspotop() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_hotspotop()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/hotspotop'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1001,8 +1086,9 @@ public function list_hotspotop() {
          * optional parameter     = download speed limit in kbps
          * optional parameter   = data transfer limit in MB
          */
    -    public function create_voucher($minutes, $count = 1, $quota = '0', $note = NULL, $up = NULL, $down = NULL, $MBytes = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function create_voucher($minutes, $count = 1, $quota = '0', $note = null, $up = null, $down = null, $MBytes = null)
    +    {
    +        if (!$this->is_loggedin) return false;
             $return = array();
             $json   = array('cmd' => 'create-voucher', 'expire' => $minutes, 'n' => $count, 'quota' => $quota);
             /**
    @@ -1029,17 +1115,18 @@ public function create_voucher($minutes, $count = 1, $quota = '0', $note = NULL,
         /**
          * Revoke voucher
          * --------------
    -     * return TRUE on success
    -     * required parameter  = _id of the voucher to revoke
    +     * return true on success
    +     * required parameter  = _id (24 char string) of the voucher to revoke
          */
    -    public function revoke_voucher($voucher_id) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function revoke_voucher($voucher_id)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = json_encode(array('_id' => $voucher_id, 'cmd' => 'delete-voucher'));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/hotspot','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1051,8 +1138,9 @@ public function revoke_voucher($voucher_id) {
          * --------------------------
          * returns an array of port forwarding stats
          */
    -    public function list_portforward_stats() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_portforward_stats()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/portforward'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1073,8 +1161,9 @@ public function list_portforward_stats() {
          * -----------------------------
          * returns an array of port forwarding settings
          */
    -    public function list_portforwarding() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_portforwarding()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/portforward'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1095,8 +1184,9 @@ public function list_portforwarding() {
          * -------------------------
          * returns an array of dynamic DNS settings
          */
    -    public function list_dynamicdns() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_dynamicdns()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/dynamicdns'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1117,8 +1207,9 @@ public function list_dynamicdns() {
          * -----------------------
          * returns an array of port configurations
          */
    -    public function list_portconf() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_portconf()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/portconf'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1139,8 +1230,9 @@ public function list_portconf() {
          * --------------------
          * returns an array of VoIP extensions
          */
    -    public function list_extension() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_extension()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/extension'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1161,8 +1253,9 @@ public function list_extension() {
          * ------------------
          * returns an array of site configuration settings
          */
    -    public function list_settings() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_settings()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/get/setting'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1178,21 +1271,44 @@ public function list_settings() {
             return $return;
         }
     
    +    /**
    +     * Adopt a device
    +     * --------------
    +     * return true on success
    +     * required parameter  = device MAC address
    +     */
    +    public function adopt_device($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $mac             = strtolower($mac);
    +        $return          = false;
    +        $json            = json_encode(array('mac' => $mac, 'cmd' => 'adopt'));
    +        $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/devmgr','json='.$json));
    +        if (isset($content_decoded->meta->rc)) {
    +            if ($content_decoded->meta->rc == 'ok') {
    +                $return = true;
    +            }
    +        }
    +
    +        return $return;
    +    }
    +
         /**
          * Reboot an access point
          * ----------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = device MAC address
          */
    -    public function restart_ap($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function restart_ap($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
             $mac             = strtolower($mac);
    -        $return          = FALSE;
    +        $return          = false;
             $json            = json_encode(array('cmd' => 'restart', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/devmgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1202,24 +1318,55 @@ public function restart_ap($mac) {
         /**
          * Disable/enable an access point
          * ------------------------------
    -     * return TRUE on success
    -     * required parameter    = value of _id for the access point which can be obtained from the device list
    -     * required parameter  = boolean; TRUE will disable the device, FALSE will enable the device
    +     * return true on success
    +     * required parameter    = value of _id (24 char string) for the access point which can be obtained from the device list
    +     * required parameter  = boolean; true will disable the device, false will enable the device
          *
          * NOTES:
          * - a disabled device will be excluded from the dashboard status and device count and its LED and WLAN will be turned off
          * - appears to only be supported for access points
          * - available since controller versions 5.2.X
          */
    -    public function disable_ap($ap_id, $disable) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function disable_ap($ap_id, $disable)
    +    {
    +        if (!$this->is_loggedin) return false;
             $this->request_type = 'PUT';
    -        $return             = FALSE;
    +        $return             = false;
             $json               = json_encode(array('disabled' => $disable));
             $content_decoded    = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/rest/device/'.$ap_id, $json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
    +            }
    +        }
    +
    +        return $return;
    +    }
    +
    +    /**
    +     * Override LED mode for a device
    +     * ------------------------------
    +     * return true on success
    +     * required parameter      = value of _id (24 char string) for the device which can be obtained from the device list
    +     * required parameter  = off/on/default; "off" will disable the LED of the device, "on" will enable the LED of the device,
    +     *                                      "default" will apply the site-wide setting for device LEDs
    +     *
    +     * NOTES:
    +     * - available since controller versions 5.2.X
    +     */
    +    public function led_override($device_id, $override_mode)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $this->request_type    = 'PUT';
    +        $return                = false;
    +        $override_mode_options = array("off", "on", "default");
    +        if (in_array($override_mode, $override_mode_options)) {
    +            $json            = json_encode(array('led_override' => $override_mode));
    +            $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/rest/device/'.$device_id, $json));
    +            if (isset($content_decoded->meta->rc)) {
    +                if ($content_decoded->meta->rc == 'ok') {
    +                    $return = true;
    +                }
                 }
             }
     
    @@ -1229,18 +1376,19 @@ public function disable_ap($ap_id, $disable) {
         /**
          * Start flashing LED of an access point for locating purposes
          * -----------------------------------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = device MAC address
          */
    -    public function set_locate_ap($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function set_locate_ap($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
             $mac             = strtolower($mac);
    -        $return          = FALSE;
    +        $return          = false;
             $json            = json_encode(array('cmd' => 'set-locate', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/devmgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1250,18 +1398,19 @@ public function set_locate_ap($mac) {
         /**
          * Stop flashing LED of an access point for locating purposes
          * ----------------------------------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter  = device MAC address
          */
    -    public function unset_locate_ap($mac) {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function unset_locate_ap($mac)
    +    {
    +        if (!$this->is_loggedin) return false;
             $mac             = strtolower($mac);
    -        $return          = FALSE;
    +        $return          = false;
             $json            = json_encode(array('cmd' => 'unset-locate', 'mac' => $mac));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/devmgr','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1271,16 +1420,17 @@ public function unset_locate_ap($mac) {
         /**
          * Switch LEDs of all the access points ON
          * ---------------------------------------
    -     * return TRUE on success
    +     * return true on success
          */
    -    public function site_ledson() {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    -        $json            = json_encode(array('led_enabled' => TRUE));
    +    public function site_ledson()
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
    +        $json            = json_encode(array('led_enabled' => true));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/set/setting/mgmt','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1290,16 +1440,17 @@ public function site_ledson() {
         /**
          * Switch LEDs of all the access points OFF
          * ----------------------------------------
    -     * return TRUE on success
    +     * return true on success
          */
    -    public function site_ledsoff() {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    -        $json            = json_encode(array('led_enabled' => FALSE));
    +    public function site_ledsoff()
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
    +        $json            = json_encode(array('led_enabled' => false));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/set/setting/mgmt','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1309,7 +1460,7 @@ public function site_ledsoff() {
         /**
          * Set access point radio settings
          * -------------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter 
          * required parameter (default=ng)
          * required parameter 
    @@ -1317,15 +1468,16 @@ public function site_ledsoff() {
          * required parameter 
          * required parameter (default=0)
          */
    -    public function set_ap_radiosettings($ap_id, $radio, $channel, $ht, $tx_power_mode, $tx_power) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function set_ap_radiosettings($ap_id, $radio, $channel, $ht, $tx_power_mode, $tx_power)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $jsonsettings    = json_encode(array('radio' => $radio, 'channel' => $channel, 'ht' => $ht, 'tx_power_mode' => $tx_power_mode, 'tx_power' =>$tx_power));
             $json            = '{"radio_table": ['.$jsonsettings.']}';
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/device/'.$ap_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1335,7 +1487,7 @@ public function set_ap_radiosettings($ap_id, $radio, $channel, $ht, $tx_power_mo
         /**
          * Set guest login settings
          * ------------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter 
          * required parameter 
          * required parameter 
    @@ -1348,9 +1500,10 @@ public function set_ap_radiosettings($ap_id, $radio, $channel, $ht, $tx_power_mo
          * NOTES:
          * - both portal parameters are set to the same value!
          */
    -    public function set_guestlogin_settings($portal_enabled, $portal_customized, $redirect_enabled, $redirect_url, $x_password, $expire_number, $expire_unit, $site_id) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return = FALSE;
    +    public function set_guestlogin_settings($portal_enabled, $portal_customized, $redirect_enabled, $redirect_url, $x_password, $expire_number, $expire_unit, $site_id)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return = false;
             $json   = json_encode(array('portal_enabled' => $portal_enabled, 'portal_customized' => $portal_customized,
                                         'redirect_enabled' => $redirect_enabled, 'redirect_url' => $redirect_url,
                                         'x_password' => $x_password, 'expire_number' => $expire_number,
    @@ -1358,7 +1511,7 @@ public function set_guestlogin_settings($portal_enabled, $portal_customized, $re
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/set/setting/guest_access','json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1368,18 +1521,19 @@ public function set_guestlogin_settings($portal_enabled, $portal_customized, $re
         /**
          * Rename access point
          * -------------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter 
          * required parameter 
          */
    -    public function rename_ap($ap_id, $apname) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function rename_ap($ap_id, $apname)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = json_encode(array('name' => $apname));
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/device/'.$ap_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1389,21 +1543,22 @@ public function rename_ap($ap_id, $apname) {
         /**
          * Set wlan settings
          * -----------------
    -     * return TRUE on success
    +     * return true on success
          * required parameter 
          * required parameter  = new pre-shared key, minimal length is 8 characters, maximum length is 63
          * optional parameter 
          */
    -    public function set_wlansettings($wlan_id, $x_passphrase, $name = NULL) {
    -        if (!$this->is_loggedin) return FALSE;
    -        $return          = FALSE;
    +    public function set_wlansettings($wlan_id, $x_passphrase, $name = null)
    +    {
    +        if (!$this->is_loggedin) return false;
    +        $return          = false;
             $json            = array('x_passphrase' => $x_passphrase);
             if (!is_null($name)) $json['name'] = $name;
             $json            = json_encode($json);
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/upd/wlanconf/'.$wlan_id,'json='.$json));
             if (isset($content_decoded->meta->rc)) {
                 if ($content_decoded->meta->rc == 'ok') {
    -                $return = TRUE;
    +                $return = true;
                 }
             }
     
    @@ -1415,8 +1570,9 @@ public function set_wlansettings($wlan_id, $x_passphrase, $name = NULL) {
          * -----------
          * returns an array of known events
          */
    -    public function list_events() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_events()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/stat/event'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1437,8 +1593,9 @@ public function list_events() {
          * ----------------------
          * returns an array of wireless networks and settings
          */
    -    public function list_wlanconf() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_wlanconf()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/wlanconf'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1459,8 +1616,9 @@ public function list_wlanconf() {
          * -----------
          * returns an array of known alarms
          */
    -    public function list_alarms() {
    -        if (!$this->is_loggedin) return FALSE;
    +    public function list_alarms()
    +    {
    +        if (!$this->is_loggedin) return false;
             $return          = array();
             $content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/list/alarm'));
             if (isset($content_decoded->meta->rc)) {
    @@ -1479,7 +1637,8 @@ public function list_alarms() {
         /**
          * Internal (private) functions from here
          */
    -    private function exec_curl($url, $data = '') {
    +    private function exec_curl($url, $data = '')
    +    {
             $ch = $this->get_curl_obj();
             curl_setopt($ch, CURLOPT_URL, $url);
     
    @@ -1493,14 +1652,14 @@ private function exec_curl($url, $data = '') {
                 }
     
             } else {
    -            curl_setopt($ch, CURLOPT_POST, FALSE);
    +            curl_setopt($ch, CURLOPT_POST, false);
             }
     
    -        if (($content = curl_exec($ch)) === FALSE) {
    +        if (($content = curl_exec($ch)) === false) {
                 error_log('curl error: ' . curl_error($ch));
             }
     
    -        if ($this->debug === TRUE) {
    +        if ($this->debug === true) {
                 print '
    ';
                 print PHP_EOL.'---------cURL INFO-----------'.PHP_EOL;
                 print_r (curl_getinfo($ch));
    @@ -1517,19 +1676,20 @@ private function exec_curl($url, $data = '') {
             return $content;
         }
     
    -    private function get_curl_obj() {
    +    private function get_curl_obj()
    +    {
             $ch = curl_init();
    -        curl_setopt($ch, CURLOPT_POST, TRUE);
    -        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    -        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    -        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    +        curl_setopt($ch, CURLOPT_POST, true);
    +        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    +        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    +        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     
    -        if ($this->debug === TRUE) {
    -            curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
    +        if ($this->debug === true) {
    +            curl_setopt($ch, CURLOPT_VERBOSE, true);
             }
     
             if ($this->cookies != '') {
    -            curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
    +            curl_setopt($ch, CURLOPT_COOKIESESSION, true);
                 curl_setopt($ch, CURLOPT_COOKIE, $this->cookies);
             }