Exemple #1
0
include 'colourPicker/lib/RemoteCommand.class.php';
include 'colourPicker/conf/Configuration.php';
session_start();
session_destroy();
session_start();
if (empty($_SESSION)) {
    $_SESSION['priority'] = array();
    $_SESSION['colour'] = '00FFFF';
    $_SESSION['duration'] = -1;
}
$messages = array();
$com = new RemoteCommand();
if (isset($_POST['submit'])) {
    switch ($_POST['submit']) {
        case 'Turn On':
            $return = $com->withServer($config['serverAddress'], $config['serverUsername'], $config['serverPassword'], $config['debug'])->withController($config['serverController'])->withSleep(2)->callOn();
            if ($return) {
                $messages[] = array('type' => 'success', 'content' => 'Turned on Hyperion successfully.');
            }
            break;
        case 'Turn Off':
            $return = $com->withServer($config['serverAddress'], $config['serverUsername'], $config['serverPassword'], $config['debug'])->withController($config['serverController'])->withSleep(1)->callOff();
            if ($return) {
                $messages[] = array('type' => 'success', 'content' => 'Turned off Hyperion successfully.');
            }
            break;
        case 'Clear':
            $return = $com->withServer($config['serverAddress'], $config['serverUsername'], $config['serverPassword'], $config['debug'])->withAddress($config['hyperionAddress'])->withPriority($_POST['priority'])->callClear();
            unset($_SESSION['priority'][$_POST['priority']]);
            if ($return) {
                $messages[] = array('type' => 'success', 'content' => 'Cleared the priority channel ' . $_POST['priority'] . '.');