__('Delete') ); /* set default action */ set_default_action(); switch (get_request_var('action')) { case 'save': form_save(); break; case 'actions': form_actions(); break; case 'remove': color_remove(); header ('Location: color.php'); break; case 'edit': top_header(); color_edit(); bottom_footer(); break; case 'export': color_export(); break; case 'import': top_header(); color_import(); bottom_footer(); break; default: top_header(); color(); bottom_footer(); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { if (isset_request_var('save_component_color')) { /* ================= input validation ================= */ get_filter_request_var('id'); /* ==================================================== */ $save['id'] = get_nfilter_request_var('id'); if (get_nfilter_request_var('read_only') == '') { $save['name'] = get_nfilter_request_var('name'); $save['hex'] = form_input_validate(get_nfilter_request_var('hex'), 'hex', '^[a-fA-F0-9]+$' , false, 3); } else { $save['name'] = get_nfilter_request_var('hidden_name'); $save['read_only'] = 'on'; } if (!is_error_message()) { $color_id = sql_save($save, 'colors'); if ($color_id) { raise_message(1); } else { raise_message(2); } } if (is_error_message()) { header('Location: color.php?header=false&action=edit&id=' . (empty($color_id) ? get_nfilter_request_var('id') : $color_id)); } else { header('Location: color.php?header=false'); } } elseif (isset_request_var('save_component_import')) { if (isset($_FILES['import_file']['tmp_name'])) { if (($_FILES['import_file']['tmp_name'] != 'none') && ($_FILES['import_file']['tmp_name'] != '')) { $csv_data = file($_FILES['import_file']['tmp_name']); $debug_data = color_import_processor($csv_data); if (cacti_sizeof($debug_data)) { $_SESSION['import_debug_info'] = $debug_data; } header('Location: color.php?action=import'); } } else { raise_message(35); header('Location: color.php?action=import'); } } exit; } /* ----------------------- Color Functions ----------------------- */ function form_actions() { global $color_actions; /* ================= input validation ================= */ get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* delete */ db_execute('DELETE FROM colors WHERE ' . array_to_sql_or($selected_items, 'id')); } } header('Location: color.php?header=false'); exit; } /* setup some variables */ $color_list = ''; $i = 0; /* loop through each of the graphs selected on the previous page and get more info about them */ foreach ($_POST as $var => $val) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $color = db_fetch_row_prepared('SELECT name, hex FROM colors WHERE id = ?', array($matches[1])); $color_list .= '
" . __n('Click \'Continue\' to delete the following Color', 'Click \'Continue\' to delete the following Colors', cacti_sizeof($color_array)) . "
" . __('Cacti has imported the following items:') . "