fix incorrect parameter type for mkdir() and chmod()

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-01-25 15:47:37 +01:00
parent 6fdf2636fc
commit 61dfeb947f

View File

@@ -2,6 +2,7 @@
namespace Froxlor\Settings; namespace Froxlor\Settings;
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\FileDir;
use Froxlor\Settings; use Froxlor\Settings;
class Store class Store
@@ -373,20 +374,21 @@ class Store
if (isset($fielddata['settinggroup'], $fielddata['varname']) && is_array($fielddata) && $fielddata['settinggroup'] !== '' && $fielddata['varname'] !== '') { if (isset($fielddata['settinggroup'], $fielddata['varname']) && is_array($fielddata) && $fielddata['settinggroup'] !== '' && $fielddata['varname'] !== '') {
$save_to = null; $save_to = null;
$path = \Froxlor\Froxlor::getInstallDir().'/img/'; $path = \Froxlor\Froxlor::getInstallDir().'/img/';
$path = \Froxlor\FileDir::makeCorrectDir($path);
// New file? // New file?
if (isset($_FILES[$fieldname]) && $_FILES[$fieldname]['tmp_name']) { if (isset($_FILES[$fieldname]) && $_FILES[$fieldname]['tmp_name']) {
// Make sure upload directory exists // Make sure upload directory exists
if (!is_dir($path) && !mkdir($path, '0775')) { if (!is_dir($path) && !mkdir($path, 0775)) {
throw new \Exception("img directory does not exist and cannot be created"); throw new \Exception("img directory does not exist and cannot be created");
} }
// Make sure we can write to the upload directory // Make sure we can write to the upload directory
if (!is_writable($path)) { if (!is_writable($path)) {
if (!chmod($path, '0775')) { if (!chmod($path, 0775)) {
throw new \Exception("Cannot write to img directory"); throw new \Exception("Cannot write to img directory");
} }
} }
// Make sure mime-type matches an image // Make sure mime-type matches an image
if (!in_array(mime_content_type($_FILES[$fieldname]['tmp_name']), ['image/jpeg','image/jpg','image/png','image/gif'])) { if (!in_array(mime_content_type($_FILES[$fieldname]['tmp_name']), ['image/jpeg','image/jpg','image/png','image/gif'])) {