File
class File
Properties
| $trash_folder | |||
| array | $curl_info | Contains the info returned by CURL when calling $this->download_file_from_url(); |
Methods
No description
No description
Copies the passed file/folder to the trash folder
UTF8 Compatible basename(), because php::basename() is still buggy (e.g.: removes all umlauts at the beginning of a filename)
No description
Check a file for virus If a virus is found TRUE is returned, otherwise FALSE To use this function ClamAV (Daemon) had to be installed and the user belonged to the webserver group
Checks files uploaded through forms for:
Complete an URL to be absolute
Builds a path by concating multiple path elements It ensures all path elements use the proper separator when being glued and secures all elements to avoid relative escapes (../ is not allowed) to ensure e.g. frontend input can not escape folder
Converts a PHP INI Size as memory_limit size string to a byte value
No description
No description
callback function for getting header values from curl, used by download_file_from_url
No description
Downloads a file from a url.
No description
Include / Enable a certain stream wrapper Example: "smb://user:pass@server/share/path"
No description
Checks if the passed file exists, cached for the current call
No description
No description
No description
Get File Information
returns an array with ffmpeg compatible video extensions this is populated from video worker
No description
Returns a cascaded path based on the passed id to prevent file system storage limitations. 10.000 files per folder will be used.
Returns the content of a file or url by curl.
No description
Editable File Types for XOI or directly via MS-Office
Returns the charset of the given file. This method uses exec() to
No description
No description
Returns the encoding of the file.
No description
No description
No description
No description
No description
Get friendly filesize
No description
No description
No description
No description
Creates a temporary folder for backup data and returns the path.
No description
No description
No description
function used by get_max_upload_size to convert the ini values to a byte values
No description
If file extension considered an image format?
If file extension considered a rocessable and previewable video format? Must be compatible and supported by ffmpeg conversion process
No description
Checks if the passed PHP file is encoded via Ioncube
Check if Filename meets the nonstrict security guidelines
No description
No description
No description
Returns an array with all files in the given directory (Recursive)
No description
No description
No description
No description
No description
No description
Replaces the passed vars in the given file The file must contain markers in the format {{VARNAME}} The engine currently supports DOCX and TXT formats for replacement
Returns all files for given path recursive. It is allowed to use glob pattern to restrict the result.
No description
No description
No description
Send file to client/browser
Set permissions for files writable system user only Should be applied to files in class, modules, etc -> readable for web and writable to system only \XF_SYSTEM_UID and \XF_WEBSERVER_UID
Set permissions for files writable to the web user and system user Should be applied to files in _log, _files, etc -> readable and writable to system AND web \XF_SYSTEM_UID and \XF_WEBSERVER_UID
Slightly modified version of http://www.geekality.net/2011/05/28/php-tail-tackling-large-files/
Unzip and extract files from given source to target path.
Zip all files to
Details
at line 22
__construct()
No description
at line 35
__destruct()
No description
at line 164
bool
backup_to_trash($file_or_folder, $force = false)
Copies the passed file/folder to the trash folder
at line 1326
string
basename(string $string)
UTF8 Compatible basename(), because php::basename() is still buggy (e.g.: removes all umlauts at the beginning of a filename)
at line 500
string
change_file_extension(string $filename, string $new_ext)
No description
at line 845
bool
check_for_virus(string $filename, bool $RemoveInfectedFile = false, string $summary = null)
Check a file for virus If a virus is found TRUE is returned, otherwise FALSE To use this function ClamAV (Daemon) had to be installed and the user belonged to the webserver group
at line 810
void
check_uploaded_file(string $tempName, string $name)
Checks files uploaded through forms for:
- antivirus (if endbaled) and removes infected files
- file extension whitelist (if set)
Logging and user interaction is the calling functions responsibility
- example catch exception and output/log message
at line 1354
string
complete_absolute_url(string $url)
Complete an URL to be absolute
at line 891
string
concatPaths($paths = [])
Builds a path by concating multiple path elements It ensures all path elements use the proper separator when being glued and secures all elements to avoid relative escapes (../ is not allowed) to ensure e.g. frontend input can not escape folder
at line 1296
static float|int
convertIniSizeToBytes(string $sizeExpression)
Converts a PHP INI Size as memory_limit size string to a byte value
at line 118
bool
cp(string $file, string $target)
No description
at line 93
bool
cp_r(string $sourceDir, string $targetDir, bool $onlyContents = false)
No description
at line 1505
int
curl_header_cb(mixed $ch, mixed $header)
callback function for getting header values from curl, used by download_file_from_url
at line 1068
string
decode_file(string $filename, string $password, bool $copy_to_tmp = false)
No description
at line 1386
array|string|false
download_file_from_url(string $url, bool $return_data = false)
Downloads a file from a url.
If the URL is placed on the current host it will be requested using the current user session Note: Please make sure to set the PHP timeout if you expect to download large files. The download is aborted if it takes longer than 5 minutes.
at line 1013
string
du(string $path)
No description
at line 1660
bool
enable_stream_wrapper(string $wrapper)
Include / Enable a certain stream wrapper Example: "smb://user:pass@server/share/path"
at line 1037
string
encode_file(string $filename, string $password, bool $copy_to_tmp = false)
No description
at line 1681
file_exists_cached($file)
Checks if the passed file exists, cached for the current call
at line 352
filter_by_extension($filelist, $extension_filter = false)
No description
at line 386
filter_by_wildcard($filelist, $wildcard, $match_full_path = false)
No description
at line 409
filter_onlyfiles($filelist)
No description
at line 1991
array
getFileInfo(string $fsPath)
Get File Information
at line 982
array
getVideoExtensions()
returns an array with ffmpeg compatible video extensions this is populated from video worker
at line 774
string
get_cache_file(string $prefix, string $filename, array|bool $partition_index = false)
No description
at line 758
get_cascaded_folder(int $id)
Returns a cascaded path based on the passed id to prevent file system storage limitations. 10.000 files per folder will be used.
e.g. IDs 1-9999 will be in folder k0/[1-9999]/ and 10000 to 19999 will be in folder k1/[10000-19999]/
at line 610
bool|mixed|string
get_contents(string $target, int $request_timeout = 20, int $connection_timeout = 5)
Returns the content of a file or url by curl.
at line 736
bool|string
get_document_temp_folder($instance, $document_id, int $post_type = 0, bool $return_alternative_temp_folder = true)
No description
at line 1611
array
get_editable_file_types()
Editable File Types for XOI or directly via MS-Office
at line 592
mixed|null
get_file_charset(string|bool $file_path)
Returns the charset of the given file. This method uses exec() to
at line 637
array
get_file_contents(array|string $filelist)
No description
at line 515
array|false
get_file_details(string|string[] $filelist, bool $details = false)
No description
at line 572
null|string
get_file_encoding(string $file_path)
Returns the encoding of the file.
at line 467
string
get_file_extension(string $filename)
No description
at line 484
string|bool
get_file_extension_by_mime(string $mime)
No description
at line 452
string
get_filename_without_extension(string $filename)
No description
at line 1182
string
get_first_file_found(array $files, bool|string $path = false)
No description
at line 1097
string
get_friendly_filename(string $file)
No description
at line 1116
get_friendly_filesize(string $file)
Get friendly filesize
at line 1273
int
get_max_upload_size()
No description
at line 439
bool|mixed
get_mime(string $file)
No description
at line 424
bool|mixed
get_mime_by_extension(string $extension)
No description
at line 1126
string
get_secure_filename(string $filename, bool $strict = true)
No description
at line 719
string
get_temp_backup_folder()
Creates a temporary folder for backup data and returns the path.
at line 694
string
get_temp_folder(bool $delete_on_destruction = false)
No description
at line 680
string
get_temp_name(bool $delete_on_destruction = false)
No description
at line 29
init()
No description
at line 1285
float|int
inival_to_bytes(string $val)
deprecated
deprecated
function used by get_max_upload_size to convert the ini values to a byte values
at line 909
bool
isEmptyDirectory(string $dir)
No description
at line 947
bool
isImageExtension(string $ext)
If file extension considered an image format?
at line 973
bool
isVideoExtension(string $ext)
If file extension considered a rocessable and previewable video format? Must be compatible and supported by ffmpeg conversion process
at line 935
bool
is_image($filepath)
No description
at line 1165
is_ioncube_encoded($filename)
Checks if the passed PHP file is encoded via Ioncube
at line 1156
bool
is_secure_filename(string $filename)
Check if Filename meets the nonstrict security guidelines
at line 874
bool
is_subfolder($subfolder, $parent)
No description
at line 959
bool
is_video(string $filepath)
No description
at line 256
array|false
ll(string $dirname, array|bool $extension_filter = false, bool $skip_directories = true)
No description
at line 321
array
ll_r(string $dir, array|bool $extension_filter = false, bool $return_folders = false, bool $limit = null)
Returns an array with all files in the given directory (Recursive)
at line 55
bool
mkdir(int $pathname, int $mode = 0777, bool $recursive = false)
No description
at line 80
bool
mkdir_r($dirname, int $mode = 0777)
No description
at line 669
bool
mv(string $source, string $target)
No description
at line 657
int
put_file_contents(string $file, mixed $content)
No description
at line 922
string
relativize_path(string $subfolder, $parent)
| internal | param string $parentParent Folder, e.g. /server/dev/ |
No description
at line 1026
bool
rename(string $current_name, string $new_name)
No description
at line 1213
string
replace_vars_in_file(mixed $filename, mixed $vars = array(), int $ext = 'auto', mixed $send_file = false)
Replaces the passed vars in the given file The file must contain markers in the format {{VARNAME}} The engine currently supports DOCX and TXT formats for replacement
at line 291
array
rglob(string $path, int $flags = 0, int $stop_after = null)
Returns all files for given path recursive. It is allowed to use glob pattern to restrict the result.
E.g. /server/xelos/modules/*.yml return all YAML files.
at line 128
rm(string $filename)
No description
at line 148
mixed
rmdir(string $dirname)
No description
at line 212
array|bool
rmdir_r(string $dirname)
No description
at line 1703
bool|mixed|string
send_file($path_to_file, false $filename = false, false $download_params = false)
Send file to client/browser
at line 1961
setPermissionsSystem(string $path)
Set permissions for files writable system user only Should be applied to files in class, modules, etc -> readable for web and writable to system only \XF_SYSTEM_UID and \XF_WEBSERVER_UID
at line 1927
setPermissionsWeb(string $path)
Set permissions for files writable to the web user and system user Should be applied to files in _log, _files, etc -> readable and writable to system AND web \XF_SYSTEM_UID and \XF_WEBSERVER_UID
at line 1523
string|null
tail(string $filepath, int $lines = 1, bool $adaptiveBuffer = true)
Slightly modified version of http://www.geekality.net/2011/05/28/php-tail-tackling-large-files/
at line 1913
unzip(string $source, string $target)
Unzip and extract files from given source to target path.
at line 1890
?string
zip(array $filesToZip, string|null $zipFileDestination = null)
Zip all files to