mirror of
https://github.com/Studio-42/elFinder
synced 2026-06-08 12:37:09 +00:00
[php] add PHP error handler and remove @ error-control operator
This commit is contained in:
@@ -131,7 +131,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
// set $this->tmp by options['tmpPath']
|
||||
$this->tmp = '';
|
||||
if (!empty($this->options['tmpPath'])) {
|
||||
if ((is_dir($this->options['tmpPath']) || @mkdir($this->options['tmpPath'], 0755, true)) && is_writable($this->options['tmpPath'])) {
|
||||
if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'], 0755, true)) && is_writable($this->options['tmpPath'])) {
|
||||
$this->tmp = $this->options['tmpPath'];
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
return false;
|
||||
}
|
||||
$path = realpath($path);
|
||||
$mtime = @filemtime($path);
|
||||
$mtime = filemtime($path);
|
||||
if (! $mtime) {
|
||||
return false;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
if ($r === 0) {
|
||||
// changed
|
||||
clearstatcache();
|
||||
$mtime = @filemtime($path); // error on busy?
|
||||
$mtime = filemtime($path); // error on busy?
|
||||
return $mtime? $mtime : time();
|
||||
} else if ($r === 2) {
|
||||
// not changed (timeout)
|
||||
@@ -464,7 +464,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
$stat['alias'] = $this->_path($target);
|
||||
$stat['target'] = $target;
|
||||
}
|
||||
$size = sprintf('%u', @filesize($path));
|
||||
$size = sprintf('%u', filesize($path));
|
||||
$stat['ts'] = filemtime($path);
|
||||
if ($statOwner) {
|
||||
$fstat = stat($path);
|
||||
@@ -598,7 +598,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
**/
|
||||
protected function _dimensions($path, $mime) {
|
||||
clearstatcache();
|
||||
return strpos($mime, 'image') === 0 && ($s = @getimagesize($path)) !== false
|
||||
return strpos($mime, 'image') === 0 && ($s = getimagesize($path)) !== false
|
||||
? $s[0].'x'.$s[1]
|
||||
: false;
|
||||
}
|
||||
@@ -612,7 +612,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function readlink($path) {
|
||||
if (!($target = @readlink($path))) {
|
||||
if (!($target = readlink($path))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -736,7 +736,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
*/
|
||||
protected function _fopen($path, $mode='rb') {
|
||||
return @fopen($path, $mode);
|
||||
return fopen($path, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -748,7 +748,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
*/
|
||||
protected function _fclose($fp, $path='') {
|
||||
return @fclose($fp);
|
||||
return fclose($fp);
|
||||
}
|
||||
|
||||
/******************** file/dir manipulations *************************/
|
||||
@@ -764,8 +764,8 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
protected function _mkdir($path, $name) {
|
||||
$path = $this->_joinPath($path, $name);
|
||||
|
||||
if (@mkdir($path)) {
|
||||
@chmod($path, $this->options['dirMode']);
|
||||
if (mkdir($path)) {
|
||||
chmod($path, $this->options['dirMode']);
|
||||
clearstatcache();
|
||||
return $path;
|
||||
}
|
||||
@@ -784,9 +784,9 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
protected function _mkfile($path, $name) {
|
||||
$path = $this->_joinPath($path, $name);
|
||||
|
||||
if (($fp = @fopen($path, 'w'))) {
|
||||
@fclose($fp);
|
||||
@chmod($path, $this->options['fileMode']);
|
||||
if (($fp = fopen($path, 'w'))) {
|
||||
fclose($fp);
|
||||
chmod($path, $this->options['fileMode']);
|
||||
clearstatcache();
|
||||
return $path;
|
||||
}
|
||||
@@ -803,7 +803,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function _symlink($source, $targetDir, $name) {
|
||||
return @symlink($source, $this->_joinPath($targetDir, $name));
|
||||
return symlink($source, $this->_joinPath($targetDir, $name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -816,7 +816,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function _copy($source, $targetDir, $name) {
|
||||
$mtime = @filemtime($source);
|
||||
$mtime = filemtime($source);
|
||||
$target = $this->_joinPath($targetDir, $name);
|
||||
if ($ret = copy($source, $target)) {
|
||||
isset($this->options['keepTimestamp']['copy']) && $mtime && touch($target, $mtime);
|
||||
@@ -837,9 +837,9 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
*/
|
||||
protected function _move($source, $targetDir, $name) {
|
||||
$mtime = @filemtime($source);
|
||||
$mtime = filemtime($source);
|
||||
$target = $this->_joinPath($targetDir, $name);
|
||||
if ($ret = @rename($source, $target) ? $target : false) {
|
||||
if ($ret = rename($source, $target) ? $target : false) {
|
||||
isset($this->options['keepTimestamp']['move']) && $mtime && touch($target, $mtime);
|
||||
clearstatcache();
|
||||
}
|
||||
@@ -854,7 +854,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function _unlink($path) {
|
||||
$ret = @unlink($path);
|
||||
$ret = unlink($path);
|
||||
$ret && clearstatcache();
|
||||
return $ret;
|
||||
}
|
||||
@@ -867,7 +867,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function _rmdir($path) {
|
||||
$ret = @rmdir($path);
|
||||
$ret = rmdir($path);
|
||||
$ret && clearstatcache();
|
||||
return $ret;
|
||||
}
|
||||
@@ -889,11 +889,11 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
$meta = stream_get_meta_data($fp);
|
||||
$uri = isset($meta['uri'])? $meta['uri'] : '';
|
||||
if ($uri && ! preg_match('#^[a-zA-Z0-9]+://#', $uri)) {
|
||||
@fclose($fp);
|
||||
$mtime = @filemtime($uri);
|
||||
fclose($fp);
|
||||
$mtime = filemtime($uri);
|
||||
$isCmdPaste = ($this->ARGS['cmd'] === 'paste');
|
||||
$isCmdCopy = ($isCmdPaste && empty($this->ARGS['cut']));
|
||||
if (($isCmdCopy || !@rename($uri, $path)) && !@copy($uri, $path)) {
|
||||
if (($isCmdCopy || !rename($uri, $path)) && !copy($uri, $path)) {
|
||||
return false;
|
||||
}
|
||||
// keep timestamp on upload
|
||||
@@ -903,7 +903,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
// re-create the source file for remove processing of paste command
|
||||
$isCmdPaste && !$isCmdCopy && touch($uri);
|
||||
} else {
|
||||
if (@file_put_contents($path, $fp, LOCK_EX) === false) {
|
||||
if (file_put_contents($path, $fp, LOCK_EX) === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -913,7 +913,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
return $this->setError(elFinder::ERROR_SAVE, $name);
|
||||
}
|
||||
|
||||
@chmod($path, $this->options['fileMode']);
|
||||
chmod($path, $this->options['fileMode']);
|
||||
clearstatcache();
|
||||
return $path;
|
||||
}
|
||||
@@ -938,7 +938,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
* @author Dmitry (dio) Levashov
|
||||
**/
|
||||
protected function _filePutContents($path, $content) {
|
||||
if (@file_put_contents($path, $content, LOCK_EX) !== false) {
|
||||
if (file_put_contents($path, $content, LOCK_EX) !== false) {
|
||||
clearstatcache();
|
||||
return true;
|
||||
}
|
||||
@@ -964,7 +964,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
*/
|
||||
protected function _chmod($path, $mode) {
|
||||
$modeOct = is_string($mode) ? octdec($mode) : octdec(sprintf("%04o",$mode));
|
||||
$ret = @chmod($path, $modeOct);
|
||||
$ret = chmod($path, $modeOct);
|
||||
$ret && clearstatcache();
|
||||
return $ret;
|
||||
}
|
||||
@@ -1020,7 +1020,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
$dir = $this->quarantine.DIRECTORY_SEPARATOR.md5(basename($path).mt_rand());
|
||||
$archive = $dir.DIRECTORY_SEPARATOR.basename($path);
|
||||
|
||||
if (!@mkdir($dir)) {
|
||||
if (!mkdir($dir)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1085,7 +1085,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
if ($name !== '') {
|
||||
$result = dirname($path).DIRECTORY_SEPARATOR.$name;
|
||||
|
||||
if (! @rename($src, $result)) {
|
||||
if (! rename($src, $result)) {
|
||||
$this->delTree($dir);
|
||||
return false;
|
||||
}
|
||||
@@ -1098,7 +1098,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
|
||||
if (is_dir($target)) {
|
||||
$this->delTree($target);
|
||||
}
|
||||
if (@rename($dir.DIRECTORY_SEPARATOR.$name, $target)) {
|
||||
if (rename($dir.DIRECTORY_SEPARATOR.$name, $target)) {
|
||||
$result[] = $target;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user