Check file/dir permissions prior to LoTW download

This commit is contained in:
phl0 2023-12-10 22:27:20 +01:00
parent dd94f5bb86
commit 8e668a930c
No known key found for this signature in database
GPG Key ID: 48EA1E640798CA9A
2 changed files with 25 additions and 4 deletions

View File

@ -746,10 +746,24 @@ class Lotw extends CI_Controller {
$lotw_url .= "&qso_owncall=".$this->input->post('callsign');
}
file_put_contents($file, file_get_contents($lotw_url));
if (is_writable(dirname($file)) && (!file_exists($file) || is_writable($file))) {
file_put_contents($file, file_get_contents($lotw_url));
ini_set('memory_limit', '-1');
$this->loadFromFile($file);
ini_set('memory_limit', '-1');
$this->loadFromFile($file);
} else {
if (!is_writable(dirname($file))) {
$data['errormsg'] = 'Directory '.dirname($file).' is not writable!';
} else if (!is_writable($file)) {
$data['errormsg'] = 'File '.$file.' is not writable!';
}
$this->load->model('Stations');
$data['callsigns'] = $this->Stations->callsigns_of_user($this->session->userdata('user_id'));
$this->load->view('interface_assets/header', $data);
$this->load->view('lotw/import', $data);
$this->load->view('interface_assets/footer');
}
}
else
{

View File

@ -2,10 +2,17 @@
<h2><?php echo lang('lotw_title'); ?> - <?php echo lang('lotw_title_adif_import'); ?></h2>
<?php if (isset($errormsg)) { ?>
<div class="alert alert-danger" role="alert">
<?php echo $errormsg; ?>
</div>
<?php } ?>
<div class="card">
<div class="card-header"><?php echo lang('lotw_title_adif_import_options'); ?></div>
<div class="card-body">
<?php $this->load->view('layout/messages'); ?>
<?php echo form_open_multipart('lotw/import'); ?>
@ -60,4 +67,4 @@
</div>
</div>
</div>
</div>