@@ -158,7 +158,7 @@ function draw_page() {
158158 // If the host is down, we need to insert the embedded wav file
159159 $ monitor_sound = get_monitor_sound ();
160160 if (is_monitor_audible ()) {
161- print "<audio id='audio' loop autoplay src=' " . htmlspecialchars ($ config ['url_path ' ] . "plugins/monitor/sounds/ " . $ monitor_sound ) . "'></audio> \n" ;
161+ print "<audio id='audio' loop src=' " . htmlspecialchars ($ config ['url_path ' ] . "plugins/monitor/sounds/ " . $ monitor_sound ) . "'></audio> \n" ;
162162 }
163163
164164 ?>
@@ -196,11 +196,14 @@ function closeTip() {
196196 $(document).tooltip('close');
197197 }
198198
199- function applyFilter() {
199+ function applyFilter(action = '' ) {
200200 clearTimeout(myTimer);
201201 $('.fa-server, .fa-first-order').unbind();
202202
203203 strURL = 'monitor.php?header=false';
204+ if (action >= '') {
205+ strURL += '&action='+action;
206+ }
204207 strURL += '&refresh='+$('#refresh').val();
205208 strURL += '&grouping='+$('#grouping').val();
206209 strURL += '&tree='+$('#tree').val();
@@ -241,13 +244,11 @@ function setupTooltips() {
241244 if ($('#mute').val() == 'false') {
242245 $('#mute').val('true');
243246 muteUnmuteAudio(true);
244- $('#sound').val('<?php print get_unmute_text ();?> ');
245- loadPageNoHeader('monitor.php?header=false&action=ajax_mute_all');
247+ applyFilter('ajax_mute_all');
246248 } else {
247249 $('#mute').val('false');
248250 muteUnmuteAudio(false);
249- $('#sound').val('<?php print get_mute_text ();?> ');
250- loadPageNoHeader('monitor.php?header=false&action=ajax_unmute_all');
251+ applyFilter('ajax_unmute_all');
251252 }
252253 });
253254
@@ -308,7 +309,6 @@ function() {
308309 } else {
309310 muteUnmuteAudio(false);
310311 }
311-
312312 $('#main').css('margin-right', '15px');
313313 });
314314
@@ -321,16 +321,15 @@ function() {
321321}
322322
323323function is_monitor_audible () {
324- $ sound = get_monitor_sound ();
325- if ($ sound != '' && $ sound != __ ('None ' , 'monitor ' )) {
326- return true ;
327- } else {
328- return false ;
329- }
324+ return get_monitor_sound () != '' ;
330325}
331326
332327function get_monitor_sound () {
333- return read_user_setting ('monitor_sound ' , read_config_option ('monitor_sound ' ));
328+ $ sound = read_user_setting ('monitor_sound ' , read_config_option ('monitor_sound ' ));
329+ clearstatcache ();
330+ $ file = dirname (__FILE__ ) . '/sounds/ ' . $ sound ;
331+ $ exists = file_exists ($ file );
332+ return $ exists ? $ sound : '' ;
334333}
335334
336335function find_down_hosts () {
@@ -340,26 +339,35 @@ function find_down_hosts() {
340339 if (isset ($ _SESSION ['muted_hosts ' ])) {
341340 $ unmuted_hosts = array_diff ($ dhosts , $ _SESSION ['muted_hosts ' ]);
342341 if (sizeof ($ unmuted_hosts )) {
343- set_request_var ( ' mute ' , ' false ' );
342+ unmute_user ( );
344343 }
345344 } else {
346345 set_request_var ('mute ' , 'false ' );
347346 }
348347 } else {
349- $ _SESSION ['muted_hosts ' ] = array ();
350- set_request_var ('mute ' , 'false ' );
348+ unmute_all_hosts ();
351349 set_request_var ('downhosts ' , 'false ' );
352350 }
353351}
354352
355353function mute_all_hosts () {
356354 $ _SESSION ['muted_hosts ' ] = get_hosts_down_by_permission ();
357- set_request_var ( ' mute ' , ' true ' );
355+ mute_user ( );
358356}
359357
360358function unmute_all_hosts () {
361359 $ _SESSION ['muted_hosts ' ] = array ();
360+ unmute_user ();
361+ }
362+
363+ function mute_user () {
364+ set_request_var ('mute ' , 'true ' );
365+ set_user_setting ('monitor_mute ' ,'true ' );
366+ }
367+
368+ function unmute_user () {
362369 set_request_var ('mute ' , 'false ' );
370+ set_user_setting ('monitor_mute ' ,'false ' );
363371}
364372
365373function check_tholds () {
@@ -1500,26 +1508,16 @@ function get_hosts_down_by_permission() {
15001508 }
15011509 }
15021510
1503- if ($ render_style == 'default ' ) {
1504- $ hosts = get_allowed_devices ("h.monitor='on' $ sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0) " );
1505- // do a quick loop through to pull the hosts that are down
1506- if (sizeof ($ hosts )) {
1507- foreach ($ hosts as $ host ) {
1508- $ result [] = $ host ['id ' ];
1509- sort ($ result );
1510- }
1511- }
1512- } else {
1513- /* Only get hosts */
1514- $ hosts = get_allowed_devices ("h.monitor='on' $ sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0) " );
1515- if (sizeof ($ hosts ) > 0 ) {
1516- foreach ($ hosts as $ host ) {
1517- $ result [] = $ host ['id ' ];
1518- sort ($ result );
1519- }
1511+ $ sql_where = "h.monitor='on' $ sql_add_where AND h.disabled='' AND h.status < 2 AND (h.availability_method>0 OR h.snmp_version>0) " ;
1512+
1513+ // do a quick loop through to pull the hosts that are down
1514+ $ hosts = get_allowed_devices ($ sql_where );
1515+ if (sizeof ($ hosts )) {
1516+ foreach ($ hosts as $ host ) {
1517+ $ result [] = $ host ['id ' ];
1518+ sort ($ result );
15201519 }
15211520 }
1522-
15231521 return $ result ;
15241522}
15251523
0 commit comments