contenido\includes\functions.file.php
Description: Functions to edit files. Included in Area style, js, htmltpl in Frame right_bottom.
Requirements:
- Author
- Willi Man
- Con_php_req
- 5.0
- Copyright
- four for business AG
- License
- http://www.contenido.org/license/LIZENZ.txt
- Link
- http://www.4fb.de
- Link
- http://www.contenido.org
- Package
- Contenido Backend includes
- Since
- file available since contenido release >= 4.6 {@internal created 2004-07-13 modified 2008-06-26, Frederic Schneider, add security fix modified 2008-08-14, Timo.Trautmann added file_information functions for storing file meta indormations modified 2009-10-23, Murat Purc, removed deprecated function (PHP 5.3 ready), added new function fileValidateFilename() and commented code $Id: functions.file.php 1085 2009-10-24 02:01:34Z xmurrix $: }}
- Version
- 1.0.3
Functions

createFile(string $filename, string $path) : \(void | \bool)
Creates a file.
Exits the script, if filename is not valid or creation (touch or chmod) fails!
Name | Type | Description |
---|---|---|
$filename | string | The file to create |
$path | string | Path to the file |
Type | Description |
---|---|
\(void | \bool) | Either true on success or nothing |

fileEdit(string $filename, string $sCode, string $path) : \(string | \void)
Writes passed data into a file using binary mode.
Exits the script, if file could not opened!
Name | Type | Description |
---|---|---|
$filename | string | The file to write the content |
$sCode | string | File content to write |
$path | string | Path to the file |
Type | Description |
---|---|
\(string | \void) | Either content of file o nothing |

fileValidateFilename(string $filename, bool $notifyAndExitOnFailure = true) : \(void | \bool)
Validates passed filename.
Filename can contain alphanumeric characters, dot, underscore or a hyphen.
Exits the script, if second parameter is set to true and validation fails!
Name | Type | Description |
---|---|---|
$filename | string | The filename to validate |
$notifyAndExitOnFailure | bool | Flag to display notification and to exit further script execution, ifd validation fails |
Type | Description |
---|---|
\(void | \bool) | Either validation result or nothing (depends on second parameter) |

getFileContent(string $filename, string $path) : \(string | \void)
Reads content of file into memory using binary mode and returns it back.
Exits the script, if file could not opened!
Name | Type | Description |
---|---|---|
$filename | string | The file to get the content |
$path | string | Path to the file |
Type | Description |
---|---|
\(string | \void) | Either content of file o nothing |

getFileInformation(integer $iIdClient, string $sFilename, string $sType, object $oDb) : array
Function returns file meta information from database (used when files were versionned or description is displayed)
Name | Type | Description |
---|---|---|
$iIdClient | integer |
|
$sFilename | string |
|
$sType | string |
|
$oDb | object |
|
Type | Description |
---|---|
array | Indexes: idsfi - Primary key of database record created - Datetime when file was created lastmodified - Datetime when file was last modified author - Author of file (Contenido Backend User) modifiedby - Last modifier of file (Contenido Backend User) description - Description which was inserted for this file |
- Author
- Timo Trautmann

getFileType(string $filename) : string
Returns the filetype (extension).
Name | Type | Description |
---|---|---|
$filename | string | The file to get the type |
Type | Description |
---|---|
string | Filetype |

removeFileInformation(integer $iIdClient, string $sFilename, string $sType, object $oDb) : void
Function removes file meta information from database (used when a file is deleted)
Name | Type | Description |
---|---|---|
$iIdClient | integer |
|
$sFilename | string |
|
$sType | string |
|
$oDb | object |
|
- Author
- Timo Trautmann

renameFile(string $sOldFile, string $sNewFile, string $path) : \(void | \string)
Renames a existing file.
Exits the script, if new filename is not valid or renaming fails!
Name | Type | Description |
---|---|---|
$sOldFile | string | Old filename |
$sNewFile | string | New filename |
$path | string | Path to the file |
Type | Description |
---|---|
\(void | \string) | Either new filename or nothing |

updateFileInformation(integer $iIdClient, string $sFilename, string $sType, string $sAuthor, string $sDescription, object $oDb, string $sFilenameNew = '') : void
Function updates file meta information (used when files were created or edited).
It creates new database record for file meta informations if database record does not exist. Otherwise, existing record will be updated
Name | Type | Description |
---|---|---|
$iIdClient | integer |
|
$sFilename | string |
|
$sType | string |
|
$sAuthor | string |
|
$sDescription | string |
|
$oDb | object |
|
$sFilenameNew | string |
|
- Author
- Timo Trautmann