Skip to content

Commit

Permalink
correction of command.php arguments + code_on & code_off
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinp72 committed May 1, 2017
1 parent 9cfbf26 commit 2320483
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion supervisor/checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=> Check if we need to turn on or turn off a device
*/

require '../config/include.php';
require __DIR__ . '/../config/include.php';

// Returns all devices that match the $time_columnName, $prog_state and $active
// ==> All devices that should be activated of disactivated according to the DB
Expand Down
10 changes: 6 additions & 4 deletions supervisor/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
=> Turn on or off a device
*/

require '../config/include.php';
require __DIR__ . '/../config/include.php';
$args_requiredNB = 3;

// Returns all device info that match $id id
Expand Down Expand Up @@ -46,11 +46,13 @@ function getCode($device, $origin, $command){
$values = array();

foreach($arguments as $arg){
list($x, $y) = explode('=', $arg);
$values["$x"] = $y;
$elems = explode('=', $arg);
if(count($elems) == 2){
$values["$elems[0]"] = $elems[1];
}
}

$nb = count($values) - 1;
$nb = count($values);
}

$command = $values['command']; // ON or OFF
Expand Down
14 changes: 12 additions & 2 deletions web/device_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">Code</div>
<div class="item-title label">Code d'allumage</div>
<div class="item-input">
<input class="right" type="text" value="<?php echo $data['code_on']; ?>" name="code_on">
</div>
</div>
</div>
</li>
<li>
<div class="item-content">
<div class="item-inner">
<div class="item-title label">Code d'éxtinction</div>
<div class="item-input">
<input class="right" type="text" value="<?php echo $data['code']; ?>" name="code">
<input class="right" type="text" value="<?php echo $data['code_off']; ?>" name="code_off">
</div>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions web/post_device_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

$id = $_POST['id'];
$name = $_POST['name'];
$code = $_POST['code'];
$code_on = $_POST['code_on'];
$code_off = $_POST['code_off'];

$prog_on_state = 0; // Initialization to 0 because if the checkbox is not checked, it won't exist
$prog_on_time = $_POST['prog_on_time'];
Expand Down Expand Up @@ -43,7 +44,8 @@
// Update
$query = "UPDATE devices SET
name = '". $name ."',
code = '". $code ."',
code_on = '". $code_on ."',
code_off = '". $code_off ."',
prog_on_state = ". $prog_on_state .",
prog_on_time = '". $prog_on_time ."',
Expand Down

0 comments on commit 2320483

Please sign in to comment.