@@ -68,6 +68,10 @@ public function runAll(): array
68
68
'hashtime ' => $ this ->checkHashTime (),
69
69
];
70
70
71
+ foreach (['affiliations ' , 'banners ' , 'countries ' , 'teams ' ] as $ key ) {
72
+ $ config ['publicdirwritable_ ' . $ key ] = $ this ->checkPublicdirWritable ($ key );
73
+ }
74
+
71
75
$ results ['Configuration ' ] = $ config ;
72
76
$ this ->stopwatch ->stopSection ('Configuration ' );
73
77
@@ -356,30 +360,55 @@ public function checkDebugDisabled(): ConfigCheckItem
356
360
);
357
361
}
358
362
359
- public function checkTmpdirWritable ( ): ConfigCheckItem
363
+ public function checkDirWritable ( string $ directory , string $ name , string $ success_description , string $ warning_description ): ConfigCheckItem
360
364
{
361
365
$ this ->stopwatch ->start (__FUNCTION__ );
362
- $ tmpdir = $ this ->dj ->getDomjudgeTmpDir ();
363
- if (is_writable ($ tmpdir )) {
366
+ if (is_writable ($ directory )) {
364
367
$ this ->stopwatch ->stop (__FUNCTION__ );
365
368
return new ConfigCheckItem (
366
- caption: ' TMPDIR writable ' ,
369
+ caption: $ name . ' writable ' ,
367
370
result: 'O ' ,
368
- desc: sprintf ('TMPDIR (`%s`) can be used to store temporary ' .
369
- 'files for submission diffs and edits. ' ,
370
- $ tmpdir )
371
+ desc: $ success_description ,
371
372
);
372
373
}
373
374
$ this ->stopwatch ->stop (__FUNCTION__ );
374
375
return new ConfigCheckItem (
375
- caption: ' TMPDIR writable ' ,
376
+ caption: $ name . ' writable ' ,
376
377
result: 'W ' ,
377
- desc: sprintf ('TMPDIR (`%s`) is not writable by the webserver; ' .
378
+ desc: $ warning_description ,
379
+ );
380
+ }
381
+
382
+ public function checkTmpdirWritable (): ConfigCheckItem
383
+ {
384
+ $ tmpdir = $ this ->dj ->getDomjudgeTmpDir ();
385
+ return $ this ->checkDirWritable (
386
+ $ tmpdir ,
387
+ 'TMPDIR ' ,
388
+ sprintf ('TMPDIR (`%s`) can be used to store temporary ' .
389
+ 'files for submission diffs and edits. ' ,
390
+ $ tmpdir ),
391
+ sprintf ('TMPDIR (`%s`) is not writable by the webserver; ' .
378
392
'Showing diffs and editing of submissions may not work. ' ,
379
393
$ tmpdir )
380
394
);
381
395
}
382
396
397
+ public function checkPublicdirWritable (string $ directory ): ConfigCheckItem
398
+ {
399
+ $ dir = $ this ->dj ->getDomjudgeWebappDir () . '/public/images/ ' . $ directory ;
400
+ return $ this ->checkDirWritable (
401
+ $ dir ,
402
+ 'PUBLICDIR_ ' . strtoupper ($ directory ),
403
+ sprintf ('The public directory (`%s`) can be used to store ' .
404
+ ' images, logo \'s and other resources for team affiliations. ' ,
405
+ $ dir ),
406
+ sprintf ('The public Organization directory (`%s`) is not writable by the webserver; ' .
407
+ 'Uploading images such as photo \'s and logo \'s may not work. ' ,
408
+ $ dir )
409
+ );
410
+ }
411
+
383
412
private function randomString (int $ length ): string
384
413
{
385
414
$ characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' ;
0 commit comments