コード例 #1
0
 public function processControlMenu()
 {
     if (isset($_REQUEST['main_tab'])) {
         $option = $_REQUEST['main_tab'];
         if ($option === 'lights') {
             echo Lightbulb::getLightBulbForm();
         } elseif ($option === 'locks') {
             echo Lock::getLockForm();
         } elseif ($option === 'thermostat') {
             echo Thermostat::getThermostatForm();
         } else {
             if ($option == 'lightGroups') {
                 echo LightGroup::getLightGroupForm();
             } else {
                 echo "<h3>Undefined Tab Selected</h3>";
             }
         }
         //continue with locks
         //thermostat etc.
         $this->display = FALSE;
     } else {
         $command = escapeshellcmd("python /var/www/python/killall.py");
         shell_exec($command);
         $command = escapeshellcmd("python /var/www/python/clear.py");
         shell_exec($command);
     }
 }
コード例 #2
0
 /**
  * gets lightbulb form
  * @return string HTML div
  */
 public static function getLightBulbForm()
 {
     //get all lightbulbs from db and create button for each
     $lightArray = self::get_appliances_by_type('light');
     $form = "<div><h2>Lights</h2>";
     foreach ($lightArray as $lightID) {
         $light = new Lightbulb();
         $light->load_by_id($lightID['applianceId']);
         $button = $light->getButtonDiv();
         $form .= "<div>{$button}</div>";
         $light->activateLight();
     }
     $party = "<button onclick='commenceParty(); '>Party Button</button>";
     $form .= "{$party}</div>";
     return $form;
 }
コード例 #3
0
<?php

require_once '../shell.php';
if (isset($_POST['status'])) {
    $id = $_POST['ID'];
    $light = new Lightbulb($id);
    $lightid = 1;
    $lightstatus = $_POST['status'];
    if ($light->status === '0') {
        $light->status = '1';
        //        $lightstatus = 'on';
    } else {
        $light->status = '0';
        //        $lightstatus = 'off';
    }
    echo "<br>lightstatus: {$lightstatus}";
    $light->save();
    $command = escapeshellcmd("python /var/www/python/LightsHandler.py {$light->lightID} {$lightstatus}");
    echo $command;
    $output = shell_exec($command);
    echo "Output: {$output} <br>";
}