I have a simple robot I am working on. There is a webpage, using arrows to navigate, and a streaming webcam. I've been reading that using exec(command)
is insecure. Unfortunately, I don't know how to get user input from the webpage, to securely execute code on the Raspberry Pi.
For now, I have included a few checks for date, time, user, (max run time) duration, start time, etc.
But, I would rather know how to securely get user control input from a web page, to control the I/O pins of the Raspberry Pi.
Here's a fragment: It's from the old interface, but I am still using the same basic methodology to process instructions.
<?php
if (isset($_POST['Submit1']))
{
$reg_wvar = isset($_POST['nmr']);
$reg_UName = $_POST['UName'];
$reg_Date = $_POST['ddate'];
$reg_startTime = $_POST['startTime'];
$reg_ToD = $_POST['ToD'];
$reg_duration = $_POST['duration'];
$r = "$reg_Date $reg_startTime $reg_ToD, $reg_duration, $reg_UName \n";
//echo $r . $reg_wvar;
$selected_radio = $_POST['nmr'];
switch($selected_radio)
{
case $reg_wvar = "left":
$du = 'left.py';
$command = "$du $r";
echo exec($command);
break;
case $reg_wvar = "right":
$du = 'right.py';
$command = "$du $r";
echo exec($command);
default:
;
}
}
?>