2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								< ? php 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if  ( ! file_exists ( " ../config.php " ))  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  header ( " Location: ../ " ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  require_once ( " ../config.php " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  require_once ( " ../classes/constellation.php " ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-07 21:42:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  header ( 'Cache-Control: no-cache' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  header ( 'Content-type: application/json' ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  if  ( ! isset ( $_GET [ 'id' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $array  =  $constellation -> render_status ( true ,  false ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  json_encode ( $array ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $query  =  $mysqli -> prepare ( " SELECT name FROM services WHERE id=? " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $query -> bind_param ( " i " ,  $_GET [ 'id' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $query -> execute (); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    $result  =  $query -> get_result () -> fetch_assoc (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! count ( $result ))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      die ( json_encode ([ " error "  =>  _ ( " Service does not exist! " )])); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    $sql  =  $mysqli -> prepare ( " SELECT type FROM services_status INNER JOIN status ON services_status.status_id = status.id WHERE service_id = ? AND `time` <= ? AND (`end_time` >= ? OR `end_time`=0) ORDER BY `time` DESC LIMIT 1 " ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $sql -> bind_param ( " iii " ,  $id ,  $timestamp ,  $timestamp ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $sql -> execute (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    $tmp  =  $sql -> get_result (); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( $tmp -> num_rows )  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      $service  =  new  Service ( $_GET [ 'id' ],  $result [ 'name' ],  $tmp -> fetch_assoc ()[ 'type' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-13 21:31:03 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      $service  =  new  Service ( $_GET [ 'id' ],  $result [ 'name' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    echo  json_encode ( $service ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-18 18:26:03 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}