diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 9982ec24fb..71fed08dd9 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -1215,30 +1215,29 @@ function mysql_get_fields($table) { /** * Process a file with an oracle schema sentences. * Based on the function which installs the pandoradb.sql schema. - * + * * @param string $path File path. * @param bool $handle_error Whether to handle the mysqli_query/mysql_query errors or throw an exception. - * + * * @return bool Return the final status of the operation. */ function mysql_db_process_file ($path, $handle_error = true) { global $config; - + if (file_exists($path)) { $file_content = file($path); $query = ""; - + // Begin the transaction mysql_db_process_sql_begin(); - + foreach ($file_content as $sql_line) { if (trim($sql_line) != "" && strpos($sql_line, "--") === false) { - $query .= $sql_line; - + if (preg_match("/;[\040]*\$/", $sql_line)) { if ($config["mysqli"]) { - $query_result = mysqli_query($config['dbconnection'], $query); + $query_result = mysqli_query($config['dbconnection'], $query); } else { $query_result = mysql_query($query); @@ -1246,9 +1245,14 @@ function mysql_db_process_file ($path, $handle_error = true) { if (!$result = $query_result) { // Error. Rollback the transaction mysql_db_process_sql_rollback(); - - $error_message = mysql_error(); - + + if($config["mysqli"]){ + $error_message = mysqli_error($config['dbconnection']); + } + else{ + $error_message = mysql_error(); + } + // Handle the error if ($handle_error) { $backtrace = debug_backtrace(); @@ -1258,7 +1262,7 @@ function mysql_db_process_file ($path, $handle_error = true) { set_error_handler('db_sql_error_handler'); trigger_error($error); restore_error_handler(); - + return false; } // Throw an exception with the error message @@ -1270,10 +1274,9 @@ function mysql_db_process_file ($path, $handle_error = true) { } } } - + // No errors. Commit the transaction mysql_db_process_sql_commit(); - return true; } else { diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index e800e026a4..6741f08bc1 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -3435,4 +3435,85 @@ function pandora_xhprof_display_result($key = "", $method = "link") { } } + +/** + * From a network with a mask remove the smallest ip and the highest + * + * @param string address to identify the network. + * @param string mask to identify the mask network + * @return array or false with smallest ip and highest ip + */ +function range_ips_for_network($address, $mask) { + if(!isset($address) || !isset($mask)){ + return false; + } + + //convert ip addresses to long form + $address_long = ip2long($address); + $mask_long = ip2long($mask); + + //caculate first usable address + $ip_host_first = ((~$mask_long) & $address_long); + $ip_first = ($address_long ^ $ip_host_first) + 1; + + //caculate last usable address + $ip_broadcast_invert = ~$mask_long; + $ip_last = ($address_long | $ip_broadcast_invert) - 1; + + $range = array( + 'first' => long2ip($ip_first), + 'last' => long2ip($ip_last) + ); + + return $range; +} + +/** + * from two ips find out if there is such an ip + * + * @param string ip ip wont validate + * @param string ip_lower + * @param string ip_upper + * @return bool true or false if the ip is between the two ips + */ +function is_in_network ($ip, $ip_lower, $ip_upper) { + if(!isset($ip) || !isset($ip_lower) || !isset($ip_upper)){ + return false; + } + + $ip = (float)sprintf("%u",ip2long($ip)); + $ip_lower = (float)sprintf("%u",ip2long($ip_lower)); + $ip_upper = (float)sprintf("%u",ip2long($ip_upper)); + + if ($ip >= $ip_lower && $ip <= $ip_upper){ + return true; + } else { + return false; + } +} +/** + * + */ +function ip_belongs_to_network($ip, $network, $mask) { + if ($ip == $network) { + return true; + } + $ranges = range_ips_for_network($network, $mask); + return is_in_network($ip, $ranges['first'], $ranges['last']); +} +/** + * convert the mask to cird format + * + * @param string mask + * @return string true or false if the ip is between the two ips + */ +function mask2cidr($mask){ + if(!isset($mask)) + return 0; + + $long = ip2long($mask); + $base = ip2long('255.255.255.255'); + return 32-log(($long ^ $base)+1,2); +} + ?> diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index e28c58ee4b..02690b5fd2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -32,7 +32,6 @@ include_once($config['homedir'] . "/include/functions_servers.php"); include_once($config['homedir'] . "/include/functions_planned_downtimes.php"); include_once($config['homedir'] . "/include/functions_db.php"); include_once($config['homedir'] . "/include/functions_event_responses.php"); -include_once($config['homedir'] . "/include/functions_policies.php"); enterprise_include_once ('include/functions_local_components.php'); enterprise_include_once ('include/functions_events.php'); enterprise_include_once ('include/functions_agents.php'); diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 17f6d9b345..2fd79d6d43 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -249,6 +249,10 @@ function config_update_config () { $error_update[] = __('Activate Log Collector'); if (!config_update_value ('enable_update_manager', get_parameter('enable_update_manager'))) $error_update[] = __('Enable Update Manager'); + if (!config_update_value ('ipam_ocuppied_critical_treshold', get_parameter('ipam_ocuppied_critical_treshold'))) + $error_update[] = __('Ipam Ocuppied Manager Critical'); + if (!config_update_value ('ipam_ocuppied_warning_treshold', get_parameter('ipam_ocuppied_warning_treshold'))) + $error_update[] = __('Ipam Ocuppied Manager Warning'); $inventory_changes_blacklist = get_parameter('inventory_changes_blacklist', array()); if (!config_update_value ('inventory_changes_blacklist', implode(',',$inventory_changes_blacklist))) @@ -1085,6 +1089,14 @@ function config_process_config () { config_update_value ('enable_update_manager', 1); } + if (!isset ($config["ipam_ocuppied_critical_treshold"])) { + config_update_value ('ipam_ocuppied_critical_treshold', 90); + } + + if (!isset ($config["ipam_ocuppied_warning_treshold"])) { + config_update_value ('ipam_ocuppied_warning_treshold', 80); + } + if (!isset ($config["reset_pass_option"])) { config_update_value ('reset_pass_option', 0); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 06257a5457..a3e3358c82 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1025,7 +1025,8 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle "title", "xml:lang", "onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", - "onkeypress", "onkeydown", "onkeyup", "required"); + "onkeypress", "onkeydown", "onkeyup", "required", + "autocomplete"); $output = ' $value) { + $result[$value['id_os']] = $value['name']; + } + } else { + $result = $op_systems; + } + + return $result; } function os_get_icon($id_os) { diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 8f6f5a35d8..27a42acbb4 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1584,8 +1584,8 @@ $config['css']['dialog'] = "include/javascript/introjs.css"; //End load JQuery //////////////////////////////////////////////////////////////////// - include_once($config["homedir"] . '/include/graphs/functions_flot.php'); - $output .= include_javascript_dependencies_flot_graph(true); + include_once (__DIR__ . '/graphs/functions_flot.php'); + $output .= include_javascript_dependencies_flot_graph (true); $output .= '