2011-09-20 09:55:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$pagetitle []  =  'Services' ;  
						 
					
						
							
								
									
										
										
										
											2011-10-18 14:41:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-14 13:38:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								print_optionbar_start ();  
						 
					
						
							
								
									
										
										
										
											2010-05-03 16:20:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								echo  " <span style='font-weight: bold;'>Services</span> »  " ;  
						 
					
						
							
								
									
										
										
										
											2011-04-29 23:09:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$menu_options  =  array (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    'basic'    =>  'Basic' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								);  
						 
					
						
							
								
									
										
										
										
											2011-04-09 15:20:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$sql_param  =  array ();  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( isset ( $vars [ 'state' ]))  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( $vars [ 'state' ]  ==  'up' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $state  =  '1' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 18:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    elseif  ( $vars [ 'state' ]  ==  'down' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $state  =  '0' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( $vars [ 'state' ])  {  
						 
					
						
							
								
									
										
										
										
											2015-10-17 18:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $where       .=  "  AND service_status= ? AND service_disabled='0' AND `service_ignore`='0' " ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $sql_param []  =  $state ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $vars [ 'disabled' ])  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $where       .=  ' AND service_disabled= ?' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $sql_param []  =  $vars [ 'disabled' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-13 10:05:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( $vars [ 'ignore' ])  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $where       .=  ' AND `service_ignore`= ?' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $sql_param []  =  $vars [ 'ignore' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( ! $vars [ 'view' ])  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $vars [ 'view' ]  =  'basic' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$sep  =  '' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								foreach  ( $menu_options  as  $option  =>  $text )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( empty ( $vars [ 'view' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $vars [ 'view' ]  =  $option ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  $sep ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( $vars [ 'view' ]  ==  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  " <span class='pagemenu-selected'> " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo  generate_link ( $text ,  $vars ,  array ( 'view'  =>  $option )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( $vars [ 'view' ]  ==  $option )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        echo  '</span>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $sep  =  ' | ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-09 15:20:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								unset ( $sep );  
						 
					
						
							
								
									
										
										
										
											2010-05-03 16:20:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								print_optionbar_end ();  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 18:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								echo  ' < div  class = " table-responsive " >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< table  class = " table table-condensed " >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < tr > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < th > Device </ th > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < th > Service </ th > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < th > Changed </ th > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < th > Message </ th > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ tr > ' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( $_SESSION [ 'userlevel' ]  >=  '5' )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $host_sql  =  'SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.device_id GROUP BY D.hostname ORDER BY D.hostname' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $host_par  =  array (); 
							 
						 
					
						
							
								
									
										
										
										
											2007-06-24 14:56:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								else  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $host_sql  =  'SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $host_par  =  array ( $_SESSION [ 'user_id' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$shift  =  1 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								foreach  ( dbFetchRows ( $host_sql ,  $host_par )  as  $device )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $device_id        =  $device [ 'device_id' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-26 13:05:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $device_hostname  =  $device [ 'hostname' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-02 13:55:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( $shift  ==  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        array_unshift ( $sql_param ,  $device_id ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $shift  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql_param [ 0 ]  =  $device_id ; 
							 
						 
					
						
							
								
									
										
										
										
											2007-04-03 14:10:23 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    foreach  ( dbFetchRows ( " SELECT * FROM `services` WHERE `device_id` = ?  $where " ,  $sql_param )  as  $service )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        include  'includes/print-service.inc.php' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // $samehost = 1;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $vars [ 'view' ]  ==  'details' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $graph_array [ 'height' ]  =  '100' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $graph_array [ 'width' ]   =  '215' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $graph_array [ 'to' ]      =  $config [ 'time' ][ 'now' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $graph_array [ 'id' ]      =  $service [ 'service_id' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $graph_array [ 'type' ]    =  'service_availability' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $periods  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'day' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'week' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'month' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'year' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  '<tr style="background-color: ' . $bg . '; padding: 5px;"><td colspan=6>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $periods  as  $period )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $graph_array [ 'from' ]             =  $$period ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $graph_array_zoom            =  $graph_array ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $graph_array_zoom [ 'height' ]  =  '150' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $graph_array_zoom [ 'width' ]   =  '400' ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-16 12:42:58 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                echo  overlib_link ( '' ,  generate_lazy_graph_tag ( $graph_array ),  generate_graph_tag ( $graph_array_zoom ),   NULL ); 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-13 20:10:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            echo  '</td></tr>' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } //end if
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } //end foreach
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    unset ( $samehost ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} //end foreach
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-10-17 18:13:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								echo  ' </ table >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</ div > ' ;