Last active
May 21, 2020 19:15
-
-
Save ig0r74/d1fdd58a78b3e1a5016efdea3482507f to your computer and use it in GitHub Desktop.
Запрещаем загрузку файлов в корень сайта MODX Revolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
switch($modx->event->name){ | |
case 'OnFileManagerUpload': | |
$source = & $scriptProperties['source']; | |
if(!$source->hasErrors()){ | |
/* | |
Запрещаем загрузку в корень, точнее удаляем новый файл, | |
так как в MODX нет нормальной обработки событий на загрузку файлов, | |
чтобы запретить загрузку | |
*/ | |
if($directory == '/' && $files){ | |
foreach($files as $file){ | |
$path = $directory . $source->fileHandler->sanitizePath($file['name']); | |
$source->removeObject($path); | |
} | |
$source->addError('path', "Нельзя загружать файлы в корневой раздел."); | |
} | |
} | |
break; | |
default:; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment