.
*
* Version 0.1
* Author: Octavio Benedi Sanchez
*/
// Predefined variables:
// $section contains the section folder name.
// echo "section=".$section."
";
// $plugin contains the plugin folder name.
// echo "plugin=".$plugin."
";
// $section and $plugin can be used to make a link to this plugin by just reference
// echo "This plugin"."
";
// $base_plugin contains the path that must be used as start to includes for
// plugin includes that need the local path.
// example: include_once $base_plugin.'php/my_include.php';
// echo "base_plugin=".$base_plugin."
";
// $url_plugin contains the url base that must be used to include html items
// such as images.
// example:
// echo "url_plugin=".$url_plugin."
";
// $API_core contains the path to the core API folder.
// example: include_once $API_core.'is_active.php';
// echo "API_core=".$API_core."
";
// Plugin server produced data will returned to the ajax call that made the
// request.
include_once $API_core.'complex_ajax_return_functions.php';
include_once $API_core.'json_api.php';
include_once $API_core.'form_fields_check.php';
include_once $base_plugin.'php/save_data.php';
include_once $base_plugin.'php/interface_generator.php';
include_once $base_plugin.'php/save_ini_file.php';
include_once $base_plugin.'php/parse_long_range_link.php';
include_once $API_core.'auto_code_generators.php';
if (!empty($_POST['action']))
{
switch ($_POST['action'])
{
case "save":
$_POST['interface']=trim($_POST['interface']);
if(!empty($_POST['interface']))
{
$form_data=jsondecode($_POST['form_fields']);
// Check if auto or manual input and make array for test with that.
if($form_data['input_method']=='Auto')
{
$fields_check_types = Array (
'distance_value' => Array ('ms_numerical','ms_mandatory'),
'acktimeout' => Array ('ms_numerical'),
'slottime' => Array ('ms_numerical'),
'ctstimeout' => Array ('ms_numerical')
);
}
else
{
$fields_check_types = Array (
'distance_value' => Array ('ms_numerical'),
'acktimeout' => Array ('ms_numerical','ms_mandatory'),
'slottime' => Array ('ms_numerical','ms_mandatory'),
'ctstimeout' => Array ('ms_numerical','ms_mandatory')
);
}
if(are_form_fields_valid ($form_data, $fields_check_types))
{
save_data($form_data, $_POST['interface']);
exec('sudo cp '.$base_plugin.'data/long_range_link.sh /etc/init.d/long_range_link.sh');
exec('chmod +x /etc/init.d/long_range_link.sh;sudo update-rc.d long_range_link.sh defaults 99;sudo /etc/init.d/long_range_link.sh');
response_additem("script", 'alert("Data saved.");data_changed=false;');
}
response_return();
}
else
{
response_additem("script", 'alert("Unexpected error!")');
}
break;
case "load_interface":
$_POST['interface']=trim($_POST['interface']);
if(!empty($_POST['interface']))
{
response_additem("html", make_interface($_POST['interface']),'interface');
}
else
{
response_additem("html", '','interface');
}
response_return();
break;
default:
break;
}
}
?>