mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Adds download of HF Propagation and Solar Data from HamQSL
This commit is contained in:
@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
||||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 256;
|
||||
$config['migration_version'] = 257;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -112,6 +112,7 @@ class Debug extends CI_Controller
|
||||
$data['wwff_update'] = $this->cron_model->cron('update_update_wwff')->row();
|
||||
$data['tle_update'] = $this->cron_model->cron('update_update_tle')->row();
|
||||
$data['hon_update'] = $this->cron_model->cron('update_update_hamsofnote')->row();
|
||||
$data['hamqsl_update'] = $this->cron_model->cron('update_update_hamqsl')->row();
|
||||
|
||||
$data['page_title'] = __("Debug");
|
||||
|
||||
|
||||
@@ -438,6 +438,25 @@ class Update extends CI_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Pulls the solarxml.php data from hamqsl
|
||||
*/
|
||||
public function update_hamqsl() {
|
||||
|
||||
$this->load->model('Update_model');
|
||||
$result = $this->Update_model->hamqsl();
|
||||
if($this->session->userdata('user_type') == '99') {
|
||||
if (substr($result, 0, 4) == 'DONE') {
|
||||
$this->session->set_flashdata('success', __("HAMqsl Update complete. Result: ") . "'" . $result . "'");
|
||||
} else {
|
||||
$this->session->set_flashdata('error', __("HAMqsl Update failed. Result: ") . "'" . $result . "'");
|
||||
}
|
||||
redirect('debug');
|
||||
} else {
|
||||
echo $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function update_pota() {
|
||||
|
||||
$this->load->model('Update_model');
|
||||
|
||||
31
application/migrations/257_add_cron_hamqsl.php
Normal file
31
application/migrations/257_add_cron_hamqsl.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
class Migration_add_cron_hamqsl extends CI_Migration {
|
||||
|
||||
public function up() {
|
||||
if ($this->db->table_exists('cron')) {
|
||||
|
||||
// add cron job for HAMqsl update
|
||||
$data = array(
|
||||
array(
|
||||
'id' => 'update_update_hamqsl',
|
||||
'enabled' => '1',
|
||||
'status' => 'pending',
|
||||
'description' => 'Download HamQSL HF Propagation Tools and Solar Data',
|
||||
'function' => 'index.php/update/update_hamqsl',
|
||||
'expression' => '0 */1 * * *',
|
||||
'last_run' => null,
|
||||
'next_run' => null
|
||||
)
|
||||
);
|
||||
$this->db->insert_batch('cron', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function down() {
|
||||
|
||||
$this->dbtry("delete from cron where id = 'update_update_hamqsl';");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -177,6 +177,29 @@ class Update_model extends CI_Model {
|
||||
}
|
||||
}
|
||||
|
||||
function hamqsl(){
|
||||
// This downloads and store hamqsl propagation data XML file
|
||||
|
||||
$contents = file_get_contents('https://www.hamqsl.com/solarxml.php', true);
|
||||
|
||||
if ($contents === FALSE) {
|
||||
return "Something went wrong with fetching the solarxml.xml file from HAMqsl website.";
|
||||
} else {
|
||||
$file = './updates/solarxml.xml';
|
||||
|
||||
if (file_put_contents($file, $contents) !== FALSE) { // Save our content to the file.
|
||||
$nCount = count(file($file));
|
||||
if ($nCount > 0) {
|
||||
return "DONE: solarxml.xml downloaded from HAMqsl website.";
|
||||
} else {
|
||||
return "FAILED: Empty file received from HAMqsl website.";
|
||||
}
|
||||
} else {
|
||||
return "FAILED: Could not write solarxml.xml file from HAMqsl website.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pota() {
|
||||
// set the last run in cron table for the correct cron id
|
||||
$this->load->model('cron_model');
|
||||
@@ -499,6 +522,7 @@ class Update_model extends CI_Model {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function update_hams_of_note() {
|
||||
if (($this->optionslib->get_option('hon_url') ?? '') == '') {
|
||||
$file = 'https://api.ham2k.net/data/ham2k/hams-of-note.txt';
|
||||
|
||||
@@ -554,15 +554,20 @@
|
||||
<td><?php echo $wwff_update->last_run ?? __("never"); ?></td>
|
||||
<td><a class="btn btn-sm btn-primary" href="<?php echo site_url('update/update_wwff'); ?>"><?= __("Update"); ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><?= __("TLE update"); ?></td>
|
||||
<td><?php echo $tle_update->last_run ?? __("never"); ?></td>
|
||||
<td><a class="btn btn-sm btn-primary" href="<?php echo site_url('update/update_tle'); ?>"><?= __("Update"); ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td><?= __("Hams Of Note update"); ?></td>
|
||||
<td><?php echo $hon_update->last_run ?? __("never"); ?></td>
|
||||
<td><a class="btn btn-sm btn-primary" href="<?php echo site_url('update/update_hamsofnote'); ?>"><?= __("Update"); ?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= __("HAMqsl"); ?></td>
|
||||
<td><?php echo $hon_update->last_run ?? __("never"); ?></td>
|
||||
<td><a class="btn btn-sm btn-primary" href="<?php echo site_url('update/update_hamqsl'); ?>"><?= __("Update"); ?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user