2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									class  Cat  extends  CI_Model  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:18:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										function  update ( $result ,  $user_id )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> where ( 'radio' ,  $result [ 'radio' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:18:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'user_id' ,  $user_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											$query  =  $this -> db -> get ( 'cat' ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											if  ( $query -> num_rows ()  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if ( $result [ 'radio' ]  ==  " SatPC32 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// Update the record
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													foreach  ( $query -> result ()  as  $row ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$radio_id  =  $row -> id ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															'sat_name'  =>  $result [ 'sat_name' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															'downlink_freq'  =>  $result [ 'downlink_freq' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															'uplink_freq'  =>  $result [ 'uplink_freq' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															'downlink_mode'  =>  $result [ 'downlink_mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															'uplink_mode'  =>  $result [ 'uplink_mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$this -> db -> where ( 'id' ,  $radio_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:18:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$this -> db -> where ( 'user_id' ,  $user_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$this -> db -> update ( 'cat' ,  $data ); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// Update the record
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													foreach  ( $query -> result ()  as  $row ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														$radio_id  =  $row -> id ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'frequency'  =>  $result [ 'frequency' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'mode'  =>  $result [ 'mode' ], 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 03:23:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														'timestamp'  =>  $result [ 'timestamp' ], 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														); 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$this -> db -> where ( 'id' ,  $radio_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-12 16:36:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$this -> db -> where ( 'user_id' ,  $user_id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														$this -> db -> update ( 'cat' ,  $data ); 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// Add a new record
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if ( $result [ 'radio' ]  ==  " SatPC32 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'radio'  =>  $result [ 'radio' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'frequency'  =>  $result [ 'frequency' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'mode'  =>  $result [ 'mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'sat_name'  =>  $result [ 'sat_name' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'downlink_freq'  =>  $result [ 'downlink_freq' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'uplink_freq'  =>  $result [ 'uplink_freq' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'downlink_mode'  =>  $result [ 'downlink_mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'uplink_mode'  =>  $result [ 'uplink_mode' ], 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:18:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														'user_id'  =>  $user_id , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													$data  =  array ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'radio'  =>  $result [ 'radio' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'frequency'  =>  $result [ 'frequency' ], 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 03:23:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														'mode'  =>  $result [ 'mode' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														'timestamp'  =>  $result [ 'timestamp' ], 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 00:18:04 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														'user_id'  =>  $user_id , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-17 00:59:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												$this -> db -> insert ( 'cat' ,  $data ); 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										function  status ()  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											//$this->db->where('radio', $result['radio']);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> where ( 'user_id' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 20:17:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$query  =  $this -> db -> get ( 'cat' ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 23:47:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-03 21:06:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										function  recent_status ()  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'user_id' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-28 01:18:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( " timestamp > date_sub(UTC_TIMESTAMP(), interval 15 minute) " ,  NULL ,  FALSE ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-03 21:06:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$query  =  $this -> db -> get ( 'cat' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 20:17:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										/* Return list of radios */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function  radios ()  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> select ( 'id, radio' ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'user_id' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 20:17:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$query  =  $this -> db -> get ( 'cat' ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 20:17:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  $query ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-06 23:55:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function  radio_status ( $id )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$sql  =  'SELECT *, CONVERT_TZ(`timestamp`, @@session.time_zone, \'+00:00\' ) as newtime FROM `cat` WHERE id = '  .  $id  .  ' and user_id ='  .  $this -> session -> userdata ( 'user_id' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  $this -> db -> query ( $sql ); 
							 
						 
					
						
							
								
									
										
										
										
											2019-09-06 23:55:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-11-14 04:14:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										function  delete ( $id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> where ( 'id' ,  $id ); 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 21:03:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$this -> db -> where ( 'user_id' ,  $this -> session -> userdata ( 'user_id' )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$this -> db -> delete ( 'cat' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2012-11-14 04:14:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2012-04-08 00:36:38 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 03:23:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>