function get_map_values($conn, $map, $name, $type, $host_types) { $r_value_max = -1; $v_value_max = -1; $a_value_max = -1; $r_value_aux = -1; $v_value_aux = -1; $a_value_aux = -1; $sensor = ''; $ips = $name; $in_assets = 0; list($map_array, $obj_map) = get_map_objects($conn, $map); foreach ($obj_map as $object) { list($name, $sensor, $type, $ips, $in_assets) = get_assets($conn, $object['type_name'], $object['type'], $host_types); list($r_value_aux, $v_value_aux, $a_value_aux) = get_values($conn, $host_types, $object['type'], $name, TRUE); if ($r_value_aux > $r_value_max) { $r_value_max = $r_value_aux; } if ($v_value_aux > $v_value_max) { $v_value_max = $v_value_aux; } if ($a_value_aux > $a_value_max) { $a_value_max = $a_value_aux; } } $r_value = get_value_by_digit($r_value_max); $v_value = get_value_by_digit($v_value_max); $a_value = get_value_by_digit($a_value_max); return array($r_value, $v_value, $a_value, $name, $sensor, $type, $ips, $in_assets); }
function get_map_values($conn, $map, $name, $type, $host_types) { $query = "select * from risk_indicators where name <> 'rect' AND map= ?"; $params = array($map); $RiskValue_max = -1; $VulnValue_max = -1; $AvailValue_max = -1; $v_ip = $a_ip = $sensor = ""; $ips = $name; $what = "name"; $in_assets = 0; if (!($rs4 =& $conn->Execute($query, $params))) { print $conn->ErrorMsg(); } else { while (!$rs4->EOF) { //print_r($rs4->fields); // Linked to other map? recursive if (preg_match("/view\\.php\\?map\\=(\\d+)/", $rs4->fields['url'], $found)) { return get_map_values($conn, $found[1], $rs4->fields["type_name"], $rs4->fields["type"], $host_types); } // Asset Values per link. Get the most risk value list($name, $sensor, $type, $ips, $what, $in_assets) = get_assets($conn, $rs4->fields["type_name"], $rs4->fields["type"], $host_types); list($RiskValue_aux, $VulnValue_aux, $AvailValue_aux, $v_ip_aux, $a_ip_aux, $r_ip_aux) = get_values($conn, $host_types, $rs4->fields["type"], $name, $ips, true); if ($RiskValue_aux > $RiskValue_max) { $RiskValue_max = $RiskValue_aux; } if ($VulnValue_aux > $VulnValue_max) { $VulnValue_max = $VulnValue_aux; $v_ip = $v_ip_aux; } if ($AvailValue_aux > $AvailValue_max) { $AvailValue_max = $AvailValue_aux; $a_ip = $a_ip_aux; } //echo "$RiskValue_aux,$VulnValue_aux,$AvailValue_aux,$v_ip_aux,$a_ip_aux\n<br>"; $rs4->MoveNext(); } } $RiskValue = get_value_by_digit($RiskValue_max); $VulnValue = get_value_by_digit($VulnValue_max); $AvailValue = get_value_by_digit($AvailValue_max); return array($RiskValue, $VulnValue, $AvailValue, $v_ip, $a_ip, $name, $sensor, $type, $ips, $what, $in_assets); }