From b3a700e8ef54d10c150f4f688d6c411aeea44ac0 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 5 Oct 2017 08:50:17 +1000 Subject: [PATCH 01/31] Fixed spelling of hostname. --- code_igniter/application/models/m_device.php | 2 +- .../application/views/theme-bootstrap/v_devices_read.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code_igniter/application/models/m_device.php b/code_igniter/application/models/m_device.php index 699845059..06055f694 100644 --- a/code_igniter/application/models/m_device.php +++ b/code_igniter/application/models/m_device.php @@ -88,7 +88,7 @@ public function match($details, $command = '') } else { # we have an ip address in the hostname field - remove it # likely because DNS is not fully setup and working correctly - $log_message[] = "Provided hostame is actually an IP address (" . $details->hostname . ")."; + $log_message[] = "Provided hostname is actually an IP address (" . $details->hostname . ")."; if (empty($details->ip)) { $details->ip = $details->hostname; $log_message[] = "No IP provided, but provided hostname is an IP. Storing in ip (" . $details->ip . ")."; diff --git a/code_igniter/application/views/theme-bootstrap/v_devices_read.php b/code_igniter/application/views/theme-bootstrap/v_devices_read.php index 6c32ccb7d..17872da29 100644 --- a/code_igniter/application/views/theme-bootstrap/v_devices_read.php +++ b/code_igniter/application/views/theme-bootstrap/v_devices_read.php @@ -320,7 +320,7 @@
- +
@@ -344,7 +344,7 @@
- +
From 79857dd6bd4800ec97a2e35ddd1d2469d771b609 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Mon, 9 Oct 2017 13:50:35 +1000 Subject: [PATCH 02/31] Fix delete credentials button for FireFox on device details template. --- .../application/views/theme-bootstrap/v_devices_read.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code_igniter/application/views/theme-bootstrap/v_devices_read.php b/code_igniter/application/views/theme-bootstrap/v_devices_read.php index 17872da29..8fe0c28b2 100644 --- a/code_igniter/application/views/theme-bootstrap/v_devices_read.php +++ b/code_igniter/application/views/theme-bootstrap/v_devices_read.php @@ -994,7 +994,7 @@ name, REPLACE_FLAGS, CHARSET); ?> description, REPLACE_FLAGS, CHARSET); ?> m_users->get_user_permission('', 'credentials', 'd')) { ?> - + From 02f3bf3bb36de968a6e33b09b1fa926c9f0545c6 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Mon, 9 Oct 2017 13:51:38 +1000 Subject: [PATCH 03/31] Provide a Netmask on the manual create device page and insert a Networks if required upon Submit. --- .../application/controllers/devices.php | 22 +++++++++++++++++++ .../theme-bootstrap/v_devices_create_form.php | 8 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/code_igniter/application/controllers/devices.php b/code_igniter/application/controllers/devices.php index 30c77f3f1..aff535b2e 100644 --- a/code_igniter/application/controllers/devices.php +++ b/code_igniter/application/controllers/devices.php @@ -191,6 +191,28 @@ private function create() $device->last_seen = $this->config->config['timestamp']; $this->load->model('m_devices'); $id = $this->m_devices->create($device); + $device->id = $id; + if (!empty($device->ip) and !empty($device->netmask)) { + $this->load->helper('network'); + $network = network_details($device->ip . ' ' . $device->netmask); + if (empty($network->error)) { + $this->load->model('m_devices_components'); + $device_ip = new stdClass(); + $device_ip->mac = ''; + $device_ip->net_index = ''; + $device_ip->ip = $network->address; + $device_ip->netmask = $network->netmask; + $device_ip->cidr = $network->network_slash; + $device_ip->version = 4; + $device_ip->network = $network->network . '/' . $network->network_slash; + $device_ip->set_by = ''; + $input = new stdClass(); + $input->item = array(); + $input->item[] = $device_ip; + $error = $this->m_devices_components->process_component('ip', $device, $input); + } + } + if ($this->response->meta->format == 'screen') { redirect('devices/' . $id); } else { diff --git a/code_igniter/application/views/theme-bootstrap/v_devices_create_form.php b/code_igniter/application/views/theme-bootstrap/v_devices_create_form.php index 48513ca23..83ba4b32c 100644 --- a/code_igniter/application/views/theme-bootstrap/v_devices_create_form.php +++ b/code_igniter/application/views/theme-bootstrap/v_devices_create_form.php @@ -102,7 +102,13 @@
- + +
+ +
+
+
+
+
From e37cb8f84045601214e0cd827fb21370f5277971 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 15:20:57 +1000 Subject: [PATCH 21/31] Fix issue with not setting user->type when using LDAP for login. --- code_igniter/application/controllers/logon.php | 2 +- code_igniter/application/models/m_logon.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/code_igniter/application/controllers/logon.php b/code_igniter/application/controllers/logon.php index dd7cff126..97935860d 100644 --- a/code_igniter/application/controllers/logon.php +++ b/code_igniter/application/controllers/logon.php @@ -204,7 +204,7 @@ public function login() exit(); } - if ($this->user->type == 'collector') { + if (!empty($this->user->type) and $this->user->type == 'collector') { // if (@$this->input->post('uuid') == '') { // log_error('ERR-0030', current_url()); // header($this->response->meta->header); diff --git a/code_igniter/application/models/m_logon.php b/code_igniter/application/models/m_logon.php index c4e7a68b7..263f4e5a1 100644 --- a/code_igniter/application/models/m_logon.php +++ b/code_igniter/application/models/m_logon.php @@ -242,7 +242,8 @@ public function logon($id = '') $user->lang = (string)$ldap->lang; $user->active = 'y'; $user->ldap = ''; - //$user->primarygroupid = @$entries[0]['primarygroupid'][0]; + $user->type = 'user'; + $user->edited_by = 'system'; if ($ldap->type == 'active directory') { $user->ldap = @(string)$entries[0]['distinguishedname'][0]; } From ffb39a3b1b3aa1ecf2751062c8257f62ab97e1de Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:04:53 +1000 Subject: [PATCH 22/31] Fix netstat audit processing. --- .../controllers/db_upgrades/db_2.0.10.php | 16 +++ .../controllers/include_input_devices.php | 6 +- .../models/m_devices_components.php | 97 ++++++++++--------- 3 files changed, 69 insertions(+), 50 deletions(-) diff --git a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php index 4a46d44dd..8fb0df5e9 100644 --- a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php +++ b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php @@ -37,6 +37,22 @@ $this->db->query($sql); $this->log_db($this->db->last_query()); +$sql = "DELETE FROM `configuration` WHERE name = 'delete_noncurrent_netstat'"; +$this->db->query($sql); +$this->log_db($this->db->last_query()); + +$sql = "INSERT INTO `configuration` VALUES (NULL,'delete_noncurrent_netstat','y','bool','y','system','2000-01-01 00:00:00','Should we store non-current netstat data and generate change logs.')"; +$this->db->query($sql); +$this->log_db($this->db->last_query()); + +$sql = "DELETE FROM `configuration` WHERE name = 'delete_noncurrent_variable'"; +$this->db->query($sql); +$this->log_db($this->db->last_query()); + +$sql = "INSERT INTO `configuration` VALUES (NULL,'delete_noncurrent_variable','y','bool','y','system','2000-01-01 00:00:00','Should we store non-current environment variable data and generate change logs.')"; +$this->db->query($sql); +$this->log_db($this->db->last_query()); + # set our versions $sql = "UPDATE `configuration` SET `value` = '20171010' WHERE `name` = 'internal_version'"; $this->db->query($sql); diff --git a/code_igniter/application/controllers/include_input_devices.php b/code_igniter/application/controllers/include_input_devices.php index ded83ba57..2c9b9d417 100644 --- a/code_igniter/application/controllers/include_input_devices.php +++ b/code_igniter/application/controllers/include_input_devices.php @@ -187,7 +187,6 @@ } $details = $json->system; -$ids[] = discovery_log($log); $json->system->mac_addresses = array(); if (!empty($json->network->item) and count($json->network->item) > 0) { foreach ($json->network->item as $card) { @@ -324,9 +323,6 @@ $sql = "/* include_input_device */" . " DELETE FROM `discovery_log` WHERE `system_id` = ? AND `command` = 'process audit' AND pid != ?"; $data = array(intval($details->id), intval(getmypid())); $query = $this->db->query($sql, $data); - // if ($this->response->meta->format == 'screen') { - // echo $this->db->last_query(); - // } } else { # we were supplied an audit result, but no discovery_id # delete all dicovery logs where system_id = our ID and log.pid != our pid @@ -341,7 +337,7 @@ foreach ($json as $key => $value) { if ($key != 'system' and $key != 'audit_wmi_fail' and $key != 'dns') { - if (!empty($json->{$key}->item)) { + if (!empty($json->{$key}->item) or $key == 'netstat') { $this->m_devices_components->process_component($key, $details, $json->{$key}); } } diff --git a/code_igniter/application/models/m_devices_components.php b/code_igniter/application/models/m_devices_components.php index e775d9714..3d1e55a30 100644 --- a/code_igniter/application/models/m_devices_components.php +++ b/code_igniter/application/models/m_devices_components.php @@ -299,9 +299,7 @@ public function match_columns($table) public function process_component($table = '', $details, $input, $display = 'n', $match_columns = array()) { - $create_alerts = $this->config->config['discovery_create_alerts']; - $delete_noncurrent = $this->config->config['delete_noncurrent']; $log = new stdClass(); $log->discovery_id = (string)@$details->discovery_id; @@ -360,7 +358,6 @@ public function process_component($table = '', $details, $input, $display = 'n', $log->message = 'No columns to match supplied for '.@ip_address_from_db($details->ip).' ('.$name.')'; $message = "$table - No columns to match supplied - failed"; } - # if (!isset($details->id)) { # this will be changed when we convert the system table if (!isset($details->id)) { $log->message = 'No id supplied for '.@ip_address_from_db($details->ip).' ('.$name.')'; $message = "$table - No id supplied - failed"; @@ -378,13 +375,18 @@ public function process_component($table = '', $details, $input, $display = 'n', // discovery_log($log); } + ### NETSTAT ### + # Need to do this first as until we convert the data + # there won't be an input->item + if ((string)$table == 'netstat') { + $input = $this->format_netstat_data($input, $details); + } + // make sure we have an entry for each match column, even if it's empty - if ($table != 'netstat') { - foreach ($match_columns as $match_column) { - for ($i=0; $iitem); $i++) { - if (isset($input->item[$i]) and !isset($input->item[$i]->$match_column)) { - $input->item[$i]->$match_column = ''; - } + foreach ($match_columns as $match_column) { + for ($i=0; $iitem); $i++) { + if (isset($input->item[$i]) and !isset($input->item[$i]->$match_column)) { + $input->item[$i]->$match_column = ''; } } } @@ -472,11 +474,6 @@ public function process_component($table = '', $details, $input, $display = 'n', } } - ### NETSTAT ### - if ((string)$table == 'netstat') { - $input = $this->format_netstat_data($input, $details); - } - ### NETWORK ### # depending on the device type we need to alter our matching columns for the network card if ((string)$table == 'network') { @@ -779,43 +776,57 @@ public function process_component($table = '', $details, $input, $display = 'n', $log->severity = 7; discovery_log($log); } - foreach ($db_result as $db_item) { - if (strtolower($delete_noncurrent) == 'y') { + + if (!empty($this->config->config['delete_noncurrent']) and strtolower($this->config->config['delete_noncurrent']) == 'y') { + foreach ($db_result as $db_item) { $sql = "DELETE FROM `$table` WHERE `id` = ?"; $sql = $this->clean_sql($sql); $data = array($db_item->id); $query = $this->db->query($sql, $data); - } else { - $sql = "UPDATE `$table` SET current = 'n' WHERE id = ?"; + } + return; + } + + if (!empty($this->config->config['delete_noncurrent_' . $table]) and strtolower($this->config->config['delete_noncurrent_' . $table]) == 'y') { + foreach ($db_result as $db_item) { + $sql = "DELETE FROM `$table` WHERE `id` = ?"; $sql = $this->clean_sql($sql); $data = array($db_item->id); $query = $this->db->query($sql, $data); - if (strtolower($create_alerts) == 'y') { - $alert_details = ''; - foreach ($match_columns as $key => $value) { - if (!empty($db_item->$value)) { - $alert_details .= $value . ' is ' . $db_item->$value . ', '; - } - } - $alert_details = substr($alert_details, 0, -2); - $alert_details = "Item removed from $table - " . $alert_details; - if (!isset($details->last_seen) or $details->last_seen == '0000-00-00 00:00:00' or $details->last_seen =='') { - $sql = "SELECT last_seen FROM `system` WHERE id = ?"; - $sql = $this->clean_sql($sql); - $data = array($details->id); - $query = $this->db->query($sql, $data); - $result = $query->result(); - $details->last_seen = $result[0]->last_seen; + } + return; + } + + foreach ($db_result as $db_item) { + $sql = "UPDATE `$table` SET current = 'n' WHERE id = ?"; + $sql = $this->clean_sql($sql); + $data = array($db_item->id); + $query = $this->db->query($sql, $data); + if (strtolower($create_alerts) == 'y') { + $alert_details = ''; + foreach ($match_columns as $key => $value) { + if (!empty($db_item->$value)) { + $alert_details .= $value . ' is ' . $db_item->$value . ', '; } - $sql = "INSERT INTO change_log (system_id, db_table, db_row, db_action, details, `timestamp`) VALUES (?, ?, ?, ?, ?, ?)"; + } + $alert_details = substr($alert_details, 0, -2); + $alert_details = "Item removed from $table - " . $alert_details; + if (!isset($details->last_seen) or $details->last_seen == '0000-00-00 00:00:00' or $details->last_seen =='') { + $sql = "SELECT last_seen FROM `system` WHERE id = ?"; $sql = $this->clean_sql($sql); - $data = array("$details->id", "$table", "$db_item->id", "delete", "$alert_details", "$details->last_seen"); + $data = array($details->id); $query = $this->db->query($sql, $data); - # add a count to our chart table - $sql = "INSERT INTO chart (`when`, `what`, `org_id`, `count`) VALUES (DATE(NOW()), '" . $table . "_delete', " . intval($details->org_id) . ", 1) ON DUPLICATE KEY UPDATE `count` = `count` + 1"; - $sql = $this->clean_sql($sql); - $query = $this->db->query($sql); + $result = $query->result(); + $details->last_seen = $result[0]->last_seen; } + $sql = "INSERT INTO change_log (system_id, db_table, db_row, db_action, details, `timestamp`) VALUES (?, ?, ?, ?, ?, ?)"; + $sql = $this->clean_sql($sql); + $data = array("$details->id", "$table", "$db_item->id", "delete", "$alert_details", "$details->last_seen"); + $query = $this->db->query($sql, $data); + # add a count to our chart table + $sql = "INSERT INTO chart (`when`, `what`, `org_id`, `count`) VALUES (DATE(NOW()), '" . $table . "_delete', " . intval($details->org_id) . ", 1) ON DUPLICATE KEY UPDATE `count` = `count` + 1"; + $sql = $this->clean_sql($sql); + $query = $this->db->query($sql); } } # removed - just way too much log output @@ -1166,10 +1177,7 @@ public function get_sql_server_version_string($version) public function format_netstat_data($input, $details) { - $lines = array(); - foreach ($input->item as $item) { - $lines[] = $item->line; - } + $lines = explode("\n", $input); if (count($lines) == 0) { define('NL_NIX', "\n"); define('NL_WIN', "\r\n"); @@ -1253,7 +1261,6 @@ public function format_netstat_data($input, $details) } if ($i->protocol != '') { $input_array[] = $i; - print_r($i); } } } From e03476dd6cf55d863dc70aa56b355958e3975b37 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:05:50 +1000 Subject: [PATCH 23/31] Fix default port for ldap_servers in shcema. Add config items for noncurrent netstat and variable. --- .../application/controllers/db_upgrades/db_2.0.10.php | 3 +++ other/openaudit_mysql.sql | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php index 8fb0df5e9..26f366856 100644 --- a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php +++ b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php @@ -53,6 +53,9 @@ $this->db->query($sql); $this->log_db($this->db->last_query()); +# ldap_servers +alter_table('ldap_servers', 'port', "`port` varchar(200) NOT NULL DEFAULT '389'"); + # set our versions $sql = "UPDATE `configuration` SET `value` = '20171010' WHERE `name` = 'internal_version'"; $this->db->query($sql); diff --git a/other/openaudit_mysql.sql b/other/openaudit_mysql.sql index 73d21b356..339bd4610 100644 --- a/other/openaudit_mysql.sql +++ b/other/openaudit_mysql.sql @@ -527,6 +527,8 @@ INSERT INTO `configuration` VALUES (53,'database_show_row_limit','1000','number' INSERT INTO `configuration` VALUES (54,'collector_check_minutes','15','number','y','system','2000-01-01 00:00:00','The default check interval for collectors.'); INSERT INTO `configuration` VALUES (55,'page_size','1000','number','y','system','2000-01-01 00:00:00','The default limit of rows to retrieve.'); INSERT INTO `configuration` VALUES (56,'discovery_linux_use_sudo','y','bool','y','system','2000-01-01 00:00:00','When running discovery commands on a Linux target, should we use sudo.'); +INSERT INTO `configuration` VALUES (57,'delete_noncurrent_netstat','y','bool','y','system','2000-01-01 00:00:00','Should we store non-current netstat data and generate change logs.') +INSERT INTO `configuration` VALUES (58,'delete_noncurrent_variable','y','bool','y','system','2000-01-01 00:00:00','Should we store non-current environment variable data and generate change logs.'); /*!40000 ALTER TABLE `configuration` ENABLE KEYS */; UNLOCK TABLES; @@ -1167,7 +1169,7 @@ CREATE TABLE `ldap_servers` ( `description` text NOT NULL, `lang` varchar(200) NOT NULL DEFAULT 'en', `host` varchar(200) NOT NULL DEFAULT '', - `port` varchar(200) NOT NULL DEFAULT '385', + `port` varchar(200) NOT NULL DEFAULT '389', `secure` enum('y','n') NOT NULL DEFAULT 'n', `domain` varchar(200) NOT NULL DEFAULT '', `type` enum('active directory','openldap') NOT NULL DEFAULT 'active directory', From d623ef4d4b19aaadf32c68a9e09cfdad3474e01f Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:06:05 +1000 Subject: [PATCH 24/31] Improved log entry. --- .../application/controllers/include_input_discoveries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code_igniter/application/controllers/include_input_discoveries.php b/code_igniter/application/controllers/include_input_discoveries.php index b3855478e..2a5577e57 100644 --- a/code_igniter/application/controllers/include_input_discoveries.php +++ b/code_igniter/application/controllers/include_input_discoveries.php @@ -1135,7 +1135,7 @@ $unlink = ''; $source_name = $audit_script; $log->message = 'Could not retrieve script from database for ' . $device->os_group; - $log->command = 'Nothing returned from database'; + $log->command = $sql; $log->status = 'fail'; discovery_log($log); unset($log->command, $log->message, $log->status); From 214d66babef738c9bc9e2d06096223781ea62e4f Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:12:08 +1000 Subject: [PATCH 25/31] Added a todo item. --- code_igniter/application/models/m_devices.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code_igniter/application/models/m_devices.php b/code_igniter/application/models/m_devices.php index 0ba19a646..a795b9ea0 100644 --- a/code_igniter/application/models/m_devices.php +++ b/code_igniter/application/models/m_devices.php @@ -559,6 +559,10 @@ public function collection() unset($result); $sql = "/* m_devices::collection */ " . "SELECT " . $CI->response->meta->internal->properties . " FROM system " . $join . " WHERE system.org_id IN (" . $CI->user->org_list . ") " . $filter . " " . $CI->response->meta->internal->groupby . " " . $CI->response->meta->internal->sort . " " . $CI->response->meta->internal->limit; $result = $this->run_sql($sql, array()); + + # TODO - make a system.seen_by and populate upon audit received or + # discovery recieved. + // if ($CI->response->meta->format == 'json' or $CI->response->meta->format == 'json_data') { // $sql = "/* m_devices::collection */ " . "SELECT audit_log.system_id AS `id`, GROUP_CONCAT(DISTINCT(audit_log.type) ORDER BY audit_log.type) AS `seen_by` FROM audit_log LEFT JOIN system ON audit_log.system_id = system.id WHERE system.org_id IN (" . $CI->user->org_list . ") GROUP BY audit_log.system_id"; // $seen_by = $this->run_sql($sql, array()); From c5385f664905a2c92a86f8b0dc7232754b67d243 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:17:10 +1000 Subject: [PATCH 26/31] Add another field type of 'date'. --- code_igniter/application/controllers/db_upgrades/db_2.0.10.php | 3 +++ other/openaudit_mysql.sql | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php index 26f366856..1a1e2bedb 100644 --- a/code_igniter/application/controllers/db_upgrades/db_2.0.10.php +++ b/code_igniter/application/controllers/db_upgrades/db_2.0.10.php @@ -53,6 +53,9 @@ $this->db->query($sql); $this->log_db($this->db->last_query()); +# fields +alter_table('fields', 'type', "`type` enum('varchar','list','date') NOT NULL DEFAULT 'varchar'"); + # ldap_servers alter_table('ldap_servers', 'port', "`port` varchar(200) NOT NULL DEFAULT '389'"); diff --git a/other/openaudit_mysql.sql b/other/openaudit_mysql.sql index 339bd4610..2b27bedcb 100644 --- a/other/openaudit_mysql.sql +++ b/other/openaudit_mysql.sql @@ -862,7 +862,7 @@ CREATE TABLE `fields` ( `name` varchar(200) NOT NULL DEFAULT '', `org_id` int(10) unsigned NOT NULL DEFAULT '1', `group_id` int(10) unsigned NOT NULL DEFAULT '1', - `type` enum('varchar','list') NOT NULL DEFAULT 'varchar', + `type` enum('varchar','list','date') NOT NULL DEFAULT 'varchar', `values` text NOT NULL, `placement` enum('custom','system') NOT NULL DEFAULT 'system', `edited_by` varchar(200) NOT NULL DEFAULT '', From ffd1e9a1458245f9ee7968855ad963d761325384 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 16:39:26 +1000 Subject: [PATCH 27/31] Enable fields.type == date. --- .../views/theme-bootstrap/v_devices_read.php | 17 ++++++++++++++++- .../theme-bootstrap/v_fields_create_form.php | 3 ++- .../views/theme-bootstrap/v_fields_read.php | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/code_igniter/application/views/theme-bootstrap/v_devices_read.php b/code_igniter/application/views/theme-bootstrap/v_devices_read.php index a9bff6d67..0e2255aef 100644 --- a/code_igniter/application/views/theme-bootstrap/v_devices_read.php +++ b/code_igniter/application/views/theme-bootstrap/v_devices_read.php @@ -1825,7 +1825,6 @@ function insert_additional_fields($section = '', $additional_fields = array(), $ } echo " \n"; } - echo ' '; if ($edit) { echo ' @@ -1839,6 +1838,22 @@ function insert_additional_fields($section = '', $additional_fields = array(), $
' . "\n"; } + + if ($field->{'type'} == 'date') { + echo '
+ +
+ '; + if ($edit) { + echo ' + + + '; + } + echo ' +
+
' . "\n"; + } } } } \ No newline at end of file diff --git a/code_igniter/application/views/theme-bootstrap/v_fields_create_form.php b/code_igniter/application/views/theme-bootstrap/v_fields_create_form.php index 361196277..b2122d61e 100644 --- a/code_igniter/application/views/theme-bootstrap/v_fields_create_form.php +++ b/code_igniter/application/views/theme-bootstrap/v_fields_create_form.php @@ -75,6 +75,7 @@ @@ -145,7 +146,7 @@ $(document).ready(function(){ $('.data_type').change(function() { var $type = $(this).val(); - if ($type == "varchar") { + if ($type == "varchar" || $type == "date") { $(".data-values").prop('disabled', true); } else { $(".data-values").prop('disabled', false); diff --git a/code_igniter/application/views/theme-bootstrap/v_fields_read.php b/code_igniter/application/views/theme-bootstrap/v_fields_read.php index 969b7bf7d..014b3c03d 100644 --- a/code_igniter/application/views/theme-bootstrap/v_fields_read.php +++ b/code_igniter/application/views/theme-bootstrap/v_fields_read.php @@ -88,6 +88,7 @@ From 8aadcf4faedbac7bbaa575df20c4a3291e170e5f Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 20:18:20 +1000 Subject: [PATCH 28/31] Minor code formatting. --- code_igniter/application/controllers/include_update.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code_igniter/application/controllers/include_update.php b/code_igniter/application/controllers/include_update.php index c3008a31d..2a1a2262a 100644 --- a/code_igniter/application/controllers/include_update.php +++ b/code_igniter/application/controllers/include_update.php @@ -26,9 +26,9 @@ # ***************************************************************************** if (empty($this->response->meta->received_data)) { - log_error('ERR-0025'); - output($this->response); - exit(); + log_error('ERR-0025'); + output($this->response); + exit(); } $this->load->model('m_collection'); $this->{'m_collection'}->update(); @@ -42,7 +42,7 @@ $log = new stdClass(); $log->object = $this->response->meta->collection; -$log->function = strtolower($this->response->meta->collection) . '::' . strtolower($this->response->meta->action); +$log->function = strtolower($this->response->meta->collection) . '::' . strtolower($this->response->meta->action); $log->severity = 7; $log->status = 'finish'; $log->type = 'access'; From 15c80523e9391b32c8203ee9dc57d83126995986 Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 20:19:04 +1000 Subject: [PATCH 29/31] Fixed an error when sending attributes->options in a PATCH. --- .../application/helpers/input_helper.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/code_igniter/application/helpers/input_helper.php b/code_igniter/application/helpers/input_helper.php index e2edcfd8e..167a5fc7f 100644 --- a/code_igniter/application/helpers/input_helper.php +++ b/code_igniter/application/helpers/input_helper.php @@ -412,16 +412,25 @@ function inputRead() $CI->response->meta->received_data = @json_decode($_POST{'data'}); } } + if ($REQUEST_METHOD == 'PATCH') { - $data = urldecode(str_replace('data=', '', file_get_contents('php://input'))); - $data = json_decode($data); - if (empty($data)) { + unset($data_json); + unset($data_object); + $data_json = urldecode(str_replace('data=', '', file_get_contents('php://input'))); + $data_object = json_decode($data_json); + $options = $data_object->data->attributes->options; + if (empty($data_object)) { $log->summary = 'Request method is PATCH but no data supplied.'; stdlog($log); } else { - $CI->response->meta->received_data = $data->data; + $CI->response->meta->received_data = new stdClass(); + $CI->response->meta->received_data = $data_object->data; + if (!empty($options)) { + $CI->response->meta->received_data->attributes->options = $options; + } } } + if (!empty($CI->response->meta->received_data->id)) { if ($CI->response->meta->collection != 'database' and $CI->response->meta->collection != 'configuration') { $CI->response->meta->id = intval($CI->response->meta->received_data->id); From 94d2af30738527e4ecb5c8cff5e5213f6d3a31df Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 20:20:16 +1000 Subject: [PATCH 30/31] Fixed an issue processing new options for script updates. --- code_igniter/application/models/m_collection.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/code_igniter/application/models/m_collection.php b/code_igniter/application/models/m_collection.php index 392200988..6beb68aca 100644 --- a/code_igniter/application/models/m_collection.php +++ b/code_igniter/application/models/m_collection.php @@ -649,10 +649,6 @@ public function update($data = null, $collection = '') if ($collection === 'scripts') { if (!empty($data->options)) { - $received = new stdClass(); - foreach ($data->options as $key => $value) { - $received->$key = $value; - } $select = "SELECT * FROM scripts WHERE id = ?"; $query = $this->db->query($select, array($data->id)); $result = $query->result(); @@ -661,15 +657,10 @@ public function update($data = null, $collection = '') } else { $existing = new stdClass(); } - $new = new stdClass(); - foreach ($existing as $existing_key => $existing_value) { - if (isset($received->$existing_key)) { - $new->$existing_key = $received->$existing_key; - } else { - $new->$existing_key = $existing->$existing_key; - } + foreach ($data->options as $key => $value) { + $existing->$key = $value; } - $data->options = (string)json_encode($new); + $data->options = (string)json_encode($existing); } } From 4f89aa8df1d602c8f09280d017846cd95354179a Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Thu, 19 Oct 2017 20:21:55 +1000 Subject: [PATCH 31/31] Fixed bug in scripts read template where it would only (previously) show options that were set, not all options available. --- .../views/theme-bootstrap/v_scripts_read.php | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/code_igniter/application/views/theme-bootstrap/v_scripts_read.php b/code_igniter/application/views/theme-bootstrap/v_scripts_read.php index e985cc877..2d1496229 100644 --- a/code_igniter/application/views/theme-bootstrap/v_scripts_read.php +++ b/code_igniter/application/views/theme-bootstrap/v_scripts_read.php @@ -131,6 +131,14 @@ + response->included as $option) { + if (!empty($option->type) and $option->type == 'script_option' and $option->id == $item->attributes->based_on) { + $script_options = $option->attributes; + break; + } + } + ?>
@@ -141,23 +149,33 @@
- attributes->options)) { ?> - attributes->options as $key => $value) { ?> - + response->included as $option) { + if ($option->id == $script_option) { + foreach ($item->attributes->options as $key => $value) { + if ($key == $script_option) { + $option_value = $value; + } + } + } + } + ?>
- +
- + - +
- - - +