Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/php
File: elFinder.class.php
const ERROR_EXTRACT_EXEC = 'errExtractExec';
[500] Fix | Delete
const ERROR_FILE_NOT_FOUND = 'errFileNotFound'; // 'File not found.'
[501] Fix | Delete
const ERROR_FTP_DOWNLOAD_FILE = 'errFtpDownloadFile';
[502] Fix | Delete
const ERROR_FTP_MKDIR = 'errFtpMkdir';
[503] Fix | Delete
const ERROR_FTP_UPLOAD_FILE = 'errFtpUploadFile';
[504] Fix | Delete
const ERROR_INV_PARAMS = 'errCmdParams';
[505] Fix | Delete
const ERROR_INVALID_DIRNAME = 'errInvDirname'; // 'Invalid folder name.'
[506] Fix | Delete
const ERROR_INVALID_NAME = 'errInvName'; // 'Invalid file name.'
[507] Fix | Delete
const ERROR_LOCKED = 'errLocked'; // '"$1" is locked and can not be renamed, moved or removed.'
[508] Fix | Delete
const ERROR_MAX_TARGTES = 'errMaxTargets'; // 'Max number of selectable items is $1.'
[509] Fix | Delete
const ERROR_MKDIR = 'errMkdir';
[510] Fix | Delete
const ERROR_MKFILE = 'errMkfile';
[511] Fix | Delete
const ERROR_MKOUTLINK = 'errMkOutLink'; // 'Unable to create a link to outside the volume root.'
[512] Fix | Delete
const ERROR_MOVE = 'errMove';
[513] Fix | Delete
const ERROR_NETMOUNT = 'errNetMount';
[514] Fix | Delete
const ERROR_NETMOUNT_FAILED = 'errNetMountFailed';
[515] Fix | Delete
const ERROR_NETMOUNT_NO_DRIVER = 'errNetMountNoDriver';
[516] Fix | Delete
const ERROR_NETUNMOUNT = 'errNetUnMount';
[517] Fix | Delete
const ERROR_NOT_ARCHIVE = 'errNoArchive';
[518] Fix | Delete
const ERROR_NOT_DIR = 'errNotFolder';
[519] Fix | Delete
const ERROR_NOT_FILE = 'errNotFile';
[520] Fix | Delete
const ERROR_NOT_REPLACE = 'errNotReplace'; // Object "$1" already exists at this location and can not be replaced with object of another type.
[521] Fix | Delete
const ERROR_NOT_UTF8_CONTENT = 'errNotUTF8Content';
[522] Fix | Delete
const ERROR_OPEN = 'errOpen';
[523] Fix | Delete
const ERROR_PERM_DENIED = 'errPerm';
[524] Fix | Delete
const ERROR_REAUTH_REQUIRE = 'errReauthRequire'; // 'Re-authorization is required.'
[525] Fix | Delete
const ERROR_RENAME = 'errRename';
[526] Fix | Delete
const ERROR_REPLACE = 'errReplace'; // 'Unable to replace "$1".'
[527] Fix | Delete
const ERROR_RESIZE = 'errResize';
[528] Fix | Delete
const ERROR_RESIZESIZE = 'errResizeSize';
[529] Fix | Delete
const ERROR_RM = 'errRm'; // 'Unable to remove "$1".'
[530] Fix | Delete
const ERROR_RM_SRC = 'errRmSrc'; // 'Unable remove source file(s)'
[531] Fix | Delete
const ERROR_SAVE = 'errSave';
[532] Fix | Delete
const ERROR_SEARCH_TIMEOUT = 'errSearchTimeout'; // 'Timed out while searching "$1". Search result is partial.'
[533] Fix | Delete
const ERROR_SESSION_EXPIRES = 'errSessionExpires';
[534] Fix | Delete
const ERROR_TRGDIR_NOT_FOUND = 'errTrgFolderNotFound'; // 'Target folder "$1" not found.'
[535] Fix | Delete
const ERROR_UNKNOWN = 'errUnknown';
[536] Fix | Delete
const ERROR_UNKNOWN_CMD = 'errUnknownCmd';
[537] Fix | Delete
const ERROR_UNSUPPORT_TYPE = 'errUsupportType';
[538] Fix | Delete
const ERROR_UPLOAD = 'errUpload'; // 'Upload error.'
[539] Fix | Delete
const ERROR_UPLOAD_FILE = 'errUploadFile'; // 'Unable to upload "$1".'
[540] Fix | Delete
const ERROR_UPLOAD_FILE_MIME = 'errUploadMime'; // 'File type not allowed.'
[541] Fix | Delete
const ERROR_UPLOAD_FILE_SIZE = 'errUploadFileSize'; // 'File exceeds maximum allowed size.'
[542] Fix | Delete
const ERROR_UPLOAD_NO_FILES = 'errUploadNoFiles'; // 'No files found for upload.'
[543] Fix | Delete
const ERROR_UPLOAD_TEMP = 'errUploadTemp'; // 'Unable to make temporary file for upload.'
[544] Fix | Delete
const ERROR_UPLOAD_TOTAL_SIZE = 'errUploadTotalSize'; // 'Data exceeds the maximum allowed size.'
[545] Fix | Delete
const ERROR_UPLOAD_TRANSFER = 'errUploadTransfer'; // '"$1" transfer error.'
[546] Fix | Delete
const ERROR_MAX_MKDIRS = 'errMaxMkdirs'; // 'You can create up to $1 folders at one time.'
[547] Fix | Delete
[548] Fix | Delete
/**
[549] Fix | Delete
* Constructor
[550] Fix | Delete
*
[551] Fix | Delete
* @param array elFinder and roots configurations
[552] Fix | Delete
*
[553] Fix | Delete
* @author Dmitry (dio) Levashov
[554] Fix | Delete
*/
[555] Fix | Delete
public function __construct($opts)
[556] Fix | Delete
{
[557] Fix | Delete
// set default_charset
[558] Fix | Delete
if (version_compare(PHP_VERSION, '5.6', '>=')) {
[559] Fix | Delete
if (($_val = ini_get('iconv.internal_encoding')) && strtoupper($_val) !== 'UTF-8') {
[560] Fix | Delete
ini_set('iconv.internal_encoding', '');
[561] Fix | Delete
}
[562] Fix | Delete
if (($_val = ini_get('mbstring.internal_encoding')) && strtoupper($_val) !== 'UTF-8') {
[563] Fix | Delete
ini_set('mbstring.internal_encoding', '');
[564] Fix | Delete
}
[565] Fix | Delete
if (($_val = ini_get('internal_encoding')) && strtoupper($_val) !== 'UTF-8') {
[566] Fix | Delete
ini_set('internal_encoding', '');
[567] Fix | Delete
}
[568] Fix | Delete
} else {
[569] Fix | Delete
if (function_exists('iconv_set_encoding') && strtoupper(iconv_get_encoding('internal_encoding')) !== 'UTF-8') {
[570] Fix | Delete
iconv_set_encoding('internal_encoding', 'UTF-8');
[571] Fix | Delete
}
[572] Fix | Delete
if (function_exists('mb_internal_encoding') && strtoupper(mb_internal_encoding()) !== 'UTF-8') {
[573] Fix | Delete
mb_internal_encoding('UTF-8');
[574] Fix | Delete
}
[575] Fix | Delete
}
[576] Fix | Delete
ini_set('default_charset', 'UTF-8');
[577] Fix | Delete
[578] Fix | Delete
// define accept constant of server commands path
[579] Fix | Delete
!defined('ELFINDER_TAR_PATH') && define('ELFINDER_TAR_PATH', 'tar');
[580] Fix | Delete
!defined('ELFINDER_GZIP_PATH') && define('ELFINDER_GZIP_PATH', 'gzip');
[581] Fix | Delete
!defined('ELFINDER_BZIP2_PATH') && define('ELFINDER_BZIP2_PATH', 'bzip2');
[582] Fix | Delete
!defined('ELFINDER_XZ_PATH') && define('ELFINDER_XZ_PATH', 'xz');
[583] Fix | Delete
!defined('ELFINDER_ZIP_PATH') && define('ELFINDER_ZIP_PATH', 'zip');
[584] Fix | Delete
!defined('ELFINDER_UNZIP_PATH') && define('ELFINDER_UNZIP_PATH', 'unzip');
[585] Fix | Delete
!defined('ELFINDER_RAR_PATH') && define('ELFINDER_RAR_PATH', 'rar');
[586] Fix | Delete
// Create archive in RAR4 format even when using RAR5 library (true or false)
[587] Fix | Delete
!defined('ELFINDER_RAR_MA4') && define('ELFINDER_RAR_MA4', false);
[588] Fix | Delete
!defined('ELFINDER_UNRAR_PATH') && define('ELFINDER_UNRAR_PATH', 'unrar');
[589] Fix | Delete
!defined('ELFINDER_7Z_PATH') && define('ELFINDER_7Z_PATH', (substr(PHP_OS, 0, 3) === 'WIN') ? '7z' : '7za');
[590] Fix | Delete
!defined('ELFINDER_CONVERT_PATH') && define('ELFINDER_CONVERT_PATH', 'convert');
[591] Fix | Delete
!defined('ELFINDER_IDENTIFY_PATH') && define('ELFINDER_IDENTIFY_PATH', 'identify');
[592] Fix | Delete
!defined('ELFINDER_EXIFTRAN_PATH') && define('ELFINDER_EXIFTRAN_PATH', 'exiftran');
[593] Fix | Delete
!defined('ELFINDER_JPEGTRAN_PATH') && define('ELFINDER_JPEGTRAN_PATH', 'jpegtran');
[594] Fix | Delete
!defined('ELFINDER_FFMPEG_PATH') && define('ELFINDER_FFMPEG_PATH', 'ffmpeg');
[595] Fix | Delete
[596] Fix | Delete
!defined('ELFINDER_DISABLE_ZIPEDITOR') && define('ELFINDER_DISABLE_ZIPEDITOR', false);
[597] Fix | Delete
[598] Fix | Delete
// enable(true)/disable(false) handling postscript on ImageMagick
[599] Fix | Delete
// Should be `false` as long as there is a Ghostscript vulnerability
[600] Fix | Delete
// see https://artifex.com/news/ghostscript-security-resolved/
[601] Fix | Delete
!defined('ELFINDER_IMAGEMAGICK_PS') && define('ELFINDER_IMAGEMAGICK_PS', false);
[602] Fix | Delete
[603] Fix | Delete
// for backward compat
[604] Fix | Delete
$this->version = (string)self::$ApiVersion;
[605] Fix | Delete
[606] Fix | Delete
// set error handler of WARNING, NOTICE
[607] Fix | Delete
$errLevel = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_RECOVERABLE_ERROR;
[608] Fix | Delete
if (defined('E_DEPRECATED')) {
[609] Fix | Delete
$errLevel |= E_DEPRECATED | E_USER_DEPRECATED;
[610] Fix | Delete
}
[611] Fix | Delete
set_error_handler('elFinder::phpErrorHandler', $errLevel);
[612] Fix | Delete
[613] Fix | Delete
// Associative array of file pointers to close at the end of script: ['temp file pointer' => true]
[614] Fix | Delete
$GLOBALS['elFinderTempFps'] = array();
[615] Fix | Delete
// Associative array of files to delete at the end of script: ['temp file path' => true]
[616] Fix | Delete
$GLOBALS['elFinderTempFiles'] = array();
[617] Fix | Delete
// regist Shutdown function
[618] Fix | Delete
register_shutdown_function(array('elFinder', 'onShutdown'));
[619] Fix | Delete
[620] Fix | Delete
// convert PATH_INFO to GET query
[621] Fix | Delete
if (!empty($_SERVER['PATH_INFO'])) {
[622] Fix | Delete
$_ps = explode('/', trim($_SERVER['PATH_INFO'], '/'));
[623] Fix | Delete
if (!isset($_GET['cmd'])) {
[624] Fix | Delete
$_cmd = $_ps[0];
[625] Fix | Delete
if (isset($this->commands[$_cmd])) {
[626] Fix | Delete
$_GET['cmd'] = $_cmd;
[627] Fix | Delete
$_i = 1;
[628] Fix | Delete
foreach (array_keys($this->commands[$_cmd]) as $_k) {
[629] Fix | Delete
if (isset($_ps[$_i])) {
[630] Fix | Delete
if (!isset($_GET[$_k])) {
[631] Fix | Delete
$_GET[$_k] = $_ps[$_i++];
[632] Fix | Delete
}
[633] Fix | Delete
} else {
[634] Fix | Delete
break;
[635] Fix | Delete
}
[636] Fix | Delete
}
[637] Fix | Delete
}
[638] Fix | Delete
}
[639] Fix | Delete
}
[640] Fix | Delete
[641] Fix | Delete
// set elFinder instance
[642] Fix | Delete
elFinder::$instance = $this;
[643] Fix | Delete
[644] Fix | Delete
// setup debug mode
[645] Fix | Delete
$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);
[646] Fix | Delete
if ($this->debug) {
[647] Fix | Delete
error_reporting(defined('ELFINDER_DEBUG_ERRORLEVEL') ? ELFINDER_DEBUG_ERRORLEVEL : -1);
[648] Fix | Delete
ini_set('display_errors', '1');
[649] Fix | Delete
// clear output buffer and stop output filters
[650] Fix | Delete
while (ob_get_level() && ob_end_clean()) {
[651] Fix | Delete
}
[652] Fix | Delete
}
[653] Fix | Delete
[654] Fix | Delete
if (!interface_exists('elFinderSessionInterface')) {
[655] Fix | Delete
include_once dirname(__FILE__) . '/elFinderSessionInterface.php';
[656] Fix | Delete
}
[657] Fix | Delete
[658] Fix | Delete
// session handler
[659] Fix | Delete
if (!empty($opts['session']) && $opts['session'] instanceof elFinderSessionInterface) {
[660] Fix | Delete
$this->session = $opts['session'];
[661] Fix | Delete
} else {
[662] Fix | Delete
$sessionOpts = array(
[663] Fix | Delete
'base64encode' => !empty($opts['base64encodeSessionData']),
[664] Fix | Delete
'keys' => array(
[665] Fix | Delete
'default' => !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches',
[666] Fix | Delete
'netvolume' => !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes'
[667] Fix | Delete
)
[668] Fix | Delete
);
[669] Fix | Delete
if (!class_exists('elFinderSession')) {
[670] Fix | Delete
include_once dirname(__FILE__) . '/elFinderSession.php';
[671] Fix | Delete
}
[672] Fix | Delete
$this->session = new elFinderSession($sessionOpts);
[673] Fix | Delete
}
[674] Fix | Delete
// try session start | restart
[675] Fix | Delete
$this->session->start();
[676] Fix | Delete
[677] Fix | Delete
// 'netmount' added to handle requests synchronously on unmount
[678] Fix | Delete
$sessionUseCmds = array('netmount');
[679] Fix | Delete
if (isset($opts['sessionUseCmds']) && is_array($opts['sessionUseCmds'])) {
[680] Fix | Delete
$sessionUseCmds = array_merge($sessionUseCmds, $opts['sessionUseCmds']);
[681] Fix | Delete
}
[682] Fix | Delete
[683] Fix | Delete
// set self::$volumesCnt by HTTP header "X-elFinder-VolumesCntStart"
[684] Fix | Delete
if (isset($_SERVER['HTTP_X_ELFINDER_VOLUMESCNTSTART']) && ($volumesCntStart = intval($_SERVER['HTTP_X_ELFINDER_VOLUMESCNTSTART']))) {
[685] Fix | Delete
self::$volumesCnt = $volumesCntStart;
[686] Fix | Delete
}
[687] Fix | Delete
[688] Fix | Delete
$this->time = $this->utime();
[689] Fix | Delete
$this->sessionCloseEarlier = isset($opts['sessionCloseEarlier']) ? (bool)$opts['sessionCloseEarlier'] : true;
[690] Fix | Delete
$this->sessionUseCmds = array_flip($sessionUseCmds);
[691] Fix | Delete
$this->timeout = (isset($opts['timeout']) ? $opts['timeout'] : 0);
[692] Fix | Delete
$this->uploadTempPath = (isset($opts['uploadTempPath']) ? $opts['uploadTempPath'] : '');
[693] Fix | Delete
$this->callbackWindowURL = (isset($opts['callbackWindowURL']) ? $opts['callbackWindowURL'] : '');
[694] Fix | Delete
$this->maxTargets = (isset($opts['maxTargets']) ? intval($opts['maxTargets']) : $this->maxTargets);
[695] Fix | Delete
elFinder::$commonTempPath = (isset($opts['commonTempPath']) ? realpath($opts['commonTempPath']) : dirname(__FILE__) . '/.tmp');
[696] Fix | Delete
if (!is_writable(elFinder::$commonTempPath)) {
[697] Fix | Delete
elFinder::$commonTempPath = sys_get_temp_dir();
[698] Fix | Delete
if (!is_writable(elFinder::$commonTempPath)) {
[699] Fix | Delete
elFinder::$commonTempPath = '';
[700] Fix | Delete
}
[701] Fix | Delete
}
[702] Fix | Delete
if (isset($opts['connectionFlagsPath']) && is_writable($opts['connectionFlagsPath'] = realpath($opts['connectionFlagsPath']))) {
[703] Fix | Delete
elFinder::$connectionFlagsPath = $opts['connectionFlagsPath'];
[704] Fix | Delete
} else {
[705] Fix | Delete
elFinder::$connectionFlagsPath = elFinder::$commonTempPath;
[706] Fix | Delete
}
[707] Fix | Delete
[708] Fix | Delete
if (!empty($opts['tmpLinkPath'])) {
[709] Fix | Delete
elFinder::$tmpLinkPath = realpath($opts['tmpLinkPath']);
[710] Fix | Delete
}
[711] Fix | Delete
if (!empty($opts['tmpLinkUrl'])) {
[712] Fix | Delete
elFinder::$tmpLinkUrl = $opts['tmpLinkUrl'];
[713] Fix | Delete
}
[714] Fix | Delete
if (!empty($opts['tmpLinkLifeTime'])) {
[715] Fix | Delete
elFinder::$tmpLinkLifeTime = $opts['tmpLinkLifeTime'];
[716] Fix | Delete
}
[717] Fix | Delete
if (!empty($opts['textMimes']) && is_array($opts['textMimes'])) {
[718] Fix | Delete
elfinder::$textMimes = $opts['textMimes'];
[719] Fix | Delete
}
[720] Fix | Delete
if (!empty($opts['urlUploadFilter'])) {
[721] Fix | Delete
$this->urlUploadFilter = $opts['urlUploadFilter'];
[722] Fix | Delete
}
[723] Fix | Delete
$this->maxArcFilesSize = isset($opts['maxArcFilesSize']) ? intval($opts['maxArcFilesSize']) : 0;
[724] Fix | Delete
$this->optionsNetVolumes = (isset($opts['optionsNetVolumes']) && is_array($opts['optionsNetVolumes'])) ? $opts['optionsNetVolumes'] : array();
[725] Fix | Delete
if (isset($opts['itemLockExpire'])) {
[726] Fix | Delete
$this->itemLockExpire = intval($opts['itemLockExpire']);
[727] Fix | Delete
}
[728] Fix | Delete
[729] Fix | Delete
if (!empty($opts['uploadAllowedLanIpClasses'])) {
[730] Fix | Delete
$this->uploadAllowedLanIpClasses = array_flip($opts['uploadAllowedLanIpClasses']);
[731] Fix | Delete
}
[732] Fix | Delete
[733] Fix | Delete
// deprecated settings
[734] Fix | Delete
$this->netVolumesSessionKey = !empty($opts['netVolumesSessionKey']) ? $opts['netVolumesSessionKey'] : 'elFinderNetVolumes';
[735] Fix | Delete
self::$sessionCacheKey = !empty($opts['sessionCacheKey']) ? $opts['sessionCacheKey'] : 'elFinderCaches';
[736] Fix | Delete
[737] Fix | Delete
// check session cache
[738] Fix | Delete
$_optsMD5 = md5(json_encode($opts['roots']));
[739] Fix | Delete
if ($this->session->get('_optsMD5') !== $_optsMD5) {
[740] Fix | Delete
$this->session->set('_optsMD5', $_optsMD5);
[741] Fix | Delete
}
[742] Fix | Delete
[743] Fix | Delete
// setlocale and global locale regists to elFinder::locale
[744] Fix | Delete
self::$locale = !empty($opts['locale']) ? $opts['locale'] : (substr(PHP_OS, 0, 3) === 'WIN' ? 'C' : 'en_US.UTF-8');
[745] Fix | Delete
if (false === setlocale(LC_ALL, self::$locale)) {
[746] Fix | Delete
self::$locale = setlocale(LC_ALL, '0');
[747] Fix | Delete
}
[748] Fix | Delete
[749] Fix | Delete
// set defaultMimefile
[750] Fix | Delete
elFinder::$defaultMimefile = isset($opts['defaultMimefile']) ? $opts['defaultMimefile'] : '';
[751] Fix | Delete
[752] Fix | Delete
// set memoryLimitGD
[753] Fix | Delete
elFinder::$memoryLimitGD = isset($opts['memoryLimitGD']) ? $opts['memoryLimitGD'] : 0;
[754] Fix | Delete
[755] Fix | Delete
// set flag of throwErrorOnExec
[756] Fix | Delete
// `true` need `try{}` block for `$connector->run();`
[757] Fix | Delete
$this->throwErrorOnExec = !empty($opts['throwErrorOnExec']);
[758] Fix | Delete
[759] Fix | Delete
// set archivers
[760] Fix | Delete
elFinder::$archivers = isset($opts['archivers']) && is_array($opts['archivers']) ? $opts['archivers'] : array();
[761] Fix | Delete
[762] Fix | Delete
// set utf8Encoder
[763] Fix | Delete
if (isset($opts['utf8Encoder']) && is_callable($opts['utf8Encoder'])) {
[764] Fix | Delete
$this->utf8Encoder = $opts['utf8Encoder'];
[765] Fix | Delete
}
[766] Fix | Delete
[767] Fix | Delete
// for LocalFileSystem driver on Windows server
[768] Fix | Delete
if (DIRECTORY_SEPARATOR !== '/') {
[769] Fix | Delete
if (empty($opts['bind'])) {
[770] Fix | Delete
$opts['bind'] = array();
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
$_key = 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre';
[774] Fix | Delete
if (!isset($opts['bind'][$_key])) {
[775] Fix | Delete
$opts['bind'][$_key] = array();
[776] Fix | Delete
}
[777] Fix | Delete
array_push($opts['bind'][$_key], 'Plugin.WinRemoveTailDots.cmdPreprocess');
[778] Fix | Delete
[779] Fix | Delete
$_key = 'upload.presave paste.copyfrom';
[780] Fix | Delete
if (!isset($opts['bind'][$_key])) {
[781] Fix | Delete
$opts['bind'][$_key] = array();
[782] Fix | Delete
}
[783] Fix | Delete
array_push($opts['bind'][$_key], 'Plugin.WinRemoveTailDots.onUpLoadPreSave');
[784] Fix | Delete
}
[785] Fix | Delete
[786] Fix | Delete
// bind events listeners
[787] Fix | Delete
if (!empty($opts['bind']) && is_array($opts['bind'])) {
[788] Fix | Delete
$_req = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
[789] Fix | Delete
$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
[790] Fix | Delete
foreach ($opts['bind'] as $cmd => $handlers) {
[791] Fix | Delete
$doRegist = (strpos($cmd, '*') !== false);
[792] Fix | Delete
if (!$doRegist) {
[793] Fix | Delete
$doRegist = ($_reqCmd && in_array($_reqCmd, array_map('elFinder::getCmdOfBind', explode(' ', $cmd))));
[794] Fix | Delete
}
[795] Fix | Delete
if ($doRegist) {
[796] Fix | Delete
// for backward compatibility
[797] Fix | Delete
if (!is_array($handlers)) {
[798] Fix | Delete
$handlers = array($handlers);
[799] Fix | Delete
} else {
[800] Fix | Delete
if (count($handlers) === 2 && is_callable($handlers)) {
[801] Fix | Delete
$handlers = array($handlers);
[802] Fix | Delete
}
[803] Fix | Delete
}
[804] Fix | Delete
foreach ($handlers as $handler) {
[805] Fix | Delete
if ($handler) {
[806] Fix | Delete
if (is_string($handler) && strpos($handler, '.')) {
[807] Fix | Delete
list($_domain, $_name, $_method) = array_pad(explode('.', $handler), 3, '');
[808] Fix | Delete
if (strcasecmp($_domain, 'plugin') === 0) {
[809] Fix | Delete
if ($plugin = $this->getPluginInstance($_name, isset($opts['plugin'][$_name]) ? $opts['plugin'][$_name] : array())
[810] Fix | Delete
and method_exists($plugin, $_method)) {
[811] Fix | Delete
$this->bind($cmd, array($plugin, $_method));
[812] Fix | Delete
}
[813] Fix | Delete
}
[814] Fix | Delete
} else {
[815] Fix | Delete
$this->bind($cmd, $handler);
[816] Fix | Delete
}
[817] Fix | Delete
}
[818] Fix | Delete
}
[819] Fix | Delete
}
[820] Fix | Delete
}
[821] Fix | Delete
}
[822] Fix | Delete
[823] Fix | Delete
if (!isset($opts['roots']) || !is_array($opts['roots'])) {
[824] Fix | Delete
$opts['roots'] = array();
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
// try to enable elFinderVolumeFlysystemZipArchiveNetmount to zip editing
[828] Fix | Delete
if (empty(elFinder::$netDrivers['ziparchive'])) {
[829] Fix | Delete
elFinder::$netDrivers['ziparchive'] = 'FlysystemZipArchiveNetmount';
[830] Fix | Delete
}
[831] Fix | Delete
[832] Fix | Delete
// check for net volumes stored in session
[833] Fix | Delete
$netVolumes = $this->getNetVolumes();
[834] Fix | Delete
foreach ($netVolumes as $key => $root) {
[835] Fix | Delete
if (!isset($root['id'])) {
[836] Fix | Delete
// given fixed unique id
[837] Fix | Delete
if (!$root['id'] = $this->getNetVolumeUniqueId($netVolumes)) {
[838] Fix | Delete
$this->mountErrors[] = 'Netmount Driver "' . $root['driver'] . '" : Could\'t given volume id.';
[839] Fix | Delete
continue;
[840] Fix | Delete
}
[841] Fix | Delete
}
[842] Fix | Delete
$root['_isNetVolume'] = true;
[843] Fix | Delete
$opts['roots'][$key] = $root;
[844] Fix | Delete
}
[845] Fix | Delete
[846] Fix | Delete
// "mount" volumes
[847] Fix | Delete
foreach ($opts['roots'] as $i => $o) {
[848] Fix | Delete
$class = 'elFinderVolume' . (isset($o['driver']) ? $o['driver'] : '');
[849] Fix | Delete
[850] Fix | Delete
if (class_exists($class)) {
[851] Fix | Delete
/* @var elFinderVolumeDriver $volume */
[852] Fix | Delete
$volume = new $class();
[853] Fix | Delete
[854] Fix | Delete
try {
[855] Fix | Delete
if ($this->maxArcFilesSize && (empty($o['maxArcFilesSize']) || $this->maxArcFilesSize < $o['maxArcFilesSize'])) {
[856] Fix | Delete
$o['maxArcFilesSize'] = $this->maxArcFilesSize;
[857] Fix | Delete
}
[858] Fix | Delete
// pass session handler
[859] Fix | Delete
$volume->setSession($this->session);
[860] Fix | Delete
if (!$this->default) {
[861] Fix | Delete
$volume->setNeedOnline(true);
[862] Fix | Delete
}
[863] Fix | Delete
if ($volume->mount($o)) {
[864] Fix | Delete
// unique volume id (ends on "_") - used as prefix to files hash
[865] Fix | Delete
$id = $volume->id();
[866] Fix | Delete
[867] Fix | Delete
$this->volumes[$id] = $volume;
[868] Fix | Delete
if ((!$this->default || $volume->root() !== $volume->defaultPath()) && $volume->isReadable()) {
[869] Fix | Delete
$this->default = $volume;
[870] Fix | Delete
}
[871] Fix | Delete
} else {
[872] Fix | Delete
if (!empty($o['_isNetVolume'])) {
[873] Fix | Delete
$this->removeNetVolume($i, $volume);
[874] Fix | Delete
}
[875] Fix | Delete
$this->mountErrors[] = 'Driver "' . $class . '" : ' . implode(' ', $volume->error());
[876] Fix | Delete
}
[877] Fix | Delete
} catch (Exception $e) {
[878] Fix | Delete
if (!empty($o['_isNetVolume'])) {
[879] Fix | Delete
$this->removeNetVolume($i, $volume);
[880] Fix | Delete
}
[881] Fix | Delete
$this->mountErrors[] = 'Driver "' . $class . '" : ' . $e->getMessage();
[882] Fix | Delete
}
[883] Fix | Delete
} else {
[884] Fix | Delete
if (!empty($o['_isNetVolume'])) {
[885] Fix | Delete
$this->removeNetVolume($i, $volume);
[886] Fix | Delete
}
[887] Fix | Delete
$this->mountErrors[] = 'Driver "' . $class . '" does not exist';
[888] Fix | Delete
}
[889] Fix | Delete
}
[890] Fix | Delete
[891] Fix | Delete
// if at least one readable volume - ii desu >_<
[892] Fix | Delete
$this->loaded = !empty($this->default);
[893] Fix | Delete
[894] Fix | Delete
// restore error handler for now
[895] Fix | Delete
restore_error_handler();
[896] Fix | Delete
}
[897] Fix | Delete
[898] Fix | Delete
/**
[899] Fix | Delete
* Return elFinder session wrapper instance
[900] Fix | Delete
*
[901] Fix | Delete
* @return elFinderSessionInterface
[902] Fix | Delete
**/
[903] Fix | Delete
public function getSession()
[904] Fix | Delete
{
[905] Fix | Delete
return $this->session;
[906] Fix | Delete
}
[907] Fix | Delete
[908] Fix | Delete
/**
[909] Fix | Delete
* Return true if fm init correctly
[910] Fix | Delete
*
[911] Fix | Delete
* @return bool
[912] Fix | Delete
* @author Dmitry (dio) Levashov
[913] Fix | Delete
**/
[914] Fix | Delete
public function loaded()
[915] Fix | Delete
{
[916] Fix | Delete
return $this->loaded;
[917] Fix | Delete
}
[918] Fix | Delete
[919] Fix | Delete
/**
[920] Fix | Delete
* Return version (api) number
[921] Fix | Delete
*
[922] Fix | Delete
* @return string
[923] Fix | Delete
* @author Dmitry (dio) Levashov
[924] Fix | Delete
**/
[925] Fix | Delete
public function version()
[926] Fix | Delete
{
[927] Fix | Delete
return self::$ApiVersion;
[928] Fix | Delete
}
[929] Fix | Delete
[930] Fix | Delete
/**
[931] Fix | Delete
* Return revision (api) number
[932] Fix | Delete
*
[933] Fix | Delete
* @return string
[934] Fix | Delete
* @author Naoki Sawada
[935] Fix | Delete
**/
[936] Fix | Delete
public function revision()
[937] Fix | Delete
{
[938] Fix | Delete
return self::$ApiRevision;
[939] Fix | Delete
}
[940] Fix | Delete
[941] Fix | Delete
/**
[942] Fix | Delete
* Add handler to elFinder command
[943] Fix | Delete
*
[944] Fix | Delete
* @param string command name
[945] Fix | Delete
* @param string|array callback name or array(object, method)
[946] Fix | Delete
*
[947] Fix | Delete
* @return elFinder
[948] Fix | Delete
* @author Dmitry (dio) Levashov
[949] Fix | Delete
**/
[950] Fix | Delete
public function bind($cmd, $handler)
[951] Fix | Delete
{
[952] Fix | Delete
$allCmds = array_keys($this->commands);
[953] Fix | Delete
$cmds = array();
[954] Fix | Delete
foreach (explode(' ', $cmd) as $_cmd) {
[955] Fix | Delete
if ($_cmd !== '') {
[956] Fix | Delete
if ($all = strpos($_cmd, '*') !== false) {
[957] Fix | Delete
list(, $sub) = array_pad(explode('.', $_cmd), 2, '');
[958] Fix | Delete
if ($sub) {
[959] Fix | Delete
$sub = str_replace('\'', '\\\'', $sub);
[960] Fix | Delete
$subs = array_fill(0, count($allCmds), $sub);
[961] Fix | Delete
$cmds = array_merge($cmds, array_map(array('elFinder', 'addSubToBindName'), $allCmds, $subs));
[962] Fix | Delete
} else {
[963] Fix | Delete
$cmds = array_merge($cmds, $allCmds);
[964] Fix | Delete
}
[965] Fix | Delete
} else {
[966] Fix | Delete
$cmds[] = $_cmd;
[967] Fix | Delete
}
[968] Fix | Delete
}
[969] Fix | Delete
}
[970] Fix | Delete
$cmds = array_unique($cmds);
[971] Fix | Delete
[972] Fix | Delete
foreach ($cmds as $cmd) {
[973] Fix | Delete
if (!isset($this->listeners[$cmd])) {
[974] Fix | Delete
$this->listeners[$cmd] = array();
[975] Fix | Delete
}
[976] Fix | Delete
[977] Fix | Delete
if (is_callable($handler)) {
[978] Fix | Delete
$this->listeners[$cmd][] = $handler;
[979] Fix | Delete
}
[980] Fix | Delete
}
[981] Fix | Delete
[982] Fix | Delete
return $this;
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
/**
[986] Fix | Delete
* Remove event (command exec) handler
[987] Fix | Delete
*
[988] Fix | Delete
* @param string command name
[989] Fix | Delete
* @param string|array callback name or array(object, method)
[990] Fix | Delete
*
[991] Fix | Delete
* @return elFinder
[992] Fix | Delete
* @author Dmitry (dio) Levashov
[993] Fix | Delete
**/
[994] Fix | Delete
public function unbind($cmd, $handler)
[995] Fix | Delete
{
[996] Fix | Delete
if (!empty($this->listeners[$cmd])) {
[997] Fix | Delete
foreach ($this->listeners[$cmd] as $i => $h) {
[998] Fix | Delete
if ($h === $handler) {
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function