//The name of your site $username = '******'; //username for controller $password = '******'; //Password for controller $baseurl = 'https://127.0.0.1:8443'; //URL to access controller $controllerversion = "4.7.6"; //Version of controller $ssid = "SSID"; //SSID you want people to connect to with this ticket $wpapsk = "WPA"; //Security password for the SSID above $printername = "VoucherPrinter"; //Name of the printer from PC $unifidata = new unifiapi($username, $password, $baseurl, $siteid, $controllerversion); $loginresults = $unifidata->login(); if ($loginresults === 400) { echo '<div class="alert alert-danger" role="alert">HTTP response status: 400<br>This is probably caused by a Unifi controller login failure, please check your credentials in config.php</div>'; } //////////////////////////////////// // //You shouldn't need to change anything under this line unless you want to customize the script. // //////////////////////////////////// ?> <!doctype html> <html> <head> <meta charset="utf-8">
} if ($siteid === '') { $alertmessage = '<div class="alert alert-info" role="alert">Please select a site from the <b>Select site menu</b> above.</div>'; } /* load the unifi api connection class as well as the settings files and log in to the controller - if the config.php file is unreadable or does not exist, an alert is displayed on the page - if an error occurs with the login process an alert is displayed on the page */ require 'phpapi/class.unifi.php'; if (!is_readable('config.php')) { $alertmessage = '<div class="alert alert-danger" role="alert">The file config.php is not readable or does not exist.<br>If you have not yet done so, please copy/rename the config.template.php file to config.php and modify the contents as required.</div>'; } include 'config.php'; $unifidata = new unifiapi($controlleruser, $controllerpassword, $controllerurl, $siteid, $controllerversion); $loginresults = $unifidata->login(); if ($loginresults === 400) { $alertmessage = '<div class="alert alert-danger" role="alert">HTTP response status: 400<br>This is probably caused by a Unifi controller login failure, please check your credentials in config.php</div>'; } /* get the list of sites managed by the controller (if not already stored in $_SESSION) */ if (!isset($_SESSION['sites'])) { $sites = $unifidata->list_sites(); $_SESSION['sites'] = $sites; } else { $sites = $_SESSION['sites']; } /* get the version of the controller (if not already stored in $_SESSION)