Skip to content

Commit

Permalink
add log notify about trouble with ENV encoding
Browse files Browse the repository at this point in the history
начинающиеся с «#» будут проигнорированы, а пустое сообщение
  • Loading branch information
tolanych committed Sep 26, 2019
1 parent aad01d9 commit bc6261f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/model/modx/processors/browser/file/remove.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function process() {
if (empty($file)) {
return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
}
$oldlocale = setlocale(LC_ALL, 0);
setlocale(LC_ALL,'C.UTF-8');
$pathinfo = pathinfo($file);
setlocale(LC_ALL,$oldlocale);
if ($pathinfo['dirname'].DIRECTORY_SEPARATOR.$pathinfo['basename'] != $file) {
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $file . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
}
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
$name = htmlspecialchars($pathinfo['basename']);
$path = $directory.DIRECTORY_SEPARATOR.$name;
Expand Down
9 changes: 6 additions & 3 deletions core/model/modx/processors/browser/file/rename.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ public function process() {
}

$oldFile = $this->getProperty('path');
$oldlocale = setlocale(LC_ALL, 0);
setlocale(LC_ALL,'C.UTF-8');
$pathinfo = pathinfo($oldFile);
if ($pathinfo['dirname'].DIRECTORY_SEPARATOR.$pathinfo['basename'] != $oldFile) {
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $oldFile . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
}
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
$name = htmlspecialchars($pathinfo['basename']);
$oldFile = $directory.DIRECTORY_SEPARATOR.$name;

$newFile = $this->getProperty('name');
$pathinfo = pathinfo($newFile);
if ($pathinfo['basename'] != $newFile) {
$this->modx->log (modX::LOG_LEVEL_ERROR, 'Could not prepare the filepath ' . $newFile . '. Please set a valid UTF8 capable locale in the MODX system setting "locale".');
}
$directory = preg_replace('/[\.]{2,}/', '', htmlspecialchars($pathinfo['dirname']));
$name = htmlspecialchars($pathinfo['basename']);
$newFile = $directory.DIRECTORY_SEPARATOR.$name;
setlocale(LC_ALL,$oldlocale);
$success = $this->source->renameObject($oldFile, $newFile);

if (empty($success)) {
Expand Down

0 comments on commit bc6261f

Please sign in to comment.