mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Show hint about upload permissions on LotW page
This commit is contained in:
@@ -55,6 +55,10 @@ class Lotw extends CI_Controller {
|
||||
// Set Page Title
|
||||
$data['page_title'] = "Logbook of the World";
|
||||
|
||||
// Check folder permissions
|
||||
$uploads_folder = $this->is_really_writable('uploads');
|
||||
$data['uploads_folder'] = $uploads_folder;
|
||||
|
||||
// Load Views
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('lotw_views/index');
|
||||
@@ -1123,4 +1127,31 @@ class Lotw extends CI_Controller {
|
||||
endswitch;
|
||||
}
|
||||
|
||||
private function is_really_writable($folder) {
|
||||
// Get the absolute path to the folder
|
||||
$path = FCPATH . $folder;
|
||||
|
||||
// Check if the folder exists
|
||||
if (!file_exists($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the folder is writable
|
||||
if (is_writable($path)) {
|
||||
// Check if the subdirectories are writable (recursive check)
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDir() && basename($item->getPathName()) != '..') {
|
||||
if (!is_writable($item->getRealPath())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end class
|
||||
|
||||
@@ -61,3 +61,6 @@ $lang['lotw_cert_expired'] = 'At least one of your LoTW certificates is expired!
|
||||
// Lotw User
|
||||
$lang['lotw_user'] = 'This station uses LoTW.';
|
||||
$lang['lotw_last_upload'] = 'Last upload';
|
||||
|
||||
// Upload folder permissions
|
||||
$lang['lotw_upload_folder_permissions'] = 'Upload folder is not writable. Please contact your admin.';
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<div class="container lotw">
|
||||
<?php if($uploads_folder != true) { ?>
|
||||
<div class="alert alert-warning" role="alert" style="margin-top: 1rem;">
|
||||
<span class="badge text-bg-info"><?php echo lang('general_word_important'); ?></span> <i class="fas fa-ban"></i> <?php echo lang('lotw_upload_folder_permissions'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<br>
|
||||
<a class="btn btn-outline-primary btn-sm float-end" href="<?php echo site_url('/lotw/import'); ?>" role="button"><i class="fas fa-cloud-download-alt"></i> <?php echo lang('lotw_btn_lotw_import'); ?></a>
|
||||
<h2><?php echo lang('lotw_title'); ?></h2>
|
||||
|
||||
Reference in New Issue
Block a user