diff --git a/.gitignore b/.gitignore index b048aa2..06967d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea + uploads/*.csv sqlite/*.db diff --git a/README.md b/README.md index 09dd661..0177979 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ This is very simple and very useful. ## Screenshots #### Screenshot1 -![Network1](screenshots/Networks1.png) +![Network1](_doc/screenshots/Networks1.png) #### Screenshot2 -![Hosts1](screenshots/Hosts1.png) +![Hosts1](_doc/screenshots/Hosts1.png) #### Screenshot3 -![Hosts2](screenshots/Hosts2.png) +![Hosts2](_doc/screenshots/Hosts2.png) ## Features @@ -24,7 +24,7 @@ This is very simple and very useful. ## Dependencies * PHP >= 5.3.7 (recommends PHP 5.4 or newer) -* Apache (Nginx etc) +* Apache (uses .htaccess) * SQLite3 ## Using @@ -39,34 +39,57 @@ This is very simple and very useful. ## Installation +- Install Dependencies - Download SimpeIPAM with GitHub -- Upload SimpeIPAM in Document Root in Nginx # /var/www/html/simpleipam +- Upload SimpeIPAM in Document Root in Apache # /var/www/html/simpleipam - Copy ipam.db.sample to ipam.db # sqlite/ipam.db ## Configuration +### Adjust `Firewall` +Please seek information about `SELinux`, `firewall` to web.. +And adjust settings properly.. +(If settings are too firm (example, SELinux is `Enforcing`), + you might fail to add/update/delete record to db.) + +### Enable `log_message` +Edit $config['log_threshold'] in config/config.php +(If need, set $config['log_path'], $config['log_file_extension'] properly. + Pay attention to the permissions of log file output directory.) +For example, change "0" to "1 :Error Messages (including PHP errors)" + +``` +//$config['log_threshold'] = 0; +$config['log_threshold'] = 1; +``` + ### Change Per Page Edit $config['per_page'] in controllers/Networks.php and controllers/Hosts.php -For example, change "5" to "300" +For example, change "5" to "300" ``` public function index() { .... - $config['per_page'] = "5"; + //$config['per_page'] = "5"; + $config['per_page'] = "300"; .... } function search() { .... - $config['per_page'] = "5"; + //$config['per_page'] = "5"; + $config['per_page'] = "300"; .... } ``` ## ChangeLog +v3.0 + * Add Columns (See sqlite\NOTE.txt) + v2.0 * Delete Model Column in hosts diff --git a/_doc/screenshots/Hosts1.png b/_doc/screenshots/Hosts1.png new file mode 100644 index 0000000..e6bf7ac Binary files /dev/null and b/_doc/screenshots/Hosts1.png differ diff --git a/_doc/screenshots/Hosts2.png b/_doc/screenshots/Hosts2.png new file mode 100644 index 0000000..5770e09 Binary files /dev/null and b/_doc/screenshots/Hosts2.png differ diff --git a/_doc/screenshots/Networks1.png b/_doc/screenshots/Networks1.png new file mode 100644 index 0000000..0e9e730 Binary files /dev/null and b/_doc/screenshots/Networks1.png differ diff --git a/application/controllers/Cidr.php b/application/controllers/Cidr.php new file mode 100644 index 0000000..21b3bc1 --- /dev/null +++ b/application/controllers/Cidr.php @@ -0,0 +1,43 @@ +load->helper('url'); + $this->load->helper('form'); + //$this->load->helper('myip'); + + //library + //$this->load->library('session'); + //$this->load->library('csvimport'); + //$this->load->library('pagination'); + + //model + //$this->load->model('Ipam'); + } + + /** + * + */ + public function index() + { + $data["host_name"] = ""; //this is form in header + + $data['title'] = 'SimpleIPAM Cidr Note'; + $this->load->view('template/header', $data); + $this->load->view('cidr_view'); + $this->load->view('template/footer'); + } + +} diff --git a/application/controllers/Hello.php b/application/controllers/Hello.php deleted file mode 100644 index a561aeb..0000000 --- a/application/controllers/Hello.php +++ /dev/null @@ -1,19 +0,0 @@ -"; - echo "$param2
"; - } -} -?> diff --git a/application/controllers/Hosts.php b/application/controllers/Hosts.php index f3bc402..cad2f66 100644 --- a/application/controllers/Hosts.php +++ b/application/controllers/Hosts.php @@ -1,19 +1,21 @@ load->helper('url'); $this->load->helper('form'); $this->load->helper('myip'); //$this->load->helper(array('form','url')); - + //library - $this->load->library('session'); + $this->load->library('session'); $this->load->library('csvimport'); $this->load->library('pagination'); @@ -23,18 +25,18 @@ function __construct() { } - public function index() - { + public function index() + { - $data["host_name"]=""; + $data["host_name"] = ""; //pagination settings $config['base_url'] = site_url("hosts/search/NIL"); $config['total_rows'] = $this->db->count_all('hosts'); $data['total_rows'] = $config['total_rows']; - $config['per_page'] = "5"; + $config['per_page'] = "20"; $config["uri_segment"] = 4; - $choice = $config["total_rows"]/$config["per_page"]; + $choice = $config["total_rows"] / $config["per_page"]; $config["num_links"] = floor($choice); // integrate bootstrap pagination @@ -64,43 +66,45 @@ public function index() $data['hosts'] = $this->Ipam->get_hosts($config["per_page"], $data['page'], NULL); $data['pagination'] = $this->pagination->create_links(); - + //$data['hosts'] =$this->Ipam->get_all_hosts(); $data['total_rows'] = $config['total_rows']; $data['start'] = $data['page'] + 1; - $data['end'] = $data['start'] + $config['per_page'] - 1 ; + $data['end'] = $data['start'] + $config['per_page'] - 1; - $data['title'] = 'SimpleIPAM Hosts'; - $this->load->view('template/header', $data); - $this->load->view('hosts_view'); - $this->load->view('template/footer'); - } + $data['title'] = 'SimpleIPAM Hosts'; + $this->load->view('template/header', $data); + $this->load->view('hosts_view'); + $this->load->view('template/footer'); + } function search() { - $data["host_name"]=""; //this is form in header + $data["host_name"] = ""; //this is form in header //input search // post - $search = ($this->input->post("host_name"))? $this->input->post("host_name") : "NIL"; + $search = ($this->input->post("host_name")) ? $this->input->post("host_name") : "NIL"; // get $search = ($this->uri->segment(3)) ? $this->uri->segment(3) : $search; // url encode for japanese - $search= urldecode($search); + $search = urldecode($search); + - - empty($search) ? $data["host_name"]="" : $data["host_name"]=$search; - if($search == "NIL" ){ $data["host_name"]=""; } + empty($search) ? $data["host_name"] = "" : $data["host_name"] = $search; + if ($search == "NIL") { + $data["host_name"] = ""; + } // pagination settings $config = array(); $config['base_url'] = site_url("hosts/search/$search"); $config['total_rows'] = $this->Ipam->get_hosts_count($search); - $config['per_page'] = "5"; + $config['per_page'] = "20"; $config["uri_segment"] = 4; - $choice = $config["total_rows"]/$config["per_page"]; + $choice = $config["total_rows"] / $config["per_page"]; $config["num_links"] = floor($choice); // integrate bootstrap pagination @@ -132,58 +136,63 @@ function search() $data['total_rows'] = $config['total_rows']; $data['start'] = $data['page'] + 1; - $data['end'] = $data['start'] + $config['per_page'] - 1 ; + $data['end'] = $data['start'] + $config['per_page'] - 1; //load view - $data['title'] = 'SimpleIPAM Hosts'; - $this->load->view('template/header', $data); - $this->load->view('hosts_view', $data ); - $this->load->view('template/footer' ); + $data['title'] = 'SimpleIPAM Hosts'; + $this->load->view('template/header', $data); + $this->load->view('hosts_view', $data); + $this->load->view('template/footer'); + } + + + public function hosts_add() + { + $this->_validate(); + $data = array( + 'ip_address' => $this->input->post('ip_address'), + 'subnet_mask' => $this->input->post('subnet_mask'), + 'host' => $this->input->post('host'), + 'note' => $this->input->post('note'), + 'public_ip' => $this->input->post('public_ip'), + 'state' => $this->input->post('state'), + 'spec' => $this->input->post('spec'), + ); + $insert = $this->Ipam->hosts_add($data); + echo json_encode(array("status" => TRUE)); } - - public function hosts_add() - { + public function ajax_edit($id) + { + $data = $this->Ipam->hosts_get_by_id($id); + + echo json_encode($data); + } + + + public function hosts_update() + { $this->_validate(); - $data = array( - 'ip_address' => $this->input->post('ip_address'), - 'subnet_mask' => $this->input->post('subnet_mask'), - 'host' => $this->input->post('host'), - 'note' => $this->input->post('note'), - ); - $insert = $this->Ipam->hosts_add($data); - echo json_encode(array("status" => TRUE)); - } - - public function ajax_edit($id) - { - $data = $this->Ipam->hosts_get_by_id($id); - - echo json_encode($data); - } - - - public function hosts_update() - { - $this->_validate(); - $data = array( - 'ip_address' => $this->input->post('ip_address'), - 'subnet_mask' => $this->input->post('subnet_mask'), - 'host' => $this->input->post('host'), - 'note' => $this->input->post('note'), - ); - $this->Ipam->hosts_update(array('id' => $this->input->post('id')), $data); - echo json_encode(array("status" => TRUE)); - } - - - public function hosts_delete($id) - { - $this->Ipam->hosts_delete_by_id($id); - echo json_encode(array("status" => TRUE)); - } + $data = array( + 'ip_address' => $this->input->post('ip_address'), + 'subnet_mask' => $this->input->post('subnet_mask'), + 'host' => $this->input->post('host'), + 'note' => $this->input->post('note'), + 'public_ip' => $this->input->post('public_ip'), + 'state' => $this->input->post('state'), + 'spec' => $this->input->post('spec'), + ); + $this->Ipam->hosts_update(array('id' => $this->input->post('id')), $data); + echo json_encode(array("status" => TRUE)); + } + + public function hosts_delete($id) + { + $this->Ipam->hosts_delete_by_id($id); + echo json_encode(array("status" => TRUE)); + } private function _validate() @@ -192,16 +201,15 @@ private function _validate() $data['error_string'] = array(); $data['inputerror'] = array(); $data['status'] = TRUE; - - if($this->input->post('ip_address') == '') - { + + if ($this->input->post('ip_address') == '') { $data['inputerror'][] = 'ip_address'; $data['error_string'][] = 'IP Address is required'; $data['status'] = FALSE; } - $subnet_mask=$this->input->post('subnet_mask'); + $subnet_mask = $this->input->post('subnet_mask'); /* if (!is_numeric($subnet_mask)) { @@ -210,8 +218,7 @@ private function _validate() $data['status'] = FALSE; } */ - if($subnet_mask == '') - { + if ($subnet_mask == '') { $data['inputerror'][] = 'subnet_mask'; $data['error_string'][] = 'Subnet mask is required'; $data['status'] = FALSE; @@ -225,21 +232,19 @@ private function _validate() $data['status'] = FALSE; } */ - - if($this->input->post('host') == '') - { + + if ($this->input->post('host') == '') { $data['inputerror'][] = 'host'; $data['error_string'][] = 'host is required'; $data['status'] = FALSE; } - - if($data['status'] === FALSE) - { + + if ($data['status'] === FALSE) { echo json_encode($data); exit(); } - + } @@ -248,78 +253,79 @@ private function _validate() * CSV *====================================================== */ - public function csv() - { - $data["host_name"]=""; //this is form in header - $data['title'] = 'SimpleIPAM Hosts'; - - $this->load->view('template/header', $data); - $this->load->view('hosts_csv'); - $this->load->view('template/footer' ); - } - - public function export_csv() { - $file_name = 'hosts_'.date("Y-m-d h-i-s").'.csv'; - $delimiter = ","; + public function csv() + { + $data["host_name"] = ""; //this is form in header + $data['title'] = 'SimpleIPAM Hosts'; + + $this->load->view('template/header', $data); + $this->load->view('hosts_csv'); + $this->load->view('template/footer'); + } + + public function export_csv() + { + $file_name = 'hosts_' . date("Y-m-d h-i-s") . '.csv'; + $delimiter = ","; $newline = "\r\n"; $sql_order = " order by CAST(substr(trim(ip_address),1,instr(trim(ip_address),'.')-1) AS INTEGER), CAST(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')-1) AS INTEGER), CAST(substr(substr(trim(ip_address),length(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')-1) AS INTEGER), CAST(substr(trim(ip_address),length(substr(substr(trim(ip_address),length(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+ length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+length(substr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)) ,1, instr(substr(trim(ip_address),length(substr(trim(ip_address),1,instr(trim(ip_address),'.')))+1,length(ip_address)),'.')))+1,length(trim(ip_address))) AS INTEGER) "; - $query = $this->db->query('SELECT ip_address, subnet_mask, host, note FROM hosts WHERE 1'.$sql_order); - $this->load->dbutil(); - $data = $this->dbutil->csv_from_result($query, $delimiter, $newline); - $this->load->helper('download'); - force_download($file_name, $data); - exit(); - } + $query = $this->db->query('SELECT ip_address, subnet_mask, host, note, public_ip, state, spec FROM hosts WHERE 1' . $sql_order); + $this->load->dbutil(); + $data = $this->dbutil->csv_from_result($query, $delimiter, $newline); + $this->load->helper('download'); + force_download($file_name, $data); + exit(); + } - function import_csv() { + function import_csv() + { $data['error'] = ''; //initialize image upload error array to empty - + $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'csv'; $config['max_size'] = '50000'; //50,000KB = 50MB - + $this->load->library('upload', $config); - + // If upload failed, display error if (!$this->upload->do_upload()) { $data['error'] = $this->upload->display_errors(); - - $this->load->view('template/header', $data); - $this->load->view('hosts_csv', $data); - $this->load->view('template/footer' ); + + $this->load->view('template/header', $data); + $this->load->view('hosts_csv', $data); + $this->load->view('template/footer'); } else { $file_data = $this->upload->data(); - $file_path = './uploads/'.$file_data['file_name']; - + $file_path = './uploads/' . $file_data['file_name']; + if ($this->csvimport->get_array($file_path)) { $csv_array = $this->csvimport->get_array($file_path); foreach ($csv_array as $row) { $insert_data = array( - 'ip_address'=>$row['ip_address'], - 'subnet_mask'=>$row['subnet_mask'], - 'host'=>$row['host'], - 'note'=>$row['note'], + 'ip_address' => $row['ip_address'], + 'subnet_mask' => $row['subnet_mask'], + 'host' => $row['host'], + 'note' => $row['note'], + 'public_ip' => $row['public_ip'], + 'state' => $row['state'], + 'spec' => $row['spec'], ); $this->Ipam->hosts_insert_csv($insert_data); } $this->session->set_flashdata('success', 'Csv Data Imported Succesfully'); //redirect(base_url().'networks/export_csv'); //echo "
"; print_r($insert_data);
-            } else 
-				$data['error'] = "Error occured";
-				$this->load->view('template/header', $data);
-				$this->load->view('hosts_csv', $data);
-				$this->load->view('template/footer' );
+            } else
+                $data['error'] = "Error occured";
+            $this->load->view('template/header', $data);
+            $this->load->view('hosts_csv', $data);
+            $this->load->view('template/footer');
         }
         //echo "$file_path";
         unlink($file_path);
-	}    
-
-
-
-
+    }
 
 
 }
diff --git a/application/controllers/Networks.php b/application/controllers/Networks.php
index 3c7a738..f627f12 100644
--- a/application/controllers/Networks.php
+++ b/application/controllers/Networks.php
@@ -1,19 +1,21 @@
 load->helper('url');
         $this->load->helper('form');
         $this->load->helper('myip');
         //$this->load->helper(array('form','url'));
-        
+
         //library
-		$this->load->library('session');
+        $this->load->library('session');
         $this->load->library('csvimport');
         $this->load->library('pagination');
 
@@ -23,18 +25,18 @@ function __construct() {
     }
 
 
-	public function index()
-	{
-        $data["host_name"]="";    //this is form in header
-        $data["network_name"]="";
+    public function index()
+    {
+        $data["host_name"] = "";    //this is form in header
+        $data["network_name"] = "";
 
         //pagination settings
         $config['base_url'] = site_url("networks/search/NIL");
         $config['total_rows'] = $this->db->count_all('networks');
         $data['total_rows'] = $config['total_rows'];
-        $config['per_page'] = "5";
+        $config['per_page'] = "10";
         $config["uri_segment"] = 4;
-        $choice = $config["total_rows"]/$config["per_page"];
+        $choice = $config["total_rows"] / $config["per_page"];
         $config["num_links"] = floor($choice);
 
         // integrate bootstrap pagination
@@ -59,48 +61,50 @@ public function index()
         $this->pagination->initialize($config);
 
         $data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
-        
+
         // get networks list
         $data['networks'] = $this->Ipam->get_networks($config["per_page"], $data['page'], NULL);
-        
+
         $data['pagination'] = $this->pagination->create_links();
 
         //$data['networks'] =$this->Ipam->get_all_networks();
 
         $data['total_rows'] = $config['total_rows'];
         $data['start'] = $data['page'] + 1;
-        $data['end'] = $data['start'] + $config['per_page'] - 1 ;
+        $data['end'] = $data['start'] + $config['per_page'] - 1;
 
-		$data['title'] = 'SimpleIPAM Networks';
-		$this->load->view('template/header', $data);
-		$this->load->view('networks_view', $data );
-		$this->load->view('template/footer' );
+        $data['title'] = 'SimpleIPAM Networks';
+        $this->load->view('template/header', $data);
+        $this->load->view('networks_view', $data);
+        $this->load->view('template/footer');
     }
-    
+
 
     function search()
     {
-        $data["host_name"]="";    //this is form in header
+        $data["host_name"] = "";    //this is form in header
         //input search
         // post
-        $search = ($this->input->post("network_name"))? $this->input->post("network_name") : "NIL";
+        $search = ($this->input->post("network_name")) ? $this->input->post("network_name") : "NIL";
         // get
         $search = ($this->uri->segment(3)) ? $this->uri->segment(3) : $search;
         // url encode for japanese
-        $search= urldecode($search);
+        $search = urldecode($search);
 
-        
-        empty($search) ? $data["network_name"]="" : $data["network_name"]=$search;
-        if($search == "NIL" ){ $data["network_name"]=""; }
+
+        empty($search) ? $data["network_name"] = "" : $data["network_name"] = $search;
+        if ($search == "NIL") {
+            $data["network_name"] = "";
+        }
 
 
         // pagination settings
         $config = array();
         $config['base_url'] = site_url("networks/search/$search");
         $config['total_rows'] = $this->Ipam->get_networks_count($search);
-        $config['per_page'] = "5";
+        $config['per_page'] = "10";
         $config["uri_segment"] = 4;
-        $choice = $config["total_rows"]/$config["per_page"];
+        $choice = $config["total_rows"] / $config["per_page"];
         $config["num_links"] = floor($choice);
 
         // integrate bootstrap pagination
@@ -132,61 +136,63 @@ function search()
 
         $data['total_rows'] = $config['total_rows'];
         $data['start'] = $data['page'] + 1;
-        $data['end'] = $data['start'] + $config['per_page'] - 1 ;
+        $data['end'] = $data['start'] + $config['per_page'] - 1;
 
 
         //load view
-		$data['title'] = 'SimpleIPAM Networks';
-		$this->load->view('template/header', $data);
-		$this->load->view('networks_view', $data );
-		$this->load->view('template/footer' );
+        $data['title'] = 'SimpleIPAM Networks';
+        $this->load->view('template/header', $data);
+        $this->load->view('networks_view', $data);
+        $this->load->view('template/footer');
+    }
+
+
+    public function networks_add()
+    {
+        $this->_validate();
+        $data = array(
+            'networks' => $this->input->post('networks'),
+            'cidr' => $this->input->post('cidr'),
+            'broadcast_address' => $this->input->post('broadcast_address'),
+            'vlan_id' => $this->input->post('vlan_id'),
+            'note1' => $this->input->post('note1'),
+            'note2' => $this->input->post('note2'),
+            'note3' => $this->input->post('note3'),
+        );
+        $insert = $this->Ipam->networks_add($data);
+        echo json_encode(array("status" => TRUE));
+    }
+
+    public function ajax_edit($id)
+    {
+        $data = $this->Ipam->networks_get_by_id($id);
+
+        echo json_encode($data);
     }
 
-	
-	public function networks_add()
-	{
+
+    public function networks_update()
+    {
         $this->_validate();
-		$data = array(
-				'networks' => $this->input->post('networks'),
-				'cidr' => $this->input->post('cidr'),
-				'broadcast_address' => $this->input->post('broadcast_address'),
-				'vlan_id' => $this->input->post('vlan_id'),
-				'note1' => $this->input->post('note1'),
-				'note2' => $this->input->post('note2'),
-			);
-		$insert = $this->Ipam->networks_add($data);
-		echo json_encode(array("status" => TRUE));
-	}
-
-	public function ajax_edit($id)
-	{
-		$data = $this->Ipam->networks_get_by_id($id);
-
-		echo json_encode($data);
-	}
-
-
-	public function networks_update()
-	{
-    $this->_validate();
-	$data = array(
-		'networks' => $this->input->post('networks'),
-		'cidr' => $this->input->post('cidr'),
-		'broadcast_address' => $this->input->post('broadcast_address'),
-		'vlan_id' => $this->input->post('vlan_id'),
-		'note1' => $this->input->post('note1'),
-		'note2' => $this->input->post('note2'),
-		);
-	$this->Ipam->networks_update(array('id' => $this->input->post('id')), $data);
-	echo json_encode(array("status" => TRUE));
-	}
-
-
-	public function networks_delete($id)
-	{
-		$this->Ipam->networks_delete_by_id($id);
-		echo json_encode(array("status" => TRUE));
-	}
+        $data = array(
+            'networks' => $this->input->post('networks'),
+            'cidr' => $this->input->post('cidr'),
+            'broadcast_address' => $this->input->post('broadcast_address'),
+            'vlan_id' => $this->input->post('vlan_id'),
+            'note1' => $this->input->post('note1'),
+            'note2' => $this->input->post('note2'),
+            'note3' => $this->input->post('note3'),
+        );
+        $this->Ipam->networks_update(array('id' => $this->input->post('id')), $data);
+        echo json_encode(array("status" => TRUE));
+    }
+
+
+    public function networks_delete($id)
+    {
+        $this->Ipam->networks_delete_by_id($id);
+        echo json_encode(array("status" => TRUE));
+    }
 
 
     private function _validate()
@@ -195,24 +201,21 @@ private function _validate()
         $data['error_string'] = array();
         $data['inputerror'] = array();
         $data['status'] = TRUE;
- 
-        if($this->input->post('networks') == '')
-        {
+
+        if ($this->input->post('networks') == '') {
             $data['inputerror'][] = 'networks';
             $data['error_string'][] = 'Networks is required';
             $data['status'] = FALSE;
         }
 
 
-        $cidr=$this->input->post('cidr');
-        if (!is_numeric($cidr))
-        {
+        $cidr = $this->input->post('cidr');
+        if (!is_numeric($cidr)) {
             $data['inputerror'][] = 'cidr';
             $data['error_string'][] = 'Cidr must be number';
             $data['status'] = FALSE;
         }
-        if($cidr == '')
-        {
+        if ($cidr == '') {
             $data['inputerror'][] = 'cidr';
             $data['error_string'][] = 'Cidr is required';
             $data['status'] = FALSE;
@@ -226,17 +229,15 @@ private function _validate()
             $data['status'] = FALSE;
         }
         */
- 
-        if($this->input->post('broadcast_address') == '')
-        {
+
+        if ($this->input->post('broadcast_address') == '') {
             $data['inputerror'][] = 'broadcast_address';
             $data['error_string'][] = 'Broadcast Address is required';
             $data['status'] = FALSE;
         }
 
- 
-        if($data['status'] === FALSE)
-        {
+
+        if ($data['status'] === FALSE) {
             echo json_encode($data);
             exit();
         }
@@ -247,81 +248,85 @@ private function _validate()
      * CSV
      *======================================================
     */
-	public function csv()
-	{
-        $data["host_name"]="";    //this is form in header
-		$data['title'] = 'SimpleIPAM Networks';
-
-		$this->load->view('template/header', $data);
-		$this->load->view('networks_csv');
-		$this->load->view('template/footer' );
-	}
-
-	public function export_csv() {
-		$file_name = 'networks_'.date("Y-m-d h-i-s").'.csv';
-		$delimiter = ",";
+    public function csv()
+    {
+        $data["host_name"] = "";    //this is form in header
+        $data['title'] = 'SimpleIPAM Networks';
+
+        $this->load->view('template/header', $data);
+        $this->load->view('networks_csv');
+        $this->load->view('template/footer');
+    }
+
+    public function export_csv()
+    {
+        $file_name = 'networks_' . date("Y-m-d h-i-s") . '.csv';
+        $delimiter = ",";
         $newline = "\r\n";
         $sql_order = " order by CAST(substr(trim(networks),1,instr(trim(networks),'.')-1) AS INTEGER), CAST(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')-1) AS INTEGER), CAST(substr(substr(trim(networks),length(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')-1) AS INTEGER), CAST(substr(trim(networks),length(substr(substr(trim(networks),length(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+ length(substr(trim(networks),1,instr(trim(networks),'.')))+length(substr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)) ,1, instr(substr(trim(networks),length(substr(trim(networks),1,instr(trim(networks),'.')))+1,length(networks)),'.')))+1,length(trim(networks))) AS INTEGER) ";
-		$query = $this->db->query('SELECT networks, cidr, broadcast_address, vlan_id, note1, note2 FROM networks WHERE 1'.$sql_order);
-		$this->load->dbutil();
-		$data = $this->dbutil->csv_from_result($query, $delimiter, $newline);
-		$this->load->helper('download');
-		force_download($file_name, $data);  
-		exit();
-	}
-
-	function import_csv() {
-        $data["host_name"]="";    //this is form in header
+        $query = $this->db->query('SELECT networks, cidr, broadcast_address, vlan_id, note1, note2, note3 FROM networks WHERE 1' . $sql_order);
+        $this->load->dbutil();
+        $data = $this->dbutil->csv_from_result($query, $delimiter, $newline);
+        $this->load->helper('download');
+        force_download($file_name, $data);
+        exit();
+    }
+
+    function import_csv()
+    {
+        $data["host_name"] = "";    //this is form in header
         $data['error'] = '';    //initialize image upload error array to empty
- 
+
         $config['upload_path'] = './uploads/';
         $config['allowed_types'] = 'csv';
         $config['max_size'] = '50000';  //50,000KB = 50MB
- 
+
         $this->load->library('upload', $config);
- 
+
 
         // If upload failed, display error
         if (!$this->upload->do_upload()) {
             $data['error'] = $this->upload->display_errors();
- 
-			$this->load->view('template/header', $data);
-			$this->load->view('networks_csv', $data);
-			$this->load->view('template/footer' );
+
+            $this->load->view('template/header', $data);
+            $this->load->view('networks_csv', $data);
+            $this->load->view('template/footer');
         } else {
             $file_data = $this->upload->data();
-            $file_path =  './uploads/'.$file_data['file_name'];
- 
+            $file_path = './uploads/' . $file_data['file_name'];
+
             if ($this->csvimport->get_array($file_path)) {
                 $csv_array = $this->csvimport->get_array($file_path);
                 foreach ($csv_array as $row) {
                     $insert_data = array(
-                        'networks'=>$row['networks'],
-                        'cidr'=>$row['cidr'],
-						'broadcast_address'=>$row['broadcast_address'],
-						'vlan_id'=>$row['vlan_id'],
-						'note1'=>$row['note1'],
-						'note2'=>$row['note2'],
+                        'networks' => $row['networks'],
+                        'cidr' => $row['cidr'],
+                        'broadcast_address' => $row['broadcast_address'],
+                        'vlan_id' => $row['vlan_id'],
+                        'note1' => $row['note1'],
+                        'note2' => $row['note2'],
+                        'note3' => $row['note3'],
                     );
                     $this->Ipam->networks_insert_csv($insert_data);
                 }
                 $this->session->set_flashdata('success', 'Csv Data Imported Succesfully');
                 //redirect(base_url().'networks/export_csv');
                 //echo "
"; print_r($insert_data);
-            } else 
-				$data['error'] = "Error occured";
-				$this->load->view('template/header', $data);
-				$this->load->view('networks_csv', $data);
-                $this->load->view('template/footer' );
+            } else
+                $data['error'] = "Error occured";
+            $this->load->view('template/header', $data);
+            $this->load->view('networks_csv', $data);
+            $this->load->view('template/footer');
 
         }
         //echo "$file_path";
         unlink($file_path);
- 
-	}
 
- 
-     function importcsv_purge_add() {
+    }
+
+
+    function importcsv_purge_add()
+    {
         $data['error'] = '';    //initialize image upload error array to empty
         $config['upload_path'] = './uploads/';
         $config['allowed_types'] = 'csv';
@@ -336,33 +341,34 @@ function importcsv_purge_add() {
 
             $this->load->view('template/header', $data);
             $this->load->view('networks_csv', $data);
-            $this->load->view('template/footer' );
+            $this->load->view('template/footer');
         } else {
             $file_data = $this->upload->data();
-            $file_path =  './uploads/'.$file_data['file_name'];
+            $file_path = './uploads/' . $file_data['file_name'];
             if ($this->csvimport->get_array($file_path)) {
-                    //import csv
-                    $csv_array = $this->csvimport->get_array($file_path);
-                    foreach ($csv_array as $row) {
-                        $insert_data = array(
-                        'id'=>$row['id'],
-                        'networks'=>$row['networks'],
-                        'cidr'=>$row['cidr'],
-                        'broadcast_address'=>$row['broadcast_address'],
-                        'vlan_id'=>$row['vlan_id'],
-                        'note1'=>$row['note1'],
-                        'note2'=>$row['note2'],
+                //import csv
+                $csv_array = $this->csvimport->get_array($file_path);
+                foreach ($csv_array as $row) {
+                    $insert_data = array(
+                        'id' => $row['id'],
+                        'networks' => $row['networks'],
+                        'cidr' => $row['cidr'],
+                        'broadcast_address' => $row['broadcast_address'],
+                        'vlan_id' => $row['vlan_id'],
+                        'note1' => $row['note1'],
+                        'note2' => $row['note2'],
+                        'note3' => $row['note3'],
                     );
                     $this->Ipam->networks_insert_csv($insert_data);
                 }
                 $this->session->set_flashdata('success', 'Csv Data Imported Succesfully');
                 //redirect(base_url().'networks/export_csv');
                 //echo "
"; print_r($insert_data);
-            } else 
+            } else
                 $data['error'] = "Error occured";
-                $this->load->view('template/header', $data);
-                $this->load->view('networks_csv', $data);
-                $this->load->view('template/footer' );
+            $this->load->view('template/header', $data);
+            $this->load->view('networks_csv', $data);
+            $this->load->view('template/footer');
         }
     }
 
diff --git a/application/controllers/Note.php b/application/controllers/Note.php
index 88c741f..a9881e2 100644
--- a/application/controllers/Note.php
+++ b/application/controllers/Note.php
@@ -1,15 +1,16 @@
 load->helper('url');
+    public function index()
+    {
+        $this->load->helper('url');
 
-		$data['title'] = 'SimpleIPAM IP List';
-		$this->load->view('template/header', $data);
-		$this->load->view('result');
-		$this->load->view('template/footer');
-	}
+        $data['title'] = 'SimpleIPAM IP List';
+        $this->load->view('template/header', $data);
+        $this->load->view('result');
+        $this->load->view('template/footer');
+    }
 }
diff --git a/application/controllers/Pages.php b/application/controllers/Pages.php
index 3ecd566..7b4dbc6 100644
--- a/application/controllers/Pages.php
+++ b/application/controllers/Pages.php
@@ -1,7 +1,9 @@
 load->helper('url');
+        $this->load->helper('form');
+        //$this->load->helper('myip');
+
+        //library
+        //$this->load->library('session');
+        //$this->load->library('csvimport');
+        //$this->load->library('pagination');
+
+        //model
+        //$this->load->model('Ipam');
+    }
+
+    /**
+     *
+     */
+    public function index()
+    {
+        $data["host_name"] = "";     //this is form in header
+
+        $data['title'] = 'SimpleIPAM Private Address Note';
+        $this->load->view('template/header', $data);
+        $this->load->view('private_address_view');
+        $this->load->view('template/footer');
+    }
+
+}
diff --git a/application/controllers/Test.php b/application/controllers/Test.php
deleted file mode 100644
index 197eeaa..0000000
--- a/application/controllers/Test.php
+++ /dev/null
@@ -1,10 +0,0 @@
-load->view('welcome_message');
-	}
-}
diff --git a/application/controllers/Top.php b/application/controllers/Top.php
index 303626b..1534382 100644
--- a/application/controllers/Top.php
+++ b/application/controllers/Top.php
@@ -1,18 +1,22 @@
 load->helper('url');
         $this->load->helper('form');
         //$this->load->helper('myip');
-        
+
         //library
-		//$this->load->library('session');
+        //$this->load->library('session');
         //$this->load->library('csvimport');
         //$this->load->library('pagination');
 
@@ -20,34 +24,19 @@ function __construct() {
         //$this->load->model('Ipam');
     }
 
+    /**
+     *
+     */
+    public function index()
+    {
+        $data["host_name"] = "";     //this is form in header
+
+        $data['title'] = 'SimpleIPAM Top';
+        $this->load->view('template/header', $data);
+        $this->load->view('top_view');
+        $this->load->view('template/footer');
+
+
+    }
 
-	public function index()
-	{
-		$data["host_name"]="";     //this is form in header
-
-		$data['title'] = 'SimpleIPAM Top';
-		$this->load->view('template/header', $data);
-		$this->load->view('top_view');
-		$this->load->view('template/footer');
-
-
-	}
-
-	
-/*
-	public function result()
-	{
-		$data['title'] = 'SimpleIPAM Top';
-		$this->load->view('template/header', $data);
-		$this->load->view('result');
-		$this->load->view('template/footer');
-	}
-	public function note()
-	{
-		$data['title'] = 'SimpleIPAM Top';
-		$this->load->view('template/header', $data);
-		$this->load->view('note');
-		$this->load->view('template/footer');
-	}
-*/
 }
diff --git a/application/controllers/View.php b/application/controllers/View.php
index f645e0a..37a9403 100644
--- a/application/controllers/View.php
+++ b/application/controllers/View.php
@@ -1,12 +1,17 @@
 load->view('view', $data);
     }
 }
-?>
+
diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php
deleted file mode 100644
index 9213c0c..0000000
--- a/application/controllers/Welcome.php
+++ /dev/null
@@ -1,25 +0,0 @@
-
-	 * @see https://codeigniter.com/user_guide/general/urls.html
-	 */
-	public function index()
-	{
-		$this->load->view('welcome_message');
-	}
-}
diff --git a/application/controllers/cidr.php b/application/controllers/cidr.php
deleted file mode 100644
index 723b489..0000000
--- a/application/controllers/cidr.php
+++ /dev/null
@@ -1,36 +0,0 @@
-load->helper('url');
-        $this->load->helper('form');
-        //$this->load->helper('myip');
-        
-        //library
-		//$this->load->library('session');
-        //$this->load->library('csvimport');
-        //$this->load->library('pagination');
-
-        //model
-        //$this->load->model('Ipam');
-    }
-
-
-	public function index()
-	{
-		$data["host_name"]="";     //this is form in header
-
-		$data['title'] = 'SimpleIPAM Private Address';
-		$this->load->view('template/header', $data);
-		$this->load->view('cidr_view');
-		$this->load->view('template/footer');
-
-
-	}
-
-}
diff --git a/application/controllers/private_address.php b/application/controllers/private_address.php
deleted file mode 100644
index 55e0204..0000000
--- a/application/controllers/private_address.php
+++ /dev/null
@@ -1,36 +0,0 @@
-load->helper('url');
-        $this->load->helper('form');
-        //$this->load->helper('myip');
-        
-        //library
-		//$this->load->library('session');
-        //$this->load->library('csvimport');
-        //$this->load->library('pagination');
-
-        //model
-        //$this->load->model('Ipam');
-    }
-
-
-	public function index()
-	{
-		$data["host_name"]="";     //this is form in header
-
-		$data['title'] = 'SimpleIPAM Private Address';
-		$this->load->view('template/header', $data);
-		$this->load->view('private_address_view');
-		$this->load->view('template/footer');
-
-
-	}
-
-}
diff --git a/application/helpers/myip_helper.php b/application/helpers/myip_helper.php
index a7da6ed..3f7df89 100644
--- a/application/helpers/myip_helper.php
+++ b/application/helpers/myip_helper.php
@@ -13,7 +13,7 @@
  */
 
    /**
-     * get only host address from IP adress
+     * get only host address from IP address
      *
      * @access  private
      * @return  void
diff --git a/application/models/Ipam.php b/application/models/Ipam.php
index de10827..2e48410 100644
--- a/application/models/Ipam.php
+++ b/application/models/Ipam.php
@@ -1,26 +1,27 @@
 load->database();
-        } 
+    public function __construct()
+    {
+        parent::__construct();
+        $this->load->database();
+    }
 
 
     /*======================================================
-     *Networks
+     * Networks
      *======================================================
      */
 
-    function get_all_networks() {
+    function get_all_networks()
+    {
         $this->db->order_by("networks", 'ASC');
         $query = $this->db->get("networks");
         return $query->result_array();
- 
+
         //if($query->num_rows() > 0) {
         //    return $query->result_array();
         //}
@@ -33,7 +34,7 @@ function get_networks($limit, $start, $st = NULL)
         //$sql = "select * from networks where networks like '%$st%' limit " . $start . ", " . $limit;
         $sql1 = " select * from networks where networks like '%$st%' ";
         $sql2 = " or cidr like '%$st%' or broadcast_address like '%$st%' or vlan_id like '%$st%' ";
-        $sql3 = " or note1 like '%$st%' or note2 like '%$st%' ";
+        $sql3 = " or note1 like '%$st%' or note2 like '%$st%' or note3 like '%$st%' ";
         //https://stackoverflow.com/questions/23092783/best-way-to-sort-by-ip-addresses-in-sql
         //$sql_order = " order by networks ";
         //$sql_order = " order by CAST(substr(networks,1,instr(networks,'.')) AS NUMERIC) ";
@@ -41,29 +42,30 @@ function get_networks($limit, $start, $st = NULL)
         $sql_limit = " limit " . $start . ", " . $limit;
         $sql = "$sql1 $sql2 $sql3 $sql_order $sql_limit";
         $query = $this->db->query($sql);
-        //return $query->result();
         return $query->result_array();
     }
-    
+
     function get_networks_count($st = NULL)
     {
         if ($st == "NIL") $st = "";
         //$sql = "select * from networks where networks like '%$st%'";
         $sql1 = "select * from networks where networks like '%$st%' ";
         $sql2 = "or cidr like '%$st%' or broadcast_address like '%$st%' or vlan_id like '%$st%' ";
-        $sql3 = "or note1 like '%$st%' or note2 like '%$st%' ";
+        $sql3 = "or note1 like '%$st%' or note2 like '%$st%' or note3 like '%$st%' ";
         $sql = "$sql1 $sql2 $sql3";
         $query = $this->db->query($sql);
         return $query->num_rows();
     }
 
 
-    function networks_search($str) {
+    function networks_search($str)
+    {
         $str = urldecode($str); // for japanese
         $this->db->like('networks', "$str");
-        $this->db->or_like('note1', $str); 
-        $this->db->or_like('note2', $str); 
-        $this->db->order_by("networks", "ASC"); 
+        $this->db->or_like('note1', $str);
+        $this->db->or_like('note2', $str);
+        $this->db->or_like('note3', $str);
+        $this->db->order_by("networks", "ASC");
         $query = $this->db->get('networks');
 
         if ($query->num_rows() <= 0) {
@@ -74,43 +76,43 @@ function networks_search($str) {
     }
 
 
-	public function networks_get_by_id($id)
-	{
-        //$this->db->from($this->table);
+    public function networks_get_by_id($id)
+    {
         $this->db->from("networks");
-		$this->db->where('id',$id);
-		$query = $this->db->get();
- 
-		return $query->row();
-	}
- 
-	public function networks_add($data)
-	{
-		$this->db->insert($this->table, $data);
-		return $this->db->insert_id();
-	}
- 
-	public function networks_update($where, $data)
-	{
-		//$this->db->update($this->table, $data, $where);
-		$this->db->update("networks", $data, $where);
-		return $this->db->affected_rows();
-	}
- 
-	public function networks_delete_by_id($id)
-	{
-		$this->db->where('id', $id);
-		$this->db->delete($this->table);
-	}
-
-    public function networks_insert_csv($data) {
+        $this->db->where('id', $id);
+        $query = $this->db->get();
+
+        return $query->row();
+    }
+
+    public function networks_add($data)
+    {
+        $this->db->insert("networks", $data);
+        return $this->db->insert_id();
+    }
+
+    public function networks_update($where, $data)
+    {
+        $this->db->update("networks", $data, $where);
+        return $this->db->affected_rows();
+    }
+
+    public function networks_delete_by_id($id)
+    {
+        $this->db->where('id', $id);
+        $this->db->delete("networks");
+    }
+
+    public function networks_insert_csv($data)
+    {
         $this->db->insert('networks', $data);
     }
 
-    function truncate_networks() {
+    function truncate_networks()
+    {
         $sql = 'delete from networks where id > 0 ';
         $this->db->query($sql);
- 
+
         $sql = 'VACUUM;';
         $this->db->query($sql);
 
@@ -121,10 +123,11 @@ function truncate_networks() {
      * Hosts
      *======================================================
     */
-    function get_all_hosts() {
+    function get_all_hosts()
+    {
         $query = $this->db->get("hosts");
         return $query->result_array();
- 
+
         //if($query->num_rows() > 0) {
         //    return $query->result_array();
         //}
@@ -136,7 +139,7 @@ function get_hosts($limit, $start, $st = NULL)
         if ($st == "NIL") $st = "";
         //$sql = "select * from hosts where ip_addr like '%$st%' limit " . $start . ", " . $limit;
         $sql1 = " select * from hosts where ip_address like '%$st%' ";
-        $sql2 = " or host like '%$st%' or note like '%$st%' ";
+        $sql2 = " or host like '%$st%' or note like '%$st%' or public_ip like '%$st%' or state like '%$st%' or spec like '%$st%' ";
         // https://stackoverflow.com/questions/23092783/best-way-to-sort-by-ip-addresses-in-sql
         //$sql_order = " order by ip_address ";
         //$sql_order = " order by CAST(substr(ip_address,1,instr(ip_address,'.')) AS NUMERIC) ";
@@ -144,28 +147,31 @@ function get_hosts($limit, $start, $st = NULL)
         $sql_limit = " limit " . $start . ", " . $limit;
         $sql = "$sql1 $sql2 $sql_order $sql_limit";
         $query = $this->db->query($sql);
-        //return $query->result();
         return $query->result_array();
     }
-    
+
     function get_hosts_count($st = NULL)
     {
         if ($st == "NIL") $st = "";
         //$sql = "select * from hosts where hosts like '%$st%'";
         $sql1 = "select * from hosts where ip_address like '%$st%' ";
-        $sql2 = " or host like '%$st%' or note like '%$st%' ";
+        $sql2 = " or host like '%$st%' or note like '%$st%' or public_ip like '%$st%' or state like '%$st%' or spec like '%$st%' ";
         $sql = "$sql1 $sql2";
         $query = $this->db->query($sql);
         return $query->num_rows();
     }
 
 
-    function hosts_search($str) {
+    function hosts_search($str)
+    {
         $str = urldecode($str); // for japanese
         $this->db->like('ip_address', "$str");
-        $this->db->or_like('host', $str); 
-        $this->db->or_like('note', $str); 
-        $this->db->order_by("hosts", "ASC"); 
+        $this->db->or_like('host', $str);
+        $this->db->or_like('note', $str);
+        $this->db->or_like('public_ip', $str);
+        $this->db->or_like('state', $str);
+        $this->db->or_like('spec', $str);
+        $this->db->order_by("hosts", "ASC");
         $query = $this->db->get('hosts');
 
         if ($query->num_rows() <= 0) {
@@ -176,38 +182,35 @@ function hosts_search($str) {
     }
 
 
-	public function hosts_get_by_id($id)
-	{
-        //$this->db->from($this->table);
+    public function hosts_get_by_id($id)
+    {
         $this->db->from("hosts");
-		$this->db->where('id',$id);
-		$query = $this->db->get();
- 
-		return $query->row();
-	}
-
-	public function hosts_add($data)
-	{
-        //$this->db->insert($this->table, $data);
+        $this->db->where('id', $id);
+        $query = $this->db->get();
+
+        return $query->row();
+    }
+
+    public function hosts_add($data)
+    {
         $this->db->insert("hosts", $data);
-		return $this->db->insert_id();
-	}
- 
-	public function hosts_update($where, $data)
-	{
-		//$this->db->update($this->table, $data, $where);
-		$this->db->update("hosts", $data, $where);
-		return $this->db->affected_rows();
-	}
-
-	public function hosts_delete_by_id($id)
-	{
-		$this->db->where('id', $id);
-        //$this->db->delete($this->table);
+        return $this->db->insert_id();
+    }
+
+    public function hosts_update($where, $data)
+    {
+        $this->db->update("hosts", $data, $where);
+        return $this->db->affected_rows();
+    }
+
+    public function hosts_delete_by_id($id)
+    {
+        $this->db->where('id', $id);
         $this->db->delete("hosts");
-	}
+    }
 
-    public function hosts_insert_csv($data) {
+    public function hosts_insert_csv($data)
+    {
         $this->db->insert('hosts', $data);
     }
 
@@ -218,38 +221,34 @@ public function hosts_insert_csv($data) {
     */
     private function _get_datatables_query()
     {
-         
+
         $this->db->from($this->table);
- 
+
         $i = 0;
-     
+
         foreach ($this->column_search as $item) // loop column 
         {
-            if($_POST['search']['value']) // if datatable send POST for search
+            if ($_POST['search']['value']) // if datatable send POST for search
             {
-                 
-                if($i===0) // first loop
+
+                if ($i === 0) // first loop
                 {
                     $this->db->group_start(); // open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
                     $this->db->like($item, $_POST['search']['value']);
-                }
-                else
-                {
+                } else {
                     $this->db->or_like($item, $_POST['search']['value']);
                 }
- 
-                if(count($this->column_search) - 1 == $i) //last loop
+
+                if (count($this->column_search) - 1 == $i) //last loop
                     $this->db->group_end(); //close bracket
             }
             $i++;
         }
-         
-        if(isset($_POST['order'])) // here order processing
+
+        if (isset($_POST['order'])) // here order processing
         {
             $this->db->order_by($this->column_order[$_POST['order']['0']['column']], $_POST['order']['0']['dir']);
-        } 
-        else if(isset($this->order))
-        {
+        } else if (isset($this->order)) {
             $order = $this->order;
             $this->db->order_by(key($order), $order[key($order)]);
         }
@@ -259,12 +258,11 @@ private function _get_datatables_query()
     function get_datatables()
     {
         $this->_get_datatables_query();
-        if($_POST['length'] != -1)
-        $this->db->limit($_POST['length'], $_POST['start']);
+        if ($_POST['length'] != -1)
+            $this->db->limit($_POST['length'], $_POST['start']);
         $query = $this->db->get("hosts");
         return $query->result();
     }
 
 
-
 }
diff --git a/application/views/cidr_view.php b/application/views/cidr_view.php
index 0101cac..77ac8b7 100644
--- a/application/views/cidr_view.php
+++ b/application/views/cidr_view.php
@@ -1,311 +1,647 @@
 
-

Note : CIDR

+

Note : CIDR

-
-

This page is a quote from https://cmdref.net/network/ip.html

+
+

This page is a quote from https://cmdref.net/network/ip.html +

-
-
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CIDRMaskHoststhe number of available host
/32255.255.255.2551-
/31 255.255.255.254 2 0
/30 255.255.255.252 4 2
/29 255.255.255.248 8 6
/28 255.255.255.240 16 14
/27 255.255.255.224 32 30
/26 255.255.255.192 64 62
/25 255.255.255.128 128 126
/24 255.255.255.0 256 254
/23 255.255.254.0 512 510
/22 255.255.252.0 1,024 1,022
/21 255.255.248.0 2,048 2,046
/20 255.255.240.0 4,096 4,094
/19 255.255.224.0 8,192 8,190
/16 255.255.0.0 131,072 131,070
/8 255.0.0.0 16,777,216 16,777,214
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CIDRMaskHoststhe number of available host
/32255.255.255.2551-
/31255.255.255.25420
/30255.255.255.25242
/29255.255.255.24886
/28255.255.255.2401614
/27255.255.255.2243230
/26255.255.255.1926462
/25255.255.255.128128126
/24255.255.255.0256254
/23255.255.254.0512510
/22255.255.252.01,0241,022
/21255.255.248.02,0482,046
/20255.255.240.04,0964,094
/19255.255.224.08,1928,190
/16255.255.0.0131,072131,070
/8255.0.0.016,777,21616,777,214
-
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/23 /24 /25 /26 /27 /28 /29 /30
255.255.254.0 255.255.255.0 255.255.255.128 255.255.255.192 255.255.255.224 255.255.255.240 255.255.255.248 255.255.255.252
510 254 126 62 30 14 6 2
10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0
10.1.0.32
10.1.0.64 10.1.0.64
10.1.0.96
10.1.0.128 10.1.0.128 10.1.0.128
10.1.0.160
10.1.0.192 10.1.0.192
10.1.0.224
10.1.1.0 10.1.1.0 10.1.1.0 10.1.1.0
10.1.1.32
10.1.1.64 10.1.1.64
10.1.1.96
10.1.1.128 10.1.1.128 10.1.1.128
10.1.1.160
10.1.1.192 10.1.1.192
10.1.1.224
10.1.2.0 10.1.2.0
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
/23 /24 /25 /26 /27 /28 /29 /30
255.255.254.0 255.255.255.0 255.255.255.128 255.255.255.192 255.255.255.224 255.255.255.240 255.255.255.248 255.255.255.252
510 254 126 62 30 14 6 2
10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0
10.1.0.32
10.1.0.64 10.1.0.64
10.1.0.96
10.1.0.128 10.1.0.128 10.1.0.128
10.1.0.160
10.1.0.192 10.1.0.192
10.1.0.224
10.1.1.0 10.1.1.0 10.1.1.0 10.1.1.0
10.1.1.32
10.1.1.64 10.1.1.64
10.1.1.96
10.1.1.128 10.1.1.128 10.1.1.128
10.1.1.160
10.1.1.192 10.1.1.192
10.1.1.224
10.1.2.0 10.1.2.0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/30 /29 /28 /27
192.168.0.X 2 6 14 30
0 the network itself the network itself the network itself the network itself
1 host1 host1 host1 host1
2 host2 host2 host2 host2
3 broadcast address host3 host3 host3
4 the network itself host4 host4 host4
5 host1 host5 host5 host5
6 host2 host6 host6 host6
7 broadcast address the network itself host7 host7
8 the network itself the network itself host8 host8
9 host1 host1 host9 host9
10 host2 host2 host10 host10
11 broadcast address host3 host11 host11
12 the network itself host4 host12 host12
13 host1 host5 host13 host13
14 host2 host6 host14 host14
15 broadcast address broadcast address broadcast address host15
16 the network itself the network itself the network itself host16
17 host1 host1 host1 host17
18 host2 host2 host2 host18
19 broadcast address host3 host3 host19
20 the network itself host4 host4 host20
21 host1 host5 host5 host21
22 host2 host6 host6 host22
23 broadcast address broadcast address host7 host23
24 the network itself the network itself host8 host24
25 host1 host1 host9 host25
26 host2 host2 host10 host26
27 broadcast address host3 host11 host27
28 the network itself host4 host12 host28
29 host1 host5 host13 host29
30 host2 host6 host14 host30
31 broadcast address broadcast address broadcast address broadcast address
abbr abbr abbr abbr abbr
240 the network itself the network itself the network itself
241 host1 host1 host1
242 host2 host2 host2
243 broadcast address host3 host3
244 the network itself host4 host4
245 host1 host5 host5
246 host2 host6 host6
247 broadcast address broadcast address host7
248 the network itself the network itself host8
249 host1 host1 host9
250 host2 host2 host10
251 broadcast address host3 host11
252 the network itself host4 host12
253 host1 host5 host13
254 host2 host6 host14
255 broadcast address broadcast address broadcast address
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
/30 /29 /28 /27
192.168.0.X 2 6 14 30
0 the network itself the network itself the network itself the network itself
1 host1 host1 host1 host1
2 host2 host2 host2 host2
3 broadcast address host3 host3 host3
4 the network itself host4 host4 host4
5 host1 host5 host5 host5
6 host2 host6 host6 host6
7 broadcast address the network itself host7 host7
8 the network itself the network itself host8 host8
9 host1 host1 host9 host9
10 host2 host2 host10 host10
11 broadcast address host3 host11 host11
12 the network itself host4 host12 host12
13 host1 host5 host13 host13
14 host2 host6 host14 host14
15 broadcast address broadcast address broadcast address host15
16 the network itself the network itself the network itself host16
17 host1 host1 host1 host17
18 host2 host2 host2 host18
19 broadcast address host3 host3 host19
20 the network itself host4 host4 host20
21 host1 host5 host5 host21
22 host2 host6 host6 host22
23 broadcast address broadcast address host7 host23
24 the network itself the network itself host8 host24
25 host1 host1 host9 host25
26 host2 host2 host10 host26
27 broadcast address host3 host11 host27
28 the network itself host4 host12 host28
29 host1 host5 host13 host29
30 host2 host6 host14 host30
31 broadcast address broadcast address broadcast address broadcast address
abbr abbr abbr abbr abbr
240 the network itself the network itself the network itself
241 host1 host1 host1
242 host2 host2 host2
243 broadcast address host3 host3
244 the network itself host4 host4
245 host1 host5 host5
246 host2 host6 host6
247 broadcast address broadcast address host7
248 the network itself the network itself host8
249 host1 host1 host9
250 host2 host2 host10
251 broadcast address host3 host11
252 the network itself host4 host12
253 host1 host5 host13
254 host2 host6 host14
255 broadcast address broadcast address broadcast address
- - - - + + + + diff --git a/application/views/home.php b/application/views/home.php deleted file mode 100644 index c384c73..0000000 --- a/application/views/home.php +++ /dev/null @@ -1,14 +0,0 @@ -public function view($page = 'home') -{ - if ( ! file_exists(APPPATH.'views/pages/'.$page.'.php')) - { - // Whoops, we don't have a page for that! - show_404(); - } - - $data['title'] = ucfirst($page); // Capitalize the first letter - - $this->load->view('templates/header', $data); - $this->load->view('pages/'.$page, $data); - $this->load->view('templates/footer', $data); -} diff --git a/application/views/hosts_csv.php b/application/views/hosts_csv.php index 50bb7ad..fac6f71 100644 --- a/application/views/hosts_csv.php +++ b/application/views/hosts_csv.php @@ -1,150 +1,124 @@
-

Hosts CSV Import & Export

- - -
-
-
-
- -
-
- - -
-
-
-
-
-
-

Import from CSV

Add CSV to the last line

-
-
- -
+

Hosts + CSV Import & Export +

+ + +
+
+
+
+ +
+
+ + +
+
+
+
+
+
+

Import from CSV

+

Add CSV to the last line

+
+
+ +
session->flashdata('success') == TRUE): ?> -
session->flashdata('success'); ?>
- - -
-

- -
-
-
- -
-
-
-
-

CSV Example

-
-"ip_address","subnet_mask","host","note"
-"10.0.0.1","255.255.255.0","test-l3","Global IP xx.xx.xx.xx"
-"10.0.0.3","255.255.255.0","test-host2","bbbb"
-"10.0.0.4","255.255.255.0","test-host3","bbbb"
-"10.0.0.5","255.255.255.0","test-host4","bbbb"
-"10.0.0.6","255.255.255.0","test-host5","bbbb"
-
-
    -
  • networks column must be not null and unique.
  • -
  • CSV Import isn't work validation.
  • -
-
-
- - - - -
-
-
-
- -
-
-
-
-

Export to CSV

-
-
-
"> - -
-
-
- -
-
-
-
-

CSV Example

-
-"ip_address","subnet_mask","host","note"
-"10.0.0.1","255.255.255.0","test-l3","Global IP xx.xx.xx.xx"
-"10.0.0.3","255.255.255.0","test-host2","bbbb"
-"10.0.0.4","255.255.255.0","test-host3","bbbb"
-"10.0.0.5","255.255.255.0","test-host4","bbbb"
-"10.0.0.6","255.255.255.0","test-host5","bbbb"
-"10.0.0.7","255.255.255.0","test-host6","bbbb"
-
-
-
- - - - -
-
-
-
-
-
-
-
-

Purge Table

-
-
- -
-
-
-
-

I'm not preparing to purge table from the Web.
- If you want to purge table, you use SQLite database manager or execute the following command in Linux

-
+            
+

+ +
+
+
+ +
+
+
+
+

CSV Example

+
+"ip_address","subnet_mask","host","note","public_ip","state","spec"
+"10.0.0.1","255.255.255.0","test-l3","L3SW","xx.xx.xx.xx","Running","1Gbps"
+"10.0.0.3","255.255.255.0","test-host2","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.4","255.255.255.0","test-host3","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.5","255.255.255.0","test-host4","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.6","255.255.255.0","test-host5","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+            
+
    +
  • hosts column must be not null and unique.
  • +
  • CSV Import isn't work validation.
  • +
+
+
+ +
+
+
+
+ +
+
+
+
+

Export to CSV

+
+
+
"> + +
+
+
+ +
+
+
+
+

CSV Example

+
+"ip_address","subnet_mask","host","note","public_ip","state","spec"
+"10.0.0.1","255.255.255.0","test-l3","L3SW","xx.xx.xx.xx","Running","1Gbps"
+"10.0.0.3","255.255.255.0","test-host2","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.4","255.255.255.0","test-host3","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.5","255.255.255.0","test-host4","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+"10.0.0.6","255.255.255.0","test-host5","bbbb","xx.xx.xx.xx","Running","CPU:2Core, Memory:2G, Disk:10G"
+            
+
+
+ + +
+
+
+
+
+
+
+
+

Purge Table

+
+
+ +
+
+
+
+

I'm not preparing to purge table from the Web.
+ If you want to purge table, you use SQLite database manager or execute the following command in Linux +

+
 SQLite> DELETE FROM COMPANY;
 SQLite> VACUUM;
-
+
+ - diff --git a/application/views/hosts_view.php b/application/views/hosts_view.php index 475e900..c765c5a 100644 --- a/application/views/hosts_view.php +++ b/application/views/hosts_view.php @@ -1,302 +1,317 @@
-

Hosts

- -
- -
-
- "form-horizontal", "role" => "form", "id" => "form1", "name" => "form1"); - echo form_open("hosts/search", $attr);?> - - -
-
- - -
+

Hosts

+ +
+ +
+
+ "form-horizontal", "role" => "form", "id" => "form1", "name" => "form1"); + echo form_open("hosts/search", $attr); ?> + + +
+
+ + +
-
+
- - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IP AddressSubnet maskHostNoteOperation
- - -
IP AddressSubnet maskHostNoteOperation
IP AddressSubnet maskHost[Name]Note[Purpose]Public IPStateSpecOperation
+ + +
IP AddressSubnet maskHost[Name]Note[Purpose]Public IPStateSpecOperation

-
-
- - -
-
- -
-
+
+
+ + +
+
+ +
+
- - - - - - + + + + + + - + location.reload(); + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('Error deleting data'); + } + }); + } + } + - -