<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>Floorplan2</title><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><meta name="HandheldFriendly" content="true"/><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="viewport" content="width=device-width,height=device-height,user-scalable=yes,minimal-ui"/><link rel="icon" type="image/png" href="images/domoticzphp48.png"/><link rel="shortcut icon" href="images/domoticzphp48.png"/><link rel="apple-touch-startup-image" href="images/domoticzphp450.png"/><link rel="apple-touch-icon" href="images/domoticzphp48.png"/><meta name="msapplication-TileColor" content="#ffffff"><meta name="msapplication-TileImage" content="images/domoticzphp48.png"><meta name="msapplication-config" content="browserconfig.xml"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#ffffff"><link href="floorplan.css" rel="stylesheet" type="text/css"/><style>body{background-image:none;}</style></head><body>
<?php 
require "secure/settings.php";
require "secure/functions2.php";
if ($authenticated) {
    if (isset($_POST['Schakel'])) {
        if (Schakel($_POST['Schakel'], $_POST['Actie'], $_POST['Naam']) == 'ERROR') {
            echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
        }
        if (isset($_POST['halfuurwater'])) {
            cset('water', 1800);
        }
    } else {
        if (isset($_POST['Udevice'])) {
            if (Udevice($_POST['Udevice'], $_POST['Naam']) == 'ERROR') {
                echo '<div id="message" class="balloon">' . $_POST['Naam'] . ' ' . $_POST['Actie'] . '<br/>ERROR</div>';
            }
        } else {
            if (isset($_POST['imacpicam1'])) {
                shell_exec('/volume1/web/secure/picam1.sh');
            } else {
                if (isset($_POST['imacsleep'])) {
                    shell_exec('/volume1/web/secure/imacsleep.sh');
                }
            }
        }
    }
    $domoticz = json_decode(file_get_contents($domoticzurl . 'json.htm?type=devices&used=true&plan=5', true, $ctx), true);
    $domotime = microtime(true) - $start;
    //&plan=2
    if ($domoticz) {
             if (isset($_POST['Naam'])) {
                 switch ($_POST['Naam']) {
                     case 'radioluisteren':
                         $idx = 72;
                         break;
                     case 'tvkijken':
                         $idx = 73;
                         break;
                     case 'kodikijken':
                         $idx = 74;
                         break;
                     case 'eten':
                         $idx = 75;
                         break;
                 }
                 if (Schakel($idx, 'On', $_POST['Naam']) == 'ERROR') {
                     echo '<div id="message" class="balloon">Scene ' . $_POST['Naam'] . ' activeren' . '<br/>ERROR</div>';
                 }
                 if ($_POST['Naam'] == 'eten') {
                     cset('timedimmerEettafel', $time);
                 }
             }
         }
     }
 }
 $domoticz = json_decode(file_get_contents($domoticzurl . 'json.htm?type=devices&used=true&plan=2', true, $ctx), true);
 //$domotime=microtime(true)-$start; //&plan=2
 if ($domoticz) {
     foreach ($domoticz['result'] as $dom) {
         isset($dom['Type']) ? $Type = $dom['Type'] : ($Type = 'None');
         isset($dom['SwitchType']) ? $SwitchType = $dom['SwitchType'] : ($SwitchType = 'None');
                }
            } else {
                if ($action == "sleep") {
                    if (${'Dlevel' . $place} > 1 && $mc->get('dimmer' . $place) != 1) {
                        $mc->set('dimmer' . $place, 1);
                        Dim(${'DI' . $place}, ${'Dlevel' . $place} - 1, $place);
                    }
                } else {
                    if ($action == "dimmer") {
                        if (${'Dlevel' . $place} != $detail) {
                            Dim(${'DI' . $place}, $detail, 'GCal ' . $place . ' ');
                        }
                    } else {
                        if ($action == "schakel") {
                            if (${'S' . $place} != $detail) {
                                Schakel(${'SI' . $place}, $detail, 'GCal ' . $place . ' ');
                            }
                        } else {
                            if ($action == "setpoint") {
                                $mc->set('setpoint' . ${'RI' . $place}, 2);
                                if (${'R' . $place} != $detail) {
                                    Udevice(${'RI' . $place}, 0, $detail, 'GCal ' . $place . ' ');
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
     if (is_int($status)) {
         sleep(5);
         $status2 = pingDomain('192.168.0.7', 1597);
         if (is_int($status2)) {
             Schakel($SIkodi, 'Off', 'kodi');
         }
     }
 }
 //diskstation
 if ($Sdiskstation == 'On' && $STdiskstation < $driemin) {
     $status = pingDomain('192.168.0.10', 1600);
     if (is_int($status)) {
         sleep(5);
         $status2 = pingDomain('192.168.0.10', 1600);
         if (is_int($status2)) {
             Schakel($SIdiskstation, 'Off', 'diskstation');
         }
     }
 } else {
     if ($Sdiskstation == 'Off' && ($Sbureeltobi == 'On' || $Skodi == 'On')) {
         shell_exec('wakeonlan 00:11:32:2c:b7:21');
     }
 }
 if ($mc->get('RefreshZwave20') < $tienmin - mt_rand(0, 600)) {
     RefreshZwave(20, 'cron');
 }
 if ($mc->get('RefreshZwave21') < $tienmin - mt_rand(0, 600)) {
     RefreshZwave(21, 'cron');
 }
 if ($mc->get('RefreshZwave22') < $tienmin - mt_rand(0, 600)) {
     RefreshZwave(22, 'cron');
<?php

if (isset($_REQUEST['idx']) && isset($_REQUEST['cmd']) && isset($_REQUEST['comment'])) {
    $domoticzurl = 'http://127.0.0.1:8080/';
    function Schakel($idx, $cmd, $name = NULL)
    {
        global $domoticzurl;
        $reply = json_decode(file_get_contents($domoticzurl . 'json.htm?type=command&param=switchlight&idx=' . $idx . '&switchcmd=' . $cmd . '&level=0&passcode='), true);
        if ($reply['status'] == 'OK') {
            $reply = 'OK';
        } else {
            $reply = 'ERROR';
        }
        return $reply;
    }
    echo 'Schakel: ' . Schakel($_REQUEST['idx'], $_REQUEST['cmd'], $_REQUEST['comment']);
    echo '<hr>VARS:<pre>';
    print_r(get_defined_vars());
    echo '</pre>';
}