PHP Class elFinder

Core class.
Author: Dmitry (dio) Levashov
Author: Troex Nevelin
Author: Alexey Sukhotin
Afficher le fichier Open project: studio-42/elfinder Class Usage Examples

Méthodes publiques

Свойство Type Description
$defaultMimefile string elFinderVolumeDriver default mime.type file path
$instance object elFinder instance
$locale string elFinder global locale
$maxTargets Max allowed numbar of @var targets (0 - no limit)
$mountErrors array Errors from not mounted volumes
$netDrivers array Network mount drivers
$phpErrors array Errors from PHP
$sessionCacheKey string elFinder global sessionCacheKey
$volumesCnt integer Mounted volumes count Required to create unique volume id

Protected Properties

Свойство Type Description
$base64encodeSessionData boolean elFinder base64encodeSessionData elFinder save session data as UTF-8 If the session storage mechanism of the system does not allow UTF-8 And it must be true option 'base64encodeSessionData' of elFinder
$callbackWindowURL URL for callback output window for CORS redirect to this URL when callback output
$commands array Commands and required arguments list
$commonTempPath string elFinder common tempraly path
$debug string Send debug to client?
$default elFinderStorageDriver Default root (storage)
$listeners array Commands listeners
$loaded boolean Is elFinder init correctly?
$maxArcFilesSize integer Max allowed archive files size (0 - no limit)
$netVolumesSessionKey string Session key of net mount volumes
$optionsNetVolumes array Additional volume root options for network mounting volume
$plugins array Plugins instance
$session elFinderSessionInterface elFinder session wrapper object
$sessionCloseEarlier boolean Call session_write_close() before exec command?
$sessionUseCmds array SESSION use commands @see __construct()
$time string script work time for debug
$timeout integer session expires timeout
$uploadDebug string undocumented class variable
$uploadTempPath string Temp dir path for Upload
$version string API version number
$volumes array Storages (root dirs)

Méthodes publiques

Méthode Description
__construct ( $opts ) Constructor
bind ( $cmd, $handler ) : elFinder Add handler to elFinder command
commandArgsList ( $cmd ) : array Return command required arguments info
commandExists ( $cmd ) : boolean Return true if command exists
curlExec ( resource $curl, array $options = [], array $headers = [] ) : mixed Call curl_exec() with supported redirect on safe_mode or open_basedir
error ( ) : array Normalize error messages
exec ( string $cmd, array $args ) : array Exec command and return result
extendTimeLimit ( Int $time = null ) : void Extend PHP execution time limit
getConnectorUrl ( ) : string Get script url.
getIniBytes ( string $iniName = '', string $val = '' ) : number Return bytes from php.ini value
getSession ( ) : object Return elFinder session wrapper instance
getStaticVar ( $key ) : mixed | null Return elFinder static variable
getStreamByUrl ( array $data, number $redirectLimit = 5 ) : resource | boolean Get stream resource pointer by URL
getVolume ( $hash ) : elFinderStorageDriver Return root - file's owner (public func of volume())
isAnimationGif ( string $path ) : boolean Return Is Animation Gif
isSeekableStream ( resource $resource ) : boolean Return Is seekable stream resource
loaded ( ) : boolean Return true if fm init correctly
phpErrorHandler ( integer $errno, string $errstr, string $errfile, integer $errline ) : void | boolean PHP error handler, catch error types only E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE
realpath ( string $hash ) : string Return file real path
rewind ( resource $resource ) : void Rewind stream resource
sessionDataDecode ( mixed &$var, boolean $checkIs = null ) : boolean | mixed base64_decode and unserialize of session data (If needed)
sessionDataEncode ( mixed $var ) : mixed | string serialize and base64_encode of session data (If needed)
sessionWrite ( ) : void Call session_write_close() if session is restarted
unbind ( $cmd, $handler ) : elFinder Remove event (command exec) handler
updateNetVolumeOption ( string $netKey, string $optionKey, mixed $val ) Update sesstion value of a NetVolume option
version ( ) : string Return version (api) number

Méthodes protégées

Méthode Description
archive ( array $args ) : array Create archive
callback ( $args ) Output callback result with JavaScript that control elFinder or HTTP redirect to callbackWindowURL
chmod ( $args ) : array chmod
curl_get_contents ( string &$url, integer $timeout, integer $redirect_max, string $ua, resource $outfp ) : string Get remote contents with cURL
detectFileExtension ( string $path ) : string Detect file type extension by local path
dim ( array $args ) : array Return image dimensions
duplicate ( array $args ) : array Duplicate file - create copy with "copy %d" suffix
ensureDirsRecursively ( object $volume, string $target, string $dirs, string $path = '' ) : array | false Ensure directories recursively
extract ( array $args ) : array Extract files from archive
file ( $args ) : array Required to output file in browser when volume URL is not set Return array contains opened file pointer, root itself and required headers
filter ( array $files ) : array Remove from files list hidden files and files with required mime types
fsock_get_contents ( string &$url, integer $timeout, integer $redirect_max, string $ua, resource $outfp ) : string Get remote contents with fsockopen()
get ( array $args ) : array Return file content
getNetVolumeUniqueId ( array $netVolumes = null, string $prefix = 'nm' ) : string | false Return Network mount volume unique ID
getNetVolumes ( ) : array Return network volumes config.
getPluginInstance ( string $name, array $opts = [] ) : object | boolean Get plugin instance & set to $this->plugins
get_remote_contents ( string &$url, integer $timeout = 30, integer $redirect_max = 5, string $ua = 'Mozilla/5.0', resource $fp = null ) : string Get remote contents
hashes ( array $files ) : array Return fils hashes list
info ( array $args ) : array Return file info (used by client "places" ui)
ls ( $args ) : array Return dir files names list
mkdir ( $args ) : array Create directory
mkfile ( $args ) : array Create empty file
netmount ( $args )
open ( $args ) : array "Open" directory Return array with following elements - cwd - opened dir info - files - opened dir content [and dirs tree if $args[tree]] - api - api version (if $args[init]) - uplMaxSize - if $args[init] - error - on failed
parents ( $args ) : array Return parents dir for required directory
parse_data_scheme ( string $str, array $extTable ) : array Parse Data URI scheme
paste ( $args ) : array Copy/move files into new destination
put ( $args ) : array Save content into text file
removeNetVolume ( string $key, object $volume ) : boolean Remove netmount volume
rename ( array $args ) : array Rename file
resize ( $args ) : array Resize image
rm ( $args ) : array Remove dirs/files
saveNetVolumes ( array $volumes ) : void Save network volumes config.
search ( array $args ) : array Search files
size ( $args ) : array Count total files size
tmb ( $args ) : array Return new created thumbnails list
toArray ( array $data ) : array Return files info array
tree ( $args ) : array Return subdirs for required directory
upload ( $args ) : array Save uploaded files
url ( array $args ) : array Return content URL
utime ( )
volume ( $hash ) : elFinderStorageDriver Return root - file's owner
zipdl ( $args ) : array Download files/folders as an archive file

Private Methods

Méthode Description
checkChunkedFile ( string $tmpname, string $chunk, string $cid, string $tempDir, null $volume = null ) : array Check chunked upload files
getTempDir ( string $volumeTempPath = null ) : string Get temporary directory path
session_expires ( )

Method Details

__construct() public méthode

Constructor
Author: Dmitry (dio) Levashov
public __construct ( $opts )

archive() protected méthode

Create archive
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
protected archive ( array $args ) : array
$args array command arguments
Résultat array

bind() public méthode

Add handler to elFinder command
Author: Dmitry (dio) Levashov
public bind ( $cmd, $handler ) : elFinder
Résultat elFinder

callback() protected méthode

Output callback result with JavaScript that control elFinder or HTTP redirect to callbackWindowURL
Author: Naoki Sawada
protected callback ( $args )

chmod() protected méthode

chmod
Author: David Bartle
protected chmod ( $args ) : array
Résultat array

commandArgsList() public méthode

Return command required arguments info
Author: Dmitry (dio) Levashov
public commandArgsList ( $cmd ) : array
Résultat array

commandExists() public méthode

Return true if command exists
Author: Dmitry (dio) Levashov
public commandExists ( $cmd ) : boolean
Résultat boolean

curlExec() public static méthode

Call curl_exec() with supported redirect on safe_mode or open_basedir
Author: Naoki Sawada
public static curlExec ( resource $curl, array $options = [], array $headers = [] ) : mixed
$curl resource
$options array
$headers array
Résultat mixed

curl_get_contents() protected méthode

Get remote contents with cURL
Author: Naoki Sawada
protected curl_get_contents ( string &$url, integer $timeout, integer $redirect_max, string $ua, resource $outfp ) : string
$url string target url
$timeout integer timeout (sec)
$redirect_max integer redirect max count
$ua string
$outfp resource
Résultat string or bool(false)

detectFileExtension() protected méthode

Detect file type extension by local path
Author: Naoki Sawada
protected detectFileExtension ( string $path ) : string
$path string Local path
Résultat string file type extension with dot

dim() protected méthode

Return image dimensions
Author: Dmitry (dio) Levashov
protected dim ( array $args ) : array
$args array command arguments
Résultat array

duplicate() protected méthode

Duplicate file - create copy with "copy %d" suffix
Author: Dmitry (dio) Levashov
protected duplicate ( array $args ) : array
$args array command arguments
Résultat array

ensureDirsRecursively() protected méthode

Ensure directories recursively
Author: Naoki Sawada
protected ensureDirsRecursively ( object $volume, string $target, string $dirs, string $path = '' ) : array | false
$volume object Volume object
$target string Target hash
$dirs string Array of directory tree to ensure
$path string Relative path form target hash
Résultat array | false array('stats' => array([stat of maked directory]), 'hashes' => array('[path]' => '[hash]'))

error() public méthode

Normalize error messages
Author: Dmitry (dio) Levashov
public error ( ) : array
Résultat array

exec() public méthode

Exec command and return result
Author: Dmitry (dio) Levashov
public exec ( string $cmd, array $args ) : array
$cmd string command name
$args array command arguments
Résultat array

extendTimeLimit() public static méthode

Extend PHP execution time limit
public static extendTimeLimit ( Int $time = null ) : void
$time Int
Résultat void

extract() protected méthode

Extract files from archive
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
protected extract ( array $args ) : array
$args array command arguments
Résultat array

file() protected méthode

Required to output file in browser when volume URL is not set Return array contains opened file pointer, root itself and required headers
Author: Dmitry (dio) Levashov
protected file ( $args ) : array
Résultat array

filter() protected méthode

Remove from files list hidden files and files with required mime types
Author: Dmitry (dio) Levashov
protected filter ( array $files ) : array
$files array files info
Résultat array

fsock_get_contents() protected méthode

Get remote contents with fsockopen()
Author: Naoki Sawada
protected fsock_get_contents ( string &$url, integer $timeout, integer $redirect_max, string $ua, resource $outfp ) : string
$url string url
$timeout integer timeout (sec)
$redirect_max integer redirect max count
$ua string
$outfp resource
Résultat string or bool(false)

get() protected méthode

Return file content
Author: Dmitry (dio) Levashov
protected get ( array $args ) : array
$args array command arguments
Résultat array

getConnectorUrl() public static méthode

Get script url.
Author: Naoki Sawada
public static getConnectorUrl ( ) : string
Résultat string full URL

getIniBytes() public static méthode

Return bytes from php.ini value
public static getIniBytes ( string $iniName = '', string $val = '' ) : number
$iniName string
$val string
Résultat number

getNetVolumeUniqueId() protected méthode

Return Network mount volume unique ID
Author: Naoki Sawada
protected getNetVolumeUniqueId ( array $netVolumes = null, string $prefix = 'nm' ) : string | false
$netVolumes array Saved netvolumes array
$prefix string Id prefix
Résultat string | false

getNetVolumes() protected méthode

Return network volumes config.
Author: Dmitry (dio) Levashov
protected getNetVolumes ( ) : array
Résultat array

getPluginInstance() protected méthode

Get plugin instance & set to $this->plugins
Author: Naoki Sawada
protected getPluginInstance ( string $name, array $opts = [] ) : object | boolean
$name string Plugin name (dirctory name)
$opts array Plugin options (optional)
Résultat object | boolean | bool Plugin object instance Or false

getSession() public méthode

Return elFinder session wrapper instance
public getSession ( ) : object
Résultat object elFinderSessionInterface

getStaticVar() public static méthode

Return elFinder static variable
public static getStaticVar ( $key ) : mixed | null
$key
Résultat mixed | null

getStreamByUrl() public static méthode

Get stream resource pointer by URL
Author: Naoki Sawada
public static getStreamByUrl ( array $data, number $redirectLimit = 5 ) : resource | boolean
$data array array('target'=>'URL', 'headers' => array())
$redirectLimit number
Résultat resource | boolean

getVolume() public méthode

Return root - file's owner (public func of volume())
Author: Naoki Sawada
public getVolume ( $hash ) : elFinderStorageDriver
Résultat elFinderStorageDriver

get_remote_contents() protected méthode

Get remote contents
Author: Naoki Sawada
protected get_remote_contents ( string &$url, integer $timeout = 30, integer $redirect_max = 5, string $ua = 'Mozilla/5.0', resource $fp = null ) : string
$url string target url
$timeout integer timeout (sec)
$redirect_max integer redirect max count
$ua string
$fp resource
Résultat string or bool(false)

hashes() protected méthode

Return fils hashes list
Author: Dmitry (dio) Levashov
protected hashes ( array $files ) : array
$files array files info
Résultat array

info() protected méthode

Return file info (used by client "places" ui)
Author: Dmitry Levashov
protected info ( array $args ) : array
$args array command arguments
Résultat array

isAnimationGif() public static méthode

Return Is Animation Gif
public static isAnimationGif ( string $path ) : boolean
$path string server local path of target image
Résultat boolean

isSeekableStream() public static méthode

Return Is seekable stream resource
public static isSeekableStream ( resource $resource ) : boolean
$resource resource
Résultat boolean

loaded() public méthode

Return true if fm init correctly
Author: Dmitry (dio) Levashov
public loaded ( ) : boolean
Résultat boolean

ls() protected méthode

Return dir files names list
Author: Dmitry (dio) Levashov
protected ls ( $args ) : array
Résultat array

mkdir() protected méthode

Create directory
Author: Dmitry (dio) Levashov
protected mkdir ( $args ) : array
Résultat array

mkfile() protected méthode

Create empty file
Author: Dmitry (dio) Levashov
protected mkfile ( $args ) : array
Résultat array

netmount() protected méthode

protected netmount ( $args )

open() protected méthode

"Open" directory Return array with following elements - cwd - opened dir info - files - opened dir content [and dirs tree if $args[tree]] - api - api version (if $args[init]) - uplMaxSize - if $args[init] - error - on failed
Author: Dmitry (dio) Levashov
protected open ( $args ) : array
Résultat array

parents() protected méthode

Return parents dir for required directory
Author: Dmitry (dio) Levashov
protected parents ( $args ) : array
Résultat array

parse_data_scheme() protected méthode

Parse Data URI scheme
Author: Naoki Sawada
protected parse_data_scheme ( string $str, array $extTable ) : array
$str string
$extTable array
Résultat array

paste() protected méthode

Copy/move files into new destination
Author: Dmitry (dio) Levashov
protected paste ( $args ) : array
Résultat array

phpErrorHandler() public static méthode

PHP error handler, catch error types only E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE
public static phpErrorHandler ( integer $errno, string $errstr, string $errfile, integer $errline ) : void | boolean
$errno integer
$errstr string
$errfile string
$errline integer
Résultat void | boolean

put() protected méthode

Save content into text file
Author: Dmitry (dio) Levashov
protected put ( $args ) : array
$args
Résultat array

realpath() public méthode

Return file real path
Author: Dmitry (dio) Levashov
public realpath ( string $hash ) : string
$hash string file hash
Résultat string

removeNetVolume() protected méthode

Remove netmount volume
protected removeNetVolume ( string $key, object $volume ) : boolean
$key string netvolume key
$volume object volume driver instance
Résultat boolean

rename() protected méthode

Rename file
Author: Dmitry (dio) Levashov
protected rename ( array $args ) : array
$args array
Résultat array

resize() protected méthode

Resize image
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
protected resize ( $args ) : array
Résultat array

rewind() public static méthode

Rewind stream resource
public static rewind ( resource $resource ) : void
$resource resource
Résultat void

rm() protected méthode

Remove dirs/files
Author: Dmitry (dio) Levashov
protected rm ( $args ) : array
Résultat array

saveNetVolumes() protected méthode

Save network volumes config.
Author: Dmitry (dio) Levashov
protected saveNetVolumes ( array $volumes ) : void
$volumes array volumes config
Résultat void

sessionDataDecode() public static méthode

base64_decode and unserialize of session data (If needed)
Deprecation:
Author: Naoki Sawada
public static sessionDataDecode ( mixed &$var, boolean $checkIs = null ) : boolean | mixed
$var mixed target variable
$checkIs boolean data type for check (array|string|object|int)
Résultat boolean | mixed

sessionDataEncode() public static méthode

serialize and base64_encode of session data (If needed)
Deprecation:
Author: Naoki Sawada
public static sessionDataEncode ( mixed $var ) : mixed | string
$var mixed target variable
Résultat mixed | string

sessionWrite() public static méthode

Call session_write_close() if session is restarted
Deprecation:
public static sessionWrite ( ) : void
Résultat void

size() protected méthode

Count total files size
Author: Dmitry (dio) Levashov
protected size ( $args ) : array
Résultat array

tmb() protected méthode

Return new created thumbnails list
Author: Dmitry (dio) Levashov
protected tmb ( $args ) : array
Résultat array

toArray() protected méthode

Return files info array
Author: Dmitry (dio) Levashov
protected toArray ( array $data ) : array
$data array one file info or files info
Résultat array

tree() protected méthode

Return subdirs for required directory
Author: Dmitry (dio) Levashov
protected tree ( $args ) : array
Résultat array

unbind() public méthode

Remove event (command exec) handler
Author: Dmitry (dio) Levashov
public unbind ( $cmd, $handler ) : elFinder
Résultat elFinder

updateNetVolumeOption() public méthode

Update sesstion value of a NetVolume option
public updateNetVolumeOption ( string $netKey, string $optionKey, mixed $val )
$netKey string
$optionKey string
$val mixed

upload() protected méthode

Save uploaded files
Author: Dmitry (dio) Levashov
protected upload ( $args ) : array
Résultat array

url() protected méthode

Return content URL
Author: Naoki Sawada
protected url ( array $args ) : array
$args array command arguments
Résultat array

utime() protected méthode

protected utime ( )

version() public méthode

Return version (api) number
Author: Dmitry (dio) Levashov
public version ( ) : string
Résultat string

volume() protected méthode

Return root - file's owner
Author: Dmitry (dio) Levashov
protected volume ( $hash ) : elFinderStorageDriver
Résultat elFinderStorageDriver

zipdl() protected méthode

1st: Return srrsy contains download archive file info 2nd: Return array contains opened file pointer, root itself and required headers
Author: Naoki Sawada
protected zipdl ( $args ) : array
Résultat array

Property Details

$base64encodeSessionData protected_oe static_oe property

elFinder base64encodeSessionData elFinder save session data as UTF-8 If the session storage mechanism of the system does not allow UTF-8 And it must be true option 'base64encodeSessionData' of elFinder
protected static bool $base64encodeSessionData
Résultat boolean

$callbackWindowURL protected_oe property

URL for callback output window for CORS redirect to this URL when callback output
protected $callbackWindowURL

$commands protected_oe property

Commands and required arguments list
protected array $commands
Résultat array

$commonTempPath protected_oe static_oe property

elFinder common tempraly path
protected static string $commonTempPath
Résultat string

$debug protected_oe property

Send debug to client?
protected string $debug
Résultat string

$default protected_oe property

Default root (storage)
protected elFinderStorageDriver $default
Résultat elFinderStorageDriver

$defaultMimefile public_oe static_oe property

elFinderVolumeDriver default mime.type file path
public static string $defaultMimefile
Résultat string

$instance public_oe static_oe property

elFinder instance
public static object $instance
Résultat object

$listeners protected_oe property

Commands listeners
protected array $listeners
Résultat array

$loaded protected_oe property

Is elFinder init correctly?
protected bool $loaded
Résultat boolean

$locale public_oe static_oe property

elFinder global locale
public static string $locale
Résultat string

$maxArcFilesSize protected_oe property

Max allowed archive files size (0 - no limit)
protected int $maxArcFilesSize
Résultat integer

$maxTargets public_oe property

Max allowed numbar of @var targets (0 - no limit)
public $maxTargets

$mountErrors public_oe property

Errors from not mounted volumes
public array $mountErrors
Résultat array

$netDrivers public_oe static_oe property

Network mount drivers
public static array $netDrivers
Résultat array

$netVolumesSessionKey protected_oe property

Session key of net mount volumes
Deprecation:
protected string $netVolumesSessionKey
Résultat string

$optionsNetVolumes protected_oe property

Additional volume root options for network mounting volume
protected array $optionsNetVolumes
Résultat array

$phpErrors public_oe static_oe property

Errors from PHP
public static array $phpErrors
Résultat array

$plugins protected_oe property

Plugins instance
protected array $plugins
Résultat array

$session protected_oe property

elFinder session wrapper object
protected elFinderSessionInterface $session
Résultat elFinderSessionInterface

$sessionCacheKey public_oe static_oe property

elFinder global sessionCacheKey
Deprecation:
public static string $sessionCacheKey
Résultat string

$sessionCloseEarlier protected_oe property

Call session_write_close() before exec command?
protected bool $sessionCloseEarlier
Résultat boolean

$sessionUseCmds protected_oe property

SESSION use commands @see __construct()
protected array $sessionUseCmds
Résultat array

$time protected_oe property

script work time for debug
protected string $time
Résultat string

$timeout protected_oe property

session expires timeout
protected int $timeout
Résultat integer

$uploadDebug protected_oe property

undocumented class variable
protected string $uploadDebug
Résultat string

$uploadTempPath protected_oe property

Temp dir path for Upload
protected string $uploadTempPath
Résultat string

$version protected_oe property

API version number
protected string $version
Résultat string

$volumes protected_oe property

Storages (root dirs)
protected array $volumes
Résultat array

$volumesCnt public_oe static_oe property

Mounted volumes count Required to create unique volume id
public static int $volumesCnt
Résultat integer