diff --git a/application/controllers/Update.php b/application/controllers/Update.php
index 733f9a17e..3eeb84cc6 100644
--- a/application/controllers/Update.php
+++ b/application/controllers/Update.php
@@ -389,11 +389,17 @@ class Update extends CI_Controller {
}
- public function update_tle() {
- $this->load->model('Update_model');
+ public function update_tle() {
+ $this->load->model('Update_model');
$result = $this->Update_model->tle();
echo $result;
- }
+ }
+
+ public function update_lotw_sats() {
+ $this->load->model('Update_model');
+ $result = $this->Update_model->lotw_sats();
+ echo $result;
+ }
function version_check() {
// set the last run in cron table for the correct cron id
diff --git a/application/models/Update_model.php b/application/models/Update_model.php
index ad24d3335..f03626c26 100644
--- a/application/models/Update_model.php
+++ b/application/models/Update_model.php
@@ -359,13 +359,79 @@ class Update_model extends CI_Model {
curl_close($curl);
- $mtime = microtime();
- $mtime = explode(" ",$mtime);
- $mtime = $mtime[1] + $mtime[0];
- $endtime = $mtime;
- $totaltime = ($endtime - $starttime);
- echo "This page was created in ".$totaltime." seconds
";
- echo "Records inserted: " . $count . "
";
+ $mtime = microtime();
+ $mtime = explode(" ",$mtime);
+ $mtime = $mtime[1] + $mtime[0];
+ $endtime = $mtime;
+ $totaltime = ($endtime - $starttime);
+ echo "This page was created in ".$totaltime." seconds
";
+ echo "Records inserted: " . $count . "
";
}
+ function lotw_sats() {
+ $url = 'https://lotw.arrl.org/lotw/config.tq6';
+ $curl = curl_init($url);
+
+ curl_setopt($curl, CURLOPT_FAILONERROR, true);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($curl, CURLOPT_BINARYTRANSFER,true);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 10);
+
+ $response = curl_exec($curl);
+ if (curl_errno($curl)) {
+ echo __('cURL error:').' '.curl_error($curl).' ('.curl_errno($curl).')';
+ return;
+ }
+ curl_close($curl);
+ $xml = simplexml_load_string(gzdecode($response));
+
+ $existingSats = array();
+ $this->db->select('name, lotw');
+ $query = $this->db->get('satellite');
+ foreach($query->result() as $row) {
+ $existingSats[$row->name] = $row->lotw;
+ }
+ //$existingSats = $query->result_array();
+
+ print '
| '.__('Name').' | '.__('Display Name').' | '.__('Start Date').' | '.__('End Date').' | '.__('Status').' |
|---|---|---|---|---|
| '.$name.' | '.$displayname.' | '.$startDate.' | '.$endDate.' | '.$status.' |