Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapted to configurable paths #29

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions classes/Problems/EssentialFolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,37 @@ public function __construct()
public function process()
{
$essential_folders = [
'backup' => true,
'cache' => true,
'logs' => true,
'images' => true,
'assets' => true,
'system' => false,
'user/data' => true,
'user/pages' => false,
'user/config' => false,
'user/plugins/error' => false,
'user/plugins' => false,
'user/themes' => false,
'vendor' => false,
'tmp' => true,
(str_starts_with(GRAV_BACKUP_PATH, '/') ? '' : ROOT_DIR) . GRAV_BACKUP_PATH => true,
(str_starts_with(GRAV_CACHE_PATH, '/') ? '' : ROOT_DIR) . GRAV_CACHE_PATH => true,
(str_starts_with(GRAV_LOG_PATH, '/') ? '' : ROOT_DIR) . GRAV_LOG_PATH => true,
GRAV_WEBROOT . '/images' => true,
GRAV_WEBROOT . '/assets' => true,
(str_starts_with(GRAV_SYSTEM_PATH, '/') ? '' : ROOT_DIR) . GRAV_SYSTEM_PATH => false,
USER_DIR . 'data' => true,
USER_DIR . 'pages' => false,
USER_DIR . 'config' => false,
USER_DIR . 'plugins/error' => false,
USER_DIR . 'plugins' => false,
USER_DIR . 'themes' => false,
ROOT_DIR . 'vendor' => false,
(str_starts_with(GRAV_TMP_PATH, '/') ? '' : ROOT_DIR) . GRAV_TMP_PATH => false,
];

// Check for essential files & perms
$file_errors = [];
$file_success = [];

foreach ($essential_folders as $file => $check_writable) {
$file_path = ROOT_DIR . $file;

foreach ($essential_folders as $file_path => $check_writable) {
if (!file_exists($file_path)) {
$file_errors[$file_path] = 'does not exist';
} elseif ($check_writable && !is_writable($file_path)) {
$file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
} elseif (!$check_writable) {
$file_success[$file_path] = 'exists';
} else {
$file_success[$file_path] = 'exists and is writable';
if (is_writable($file_path)) {
$file_success[$file_path] = 'exists and is writable';
} else {
$file_errors[$file_path] = 'exists but is <strong>not writeable</strong>';
}
}
}

Expand All @@ -63,4 +65,4 @@ public function process()

return $this;
}
}
}