Class CMS_file

Description

Class CMS_file

This script aimed to manage files, directory and rights on server Needs inherited classes to become more efficient

Located in /automne/classes/files/filesManagement.php (line 28)

CMS_grandFather
   |
   --CMS_file
Direct descendents
Class Description
 class CMS_image Class CMS_image
Class Constant Summary
Method Summary
 static boolean chmodFile ( $right,  $file, string $right,, string $file,)
 static boolean copyTo ( $from,  $to, string $from,, string $to,)
 static boolean deleteFile ( $file, string $file,)
 static boolean deltree ( $dir, [ $withDir = false], string $file,, boolean $withDir,)
 static boolean deltreeSimulation ( $dir, [ $withDir = false], string $file,, boolean $withDir,)
 static void download ([boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
 static void downloadFile (string $source, [boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
 static boolean fileIsExecutable ( $f, string $f,)
 static array getFileList ( $file, string $file,)
 static octal getFilePerms ( $file, [ $type = "octal"], string $file,, string $type,)
 static string getMaxUploadFileSize ([string $unit = 'M'])
 static string getParent ( $file, string $file,)
 static string getTmpPath ()
 static boolean gzipfile (string $source, string $dest, [integer $level = 6])
 static boolean isDeletable ( $f, string $file,)
 static boolean makeDir ( $f, string $f,)
 static boolean makeExecutable ( $f, string $f,)
 static boolean makeReadable ( $f, string $f,)
 static boolean makeWritable ( $f, string $f,)
 static string mimeContentType ([string $file = ''])
 static boolean moveTo ( $from,  $to, string $from,, string $to,)
 static void sendFiles (array $files, [string $contentType = 'text/html'])
 void __construct ( $name, [ $from = self::FILE_SYSTEM], [ $type = self::TYPE_FILE], string $name,, integer $from,, integer $type,)
 boolean checkUploadedFile ()
 boolean chmod ( $right, string $right,)
 boolean delete ()
 boolean exists ()
 string getContent ()
 string getExtension ()
 string getFileIcon ([ $from = self::FILE_SYSTEM], integer $from,)
 string getFilename ([ $withPath = true])
 string getFilePath ([ $from = self::FILE_SYSTEM], integer $from,)
 string getFileSize ([string $unit = false])
 string getName ([ $withPath = true])
 string/array readContent ([string $returnAs = "string"], [string $array_map_function = "trim"], [array $csvargs = array('delimiter' => ';', 'enclosure' => '"', 'strict' => true)])
 boolean setContent (string/array $content, [ $allowSetBlank = false])
 array uploadFile ([ $fileVarName = 'Filedata'], [ $destinationDirFS = PATH_UPLOAD_FS], string $fileVarName,, string $destinationDirFS,)
 boolean writeToPersistence ([boolean $allowWriteBlank = false], [boolean $createFolder = false])
Methods
static chmodFile (line 902)

function chmodFile Try to chmod a file (a dir is redirected to makeExecutable method).

  • return: true on success, false on failure
static boolean chmodFile ( $right,  $file, string $right,, string $file,)
  • string $right,: the 3 or 4 octal numbers to set (775, 664, 0664, etc.)
  • string $file,: the full filename of the file or dir
  • $right
  • $file
static copyTo (line 953)

function copyTo

Try to copy a file (and create all parents if needed)

  • return: true on success, false on failure
static boolean copyTo ( $from,  $to, string $from,, string $to,)
  • string $from,: the full filename of the file to copy
  • string $to,: the full filename of the file copied
  • $from
  • $to
static deleteFile (line 688)

function deleteFile

Delete a file or folder (recursively)

  • return: true on success, false on failure
static boolean deleteFile ( $file, string $file,)
  • string $file,: the full filename of the file or dir
  • $file
static deltree (line 708)

function deltree (rm -rf)

Delete a directory and all subdirectories and files (recursively)

  • return: true on success, false on failure
static boolean deltree ( $dir, [ $withDir = false], string $file,, boolean $withDir,)
  • string $file,: the full filename of the file or dir
  • boolean $withDir,: delete also the dir $file
  • $dir
  • $withDir
static deltreeSimulation (line 742)

function deltreeSimulation (rm -rf)

Simulate the delete a directory and all subdirectories and files (recursively)

  • return: true on success, false on failure
static boolean deltreeSimulation ( $dir, [ $withDir = false], string $file,, boolean $withDir,)
  • string $file,: the full filename of the file or dir
  • boolean $withDir,: delete also the dir $file
  • $dir
  • $withDir
static download (line 634)

Send the current file for download (inline or attachment)

  • return: or false if error
  • access: public
static void download ([boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
  • boolean $inline: : the file is sent inline (default) or as attachment
  • boolean $deleteFile: : delete the sended file at end of download (default : false)
  • mixed $forceContentType: : false to auto get the mime type to send, or string to force a mime type
static downloadFile (line 1247)

Send a given file for download (inline or attachment)

  • return: or false if error
  • access: public
static void downloadFile (string $source, [boolean $inline = true], [boolean $deleteFile = false], [mixed $forceContentType = false])
  • string $source: : the file to download (FS relative)
  • boolean $inline: : the file is sent inline (default) or as attachment
  • boolean $deleteFile: : delete the sended file at end of download (default : false)
  • mixed $forceContentType: : false to auto get the mime type to send, or string to force a mime type
static fileIsExecutable (line 880)

function fileIsExecutable

Is file or dir executable (this function exists because php function is_executable does not work on directories)

  • return: true on success, false on failure
static boolean fileIsExecutable ( $f, string $f,)
  • string $f,: the full filename of the file or dir
  • $f
static getFileList (line 1004)

function getFileList

Get an entire listing of files

  • return: (view CMS_archive::list_files to complete description)
static array getFileList ( $file, string $file,)
  • string $file,: the full filename of the file to get
  • $file
static getFilePerms (line 654)

function getFilePerms

get current file permissions

  • return: value of the file
static octal getFilePerms ( $file, [ $type = "octal"], string $file,, string $type,)
  • string $file,: the full filename of the file or dir
  • string $type,: type of the return : octal value or decimal value
  • $file
  • $type
static getMaxUploadFileSize (line 1112)

return the max uploadable file size

  • return: the max uploadable file size
  • access: public
static string getMaxUploadFileSize ([string $unit = 'M'])
  • string $unit: : the unit to return the value, accept 'M' or 'K' (default : 'M')
static getParent (line 1034)

function getParent

Get the first parent dir who exists of a file

  • return: : the parent dir filename
static string getParent ( $file, string $file,)
  • string $file,: the full filename of the file to get
  • $file
static getTmpPath (line 1049)

get temporary path

  • return: the temporary path
  • access: public
static string getTmpPath ()
static gzipfile (line 1214)

Gzip a given file into another given file

  • return: true on success, fale on failure
  • access: public
static boolean gzipfile (string $source, string $dest, [integer $level = 6])
  • string $source: : the file to gzip (FS relative)
  • string $dest: : the destination file gzipped (FS relative)
  • integer $level: : the level of compression to apply (0 to 9, default 6)
static isDeletable (line 670)

function isDeletable

is file deletable ?

  • return: true on success, false on failure
static boolean isDeletable ( $f, string $file,)
  • string $file,: the full filename of the file or dir
  • $f
static makeDir (line 930)

function makeDir

Try to create a dir (and all parents if needed)

  • return: true on success, false on failure
static boolean makeDir ( $f, string $f,)
  • string $f,: the full filename of the file or dir
  • $f
static makeExecutable (line 842)

function makeExecutable Try to make a file executable if it's not the case On windows platform, this function always return true.

  • return: true on success, false on failure
static boolean makeExecutable ( $f, string $f,)
  • string $f,: the full filename of the file or dir
  • $f
static makeReadable (line 763)

function makeReadable

Try to make a file readable if it's not the case (and executable for a dir)

  • return: true on success, false on failure
static boolean makeReadable ( $f, string $f,)
  • string $f,: the full filename of the file or dir
  • $f
static makeWritable (line 803)

function makeWritable

Try to make a file writable if it's not the case (and executable for a dir)

  • return: true on success, false on failure
static boolean makeWritable ( $f, string $f,)
  • string $f,: the full filename of the file or dir
  • $f
static mimeContentType (line 1076)

get mime type of a given file

  • return: the mime type founded or false if file does not exists. application/octet-stream is returned if no type founded
  • access: public
static string mimeContentType ([string $file = ''])
  • string $file: : the file location to get mime type (relative to FS) or none to use method on current object
static moveTo (line 979)

function moveTo

Try to move a file (and create all parents if needed)

  • return: true on success, false on failure
static boolean moveTo ( $from,  $to, string $from,, string $to,)
  • string $from,: the full filename of the file to move
  • string $to,: the full filename of the file moved
  • $from
  • $to
static sendFiles (line 1131)

Send a group of files to client (ie : JS or CSS files) Provide coherent user caching infos (1 month) for files and allow gzip when possible

  • access: public
static void sendFiles (array $files, [string $contentType = 'text/html'])
  • array $files: : array of files path to send to client (FS relative)
  • string $contentType: : the content type to send to client (default : text/html)
Constructor __construct (line 100)

Constructor

void __construct ( $name, [ $from = self::FILE_SYSTEM], [ $type = self::TYPE_FILE], string $name,, integer $from,, integer $type,)
  • string $name,: the full filename of the file or dir
  • integer $from,: the file path is : self::FILE_SYSTEM or self::WEBROOT
  • integer $type,: the type of the current object : self::TYPE_FILE for a file, self::TYPE_DIRECTORY for a dir, false for undefined
  • $name
  • $from
  • $type

Redefined in descendants as:
checkUploadedFile (line 568)

Check a file to avoid upload threat

  • return: true on success, false on failure
boolean checkUploadedFile ()
chmod (line 454)

function chmod Try to chmod this file / directory.

  • return: true on success, false on failure
boolean chmod ( $right, string $right,)
  • string $right,: the 3 or 4 octal numbers to set (775, 664, 0664, etc.)
  • $right
delete (line 437)

function delete

Delete the file or folder (recursively)

  • return: true on success, false on failure
boolean delete ()
exists (line 134)

Gets the FS existence status of the file

  • return: true if file exists, false otherwise
  • access: public
boolean exists ()
getContent (line 190)

Get the content of the file as string

  • return: the current content
  • access: public
string getContent ()
getExtension (line 226)

Get the file extension if any (lowercase)

  • return: the current file extension
  • access: public
string getExtension ()
getFileIcon (line 264)

Get the file icon if any

  • return: the current file icon
  • access: public
string getFileIcon ([ $from = self::FILE_SYSTEM], integer $from,)
  • integer $from,: the file path is : self::FILE_SYSTEM or self::WEBROOT (default : file system)
  • $from
getFilename (line 215)

Get the full filesystem filename of the file or dir

  • return: the current filename
  • access: public
string getFilename ([ $withPath = true])
  • $withPath
getFilePath (line 282)

Get the file path

  • return: the current file path
  • access: public
string getFilePath ([ $from = self::FILE_SYSTEM], integer $from,)
  • integer $from,: the file path is : self::FILE_SYSTEM or self::WEBROOT (default : file system)
  • $from
getFileSize (line 238)

Get the file size

  • return: the current file size (with unit if any)
  • access: public
string getFileSize ([string $unit = false])
  • string $unit: : the unit to return the value, accept 'M', 'K', '' or false to get the better one (default : false)
getName (line 204)

Alias of getFilename

  • return: the current content
  • access: public
string getName ([ $withPath = true])
  • $withPath
readContent (line 305)

Read the content of the file

  • return: the current content
  • access: public
string/array readContent ([string $returnAs = "string"], [string $array_map_function = "trim"], [array $csvargs = array('delimiter' => ';', 'enclosure' => '"', 'strict' => true)])
  • string $returnAs: : the content format to get : string / array (array of lines) / csv (explode csv file) if requested file is a directory then return the content of the directory (always array in this case)
  • string $array_map_function: : the function to apply at all the content (only for a file content returned as an array). trim by default.
  • array $csvargs: : only for csv format : the csv file delimiter and enclosure chars (default : array('delimiter' => ';', 'enclosure' => '"', 'strict' => true))
setContent (line 146)

Set the content of the file

  • return: true if file exists, false otherwise
  • access: public
boolean setContent (string/array $content, [ $allowSetBlank = false])
  • string/array $content: : the content to set
  • $allowSetBlank
uploadFile (line 476)

Upload a file with as much as security we can

  • return: of uploaded file meta datas
array uploadFile ([ $fileVarName = 'Filedata'], [ $destinationDirFS = PATH_UPLOAD_FS], string $fileVarName,, string $destinationDirFS,)
  • string $fileVarName,: var name in which we can found the file in $_FILES
  • string $destinationDirFS,: the destination dir in which we want the file to be moved
  • $fileVarName
  • $destinationDirFS
writeToPersistence (line 387)

Writes the file into persistence (FS)

  • return: true on success, false on failure
  • access: public
boolean writeToPersistence ([boolean $allowWriteBlank = false], [boolean $createFolder = false])
  • boolean $allowWriteBlank: : allow write of an empty file (default false)
  • boolean $createFolder: : allow the creation of file folder if not exists (default : false)

Inherited Methods

Inherited From CMS_grandFather

 CMS_grandFather::autoload()
 CMS_grandFather::hasError()
 CMS_grandFather::log()
 CMS_grandFather::PHPErrorHandler()
 CMS_grandFather::raiseError()
 CMS_grandFather::setDebug()
 CMS_grandFather::setLog()
 CMS_grandFather::_raiseError()
 CMS_grandFather::__call()
Class Constants
FILE_SYSTEM = 1 (line 30)
TYPE_DIRECTORY = 5 (line 33)
TYPE_FILE = 0 (line 32)
UPLOAD_FILE_CANCELLED = -280 (line 40)
UPLOAD_FILE_VALIDATION_FAILED = -270 (line 39)
UPLOAD_SECURITY_ERROR = -230 (line 36)
UPLOAD_UPLOAD_FAILED = -250 (line 38)
UPLOAD_UPLOAD_LIMIT_EXCEEDED = -240 (line 37)
UPLOAD_UPLOAD_STOPPED = -290 (line 41)
WEBROOT = 2 (line 31)

Inherited Constants

Inherited from CMS_grandFather

CMS_grandFather::ERROR_LOG
CMS_grandFather::SYSTEM_LABEL

Documentation generated on Wed, 15 Feb 2012 15:30:28 +0100 by phpDocumentor 1.4.3