function auth_display_custom_error_message($message) { /* kill the session */ setcookie(session_name(), "", time() - 3600, "/"); /* print error */ print "<html>\n<head>\n"; print " <title>" . "Cacti" . "</title>\n"; print " <link href=\"" . html_get_theme_css() . "\" rel=\"stylesheet\">"; print "</head>\n"; print "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n<br><br>\n"; display_custom_error_message($message); print "</body>\n</html>\n"; }
function display_output_messages() { global $config, $messages; if (isset($_SESSION["sess_messages"])) { $error_message = is_error_message(); if (is_array($_SESSION["sess_messages"])) { foreach (array_keys($_SESSION["sess_messages"]) as $current_message_id) { eval('$message = "' . $messages[$current_message_id]["message"] . '";'); switch ($messages[$current_message_id]["type"]) { case 'info': if ($error_message == false) { print "<table align='center' width='98%' style='background-color: #ffffff; border: 1px solid #bbbbbb;'>"; print "<tr><td bgcolor='#f5f5f5'><p class='textInfo'>{$message}</p></td></tr>"; print "</table><br>"; /* we don't need these if there are no error messages */ kill_session_var("sess_field_values"); } break; case 'error': print "<table align='center' width='98%' style='background-color: #ffffff; border: 1px solid #ff0000;'>"; print "<tr><td bgcolor='#f5f5f5'><p class='textError'>Error: {$message}</p></td></tr>"; print "</table><br>"; break; } } } else { display_custom_error_message($_SESSION["sess_messages"]); } } kill_session_var("sess_messages"); }
function site_remove() { global $config; /* ================= input validation ================= */ input_validate_input_number(get_request_var("id")); /* ==================================================== */ $devices = db_fetch_cell("SELECT COUNT(*) FROM device WHERE site_id='" . $_REQUEST["site_id"] . "'"); if ($devices == 0) { if ((read_config_option("remove_verification") == CHECKED) && (!isset($_GET["confirm"]))) { include("./include/top_header.php"); form_confirm(__("Are You Sure?"), __("Are you sure you want to delete the site") . " <strong>'" . db_fetch_cell("select description from device where id=" . get_request_var("device_id")) . "'</strong>?", "sites.php", "sites.php?action=remove&id=" . get_request_var("id")); include("./include/bottom_footer.php"); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { api_site_remove(get_request_var("id")); } }else{ display_custom_error_message(__("You can not delete this site while there are devices associated with it.")); } }
function field_edit() { global $registered_cacti_names, $fields_data_input_field_edit_1, $fields_data_input_field_edit_2, $fields_data_input_field_edit; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('data_input_id')); input_validate_input_regex(get_request_var_request('type'), '^(in|out)$'); /* ==================================================== */ if (!empty($_REQUEST['id'])) { $field = db_fetch_row_prepared('SELECT * FROM data_input_fields WHERE id = ?', array(get_request_var_request('id'))); } if (!empty($_REQUEST['type'])) { $current_field_type = $_REQUEST['type']; } else { $current_field_type = $field['input_output']; } if ($current_field_type == 'out') { $header_name = 'Output'; } elseif ($current_field_type == 'in') { $header_name = 'Input'; } $data_input = db_fetch_row_prepared('SELECT type_id, name FROM data_input WHERE id = ?', array(get_request_var_request('data_input_id'))); /* obtain a list of available fields for this given field type (input/output) */ if ($current_field_type == 'in' && preg_match_all('/<([_a-zA-Z0-9]+)>/', db_fetch_cell_prepared('SELECT input_string FROM data_input WHERE id = ?', array($_REQUEST['data_input_id'] ? $_REQUEST['data_input_id'] : $field['data_input_id'])), $matches)) { for ($i = 0; $i < count($matches[1]); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $current_field_name = $matches[1][$i]; $array_field_names[$current_field_name] = $current_field_name; } } } /* if there are no input fields to choose from, complain */ if (!isset($array_field_names) && (isset($_REQUEST['type']) ? $_REQUEST['type'] == 'in' : false) && $data_input['type_id'] == '1') { display_custom_error_message('This script appears to have no input values, therefore there is nothing to add.'); return; } html_start_box("<strong>{$header_name} Fields</strong> [edit: " . htmlspecialchars($data_input['name']) . ']', '100%', '', '3', 'center', ''); $form_array = array(); /* field name */ if (($data_input['type_id'] == '1' || $data_input['type_id'] == '5') && $current_field_type == 'in') { /* script */ $form_array = inject_form_variables($fields_data_input_field_edit_1, $header_name, $array_field_names, isset($field) ? $field : array()); } elseif ($data_input['type_id'] == '2' || $data_input['type_id'] == '3' || $data_input['type_id'] == '4' || $data_input['type_id'] == '6' || $data_input['type_id'] == '7' || $data_input['type_id'] == '8' || $current_field_type == 'out') { /* snmp */ $form_array = inject_form_variables($fields_data_input_field_edit_2, $header_name, isset($field) ? $field : array()); } /* ONLY if the field is an input */ if ($current_field_type == 'in') { unset($fields_data_input_field_edit['update_rra']); } elseif ($current_field_type == 'out') { unset($fields_data_input_field_edit['regexp_match']); unset($fields_data_input_field_edit['allow_nulls']); unset($fields_data_input_field_edit['type_code']); } draw_edit_form(array('config' => array(), 'fields' => $form_array + inject_form_variables($fields_data_input_field_edit, isset($field) ? $field : array(), $current_field_type, $_REQUEST))); html_end_box(); form_save_button('data_input.php?action=edit&id=' . $_REQUEST['data_input_id']); }
function display_output_messages() { global $config, $messages; $debug_message = debug_log_return('new_graphs'); if ($debug_message != '') { print "<div id='message' class='textInfo messageBox'>"; print $debug_message; print '</div>'; debug_log_clear('new_graphs'); } elseif (isset($_SESSION['sess_messages'])) { $error_message = is_error_message(); if (is_array($_SESSION['sess_messages'])) { foreach (array_keys($_SESSION['sess_messages']) as $current_message_id) { if (isset($messages[$current_message_id]['message'])) { eval('$message = "' . $messages[$current_message_id]['message'] . '";'); switch ($messages[$current_message_id]['type']) { case 'info': if ($error_message == false) { print "<div id='message' class='textInfo messageBox'>"; print $message; print '</div>'; /* we don't need these if there are no error messages */ kill_session_var('sess_field_values'); } break; case 'error': print "<div id='message' class='textError messageBox'>"; print "Error: {$message}"; print '</div>'; break; } } else { cacti_log("ERROR: Cacti Error Message Id '{$current_message_id}' Not Defined", false, 'WEBUI'); } } } else { display_custom_error_message($_SESSION['sess_messages']); } } kill_session_var('sess_messages'); }
function field_edit() { global $colors, $registered_cacti_names, $fields_data_input_field_edit_1, $fields_data_input_field_edit_2, $fields_data_input_field_edit; /* ================= input validation ================= */ input_validate_input_number(get_request_var("id")); input_validate_input_number(get_request_var("data_input_id")); input_validate_input_regex(get_request_var("type"), "^(in|out)\$"); /* ==================================================== */ if (!empty($_GET["id"])) { $field = db_fetch_row("select * from data_input_fields where id=" . $_GET["id"]); } if (!empty($_GET["type"])) { $current_field_type = $_GET["type"]; } else { $current_field_type = $field["input_output"]; } if ($current_field_type == "out") { $header_name = "Output"; } elseif ($current_field_type == "in") { $header_name = "Input"; } $data_input = db_fetch_row("select type_id,name from data_input where id=" . $_GET["data_input_id"]); /* obtain a list of available fields for this given field type (input/output) */ if ($current_field_type == "in" && preg_match_all("/<([_a-zA-Z0-9]+)>/", db_fetch_cell("select input_string from data_input where id=" . ($_GET["data_input_id"] ? $_GET["data_input_id"] : $field["data_input_id"])), $matches)) { for ($i = 0; $i < count($matches[1]); $i++) { if (in_array($matches[1][$i], $registered_cacti_names) == false) { $current_field_name = $matches[1][$i]; $array_field_names[$current_field_name] = $current_field_name; } } } /* if there are no input fields to choose from, complain */ if (!isset($array_field_names) && (isset($_GET["type"]) ? $_GET["type"] == "in" : false) && $data_input["type_id"] == "1") { display_custom_error_message("This script appears to have no input values, therefore there is nothing to add."); return; } html_start_box("<strong>{$header_name} Fields</strong> [edit: " . $data_input["name"] . "]", "100%", $colors["header"], "3", "center", ""); $form_array = array(); /* field name */ if (($data_input["type_id"] == "1" || $data_input["type_id"] == "5") && $current_field_type == "in") { /* script */ $form_array = inject_form_variables($fields_data_input_field_edit_1, $header_name, $array_field_names, isset($field) ? $field : array()); } elseif ($data_input["type_id"] == "2" || $data_input["type_id"] == "3" || $data_input["type_id"] == "4" || $data_input["type_id"] == "6" || $data_input["type_id"] == "7" || $data_input["type_id"] == "8" || $current_field_type == "out") { /* snmp */ $form_array = inject_form_variables($fields_data_input_field_edit_2, $header_name, isset($field) ? $field : array()); } /* ONLY if the field is an input */ if ($current_field_type == "in") { unset($fields_data_input_field_edit["update_rra"]); } elseif ($current_field_type == "out") { unset($fields_data_input_field_edit["regexp_match"]); unset($fields_data_input_field_edit["allow_nulls"]); unset($fields_data_input_field_edit["type_code"]); } draw_edit_form(array("config" => array(), "fields" => $form_array + inject_form_variables($fields_data_input_field_edit, isset($field) ? $field : array(), $current_field_type, $_GET))); html_end_box(); form_save_button("data_input.php?action=edit&id=" . $_GET["data_input_id"]); }
function auth_display_custom_error_message($message) { /* kill the session */ setcookie(session_name(), "", time() - 3600, "/"); /* print error */ print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"; print "<html>\n<head>\n"; print " <title>" . "Cacti" . "</title>\n"; print " <meta http-equiv='Content-Type' content='text/html;charset=utf-8'>"; print " <link href=\"include/main.css\" type=\"text/css\" rel=\"stylesheet\">"; print "</head>\n"; print "<body>\n<br><br>\n"; display_custom_error_message($message); print "</body>\n</html>\n"; }
function auth_display_custom_error_message($message) { global $config; /* kill the session */ setcookie(session_name(),"",time() - 3600,"/"); /* print error */ print "<html>\n<head>\n"; print " <title>" . "Cacti" . "</title>\n"; print " <link href=\"" . CACTI_URL_PATH . "include/main.css\" rel=\"stylesheet\" type=\"text/css\">"; print "</head>\n"; print "<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n<br><br>\n"; display_custom_error_message($message); print "</body>\n</html>\n"; }
function display_output_messages() { global $config, $messages; if (isset($_SESSION["sess_messages"])) { $error_message = is_error_message(); if (is_array($_SESSION["sess_messages"])) { foreach (array_keys($_SESSION["sess_messages"]) as $current_message_id) { if (isset($messages[$current_message_id])) { $message = $messages[$current_message_id]["message"]; }elseif (isset($_SESSION["sess_message_" . $current_message_id])) { $messages[$current_message_id] = $_SESSION["sess_message_" . $current_message_id]; $message = $messages[$current_message_id]["message"]; unset($_SESSION["sess_message_" . $current_message_id]); } switch ($messages[$current_message_id]["type"]) { case 'info': if ($error_message == false) { print "<table class='topBoxAlt'>"; print "<tr class='rowAlternate1'><td class='textInfo'>$message</td></tr>"; print "</table>"; /* we don't need these if there are no error messages */ kill_session_var("sess_field_values"); } break; case 'error': print "<table class='topBoxError'>"; print "<tr class='rowAlternate1'><td class='textError'>" . __("Error:") . " $message</td></tr>"; print "</table><br>"; break; } } }else{ display_custom_error_message($_SESSION["sess_messages"]); } } kill_session_var("sess_messages"); }
function display_output_messages() { global $config, $colors, $messages; if (isset($_SESSION["sess_messages"])) { $error_message = is_error_message(); if (is_array($_SESSION["sess_messages"])) { foreach (array_keys($_SESSION["sess_messages"]) as $current_message_id) { if (isset($messages[$current_message_id]["message"])) { eval('$message = "' . $messages[$current_message_id]["message"] . '";'); switch ($messages[$current_message_id]["type"]) { case 'info': if ($error_message == false) { print "<div id='message' class='textInfo' style='margin-bottom:5px;padding:5px;background-color:#FFFFFF;border:1px solid #BBBBBB;max-width:100%;position:relative;'>"; print "{$message}"; print "</div>"; /* we don't need these if there are no error messages */ kill_session_var("sess_field_values"); } break; case 'error': print "<div id='message' class='textError' style='margin-bottom:5px;padding:5px;background-color:#FFFFFF;border:1px solid #BBBBBB;max-width:100%;position:relative;'>"; print "Error: {$message}"; print "</div>"; break; } } else { cacti_log("ERROR: Cacti Error Message Id '{$current_message_id}' Not Defined", false, "WEBUI"); } } } else { display_custom_error_message($_SESSION["sess_messages"]); } if (read_config_option("cacti_popup_messages") == "on") { ?> <script type="text/javascript"> <!-- var obj = document.getElementById('message'); if (obj) { if (window.innerHeight) { height = window.innerHeight; width = window.innerWidth; }else{ height = document.body.clientHeight; width = document.body.clientWidth; } var opacity=1; obj.style.zIndex = 2; obj.style.position = "absolute"; obj.style.backgroundColor = "#<?php print $colors["light"]; ?> "; obj.style.border = "1px solid #<?php print $colors["header"]; ?> "; obj.style.padding = "10px"; cw = obj.scrollWidth; // Adjust for IE6 if (!cw) cw = 150; ch = obj.scrollHeight; obj.style.top = '65px'; obj.style.left = ((width/2) - (cw/2) + 60)+'px'; opacity = 1; obj.style.opacity = opacity; obj.zoom = "100%"; if (document.getElementById('message')) { setTimeout("removeMessage()", 2000); } function removeMessage() { if (obj.style.opacity <= 0) return; opacity-=0.15; iopacity = opacity * 100; obj.style.opacity = opacity; obj.style.filter = 'alpha(opacity='+iopacity+')'; setTimeout("removeMessage()",40); } } --> </script> <?php } } kill_session_var("sess_messages"); }
function change_password_form() { global $colors; $user = api_user_info( array( "id" => $_SESSION["sess_user_id"]) ); $user_realms = api_user_realms_list($_SESSION["sess_user_id"]); $form_fields = array ( "password_old" => array( "method" => "textbox_password_single", "friendly_name" => _("Current Password"), "description" => _("Enter your current password validation."), "value" => "", "max_length" => "255" ), "password_new" => array( "method" => "textbox_password", "friendly_name" => _("New Password"), "description" => _("Enter your new password twice. Remember that passwords are case sensitive!"), "value" => "", "max_length" => "255" ), ); require_once(CACTI_BASE_PATH . "/include/top_header.php"); /* check if authorized */ if ($user_realms["18"]["value"] == "1") { if ((read_config_option("auth_method") == "1") || (($current_user["realm"] == "0") && (read_config_option("auth_method") == "3"))) { /* Builtin auth method, password can be changed */ html_start_box("<strong>" . _("Change Password") . "</strong>", "98%", $colors["header_background"], "3", "center", ""); draw_edit_form(array( "config" => array("form_name" => "chk"), "fields" => inject_form_variables($form_fields, (isset($user) ? $user : array())) )); html_end_box(); form_save_button((isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "index.php"),"save"); }else{ /* Password changing not supported */ display_custom_error_message(_("Current selected Authentication Method does not support changing of passwords.")); } }else{ /* access denied */ display_custom_error_message(_("Access Denied.")); } require_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); }