kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #2675 from HB9HIL/check-folder-permissions
Debug View - Check File Permissions recursivepull/2684/head
commit
838051452c
|
@ -15,48 +15,16 @@ class Debug extends CI_Controller {
|
|||
$this->load->helper('file');
|
||||
|
||||
// Test writing to backup folder
|
||||
if ( ! write_file('backup/myfile.txt', "dummydata"))
|
||||
{
|
||||
$data['backup_folder'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(unlink(realpath('backup/myfile.txt'))) {
|
||||
$data['backup_folder'] = true;
|
||||
} else {
|
||||
$data['backup_folder'] = false;
|
||||
}
|
||||
}
|
||||
$backup_folder = $this->is_really_writable('backup');
|
||||
$data['backup_folder'] = $backup_folder;
|
||||
|
||||
// Test writing to updates folder
|
||||
if ( ! write_file('updates/myfile.txt', "dummydata"))
|
||||
{
|
||||
$data['updates_folder'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(unlink(realpath('updates/myfile.txt'))) {
|
||||
$data['updates_folder'] = true;
|
||||
} else {
|
||||
$data['updates_folder'] = false;
|
||||
}
|
||||
}
|
||||
$updates_folder = $this->is_really_writable('updates');
|
||||
$data['updates_folder'] = $updates_folder;
|
||||
|
||||
// Test writing to uploads folder
|
||||
if ( ! write_file('uploads/myfile.txt', "dummydata"))
|
||||
{
|
||||
$data['uploads_folder'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(unlink(realpath('uploads/myfile.txt'))) {
|
||||
$data['uploads_folder'] = true;
|
||||
} else {
|
||||
$data['uploads_folder'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$uploads_folder = $this->is_really_writable('uploads');
|
||||
$data['uploads_folder'] = $uploads_folder;
|
||||
|
||||
$data['page_title'] = "Debug";
|
||||
|
||||
|
@ -65,5 +33,29 @@ class Debug extends CI_Controller {
|
|||
$this->load->view('interface_assets/footer');
|
||||
}
|
||||
|
||||
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 (!is_writable($item->getPathname())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue