diff --git a/MySQL_Database/pihome_mysql_database.sql b/MySQL_Database/pihome_mysql_database.sql index 8da615de..cd2df502 100644 --- a/MySQL_Database/pihome_mysql_database.sql +++ b/MySQL_Database/pihome_mysql_database.sql @@ -329,6 +329,29 @@ ENGINE=InnoDB; /*!40000 ALTER TABLE `mqtt` DISABLE KEYS */; /*!40000 ALTER TABLE `mqtt` ENABLE KEYS */; +-- Dumping structure for table pihome.network_settings +DROP TABLE IF EXISTS `network_settings`; +CREATE TABLE IF NOT EXISTS `network_settings` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `sync` tinyint(4) NOT NULL, + `purge` tinyint(4) NOT NULL COMMENT 'Mark For Deletion', + `primary_interface` tinyint(4), + `interface_num` tinyint(4), + `interface_type` char(50) COLLATE utf16_bin, + `mac_address` char(50) COLLATE utf16_bin, + `hostname` char(50) COLLATE utf16_bin, + `ip_address` char(50) COLLATE utf16_bin, + `gateway_address` char(50) COLLATE utf16_bin, + `net_mask` char(50) COLLATE utf16_bin, + `dns1_address` char(50) COLLATE utf16_bin, + `dns2_address` char(50) COLLATE utf16_bin, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf16 COLLATE=utf16_bin; + +-- Dumping data for table pihome.network_settings: ~0 rows (approximately) +/*!40000 ALTER TABLE `system` DISABLE KEYS */; +/*!40000 ALTER TABLE `system` ENABLE KEYS */; + -- Dumping structure for table pihome.nodes DROP TABLE IF EXISTS `nodes`; CREATE TABLE IF NOT EXISTS `nodes` ( diff --git a/db.php b/db.php index 0830fcd1..9253e9bc 100644 --- a/db.php +++ b/db.php @@ -736,6 +736,40 @@ } +//network Settings +if($what=="setup_network"){ + $n_primary = $_GET['n_primary']; + $n_int_num = $_GET['n_int_num']; + $n_int_type = $_GET['n_int_type']; + $n_mac = $_GET['n_mac']; + $n_hostname = $_GET['n_hostname']; + $n_ip = $_GET['n_ip']; + $n_gateway = $_GET['n_gateway']; + $n_net_mask = $_GET['n_net_mask']; + $n_dns1 = $_GET['n_dns1']; + $n_dns2 = $_GET['n_dns2']; + + //Check interface already exists in table + $query = "SELECT * FROM `network_settings` WHERE `interface_num` = '".$n_int_num."' LIMIT 1;"; + $result = $conn->query($query); + if (mysqli_num_rows($result)==0){ + //No record, so add + $query = "INSERT INTO `network_settings`(`sync`, `purge`, `primary_interface`, `interface_num`, `interface_type`, `mac_address`, `hostname`, `ip_address`, `gateway_address`, `net_mask`, `dns1_address`, `dns2_address`) VALUES (0,0,'".$n_primary."','".$n_int_num."','".$n_int_type."','".$n_mac."','".$n_hostname."','".$n_ip."','".$n_gateway."','".$n_net_mask."','".$n_dns1."','".$n_dns2."');"; + } else { + //Update + $query = "UPDATE `network_settings` SET primary_interface = '".$n_primary."', interface_type = '".$n_int_type."', mac_address = '".$n_mac."', hostname = '".$n_hostname."', ip_address = '".$n_ip."', gateway_address = '".$n_gateway."', net_mask = '".$n_net_mask."', dns1_address = '".$n_dns1."', dns2_address = '".$n_dns2."' where interface_num = '".$n_int_num."';"; + } + if($conn->query($query)){ + header('Content-type: application/json'); + echo json_encode(array('Success'=>'Success','Query'=>$query)); + return; + }else{ + header('Content-type: application/json'); + echo json_encode(array('Message'=>'Database query failed.\r\nQuery=' . $query)); + return; + } +} + //Setup E-mail Setting if($what=="setup_email"){ $status = $_GET['status']; diff --git a/js/request.js b/js/request.js index 4527f9b2..3323f958 100644 --- a/js/request.js +++ b/js/request.js @@ -421,6 +421,34 @@ var idata="w=setup_gateway&o=update&status="+document.getElementById("checkbox1" }); } +//update network settings +function setup_network(){ +var idata="w=setup_network&o=update&n_primary="+document.getElementById("n_primary").value; + idata+="&n_int_num="+document.getElementById("n_int_num").value; + idata+="&n_int_type="+document.getElementById("n_int_type").value; + idata+="&n_mac="+document.getElementById("n_mac").value; + idata+="&n_hostname"+document.getElementById("n_hostname").value; + idata+="&n_ip="+document.getElementById("n_ip").value; + idata+="&n_gateway="+document.getElementById("n_gateway").value; + idata+="&n_net_mask="+document.getElementById("n_net_mask").value; + idata+="&n_dns1="+document.getElementById("n_dns1").value; + idata+="&n_dns2="+document.getElementById("n_dns2").value; + idata+="&wid=0"; + $.get('db.php',idata) + .done(function(odata){ + if(odata.Success) + reload_page(); + else + console.log(odata.Message); + }) + .fail(function( jqXHR, textStatus, errorThrown ){ + if(jqXHR==401 || jqXHR==403) return; + console.log("setup_network: Error.\r\n\r\njqXHR: "+jqXHR+"\r\n\r\ntextStatus: "+textStatus+"\r\n\r\nerrorThrown:"+errorThrown); + }) + .always(function() { + }); +} + //update email function setup_email(){ var idata="w=setup_email&o=update&status="+document.getElementById("checkbox3").checked; diff --git a/languages/en.php b/languages/en.php index 3fea7774..bd50e458 100644 --- a/languages/en.php +++ b/languages/en.php @@ -419,4 +419,16 @@ $lang['confirm_dell_active_zone'] = "You are about to DELETE an ACTIVE ZONE"; $lang['confirm_dell_de_active_zone'] = "You are about to DELETE a NONE active ZONE"; +$lang['network'] = "Network"; +$lang['network_settings'] = "Network Settings"; +$lang['network_text'] = "Controller Network Configuration Parameters. "; +$lang['network_interface'] = "Controller Network Interface"; +$lang['network_mac_address'] = "Controller MAC Address"; +$lang['network_hostname'] = "Controller Hostname"; +$lang['network_ip_address'] = "Controller IP Address"; +$lang['network_gateway_address'] = "Controller Gateway Address"; +$lang['network_net_mask'] = "Controller Net Mask"; +$lang['network_dns1_address'] = "Controller DNS1 Address"; +$lang['network_dns2_address'] = "Controller DNS2 Address"; +$lang['network_primary'] = "Controller Primary Interface"; ?> diff --git a/model.php b/model.php index 30a86fc2..34d51c3b 100644 --- a/model.php +++ b/model.php @@ -988,6 +988,132 @@ '; +//network settings model +echo ' +
+ +'; +?> + + diff --git a/settingslist.php b/settingslist.php index f2893b1a..69423a81 100644 --- a/settingslist.php +++ b/settingslist.php @@ -123,7 +123,14 @@