2012-04-08 12:17:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Radio extends CI_Controller {
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
2012-11-13 20:14:39 +00:00
|
|
|
// Check Auth
|
|
|
|
$this->load->model('user_model');
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2021-11-14 22:53:35 +00:00
|
|
|
// Check if users logged in
|
|
|
|
|
|
|
|
if($this->user_model->validate_session() == 0) {
|
|
|
|
// user is not logged in
|
|
|
|
redirect('user/login');
|
|
|
|
}
|
2012-04-08 15:47:18 +00:00
|
|
|
// load the view
|
2021-09-20 17:32:41 +00:00
|
|
|
$data['page_title'] = "Hardware Interfaces";
|
2012-04-08 15:47:18 +00:00
|
|
|
|
2019-01-13 15:59:16 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2012-04-08 15:47:18 +00:00
|
|
|
$this->load->view('radio/index');
|
2019-01-13 15:59:16 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-04-08 12:17:14 +00:00
|
|
|
function status() {
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
// Check Auth
|
|
|
|
$this->load->model('user_model');
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2021-11-14 22:53:35 +00:00
|
|
|
// Check if users logged in
|
|
|
|
|
|
|
|
if($this->user_model->validate_session() == 0) {
|
|
|
|
// user is not logged in
|
|
|
|
redirect('user/login');
|
|
|
|
}
|
2022-07-23 16:27:45 +00:00
|
|
|
|
2012-04-08 12:17:14 +00:00
|
|
|
$this->load->model('cat');
|
2012-04-08 15:47:18 +00:00
|
|
|
$query = $this->cat->status();
|
|
|
|
if ($query->num_rows() > 0)
|
|
|
|
{
|
2012-11-13 20:14:39 +00:00
|
|
|
echo "<tr class=\"titles\">";
|
2012-04-08 15:47:18 +00:00
|
|
|
echo "<td>Radio</td>";
|
|
|
|
echo "<td>Frequency</td>";
|
|
|
|
echo "<td>Mode</td>";
|
|
|
|
echo "<td>Timestamp</td>" ;
|
2012-11-13 20:14:39 +00:00
|
|
|
echo "<td>Options</td>";
|
2012-04-08 15:47:18 +00:00
|
|
|
echo "</tr>";
|
|
|
|
foreach ($query->result() as $row)
|
|
|
|
{
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td>".$row->radio."</td>";
|
2022-08-29 00:12:28 +00:00
|
|
|
|
|
|
|
if (empty($row->frequency) || $row->frequency == "0") {
|
|
|
|
echo "<td>- / -</td>";
|
2022-09-29 23:24:10 +00:00
|
|
|
} elseif (empty($row->frequency_rx) || $row->frequency_rx == "0") {
|
2022-05-05 11:17:26 +00:00
|
|
|
echo "<td>".$this->frequency->hz_to_mhz($row->frequency)."</td>";
|
2018-12-18 18:24:01 +00:00
|
|
|
} else {
|
2022-09-29 23:24:10 +00:00
|
|
|
echo "<td>".$this->frequency->hz_to_mhz($row->frequency_rx)." / ".$this->frequency->hz_to_mhz($row->frequency)."</td>";
|
2018-12-18 18:24:01 +00:00
|
|
|
}
|
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
if (empty($row->mode) || $row->mode == "non") {
|
|
|
|
echo "<td>N/A</td>";
|
2022-09-29 23:24:10 +00:00
|
|
|
} elseif (empty($row->mode_rx) || $row->mode_rx == "non") {
|
2018-12-18 18:24:01 +00:00
|
|
|
echo "<td>".$row->mode."</td>";
|
2018-12-18 18:26:01 +00:00
|
|
|
} else {
|
2022-09-29 23:24:10 +00:00
|
|
|
echo "<td>".$row->mode_rx." / ".$row->mode."</td>";
|
2018-12-18 18:24:01 +00:00
|
|
|
}
|
2022-08-29 00:12:28 +00:00
|
|
|
|
2018-12-18 18:24:01 +00:00
|
|
|
$phpdate = strtotime($row->timestamp);
|
|
|
|
echo "<td>".date('H:i:s d-m-y', $phpdate)."</td>" ;
|
2019-06-13 17:09:21 +00: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 15:47:18 +00:00
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
echo "<tr>";
|
|
|
|
echo "<td colspan=\"4\">No CAT Interfaced radios found.</td>";
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
2020-05-12 21:51:56 +00:00
|
|
|
|
2019-02-25 22:40:24 +00:00
|
|
|
function json($id)
|
|
|
|
{
|
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
header('Content-Type: application/json');
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
$this->load->model('cat');
|
2012-11-13 20:14:39 +00:00
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
$query = $this->cat->radio_status($id);
|
2012-11-13 20:14:39 +00:00
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
if ($query->num_rows() > 0)
|
|
|
|
{
|
|
|
|
foreach ($query->result() as $row)
|
2012-04-08 12:17:14 +00:00
|
|
|
{
|
2012-11-13 20:14:39 +00:00
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
$frequency = $row->frequency;
|
2020-05-12 21:51:56 +00:00
|
|
|
|
2022-09-29 23:24:10 +00:00
|
|
|
$frequency_rx = $row->frequency_rx;
|
2019-09-06 15:55:13 +00:00
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
$power = $row->power;
|
2022-04-06 12:50:24 +00:00
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
$prop_mode = $row->prop_mode;
|
2022-04-08 19:47:50 +00:00
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
// Check Mode
|
2022-09-29 23:24:10 +00:00
|
|
|
$mode = strtoupper($row->mode);
|
|
|
|
if ($mode == "FMN") {
|
2022-08-29 00:12:28 +00:00
|
|
|
$mode = "FM";
|
|
|
|
}
|
2016-11-16 16:59:53 +00:00
|
|
|
|
2022-08-29 00:12:28 +00:00
|
|
|
if ($row->prop_mode == "SAT") {
|
2019-09-06 15:55:13 +00:00
|
|
|
// Get Satellite Name
|
2022-09-29 23:24:10 +00:00
|
|
|
if ($row->sat_name == "AO-07") {
|
2019-09-06 15:55:13 +00:00
|
|
|
$sat_name = "AO-7";
|
2017-03-13 21:27:21 +00:00
|
|
|
} elseif ($row->sat_name == "LILACSAT") {
|
2019-09-06 15:55:13 +00:00
|
|
|
$sat_name = "CAS-3H";
|
2017-03-13 21:27:21 +00:00
|
|
|
} else {
|
2019-09-06 15:55:13 +00:00
|
|
|
$sat_name = strtoupper($row->sat_name);
|
2017-03-13 21:27:21 +00:00
|
|
|
}
|
2016-11-16 16:59:53 +00:00
|
|
|
|
2019-09-06 15:55:13 +00:00
|
|
|
// Get Satellite Mode
|
2022-09-29 23:46:54 +00:00
|
|
|
$sat_mode_uplink = $this->get_mode_designator($row->frequency);
|
|
|
|
$sat_mode_downlink = $this->get_mode_designator($row->frequency_rx);
|
2016-11-16 16:59:53 +00:00
|
|
|
|
2022-09-29 23:46:54 +00:00
|
|
|
if (empty($sat_mode_uplink)) {
|
2022-08-29 00:15:46 +00:00
|
|
|
$sat_mode = "";
|
2022-09-29 23:46:54 +00:00
|
|
|
} elseif ($sat_mode_uplink !== $sat_mode_downlink) {
|
|
|
|
$sat_mode = $sat_mode_uplink."/".$sat_mode_downlink;
|
2022-08-29 00:15:46 +00:00
|
|
|
} else {
|
2022-09-29 23:46:54 +00:00
|
|
|
$sat_mode = $sat_mode_uplink;
|
2019-09-06 15:55:13 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$sat_name = "";
|
|
|
|
$sat_mode = "";
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
2019-09-06 15:55:13 +00:00
|
|
|
|
2021-09-20 17:32:41 +00:00
|
|
|
// Calculate how old the data is in minutes
|
2022-07-23 16:27:45 +00:00
|
|
|
$datetime1 = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time
|
|
|
|
$datetime2 = new DateTime($row->timestamp, new DateTimeZone('UTC'));
|
2020-05-12 21:51:56 +00:00
|
|
|
$interval = $datetime1->diff($datetime2);
|
2020-05-12 22:18:16 +00:00
|
|
|
|
|
|
|
$minutes = $interval->days * 24 * 60;
|
|
|
|
$minutes += $interval->h * 60;
|
|
|
|
$minutes += $interval->i;
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2020-05-12 22:18:16 +00:00
|
|
|
$updated_at = $minutes;
|
2019-09-06 15:55:13 +00:00
|
|
|
|
2020-05-12 21:51:56 +00:00
|
|
|
// Return Json data
|
2022-08-29 00:12:28 +00:00
|
|
|
echo json_encode(array(
|
|
|
|
"frequency" => $frequency,
|
|
|
|
"frequency_rx" => $frequency_rx,
|
|
|
|
"mode" => $mode,
|
|
|
|
"satmode" => $sat_mode,
|
|
|
|
"satname" => $sat_name,
|
|
|
|
"power" => $power,
|
|
|
|
"prop_mode" => $prop_mode,
|
|
|
|
"updated_minutes_ago" => $updated_at,
|
|
|
|
), JSON_PRETTY_PRINT);
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
2019-09-06 15:55:13 +00:00
|
|
|
}
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2019-02-25 23:08:06 +00: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-13 20:14:39 +00: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'); }
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
$this->load->model('cat');
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
$this->cat->delete($id);
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
$this->session->set_flashdata('message', 'Radio Profile Deleted');
|
2021-09-20 17:32:41 +00:00
|
|
|
|
2012-11-13 20:14:39 +00:00
|
|
|
redirect('radio');
|
|
|
|
|
|
|
|
}
|
2012-04-08 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2020-05-12 21:51:56 +00:00
|
|
|
|
2019-09-27 16:43:01 +00:00
|
|
|
?>
|