diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php index 4bb744ee2..720af2d2d 100644 --- a/application/controllers/Lotw.php +++ b/application/controllers/Lotw.php @@ -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 diff --git a/application/language/english/lotw_lang.php b/application/language/english/lotw_lang.php index abaeacddf..ce3d63fe2 100644 --- a/application/language/english/lotw_lang.php +++ b/application/language/english/lotw_lang.php @@ -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.'; diff --git a/application/views/lotw_views/index.php b/application/views/lotw_views/index.php index 28f0a5b99..64a53a166 100644 --- a/application/views/lotw_views/index.php +++ b/application/views/lotw_views/index.php @@ -1,4 +1,9 @@