PHP Class elFinder\elFinderVolumeDriver

Show file Open project: gotcms/gotcms

Protected Properties

Property Type Description
$URL string Base URL
$access mixed Access control function/class
$archivers array Archivers config
$attributes mixed Access control function/class
$cache array Cache storage
$cryptLib string Library to crypt files name
$defaults array Defaults permissions
$diabled array List of disabled client's commands
$dirsCache array Cache by folders
$driverId string Driver id Must be started from letter and contains [a-z0-9] Used as part of volume id
$error array Errors from last failed action
$finfo object Finfo object for mimeDetect == 'finfo'
$id string Volume id - used as prefix for files hashes
$imgLib string Image manipulation lib name auto|imagick|mogtify|gd
$mimeDetect string Mimetype detect method
$mimetypes array default extensions/mimetypes for mimeDetect == 'internal'
$mounted boolean Flag - volume "mounted" and available
$onlyMimes array Mimetypes allowed to display
$options array Object configuration
$removed array Store files moved or overwrited files info
$root string Root directory path
$rootName string Root basename | alias
$separator string Directory separator - required by client
$startPath string Default directory to open
$tmbPath string Thumbnails dir path
$tmbPathWritable boolean Is thumbnails dir writable
$tmbSize integer Thumbnails size in px
$tmbURL string Thumbnails base URL
$today integer Today 24:00 timestamp
$treeDeep integer How many subdirs levels return for tree
$uploadAllow array Mime types allowed to upload
$uploadDeny array Mime types denied to upload
$uploadMaxSize integer | string Set as number or string with unit - "10M", "500K", "1G"
$uploadOrder array Order to validate uploadAllow and uploadDeny
$yesterday integer Yesterday 24:00 timestamp

Public Methods

Method Description
archive ( $hashes, $mime ) : void Add files to archive
close ( Resource $fp, string $hash ) : void Close file pointer
closest ( string $hash, string $attr, boolean $val ) : string | false Return file/dir hash or first founded child hash with required attr == $val
commandDisabled ( string $cmd ) : boolean Return true if command disabled in options
copyFromAllowed ( ) : boolean Return true if copy from this volume allowed
debug ( ) : array Return debug info for client
defaultPath ( ) : string Return root or startPath hash
dimensions ( string $hash ) : array Return image dimensions
dir ( string $hash, $resolveLink = false ) : array | false Return folder info
driverId ( ) : string Return driver id. Used as a part of volume id.
duplicate ( string $hash, string $suffix = 'copy' ) : array | false Create file copy with suffix "copy number" and return its info
error ( ) : array Return error message from last failed action
extract ( string $hash ) : array | boolean Extract files from archive
file ( string $hash ) : array | false Return file info or false on error
getContents ( string $hash ) : string | false Return file contents
id ( ) : string Return volume id
isReadable ( ) : boolean Return true if voume is readable.
ls ( string $hash ) : array Return dir files names list
mimeAccepted ( string $mime, array $mimes = [], boolean | null $empty = true ) : boolean | null Return true if mime is required mimes list
mkdir ( string $dst, string $name ) : array | false Create directory and return dir info
mkfile ( string $dst, string $name ) : array | false Create empty file and return its info
mount ( array $opts ) : boolean "Mount" volume.
open ( $hash ) : Resource Open file for reading and return file pointer
options ( $hash ) : array Return volume options required by client:
parents ( string $hash ) : array Return part of dirs tree from required dir up to root dir
paste ( Object $volume, $src, string $dst, boolean $rmSrc = false ) : array | false Paste files
path ( string $hash ) : string Return file path related to root
putContents ( string $hash, string $content ) : array Put content in text file and return file info.
realpath ( string $hash ) : string Return file real path if file exists
removed ( ) : array Return list of moved/overwrited files
rename ( string $hash, string $name ) : array | false Rename file and return file info
resetRemoved ( ) : void Clean removed files list
resize ( string $hash, integer $width, integer $height, integer $x, integer $y, string $mode = 'resize', $bg = '', $degree ) : array | false Resize image
rm ( string $hash ) : boolean Remove file/dir
root ( ) : string Return root folder hash
scandir ( string $hash ) : array | false Return directory content or false on error
search ( string $q, array $mimes ) : array Search files
setMimesFilter ( array $mimes ) : void Set mimetypes allowed to display to client
size ( $hash ) : integer Return file size / total directory size
tmb ( $hash ) : string | false Create thumbnail for required file and return its name of false on failed
tree ( string $hash = '', integer $deep, string $exclude = '' ) : array | false Return subfolders for required folder or false on error
umount ( ) : void Some "unmount" stuffs - may be required by virtual fs
uniqueName ( $dir, $name, string $suffix = ' copy', $checkNum = true ) : string Return new unique name based on file name and suffix
upload ( Resource $fp, string $dst, $name, string $tmpname ) : array | false Save uploaded file.

Protected Methods

Method Description
_abspath ( string $path ) : string Convert path related to root dir into real path
_archive ( string $dir, array $files, string $name, array $arc ) : string | boolean Create archive and return its path
_basename ( string $path ) : string Return file name
_checkArchivers ( ) : void Detect available archivers
_copy ( string $source, $targetDir, string $name ) : boolean Copy file into another file (only inside one volume)
_dimensions ( string $path, string $mime ) : string Return object width and height Ususaly used for images, but can be realize for video etc.
_dirname ( string $path ) : string Return parent directory path
_extract ( string $path, array $arc ) : boolean Extract files from archive
_fclose ( resource $fp, string $path = '' ) : boolean Close opened file
_filePutContents ( string $path, string $content ) : boolean Write a string to a file
_fopen ( string $path, $mode = "rb" ) : resource | false Open file and return file pointer
_getContents ( string $path ) : string | false Get file contents
_inpath ( string $path, string $parent ) : boolean Return true if $path is children of $parent
_joinPath ( string $dir, string $name ) : string Join dir name and file name and return full path.
_mkdir ( string $path, string $name ) : string | boolean Create dir and return created dir path or false on failed
_mkfile ( string $path, string $name ) : string | boolean Create file and return it's path or false on failed
_move ( string $source, $targetDir, string $name ) : string | boolean Move file into another parent dir.
_normpath ( string $path ) : string Return normalized path
_path ( string $path ) : string Return fake path started from root dir.
_relpath ( string $path ) : string Return file path related to root dir
_rmdir ( string $path ) : boolean Remove dir
_save ( resource $fp, string $dir, string $name, array $stat ) : boolean | string Create new file and write into it from file pointer.
_scandir ( string $path ) : array Return files list in directory
_stat ( string $path ) : array | false Return stat for given path.
_subdirs ( string $path ) : boolean Return true if path is dir and has at least one childs directory
_symlink ( string $source, string $targetDir, string $name ) : boolean Create symlink
_unlink ( string $path ) : boolean Remove file
allowCreate ( string $dir, string $name ) : boolean Return true if file with given name can be created in given folder.
attr ( string $path, string $name, boolean $val = null ) : boolean Check file attribute
cacheDir ( string $path ) : void Get stat for folder content and put in cache
canCreateTmb ( string $path, array $stat ) : string | boolean Return true if thumnbnail for required file can be created
canResize ( string $path, array $stat ) : string | boolean Return true if required file can be resized.
childsByAttr ( string $path, string $attr, boolean $val ) : string | false Return first found children with required attr == $val
clearcache ( ) : void Clean cache
closestByAttr ( string $path, string $attr, boolean $val ) : string | false If file has required attr == $val - return file path, If dir has child with has required attr == $val - return child path
configure ( ) : void Configure after successfull mount.
copy ( string $src, string $dst, string $name ) : string | false Copy file/recursive copy dir only in current volume.
copyFrom ( Object $volume, string $src, string $destination, string $name ) : string | false Copy file from another volume.
countSize ( string $path ) : integer Return file/total directory size
createTmb ( string $path, $stat ) : string | false Create thumnbnail and return it's URL on success
crypt ( $path ) : mixed Return crypted path Not implemented
decode ( $hash ) : string Decode path from hash
doSearch ( string $path, string $q, array $mimes ) : array Recursive files search
encode ( $path ) : string Encode path into hash
gdImage ( resource $image, string $filename, string $destformat, string $mime ) Output gd image to file
gdImageBackground ( resource $image, string $bgcolor ) Assign the proper background to a gd image
gdImageCreate ( string $path, string $mime ) : gd Create an gd image according to the specified mime type
getScandir ( string $path ) : array Return required dir's files info.
gettmb ( string $path, array $stat ) : string | false Return thumnbnail name if exists
gettree ( string $path, integer $deep, $exclude = '' ) : array Return subdirs tree
imgCrop ( string $path, integer $width, integer $height, boolean $x, boolean $y, string $destformat = null ) : string | false Crop image
imgResize ( string $path, integer $width, integer $height, boolean $keepProportions = false, boolean $resizeByBiggerSide = true, string $destformat = null ) : string | false Resize image
imgRotate ( string $path, integer $degree, string $bgcolor = '#ffffff', string $destformat = null ) : string | false Rotate image
imgSquareFit ( string $path, integer $width, integer $height, integer $align = 'center', integer $valign = 'middle', string $bgcolor = '#0000ff', string $destformat = null ) : string | false Put image to square
init ( ) : boolean Prepare driver before mount volume.
isSameType ( string $mime1, string $mime2 ) : boolean Return true if all mimes is directory or files
mimetype ( string $path, $name = '' ) : string Return file mimetype
mimetypeInternalDetect ( string $path ) : string Detect file mimetype using "internal" method
move ( string $src, string $dst, string $name ) : string | false Move file Return new file path or false.
nameAccepted ( string $name ) : boolean Validate file name based on $this->options['acceptedName'] regexp
procExec ( string $command, array &$output = null, array &$return_var, array &$error_output = null ) : integer Execute shell command
remove ( string $path, boolean $force = false ) : boolean Remove file/ recursive remove dir
rmTmb ( string $stat ) : void Remove thumbnail, also remove recursively if stat is directory
setError ( $error ) : false Save error message
stat ( string $path ) : array Return fileinfo
stripos ( string $haystack, string $needle, integer $offset ) : integer | boolean Find position of first occurrence of string in a string with multibyte support
tmbname ( array $stat ) : string Return thumbnail file name for required file
uncrypt ( $hash ) : mixed Return uncrypted path Not implemented
updateCache ( string $path, array $stat ) : array Put file stat in cache and return it

Method Details

_abspath() abstract protected method

Convert path related to root dir into real path
Author: Dmitry (dio) Levashov
abstract protected _abspath ( string $path ) : string
$path string rel file path
return string

_archive() abstract protected method

Create archive and return its path
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
abstract protected _archive ( string $dir, array $files, string $name, array $arc ) : string | boolean
$dir string target dir
$files array files names list
$name string archive name
$arc array archiver options
return string | boolean

_basename() abstract protected method

Return file name
Author: Dmitry (dio) Levashov
abstract protected _basename ( string $path ) : string
$path string file path
return string

_checkArchivers() abstract protected method

Detect available archivers
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
abstract protected _checkArchivers ( ) : void
return void

_copy() abstract protected method

Copy file into another file (only inside one volume)
Author: Dmitry (dio) Levashov
abstract protected _copy ( string $source, $targetDir, string $name ) : boolean
$source string source file path
$name string file name
return boolean

_dimensions() abstract protected method

..
Author: Dmitry (dio) Levashov
abstract protected _dimensions ( string $path, string $mime ) : string
$path string file path
$mime string file mime type
return string

_dirname() abstract protected method

Return parent directory path
Author: Dmitry (dio) Levashov
abstract protected _dirname ( string $path ) : string
$path string file path
return string

_extract() abstract protected method

Extract files from archive
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
abstract protected _extract ( string $path, array $arc ) : boolean
$path string file path
$arc array archiver options
return boolean

_fclose() abstract protected method

Close opened file
Author: Dmitry (dio) Levashov
abstract protected _fclose ( resource $fp, string $path = '' ) : boolean
$fp resource file pointer
$path string file path
return boolean

_filePutContents() abstract protected method

Write a string to a file
Author: Dmitry (dio) Levashov
abstract protected _filePutContents ( string $path, string $content ) : boolean
$path string file path
$content string new file content
return boolean

_fopen() abstract protected method

Open file and return file pointer
Author: Dmitry (dio) Levashov
abstract protected _fopen ( string $path, $mode = "rb" ) : resource | false
$path string file path
return resource | false

_getContents() abstract protected method

Get file contents
Author: Dmitry (dio) Levashov
abstract protected _getContents ( string $path ) : string | false
$path string file path
return string | false

_inpath() abstract protected method

Return true if $path is children of $parent
Author: Dmitry (dio) Levashov
abstract protected _inpath ( string $path, string $parent ) : boolean
$path string path to check
$parent string parent path
return boolean

_joinPath() abstract protected method

Some drivers (db) use int as path - so we give to concat path to driver itself
Author: Dmitry (dio) Levashov
abstract protected _joinPath ( string $dir, string $name ) : string
$dir string dir path
$name string file name
return string

_mkdir() abstract protected method

Create dir and return created dir path or false on failed
Author: Dmitry (dio) Levashov
abstract protected _mkdir ( string $path, string $name ) : string | boolean
$path string parent dir path
$name string new directory name
return string | boolean

_mkfile() abstract protected method

Create file and return it's path or false on failed
Author: Dmitry (dio) Levashov
abstract protected _mkfile ( string $path, string $name ) : string | boolean
$path string parent dir path
$name string new file name
return string | boolean

_move() abstract protected method

Return new file path or false.
Author: Dmitry (dio) Levashov
abstract protected _move ( string $source, $targetDir, string $name ) : string | boolean
$source string source file path
$name string file name
return string | boolean

_normpath() abstract protected method

Return normalized path
Author: Dmitry (dio) Levashov
abstract protected _normpath ( string $path ) : string
$path string file path
return string

_path() abstract protected method

Required to show path on client side.
Author: Dmitry (dio) Levashov
abstract protected _path ( string $path ) : string
$path string file path
return string

_relpath() abstract protected method

Return file path related to root dir
Author: Dmitry (dio) Levashov
abstract protected _relpath ( string $path ) : string
$path string file path
return string

_rmdir() abstract protected method

Remove dir
Author: Dmitry (dio) Levashov
abstract protected _rmdir ( string $path ) : boolean
$path string dir path
return boolean

_save() abstract protected method

Return new file path or false on error.
Author: Dmitry (dio) Levashov
abstract protected _save ( resource $fp, string $dir, string $name, array $stat ) : boolean | string
$fp resource file pointer
$dir string target dir path
$name string file name
$stat array file stat (required by some virtual fs)
return boolean | string

_scandir() abstract protected method

Return files list in directory
Author: Dmitry (dio) Levashov
abstract protected _scandir ( string $path ) : array
$path string dir path
return array

_stat() abstract protected method

Stat contains following fields: - (int) size file size in b. required - (int) ts file modification time in unix time. required - (string) mime mimetype. required for folders, others - optionally - (bool) read read permissions. required - (bool) write write permissions. required - (bool) locked is object locked. optionally - (bool) hidden is object hidden. optionally - (string) alias for symlinks - link target path relative to root path. optionally - (string) target for symlinks - link target path. optionally If file does not exists - returns empty array or false.
Author: Dmitry (dio) Levashov
abstract protected _stat ( string $path ) : array | false
$path string file path
return array | false

_subdirs() abstract protected method

Return true if path is dir and has at least one childs directory
Author: Dmitry (dio) Levashov
abstract protected _subdirs ( string $path ) : boolean
$path string dir path
return boolean

allowCreate() protected method

Return true if file with given name can be created in given folder.
Author: Dmitry (dio) Levashov
protected allowCreate ( string $dir, string $name ) : boolean
$dir string parent dir path
$name string new file name
return boolean

archive() public method

Add files to archive
public archive ( $hashes, $mime ) : void
return void

attr() protected method

Check file attribute
Author: Dmitry (dio) Levashov
protected attr ( string $path, string $name, boolean $val = null ) : boolean
$path string file path
$name string attribute name (read|write|locked|hidden)
$val boolean attribute value returned by file system
return boolean

cacheDir() protected method

Get stat for folder content and put in cache
Author: Dmitry (dio) Levashov
protected cacheDir ( string $path ) : void
$path string
return void

canCreateTmb() protected method

Return true if thumnbnail for required file can be created
Author: Dmitry (dio) Levashov
protected canCreateTmb ( string $path, array $stat ) : string | boolean
$path string thumnbnail path
$stat array file stat
return string | boolean

canResize() protected method

By default - the same as canCreateTmb
Author: Dmitry (dio) Levashov
protected canResize ( string $path, array $stat ) : string | boolean
$path string thumnbnail path
$stat array file stat
return string | boolean

childsByAttr() protected method

Return first found children with required attr == $val
Author: Dmitry (dio) Levashov
protected childsByAttr ( string $path, string $attr, boolean $val ) : string | false
$path string file path
$attr string attribute name
$val boolean attribute value
return string | false

clearcache() protected method

Clean cache
Author: Dmitry (dio) Levashov
protected clearcache ( ) : void
return void

close() public method

Close file pointer
Author: Dmitry (dio) Levashov
public close ( Resource $fp, string $hash ) : void
$fp Resource file pointer
$hash string file hash
return void

closest() public method

Return file/dir hash or first founded child hash with required attr == $val
Author: Dmitry (dio) Levashov
public closest ( string $hash, string $attr, boolean $val ) : string | false
$hash string file hash
$attr string attribute name
$val boolean attribute value
return string | false

closestByAttr() protected method

If file has required attr == $val - return file path, If dir has child with has required attr == $val - return child path
Author: Dmitry (dio) Levashov
protected closestByAttr ( string $path, string $attr, boolean $val ) : string | false
$path string file path
$attr string attribute name
$val boolean attribute value
return string | false

commandDisabled() public method

Return true if command disabled in options
Author: Dmitry (dio) Levashov
public commandDisabled ( string $cmd ) : boolean
$cmd string command name
return boolean

configure() protected method

By default set thumbnails path and image manipulation library.
Author: Dmitry (dio) Levashov
protected configure ( ) : void
return void

copy() protected method

Return new file path or false.
Author: Dmitry (dio) Levashov
protected copy ( string $src, string $dst, string $name ) : string | false
$src string source path
$dst string destination dir path
$name string new file name (optionaly)
return string | false

copyFrom() protected method

Return new file path or false.
Author: Dmitry (dio) Levashov
protected copyFrom ( Object $volume, string $src, string $destination, string $name ) : string | false
$volume Object source volume
$src string source file hash
$destination string destination dir path
$name string file name
return string | false

copyFromAllowed() public method

Return true if copy from this volume allowed
Author: Dmitry (dio) Levashov
public copyFromAllowed ( ) : boolean
return boolean

countSize() protected method

Return file/total directory size
Author: Dmitry (dio) Levashov
protected countSize ( string $path ) : integer
$path string file path
return integer

createTmb() protected method

Create thumnbnail and return it's URL on success
Author: Dmitry (dio) Levashov
protected createTmb ( string $path, $stat ) : string | false
$path string file path
return string | false

crypt() protected method

Return crypted path Not implemented
Author: Dmitry (dio) Levashov
protected crypt ( $path ) : mixed
return mixed

debug() public method

Return debug info for client
Author: Dmitry (dio) Levashov
public debug ( ) : array
return array

decode() protected method

Decode path from hash
Author: Dmitry (dio) Levashov
Author: Troex Nevelin
protected decode ( $hash ) : string
return string

defaultPath() public method

Return root or startPath hash
Author: Dmitry (dio) Levashov
public defaultPath ( ) : string
return string

dimensions() public method

Return image dimensions
Author: Dmitry (dio) Levashov
public dimensions ( string $hash ) : array
$hash string file hash
return array

dir() public method

Return folder info
Author: Dmitry (dio) Levashov
public dir ( string $hash, $resolveLink = false ) : array | false
$hash string folder hash
return array | false

doSearch() protected method

Recursive files search
Author: Dmitry (dio) Levashov
protected doSearch ( string $path, string $q, array $mimes ) : array
$path string dir path
$q string search string
$mimes array
return array

driverId() public method

Return driver id. Used as a part of volume id.
Author: Dmitry (dio) Levashov
public driverId ( ) : string
return string

duplicate() public method

Create file copy with suffix "copy number" and return its info
Author: Dmitry (dio) Levashov
public duplicate ( string $hash, string $suffix = 'copy' ) : array | false
$hash string file hash
$suffix string suffix to add to file name
return array | false

encode() protected method

Encode path into hash
Author: Dmitry (dio) Levashov
Author: Troex Nevelin
protected encode ( $path ) : string
return string

error() public method

Return error message from last failed action
Author: Dmitry (dio) Levashov
public error ( ) : array
return array

extract() public method

Extract files from archive
Author: Dmitry (dio) Levashov,
Author: Alexey Sukhotin
public extract ( string $hash ) : array | boolean
$hash string archive hash
return array | boolean

file() public method

Return file info or false on error
Author: Dmitry (dio) Levashov
public file ( string $hash ) : array | false
$hash string file hash
return array | false

gdImage() protected method

Output gd image to file
protected gdImage ( resource $image, string $filename, string $destformat, string $mime )
$image resource gd image resource
$filename string The path to save the file to.
$destformat string The Image type to use for $filename
$mime string The original image mime type

gdImageBackground() protected method

Assign the proper background to a gd image
protected gdImageBackground ( resource $image, string $bgcolor )
$image resource gd image resource
$bgcolor string background color in #rrggbb format

gdImageCreate() protected method

Create an gd image according to the specified mime type
protected gdImageCreate ( string $path, string $mime ) : gd
$path string image file
$mime string
return gd image resource identifier

getContents() public method

Return file contents
Author: Dmitry (dio) Levashov
public getContents ( string $hash ) : string | false
$hash string file hash
return string | false

getScandir() protected method

If onlyMimes is set - return only dirs and files of required mimes
Author: Dmitry (dio) Levashov
protected getScandir ( string $path ) : array
$path string dir path
return array

gettmb() protected method

Return thumnbnail name if exists
Author: Dmitry (dio) Levashov
protected gettmb ( string $path, array $stat ) : string | false
$path string file path
$stat array file stat
return string | false

gettree() protected method

Return subdirs tree
Author: Dmitry (dio) Levashov
protected gettree ( string $path, integer $deep, $exclude = '' ) : array
$path string parent dir path
$deep integer tree deep
return array

id() public method

Return volume id
Author: Dmitry (dio) Levashov
public id ( ) : string
return string

imgCrop() protected method

Crop image
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
protected imgCrop ( string $path, integer $width, integer $height, boolean $x, boolean $y, string $destformat = null ) : string | false
$path string image file
$width integer crop width
$height integer crop height
$x boolean crop left offset
$y boolean crop top offset
$destformat string image destination format
return string | false

imgResize() protected method

Resize image
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
protected imgResize ( string $path, integer $width, integer $height, boolean $keepProportions = false, boolean $resizeByBiggerSide = true, string $destformat = null ) : string | false
$path string image file
$width integer new width
$height integer new height
$keepProportions boolean crop image
$resizeByBiggerSide boolean resize image based on bigger side if true
$destformat string image destination format
return string | false

imgRotate() protected method

Rotate image
Author: nao-pon
Author: Troex Nevelin
protected imgRotate ( string $path, integer $degree, string $bgcolor = '#ffffff', string $destformat = null ) : string | false
$path string image file
$degree integer rotete degrees
$bgcolor string square background color in #rrggbb format
$destformat string image destination format
return string | false

imgSquareFit() protected method

Put image to square
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
protected imgSquareFit ( string $path, integer $width, integer $height, integer $align = 'center', integer $valign = 'middle', string $bgcolor = '#0000ff', string $destformat = null ) : string | false
$path string image file
$width integer square width
$height integer square height
$align integer reserved
$valign integer reserved
$bgcolor string square background color in #rrggbb format
$destformat string image destination format
return string | false

init() protected method

Return true if volume is ready.
Author: Dmitry (dio) Levashov
protected init ( ) : boolean
return boolean

isReadable() public method

Return true if voume is readable.
Author: Dmitry (dio) Levashov
public isReadable ( ) : boolean
return boolean

isSameType() protected method

Return true if all mimes is directory or files
Author: Dmitry (dio) Levashov
protected isSameType ( string $mime1, string $mime2 ) : boolean
$mime1 string mimetype
$mime2 string mimetype
return boolean

ls() public method

Return dir files names list
Author: Dmitry (dio) Levashov
public ls ( string $hash ) : array
$hash string file hash
return array

mimeAccepted() public method

Return true if mime is required mimes list
Author: Dmitry (dio) Levashov
Author: Troex Nevelin
public mimeAccepted ( string $mime, array $mimes = [], boolean | null $empty = true ) : boolean | null
$mime string mime type to check
$mimes array allowed mime types list or not set to use client mimes list
$empty boolean | null what to return on empty list
return boolean | null

mimetype() protected method

Return file mimetype
Author: Dmitry (dio) Levashov
protected mimetype ( string $path, $name = '' ) : string
$path string file path
return string

mimetypeInternalDetect() protected static method

Detect file mimetype using "internal" method
Author: Dmitry (dio) Levashov
protected static mimetypeInternalDetect ( string $path ) : string
$path string file path
return string

mkdir() public method

Create directory and return dir info
Author: Dmitry (dio) Levashov
public mkdir ( string $dst, string $name ) : array | false
$dst string destination directory
$name string directory name
return array | false

mkfile() public method

Create empty file and return its info
Author: Dmitry (dio) Levashov
public mkfile ( string $dst, string $name ) : array | false
$dst string destination directory
$name string file name
return array | false

mount() public method

Return true if volume available for read or write, false - otherwise
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
public mount ( array $opts ) : boolean
$opts array
return boolean

move() protected method

Move file Return new file path or false.
Author: Dmitry (dio) Levashov
protected move ( string $src, string $dst, string $name ) : string | false
$src string source path
$dst string destination dir path
$name string new file name
return string | false

nameAccepted() protected method

Validate file name based on $this->options['acceptedName'] regexp
Author: Dmitry (dio) Levashov
protected nameAccepted ( string $name ) : boolean
$name string file name
return boolean

open() public method

Open file for reading and return file pointer
Author: Dmitry (dio) Levashov
public open ( $hash ) : Resource
return Resource

options() public method

Return volume options required by client:
Author: Dmitry (dio) Levashov
public options ( $hash ) : array
return array

parents() public method

Return part of dirs tree from required dir up to root dir
Author: Dmitry (dio) Levashov
public parents ( string $hash ) : array
$hash string directory hash
return array

paste() public method

Paste files
Author: Dmitry (dio) Levashov
public paste ( Object $volume, $src, string $dst, boolean $rmSrc = false ) : array | false
$volume Object source volume
$dst string destination dir hash
$rmSrc boolean remove source after copy?
return array | false

path() public method

Return file path related to root
Author: Dmitry (dio) Levashov
public path ( string $hash ) : string
$hash string file hash
return string

procExec() protected method

Execute shell command
Author: Alexey Sukhotin
protected procExec ( string $command, array &$output = null, array &$return_var, array &$error_output = null ) : integer
$command string command line
$output array stdout strings
$return_var array process exit code
$error_output array stderr strings
return integer exit code

putContents() public method

Put content in text file and return file info.
Author: Dmitry (dio) Levashov
public putContents ( string $hash, string $content ) : array
$hash string file hash
$content string new file content
return array

realpath() public method

Return file real path if file exists
Author: Dmitry (dio) Levashov
public realpath ( string $hash ) : string
$hash string file hash
return string

remove() protected method

Remove file/ recursive remove dir
Author: Dmitry (dio) Levashov
protected remove ( string $path, boolean $force = false ) : boolean
$path string file path
$force boolean try to remove even if file locked
return boolean

removed() public method

Return list of moved/overwrited files
Author: Dmitry (dio) Levashov
public removed ( ) : array
return array

rename() public method

Rename file and return file info
Author: Dmitry (dio) Levashov
public rename ( string $hash, string $name ) : array | false
$hash string file hash
$name string new file name
return array | false

resetRemoved() public method

Clean removed files list
Author: Dmitry (dio) Levashov
public resetRemoved ( ) : void
return void

resize() public method

Resize image
Author: Dmitry (dio) Levashov
Author: Alexey Sukhotin
Author: nao-pon
Author: Troex Nevelin
public resize ( string $hash, integer $width, integer $height, integer $x, integer $y, string $mode = 'resize', $bg = '', $degree ) : array | false
$hash string image file
$width integer new width
$height integer new height
$x integer X start poistion for crop
$y integer Y start poistion for crop
$mode string action how to mainpulate image
return array | false

rm() public method

Remove file/dir
Author: Dmitry (dio) Levashov
public rm ( string $hash ) : boolean
$hash string file hash
return boolean

rmTmb() protected method

Remove thumbnail, also remove recursively if stat is directory
Author: Dmitry (dio) Levashov
Author: Naoki Sawada
Author: Troex Nevelin
protected rmTmb ( string $stat ) : void
$stat string file stat
return void

root() public method

Return root folder hash
Author: Dmitry (dio) Levashov
public root ( ) : string
return string

scandir() public method

Return directory content or false on error
Author: Dmitry (dio) Levashov
public scandir ( string $hash ) : array | false
$hash string file hash
return array | false

setError() protected method

Save error message
Author: Dmitry(dio) Levashov
protected setError ( $error ) : false
return false

setMimesFilter() public method

Set mimetypes allowed to display to client
Author: Dmitry (dio) Levashov
public setMimesFilter ( array $mimes ) : void
$mimes array
return void

size() public method

Return file size / total directory size
Author: Dmitry (dio) Levashov
public size ( $hash ) : integer
return integer

stat() protected method

Return fileinfo
Author: Dmitry (dio) Levashov
protected stat ( string $path ) : array
$path string file cache
return array

stripos() protected method

Find position of first occurrence of string in a string with multibyte support
Author: Alexey Sukhotin
protected stripos ( string $haystack, string $needle, integer $offset ) : integer | boolean
$haystack string The string being checked.
$needle string The string to find in haystack.
$offset integer The search offset. If it is not specified, 0 is used.
return integer | boolean

tmb() public method

Create thumbnail for required file and return its name of false on failed
Author: Dmitry (dio) Levashov
public tmb ( $hash ) : string | false
return string | false

tmbname() protected method

Return thumbnail file name for required file
Author: Dmitry (dio) Levashov
protected tmbname ( array $stat ) : string
$stat array file stat
return string

tree() public method

Return subfolders for required folder or false on error
Author: Dmitry (dio) Levashov
public tree ( string $hash = '', integer $deep, string $exclude = '' ) : array | false
$hash string folder hash or empty string to get tree from root folder
$deep integer subdir deep
$exclude string dir hash which subfolders must be exluded from result, required to not get stat twice on cwd subfolders
return array | false

umount() public method

Some "unmount" stuffs - may be required by virtual fs
Author: Dmitry (dio) Levashov
public umount ( ) : void
return void

uncrypt() protected method

Return uncrypted path Not implemented
Author: Dmitry (dio) Levashov
protected uncrypt ( $hash ) : mixed
return mixed

uniqueName() public method

Return new unique name based on file name and suffix
Author: Dmitry (dio) Levashov
public uniqueName ( $dir, $name, string $suffix = ' copy', $checkNum = true ) : string
$suffix string suffix append to name
return string

updateCache() protected method

Put file stat in cache and return it
Author: Dmitry (dio) Levashov
protected updateCache ( string $path, array $stat ) : array
$path string file path
$stat array file stat
return array

upload() public method

On success return array with new file stat and with removed file hash (if existed file was replaced)
Author: Dmitry (dio) Levashov
public upload ( Resource $fp, string $dst, $name, string $tmpname ) : array | false
$fp Resource file pointer
$dst string destination folder hash
$tmpname string file tmp name - required to detect mime type
return array | false

Property Details

$URL protected property

Base URL
protected string $URL
return string

$access protected property

Access control function/class
protected mixed $access
return mixed

$archivers protected property

Archivers config
protected array $archivers
return array

$attributes protected property

Access control function/class
protected mixed $attributes
return mixed

$cache protected property

Cache storage
protected array $cache
return array

$cryptLib protected property

Library to crypt files name
protected string $cryptLib
return string

$defaults protected property

Defaults permissions
protected array $defaults
return array

$diabled protected property

List of disabled client's commands
protected array $diabled
return array

$dirsCache protected property

Cache by folders
protected array $dirsCache
return array

$driverId protected property

Driver id Must be started from letter and contains [a-z0-9] Used as part of volume id
protected string $driverId
return string

$error protected property

Errors from last failed action
protected array $error
return array

$finfo protected property

Finfo object for mimeDetect == 'finfo'
protected object $finfo
return object

$id protected property

Volume id - used as prefix for files hashes
protected string $id
return string

$imgLib protected property

Image manipulation lib name auto|imagick|mogtify|gd
protected string $imgLib
return string

$mimeDetect protected property

Mimetype detect method
protected string $mimeDetect
return string

$mimetypes protected static property

default extensions/mimetypes for mimeDetect == 'internal'
protected static array $mimetypes
return array

$mounted protected property

Flag - volume "mounted" and available
protected bool $mounted
return boolean

$onlyMimes protected property

Mimetypes allowed to display
protected array $onlyMimes
return array

$options protected property

Object configuration
protected array $options
return array

$removed protected property

Store files moved or overwrited files info
protected array $removed
return array

$root protected property

Root directory path
protected string $root
return string

$rootName protected property

Root basename | alias
protected string $rootName
return string

$separator protected property

Directory separator - required by client
protected string $separator
return string

$startPath protected property

Default directory to open
protected string $startPath
return string

$tmbPath protected property

Thumbnails dir path
protected string $tmbPath
return string

$tmbPathWritable protected property

Is thumbnails dir writable
protected bool $tmbPathWritable
return boolean

$tmbSize protected property

Thumbnails size in px
protected int $tmbSize
return integer

$tmbURL protected property

Thumbnails base URL
protected string $tmbURL
return string

$today protected property

Today 24:00 timestamp
protected int $today
return integer

$treeDeep protected property

How many subdirs levels return for tree
protected int $treeDeep
return integer

$uploadAllow protected property

Mime types allowed to upload
protected array $uploadAllow
return array

$uploadDeny protected property

Mime types denied to upload
protected array $uploadDeny
return array

$uploadMaxSize protected property

Set as number or string with unit - "10M", "500K", "1G"
protected int|string $uploadMaxSize
return integer | string

$uploadOrder protected property

Order to validate uploadAllow and uploadDeny
protected array $uploadOrder
return array

$yesterday protected property

Yesterday 24:00 timestamp
protected int $yesterday
return integer