Skip to content

Instantly share code, notes, and snippets.

@ig0r74
Last active May 21, 2020 19:15
Show Gist options
  • Save ig0r74/d1fdd58a78b3e1a5016efdea3482507f to your computer and use it in GitHub Desktop.
Save ig0r74/d1fdd58a78b3e1a5016efdea3482507f to your computer and use it in GitHub Desktop.
Запрещаем загрузку файлов в корень сайта MODX Revolution
<?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