Skip to content

Commit

Permalink
Search for erroroneous system_id fields. Found a couple that would ca…
Browse files Browse the repository at this point in the history
…use issue's. Replased them and for comments changed system_id to system.id to make find/replace easier in the future.
  • Loading branch information
mark-unwin committed Aug 12, 2016
1 parent 5f35372 commit a7ef04f
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion code_igniter/application/controllers/admin_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ public function add_systems()
}
}

# first test to see if we have a system_id -
# first test to see if we have a system.id -
# if not, make a system key and find (or not) the device
if (!isset($details->id) or $details->id == '') {

Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/controllers/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function update_system_man()
# 2 - additional_field_item.additional_field_id
# 3 - additional_field.field_id

# TODO - should test if system_id is part of additional_field.group_id
# TODO - should test if system.id is part of additional_field.group_id
# The code below assumes the view has done this (and it has), but it doesn't verify it.
# Could call this directly using a URL and set a custom field on a device that is not supposed to have it

Expand Down
6 changes: 3 additions & 3 deletions code_igniter/application/controllers/discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function index()

public function discover_list($ids = '')
{
// take a list of system_id's and run discovery on them
// take a list of system.id's and run discovery on them
// do not wait for the return result, go back to the webpage ASAP
//
// ids should be a comma separated list of device id's (integers) - no spaces
Expand Down Expand Up @@ -117,7 +117,7 @@ public function discover_list($ids = '')
return;
}

// spawn a discovery process for each system_id
// spawn a discovery process for each system.id
foreach ($system_ids as $key => $value) {
$timestamp = date('Y-m-d H:i:s');
$system_id = $value;
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public function process_subnet()
$output = null;
$return_var = null;
} else {
$script_string = "$filepath\\" . $source_name . " strcomputer=".$details->ip." submit_online=y create_file=n struser=".$domain.$username." strpass=".$credentials_windows->credentials->password." url=".$url."index.php/system/add_system debugging=0 system_id=".$details->system_id;
$script_string = "$filepath\\" . $source_name . " strcomputer=".$details->ip." submit_online=y create_file=n struser=".$domain.$username." strpass=".$credentials_windows->credentials->password." url=".$url."index.php/system/add_system debugging=0 system_id=".$details->id;
$command_string = "%comspec% /c start /b cscript //nologo ".$script_string." &";
pclose(popen($command_string, "r"));
}
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/controllers/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function api_node_config()
unset($document['sys_hw_network_card_ip']);
}

$sql = "/* main::api_node_config */ SELECT id as net_id, system_id, mac as net_mac_address, manufacturer as net_manufacturer, model as net_model, description as net_description, alias as net_alias, ip_enabled as net_ip_enabled, net_index, dhcp_enabled as net_dhcp_enabled, dhcp_server as net_dhcp_server, dhcp_lease_obtained as net_dhcp_lease_obtained, dhcp_lease_expires as net_dhcp_lease_expires, dns_host_name as net_dns_host_name, dns_server as net_dns_server, dns_domain as net_dns_domain, dns_domain_reg_enabled as net_dns_domain_reg_enabled, type as net_adapter_type, connection as net_connection_id, connection_status as net_connection_status, speed as net_speed, slaves as net_slaves, ifadminstatus, iflastchange FROM network WHERE system_id = ? and current = 'y'";
$sql = "/* main::api_node_config */ SELECT id as net_id, network.system_id, mac as net_mac_address, manufacturer as net_manufacturer, model as net_model, description as net_description, alias as net_alias, ip_enabled as net_ip_enabled, net_index, dhcp_enabled as net_dhcp_enabled, dhcp_server as net_dhcp_server, dhcp_lease_obtained as net_dhcp_lease_obtained, dhcp_lease_expires as net_dhcp_lease_expires, dns_host_name as net_dns_host_name, dns_server as net_dns_server, dns_domain as net_dns_domain, dns_domain_reg_enabled as net_dns_domain_reg_enabled, type as net_adapter_type, connection as net_connection_id, connection_status as net_connection_status, speed as net_speed, slaves as net_slaves, ifadminstatus, iflastchange FROM network WHERE system_id = ? and current = 'y'";
$data = array($system_id);
$query = $this->db->query($sql, $data);
$document['sys_hw_network_card'] = $query->result();
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/controllers/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ public function add_nmap()
}

if (isset($details->id) and !empty($details->id)) {
// we have a system_id and snmp details to update
// we have a system.id and snmp details to update
$log_details = new stdClass();
$log_details->severity = 7;
$log_details->file = 'system';
Expand Down
10 changes: 5 additions & 5 deletions code_igniter/application/controllers/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function org_user()

$instring = implode(',', $org_id_list) . "\n";
echo $instring . "\n";
// $sql = "SELECT system_id, hostname, type, org_id, org_name FROM system LEFT JOIN oa_org ON system.org_id = oa_org.org_id WHERE org_id IN (" . $instring . ")";
// $sql = "SELECT system.id, hostname, type, org_id, org_name FROM system LEFT JOIN oa_org ON system.org_id = oa_org.org_id WHERE org_id IN (" . $instring . ")";
// echo $sql . "\n";
// $query = $this->db->query($sql);
// $result = $query->result();
Expand Down Expand Up @@ -552,7 +552,7 @@ public function delta()
}


$sql = "SELECT first_seen FROM $table WHERE system_id = ? ORDER BY first_seen LIMIT 1";
$sql = "SELECT first_seen FROM $table WHERE system.id = ? ORDER BY first_seen LIMIT 1";
$data = array($system_id);
$query = $this->db->query($sql, $data);
echo $this->db->last_query() . "\n";
Expand All @@ -563,19 +563,19 @@ public function delta()
}
if ($first_seen != '') {
if ($type == 'delta') {
$sql = "SELECT $table.*, IF(($table.first_seen = ?), 'y', 'n') as original_install, IF($table.current = 'y', 'y', 'n') as current_install FROM $table WHERE system_id = ? and (current = 'y' or first_seen = ?)";
$sql = "SELECT $table.*, IF(($table.first_seen = ?), 'y', 'n') as original_install, IF($table.current = 'y', 'y', 'n') as current_install FROM $table WHERE system.id = ? and (current = 'y' or first_seen = ?)";
$data = array("$first_seen", $system_id, "$first_seen");
}
if ($type == 'full') {
$sql = "SELECT $table.*, IF(($table.first_seen = ?), 'y', 'n') as original_install, IF($table.current = 'y', 'y', 'n') as current_install FROM $table WHERE system_id = ?";
$sql = "SELECT $table.*, IF(($table.first_seen = ?), 'y', 'n') as original_install, IF($table.current = 'y', 'y', 'n') as current_install FROM $table WHERE system.id = ?";
$data = array("$first_seen", $system_id);
}
$query = $this->db->query($sql, $data);
$result = $query->result();
echo $this->db->last_query() . "\n";
print_r($result);
} else {
# no data in this table for the system_id
# no data in this table for the system.id
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/core/MY_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public function make_url($col_link = '', $col_var_name_sec = '')
if (strpos($col_link, '/') === 0) {
$col_link = substr($col_link, 1);
}
// NOTE - For most reports, $col_var_name_sec is normally system_id expressed as an int
// NOTE - For most reports, $col_var_name_sec is normally system.id expressed as an int
// NOTE - Relative Index is normally like - /open-audit/index.php/
// NOTE - For an Enterprise report, $col_link is normally like - /omk/oae/device_details/
// NOTE - For a Community report, $col_link is normally like - /main/system_display/
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/helpers/input_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function inputRead()

# get the action
# valid values are typically - create, read, update, delete, list, execute
# TODO - request_method == post and body contains system_id, then update, not create
# TODO - request_method == post and body contains system.id, then update, not create
if ($CI->input->get('action')) {
$action = $CI->input->get('action');
$log->message = 'Set action to ' . $action . ', according to GET.';
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/models/m_additional_fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function get_additional_fields_data($system_id)
*
* @access public
*
* @param system_id
* @param group_id
*
* @return array
*/
Expand Down
4 changes: 2 additions & 2 deletions code_igniter/application/models/m_attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct()

public function create_system_attachment($system_id, $title, $name)
{
$sql = "INSERT INTO attachment (id, system_id, user_id, title, filename, timestamp) VALUES (NULL, ?, ?, ?, ?, ?)";
$sql = "INSERT INTO `attachment` (`id`, `system_id`, `user_id`, `title`, `filename`, `timestamp`) VALUES (NULL, ?, ?, ?, ?, ?)";
$sql = $this->clean_sql($sql);
$data = array("$system_id", $this->session->userdata['user_id'], "$title", "$name", date('Y-m-d H:i:s'));
$query = $this->db->query($sql, $data);
Expand All @@ -52,7 +52,7 @@ public function create_system_attachment($system_id, $title, $name)

public function get_system_attachment($system_id)
{
$sql = "SELECT * FROM attachment WHERE system_id = ?";
$sql = "SELECT * FROM `attachment` WHERE `attachment`.`system_id` = ?";
$sql = $this->clean_sql($sql);
$data = array("$system_id");
$query = $this->db->query($sql, $data);
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/models/m_audit_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function create($system_id, $username = '', $type = '', $ip = '', $debug
if ($timestamp == '') {
$timestamp = date('Y-m-d H:i:s');
}
$sql = "INSERT INTO audit_log (system_id, username, type, ip, debug, wmi_fails, `timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?)";
$sql = "INSERT INTO audit_log (`system_id`, `username`, `type`, `ip`, `debug`, `wmi_fails`, `timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?)";
$sql = $this->clean_sql($sql);
$data = array($system_id, "$username", "$type", "$ip", "$debug", "$wmi_fails", "$timestamp");
$query = $this->db->query($sql, $data);
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/models/m_change_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function readDevice($id)
*/
public function create($system_id, $db_table, $db_row, $db_action, $details, $timestamp)
{
$sql = "INSERT INTO change_log ( system_id, db_table, db_row, db_action, details, `timestamp` ) VALUES ( ?, ?, ?, ?, ?, ? )";
$sql = "INSERT INTO change_log (`system_id`, `db_table`, `db_row`, `db_action`, `details`, `timestamp` ) VALUES ( ?, ?, ?, ?, ?, ? )";
$sql = $this->clean_sql($sql);
$data = array("$system_id", "$db_table", "$db_row", "$db_action", "$details", "$timestamp");
$query = $this->db->query($sql, $data);
Expand Down
2 changes: 1 addition & 1 deletion code_igniter/application/models/m_oa_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function get_system_document_api_new($table = '', $system_id = '')
}
$sql = '';
if ($table == 'system') {
$sql = 'SELECT system.* FROM system LEFT JOIN oa_location ON system.location_id = oa_location.id WHERE system_id = ?';
$sql = 'SELECT system.* FROM system LEFT JOIN oa_location ON system.location_id = oa_location.id WHERE system.id = ?';
$sql = $this->clean_sql($sql);
}
if ($sql != '') {
Expand Down
8 changes: 4 additions & 4 deletions code_igniter/application/models/m_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ public function insert_system($details, $display = 'n')
$details = (object) $details;
$details = (array) $details;
$details = (object) $details;
# this is an insert - we do NOT want a system_id
# this is an insert - we do NOT want a system.id
unset($details->id);

// set a ip if not already 1.5.6
Expand Down Expand Up @@ -1021,7 +1021,7 @@ public function insert_system($details, $display = 'n')
$temp_vm_id = $row->id;
$details->vm_system_id = $row->vm_system_id;
$details->vm_server_name = $row->vm_server_name;
$sql = "SELECT icon , 'vm' FROM system WHERE system_id = ?";
$sql = "SELECT icon , 'vm' FROM system WHERE system.id = ?";
$sql = $this->clean_sql($sql);
$data = array($details->id);
$query = $this->db->query($sql, $data);
Expand Down Expand Up @@ -1071,7 +1071,7 @@ public function insert_system($details, $display = 'n')
public function update_system($details, $display = 'n')
{
if (!isset($details->id) or $details->id == '') {
# this is an update - we need a system_id
# this is an update - we need a system.id
return;
}

Expand Down Expand Up @@ -1337,7 +1337,7 @@ public function update_system($details, $display = 'n')
$temp_vm_id = $row->id;
$details->vm_system_id = $row->vm_system_id;
$details->vm_server_name = $row->vm_server_name;
$sql = "SELECT icon FROM system WHERE system_id = ?";
$sql = "SELECT icon FROM system WHERE system.id = ?";
$sql = $this->clean_sql($sql);
$data = array($details->id);
$query = $this->db->query($sql, $data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
# for every returned row
foreach ($this->response->data as $item) {

# grab the system_id if it exists
# grab the system.id if it exists
$system_id = '';
if (!empty($item->attributes->{'system.id'})) {
$system_id = $item->attributes->{'system.id'};
Expand Down

0 comments on commit a7ef04f

Please sign in to comment.