Esempio n. 1
0
  <h2>Current status:</h2>

  <form method="POST">
   <table class="status">
<?php 
foreach ($devices as $deviceName => $devicePin) {
    $deviceStatus = runGpio("read", $devicePin);
    ?>
  
    <tr>
     <th><?php 
    print $deviceName;
    ?>
 is:</th>
     <td>
<?php 
    print $deviceStatus ? "on" : "off";
    ?>
   
     </td>
     <td>
      <input type="submit" name="<?php 
    print $deviceName;
    ?>
Action" value="<?php 
    print $deviceStatus ? "Turn off" : "Turn on";
    ?>
"/>
     </td>
     <td>
<?php 
Esempio n. 2
0
<?php

require_once 'config.php';
require_once 'functions.php';
if (count($argv) != 3) {
    exit(1);
}
runGpio("write", $argv[1], $argv[2]);
Esempio n. 3
0
<?php

// run now or stop now
foreach ($devices as $deviceName => $devicePin) {
    $actionPar = $deviceName . 'Action';
    $durationPar = $deviceName . 'Duration';
    $actionPar = str_replace(' ', '_', $actionPar);
    // we love PHP
    $durationPar = str_replace(' ', '_', $durationPar);
    // we love PHP
    if (isset($_POST[$actionPar])) {
        $turnOn = $_POST[$actionPar] == 'Turn on';
        runGpio("write", $devicePin, $turnOn ? "1" : "0");
        if (isset($_POST[$durationPar]) && $_POST[$durationPar]) {
            # something other than 0
            issueAt($deviceName, $_POST[$durationPar], $turnOn ? "0" : "1");
        }
    }
}
// schedule
if (isset($_POST['change-schedule']) && $_POST['change-schedule'] == 'Save') {
    $schedule = readCrontab();
    $deviceName = $_POST['deviceName'];
    if (isset($devices[$deviceName])) {
        if ($_POST['scheduled'] == 'yes') {
            function rangeCheck($val, $min, $max)
            {
                $val = intval($val);
                if ($val < $min) {
                    $val = $min;
                } else {