1<?php 2 3// Pandora FMS - http://pandorafms.com 4// ================================================== 5// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas 6// Please see http://pandorafms.org for full contribution list 7 8// This program is free software; you can redistribute it and/or 9// modify it under the terms of the GNU General Public License 10// as published by the Free Software Foundation for version 2. 11// This program is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// Load global vars 17check_login (); 18 19if (! check_acl ($config['id_user'], 0, "AW")) { 20 db_pandora_audit("ACL Violation", 21 "Trying to access massive operation section"); 22 require ("general/noaccess.php"); 23 return; 24} 25 26require_once ('include/functions_agents.php'); 27require_once ('include/functions_alerts.php'); 28require_once ('include/functions_modules.php'); 29 30enterprise_include ('godmode/massive/massive_operations.php'); 31 32$tab = (string) get_parameter ('tab', 'massive_agents'); 33$option = (string) get_parameter ('option', ''); 34 35$options_alerts = array( 36 'add_alerts' => __('Bulk alert add'), 37 'delete_alerts' => __('Bulk alert delete'), 38 'add_action_alerts' => __('Bulk alert actions add'), 39 'delete_action_alerts' => __('Bulk alert actions delete'), 40 'enable_disable_alerts' => __('Bulk alert enable/disable'), 41 'standby_alerts' => __('Bulk alert setting standby')); 42 43$options_agents = array( 44 'edit_agents' => __('Bulk agent edit'), 45 'delete_agents' => __('Bulk agent delete')); 46 47if (check_acl ($config['id_user'], 0, "PM")) { 48 $options_users = array( 49 'add_profiles' => __('Bulk profile add'), 50 'delete_profiles' => __('Bulk profile delete')); 51} 52else { 53 $options_users = array(); 54} 55 56$options_modules = array( 57 'delete_modules' => __('Bulk module delete'), 58 'edit_modules' => __('Bulk module edit'), 59 'copy_modules' => __('Bulk module copy')); 60 61$options_plugins = array( 62 'edit_plugins' => __('Bulk plugin edit') 63 ); 64 65if (! check_acl ($config['id_user'], 0, "PM")) { 66 unset($options_modules['edit_modules']); 67} 68 69$options_policies = array(); 70$policies_options = enterprise_hook('massive_policies_options'); 71 72if ($policies_options != ENTERPRISE_NOT_HOOK) { 73 $options_policies = 74 array_merge($options_policies, $policies_options); 75} 76 77$options_snmp = array(); 78$snmp_options = enterprise_hook('massive_snmp_options'); 79 80if ($snmp_options != ENTERPRISE_NOT_HOOK) { 81 $options_snmp = 82 array_merge($options_snmp, $snmp_options); 83} 84 85$options_satellite = array(); 86$satellite_options = enterprise_hook('massive_satellite_options'); 87 88if ($satellite_options != ENTERPRISE_NOT_HOOK) { 89 $options_satellite = 90 array_merge($options_satellite, $satellite_options); 91} 92 93if (in_array($option, array_keys($options_alerts))) { 94 $tab = 'massive_alerts'; 95} 96elseif (in_array($option, array_keys($options_agents))) { 97 $tab = 'massive_agents'; 98} 99elseif (in_array($option, array_keys($options_users))) { 100 $tab = 'massive_users'; 101} 102elseif (in_array($option, array_keys($options_modules))) { 103 $tab = 'massive_modules'; 104} 105elseif (in_array($option, array_keys($options_policies))) { 106 $tab = 'massive_policies'; 107} 108elseif (in_array($option, array_keys($options_snmp))) { 109 $tab = 'massive_snmp'; 110} 111elseif (in_array($option, array_keys($options_satellite))) { 112 $tab = 'massive_satellite'; 113} 114elseif (in_array($option, array_keys($options_plugins))) { 115 $tab = 'massive_plugins'; 116} 117else { 118 $option = ''; 119} 120 121switch ($tab) { 122 case 'massive_alerts': 123 $options = $options_alerts; 124 break; 125 case 'massive_agents': 126 $options = $options_agents; 127 break; 128 case 'massive_modules': 129 $options = $options_modules; 130 break; 131 case 'massive_users': 132 $options = $options_users; 133 break; 134 case 'massive_policies': 135 $options = $options_policies; 136 break; 137 case 'massive_snmp': 138 $options = $options_snmp; 139 break; 140 case 'massive_satellite': 141 $options = $options_satellite; 142 break; 143 case 'massive_plugins': 144 $options = $options_plugins; 145 break; 146} 147 148// Set the default option of the category 149if ($option == '') { 150 $option = array_shift(array_keys($options)); 151} 152 153$alertstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_alerts">' 154 . html_print_image ('images/op_alerts.png', true, 155 array ('title' => __('Alerts operations'))) 156 . '</a>', 'active' => $tab == 'massive_alerts'); 157 158$userstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_users">' 159 . html_print_image ('images/op_workspace.png', true, 160 array ('title' => __('Users operations'))) 161 . '</a>', 'active' => $tab == 'massive_users'); 162 163$agentstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_agents">' 164 . html_print_image ('images/bricks.png', true, 165 array ('title' => __('Agents operations'))) 166 . '</a>', 'active' => $tab == 'massive_agents'); 167 168$modulestab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_modules">' 169 . html_print_image ('images/brick.png', true, 170 array ('title' => __('Modules operations'))) 171 . '</a>', 'active' => $tab == 'massive_modules'); 172 173$pluginstab = array('text' => '<a href="index.php?sec=gmassive&sec2=godmode/massive/massive_operations&tab=massive_plugins">' 174 . html_print_image ('images/plugin.png', true, 175 array ('title' => __('Plugins operations'))) 176 . '</a>', 'active' => $tab == 'massive_plugins'); 177 178$policiestab = enterprise_hook('massive_policies_tab'); 179 180if ($policiestab == ENTERPRISE_NOT_HOOK) 181 $policiestab = ""; 182 183$snmptab = enterprise_hook('massive_snmp_tab'); 184 185if ($snmptab == ENTERPRISE_NOT_HOOK) 186 $snmptab = ""; 187 188$satellitetab = enterprise_hook('massive_satellite_tab'); 189 190if ($satellitetab == ENTERPRISE_NOT_HOOK) 191 $satellitetab = ""; 192 193 194$onheader = array(); 195$onheader['massive_agents'] = $agentstab; 196$onheader['massive_modules'] = $modulestab; 197$onheader['massive_plugins'] = $pluginstab; 198if (check_acl ($config['id_user'], 0, "PM")) { 199 $onheader['user_agents'] = $userstab; 200} 201$onheader['massive_alerts'] = $alertstab; 202$onheader['policies'] = $policiestab; 203$onheader['snmp'] = $snmptab; 204$onheader['satellite'] = $satellitetab; 205 206ui_print_page_header( 207 __('Massive operations') . ' » '. $options[$option], 208 "images/gm_massive_operations.png", false, "", true, $onheader); 209 210// Checks if the PHP configuration is correctly 211if ((get_cfg_var("max_execution_time") != 0) 212 or (get_cfg_var("max_input_time") != -1)) { 213 214 echo '<div id="notify_conf" class="notify">'; 215 echo __("In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: <i>sudo vi /etc/php5/apache2/php.ini;</i><br> And set your timeout parameters to a correct value: <br><i> max_execution_time = 0</i> and <i>max_input_time = -1</i>"); 216 echo '</div>'; 217} 218 219// Catch all submit operations in this view to display Wait banner 220$submit_action = get_parameter('go'); 221$submit_update = get_parameter('updbutton'); 222$submit_del = get_parameter('del'); 223$submit_template_disabled = get_parameter('id_alert_template_disabled'); 224$submit_template_enabled = get_parameter('id_alert_template_enabled'); 225$submit_template_not_standby = get_parameter('id_alert_template_not_standby'); 226$submit_template_standby = get_parameter('id_alert_template_standby'); 227$submit_add = get_parameter('crtbutton'); 228 229echo '<div id="loading" display="none">'; 230echo html_print_image("images/wait.gif", true, array("border" => '0')) . '<br />'; 231echo '<strong>' . __('Please wait...') . '</strong>'; 232echo '</div>'; 233?> 234 235<script language="javascript" type="text/javascript"> 236 $(document).ready (function () { 237 $('#manage_config_form').submit( function() { 238 confirm_status = 239 confirm("<?php echo __('Are you sure?'); ?>"); 240 if (confirm_status) 241 $("#loading").css("display", ""); 242 else 243 return false; 244 }); 245 246 $('[id^=form]').submit( function() { 247 confirm_status = 248 confirm("<?php echo __('Are you sure?'); ?>"); 249 if (confirm_status) 250 $("#loading").css("display", ""); 251 else 252 return false; 253 }); 254 255 $("#loading").css("display", "none"); 256 }); 257</script> 258 259<?php 260echo "<br />"; 261echo '<form method="post" id="form_options" action="index.php?sec=gmassive&sec2=godmode/massive/massive_operations">'; 262echo '<table border="0"><tr><td>'; 263echo __("Action"); 264echo '</td><td>'; 265html_print_select($options, 'option', $option, 'this.form.submit()', '', 266 0, false, false, false); 267if ($option == 'edit_agents' || $option == 'edit_modules') 268 ui_print_help_tip(__("The blank fields will not be updated")); 269echo '</td></tr></table>'; 270echo '</form>'; 271echo "<br />"; 272 273switch ($option) { 274 case 'delete_alerts': 275 require_once ('godmode/massive/massive_delete_alerts.php'); 276 break; 277 case 'add_alerts': 278 require_once ('godmode/massive/massive_add_alerts.php'); 279 break; 280 case 'delete_action_alerts': 281 require_once ('godmode/massive/massive_delete_action_alerts.php'); 282 break; 283 case 'add_action_alerts': 284 require_once ('godmode/massive/massive_add_action_alerts.php'); 285 break; 286 case 'enable_disable_alerts': 287 require_once ('godmode/massive/massive_enable_disable_alerts.php'); 288 break; 289 case 'standby_alerts': 290 require_once ('godmode/massive/massive_standby_alerts.php'); 291 break; 292 case 'add_profiles': 293 require_once ('godmode/massive/massive_add_profiles.php'); 294 break; 295 case 'delete_profiles': 296 require_once ('godmode/massive/massive_delete_profiles.php'); 297 break; 298 case 'delete_agents': 299 require_once ('godmode/massive/massive_delete_agents.php'); 300 break; 301 case 'edit_agents': 302 require_once ('godmode/massive/massive_edit_agents.php'); 303 break; 304 case 'delete_modules': 305 require_once ('godmode/massive/massive_delete_modules.php'); 306 break; 307 case 'edit_modules': 308 require_once ('godmode/massive/massive_edit_modules.php'); 309 break; 310 case 'copy_modules': 311 require_once ('godmode/massive/massive_copy_modules.php'); 312 break; 313 case 'edit_plugins': 314 require_once ('godmode/massive/massive_edit_plugins.php'); 315 break; 316 default: 317 if (!enterprise_hook('massive_operations', array($option))) { 318 require_once ('godmode/massive/massive_config.php'); 319 } 320 break; 321} 322?> 323