| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	class Radio extends CI_Controller { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public function index() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 		// load the view
 | 
					
						
							|  |  |  | 		$data['page_title'] = "Radio Status"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-13 23:59:16 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 		$this->load->view('radio/index'); | 
					
						
							| 
									
										
										
										
											2019-01-13 23:59:16 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	function status() { | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 		$this->load->model('cat'); | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 		$query = $this->cat->status(); | 
					
						
							|  |  |  | 		if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 			echo "<tr class=\"titles\">"; | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 				echo "<td>Radio</td>"; | 
					
						
							|  |  |  | 				echo "<td>Frequency</td>"; | 
					
						
							|  |  |  | 				echo "<td>Mode</td>"; | 
					
						
							|  |  |  | 				echo "<td>Timestamp</td>" ; | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 				echo "<td>Options</td>"; | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 			echo "</tr>"; | 
					
						
							|  |  |  | 			foreach ($query->result() as $row) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				echo "<tr>"; | 
					
						
							|  |  |  | 				echo "<td>".$row->radio."</td>"; | 
					
						
							| 
									
										
										
										
											2018-12-19 02:24:01 +08:00
										 |  |  | 				if($row->frequency != "0") { | 
					
						
							|  |  |  | 					echo "<td>".$row->frequency."</td>"; | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					echo "<td>".$row->downlink_freq." / ".$row->uplink_freq."</td>"; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if($row->mode != "non") { | 
					
						
							|  |  |  | 					echo "<td>".$row->mode."</td>"; | 
					
						
							| 
									
										
										
										
											2018-12-19 02:26:01 +08:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2018-12-19 02:24:01 +08:00
										 |  |  | 					echo "<td>".$row->uplink_mode."</td>"; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				$phpdate = strtotime($row->timestamp); | 
					
						
							|  |  |  | 				echo "<td>".date('H:i:s d-m-y', $phpdate)."</td>" ; | 
					
						
							| 
									
										
										
										
											2019-06-14 01:09:21 +08:00
										 |  |  | 				echo "<td><a href=\"".site_url('radio/delete')."/".$row->id."\" class=\"btn btn-danger\"> <i class=\"fas fa-trash-alt\"></i> Delete</a></td>" ; | 
					
						
							| 
									
										
										
										
											2012-04-08 23:47:18 +08:00
										 |  |  | 				echo "</tr>"; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			echo "<tr>"; | 
					
						
							|  |  |  | 				echo "<td colspan=\"4\">No CAT Interfaced radios found.</td>"; | 
					
						
							|  |  |  | 			echo "</tr>"; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 			 | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 	function json($id) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 		$frequency = $this->frequency($id);  | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 		echo json_encode(array( | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 			"uplink_freq" => $frequency['uplink_freq'], | 
					
						
							|  |  |  | 			"downlink_freq" => $frequency['downlink_freq'], | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 			"mode" => $this->mode($id), | 
					
						
							|  |  |  | 			"satmode" => $this->satmode($id), | 
					
						
							|  |  |  | 			"satname" => $this->satname($id), | 
					
						
							|  |  |  | 		), JSON_PRETTY_PRINT); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 	function frequency($id) { | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 		//$this->db->where('radio', $result['radio']); 
 | 
					
						
							|  |  |  | 			$this->db->select('frequency'); | 
					
						
							|  |  |  | 			$this->db->where('id', $id);  | 
					
						
							|  |  |  | 			$query = $this->db->get('cat'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 			   foreach ($query->result() as $row) | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 					if( $row->frequency == "0") { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:13:09 +08:00
										 |  |  | 						$this->db->select('uplink_freq, downlink_freq'); | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 						$this->db->where('id', $id);  | 
					
						
							|  |  |  | 						$query = $this->db->get('cat'); | 
					
						
							|  |  |  | 						 | 
					
						
							|  |  |  | 						if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 						{ | 
					
						
							| 
									
										
										
										
											2019-02-26 06:13:09 +08:00
										 |  |  | 							foreach ($query->result() as $row) | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 							{ | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 								return array("downlink_freq" => strtoupper($row->downlink_freq), "uplink_freq" => strtoupper($row->uplink_freq)); | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 							} | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 						return array("downlink_freq" => "", "uplink_freq" => strtoupper($row->frequency));	 | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 		return array("downlink_freq" => "", "uplink_freq" => "");  | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	function mode($id) { | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 	 | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 		//$this->db->where('radio', $result['radio']); 
 | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 			$this->db->select('mode, radio, uplink_mode'); | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 			$this->db->where('id', $id);  | 
					
						
							|  |  |  | 			$query = $this->db->get('cat'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 			   foreach ($query->result() as $row) | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 					if($row->radio != "SatPC32") { | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						if(strtoupper($row->mode) == "FMN"){ | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 							return "FM"; | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						} else { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 							return strtoupper($row->mode); | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						if(strtoupper($row->uplink_mode) == "FMN"){ | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 							return "FM"; | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						} else { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 							return strtoupper($row->uplink_mode); | 
					
						
							| 
									
										
										
										
											2016-11-18 23:45:34 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 		return ""; | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function satname($id) { | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//$this->db->where('radio', $result['radio']); 
 | 
					
						
							|  |  |  | 			$this->db->select('sat_name'); | 
					
						
							|  |  |  | 			$this->db->where('id', $id);  | 
					
						
							|  |  |  | 			$query = $this->db->get('cat'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 			   foreach ($query->result() as $row) | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2017-03-14 05:27:21 +08:00
										 |  |  | 					if($row->sat_name == "AO-07") { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 						return "AO-7"; | 
					
						
							| 
									
										
										
										
											2017-03-14 05:27:21 +08:00
										 |  |  | 					} elseif ($row->sat_name == "LILACSAT") { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 						return "CAS-3H"; | 
					
						
							| 
									
										
										
										
											2017-03-14 05:27:21 +08:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 						return strtoupper($row->sat_name); | 
					
						
							| 
									
										
										
										
											2017-03-14 05:27:21 +08:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 		return ""; | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	function satmode($id) { | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//$this->db->where('radio', $result['radio']); 
 | 
					
						
							|  |  |  | 			$this->db->select('uplink_freq, downlink_freq'); | 
					
						
							|  |  |  | 			$this->db->where('id', $id);  | 
					
						
							|  |  |  | 			$query = $this->db->get('cat'); | 
					
						
							|  |  |  | 			 | 
					
						
							|  |  |  | 			if ($query->num_rows() > 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 			   foreach ($query->result() as $row) | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 					$uplink_mode = $this->get_mode_designator($row->uplink_freq);  | 
					
						
							|  |  |  | 					$downlink_mode = $this->get_mode_designator($row->downlink_freq);  | 
					
						
							| 
									
										
										
										
											2016-11-17 00:59:53 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-26 06:17:00 +08:00
										 |  |  | 					if ($uplink_mode != "" && $downlink_mode != "") | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 						return $uplink_mode."/".$downlink_mode; | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-02-26 06:40:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			return "";  | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2019-02-26 07:08:06 +08:00
										 |  |  | 	function get_mode_designator($frequency) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		if ($frequency > 21000000 && $frequency < 22000000) | 
					
						
							|  |  |  | 			return "H"; | 
					
						
							|  |  |  | 		if ($frequency > 28000000 && $frequency < 30000000) | 
					
						
							|  |  |  | 			return "A"; | 
					
						
							|  |  |  | 		if ($frequency > 144000000 && $frequency < 147000000) | 
					
						
							|  |  |  | 			return "V"; | 
					
						
							|  |  |  | 		if ($frequency > 432000000 && $frequency < 438000000) | 
					
						
							|  |  |  | 			return "U"; | 
					
						
							|  |  |  | 		if ($frequency > 1240000000 && $frequency < 1300000000) | 
					
						
							|  |  |  | 			return "L"; | 
					
						
							|  |  |  | 		if ($frequency > 2320000000 && $frequency < 2450000000) | 
					
						
							|  |  |  | 			return "S"; | 
					
						
							|  |  |  | 		if ($frequency > 3400000000 && $frequency < 3475000000) | 
					
						
							|  |  |  | 			return "S2"; | 
					
						
							|  |  |  | 		if ($frequency > 5650000000 && $frequency < 5850000000) | 
					
						
							|  |  |  | 			return "C"; | 
					
						
							|  |  |  | 		if ($frequency > 10000000000 && $frequency < 10500000000) | 
					
						
							|  |  |  | 			return "X"; | 
					
						
							|  |  |  | 		if ($frequency > 24000000000 && $frequency < 24250000000) | 
					
						
							|  |  |  | 			return "K"; | 
					
						
							|  |  |  | 		if ($frequency > 47000000000 && $frequency < 47200000000) | 
					
						
							|  |  |  | 			return "R"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return ""; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-14 04:14:39 +08:00
										 |  |  | 	function delete($id) { | 
					
						
							|  |  |  | 		// Check Auth
 | 
					
						
							|  |  |  | 		$this->load->model('user_model'); | 
					
						
							|  |  |  | 		if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$this->load->model('cat'); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$this->cat->delete($id); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		$this->session->set_flashdata('message', 'Radio Profile Deleted'); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		redirect('radio'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-04-08 20:17:14 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |