Skip to content
Merged
Changes from all commits
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
47 changes: 38 additions & 9 deletions webapp/src/Service/CheckConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public function runAll(): array
'hashtime' => $this->checkHashTime(),
];

foreach (['affiliations', 'banners', 'countries', 'teams'] as $key) {
$config['publicdirwritable_' . $key] = $this->checkPublicdirWritable($key);
}

$results['Configuration'] = $config;
$this->stopwatch->stopSection('Configuration');

Expand Down Expand Up @@ -356,30 +360,55 @@ public function checkDebugDisabled(): ConfigCheckItem
);
}

public function checkTmpdirWritable(): ConfigCheckItem
public function checkDirWritable(string $directory, string $name, string $success_description, string $warning_description): ConfigCheckItem
{
$this->stopwatch->start(__FUNCTION__);
$tmpdir = $this->dj->getDomjudgeTmpDir();
if (is_writable($tmpdir)) {
if (is_writable($directory)) {
$this->stopwatch->stop(__FUNCTION__);
return new ConfigCheckItem(
caption: 'TMPDIR writable',
caption: $name . ' writable',
result: 'O',
desc: sprintf('TMPDIR (`%s`) can be used to store temporary ' .
'files for submission diffs and edits.',
$tmpdir)
desc: $success_description,
);
}
$this->stopwatch->stop(__FUNCTION__);
return new ConfigCheckItem(
caption: 'TMPDIR writable',
caption: $name . ' writable',
result: 'W',
desc: sprintf('TMPDIR (`%s`) is not writable by the webserver; ' .
desc: $warning_description,
);
}

public function checkTmpdirWritable(): ConfigCheckItem
{
$tmpdir = $this->dj->getDomjudgeTmpDir();
return $this->checkDirWritable(
$tmpdir,
'TMPDIR',
sprintf('TMPDIR (`%s`) can be used to store temporary ' .
'files for submission diffs and edits.',
$tmpdir),
sprintf('TMPDIR (`%s`) is not writable by the webserver; ' .
'Showing diffs and editing of submissions may not work.',
$tmpdir)
);
}

public function checkPublicdirWritable(string $directory): ConfigCheckItem
{
$dir = $this->dj->getDomjudgeWebappDir() . '/public/images/' . $directory;
return $this->checkDirWritable(
$dir,
'PUBLICDIR_' . strtoupper($directory),
sprintf('The public directory (`%s`) can be used to store ' .
' images, logo\'s and other resources for team affiliations.',
$dir),
sprintf('The public Organization directory (`%s`) is not writable by the webserver; ' .
'Uploading images such as photo\'s and logo\'s may not work.',
$dir)
);
}

private function randomString(int $length): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Expand Down
Loading