. * * 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.'save_interfaces.php'; include_once $API_core.'form_fields_check.php'; if (($_POST['type']=="save")||($_POST['type']=="save_restart")) { $post_data=jsondecode($_POST['form_fields']); if($post_data['iface_sel']=='static') { $fields_check_types = Array ( 'address' => Array ('ms_ip','ms_mandatory'), 'netmask' => Array ('ms_ip','ms_mandatory'), 'gateway' => Array ('ms_ip','ms_mandatory'), 'DNS1' => Array ('ms_ip'), 'DNS2' => Array ('ms_ip'), 'broadcast' => Array ('ms_ip') ); } else { $fields_check_types = Array (); } if(are_form_fields_valid ($post_data, $fields_check_types)) { //$input=saveInterfaces('eth0',$post_data,"/etc/network/interfaces",$base_dir."data"); $input=saveInterfaces('eth0',$post_data,"/etc/network/interfaces","/etc/network/interfaces"); //exec('sudo cp '.$base_plugin."data/interfaces /etc/network/interfaces"); //response_additem("return", '
'.print_r($post_data,true).print_r($input,true).'
'); if ($_POST['type']=="save_restart") { exec('sudo ifdown eth0; sudo ifup eth0'); } response_additem("script", 'alert("Data saved")'); } response_return(); } ?>