Check whether the file is allowed based on extension and if $strict=true also on mimetype
- Will use the class defaults for optional parameters which were not passed
- Will try to 'guess' the mimetypes if a strict check is requested, but no mimetypes were
passed
- Returns true is the file passes, false if not.
bool
check_allowed_file
(string $pathtofile, [array|string $exts = null], [bool $strict = null], [array $mimetypes = null])
-
string
$pathtofile: path to the file to check
-
array|string
$exts: [optional] allowed extensions
-
bool
$strict: [optional] whether or not to check on mimetype
-
array
$mimetypes: [optional] allowed mimetypes
Check the file extension of a filename against the list of allowed extensions
- This is a case-insensitive extension check
- Will use the class defaults for optional parameters which were not passed
- Returns true if the filename passes the valid extension check
- Returns false is it fails or if the passed filename parameter is not a string
bool
check_file_extension
(string $filename, [array|string $exts = null])
-
string
$filename: filename to check
-
array|string
$exts: [optional] array of allowed extensions
Check the file-mimetype against a list of allowed mimetypes
- Will use the class defaults for optional parameters which were not passed
- Returns true if the file-mimetype is within the list of allowed mimetypes
- Returns false if not or if the passed filename parameter is not a string
bool
check_file_mimetype
(string $pathtofile, [array $mimetypes = null])
-
string
$pathtofile
-
array
$mimetypes: [optional] array of valid mimetypes
Get the total size of all files in $pathtodir
int
get_dirsize
([bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the size
-
bool
$recursive: [optional] whether to include filesize of files in subdirectories
Get a list of directories in $pathtodir
array
get_dir_list
(string $pathtodir, [bool $recursive = null])
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on directories in subdirectories
Retrieve a filelist which only contains files which comply with the allowed extension/mimetypes
- Creates a selection list of files which comply with the criteria set by
allowed extensions / allowed mimetypes
- $strict determined whether or not to check on mimetype
- $exts, $strict and $mimetypes default to the class defaults if not passed
array
get_ext_based_filelist
([bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null], [array|string $exts = null], [bool $strict = null], [array $mimetypes = null])
-
bool
$use_selection: [optional] whether or not the last made selection should be returned if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
-
array|string
$exts: [optional] allowed extensions
-
bool
$strict: [optional] whether or not to check on mimetype
-
array
$mimetypes: [optional] allowed mimetypes
Get list of files in $pathtodir
- Use this method to retrieve a filelist for a certain directory path
- If a filelist was created before and you want to retrieve this list, you can use this function
without any parameters and it will return the previously created list
- If you created a selection based on the earlier created filelist, you can choose to retrieve
that selection instead by setting $use_selection to true
- If no filelist was created before and no parameters are passed, it will retrieve a filelist
based on the class defaults
- If you call this method as a static method, logically you can not retrieve an earlier
created listing or selection list
array
get_filelist
([bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$use_selection: [optional] whether or not the last made selection should be returned if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Get the filesize of a file
int|false
get_filesize
(string $pathtofile)
Retrieve a filelist which only contains files accessed before the passed unix timestamp
- Creates a selection list of files which comply with the criteria set by $comparets
Inspired by a comment from Benan Tumkaya (benantumkaya at yahoo) - 14-Aug-2006 11:11
array
get_files_accessed_before
(int $compare_ts, [bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
int
$compare_ts: Unix timestamp for date/time to compare against
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Retrieve a filelist which only contains files accessed since the passed unix timestamp
- Creates a selection list of files which comply with the criteria set by $comparets
Inspired by a comment from Benan Tumkaya (benantumkaya at yahoo) - 14-Aug-2006 11:11
array
get_files_accessed_since
(int $compare_ts, [bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
int
$compare_ts: Unix timestamp for date/time to compare against
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Retrieve a filelist which only contains files modified before the passed unix timestamp
- Creates a selection list of files which comply with the criteria set by $comparets
Inspired by a comment from Benan Tumkaya (benantumkaya at yahoo) - 14-Aug-2006 11:11
array
get_files_modified_before
(int $compare_ts, [bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
int
$compare_ts: Unix timestamp for date/time to compare against
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Retrieve a filelist which only contains files modified since the passed unix timestamp
- Creates a selection list of files which comply with the criteria set by $comparets
Inspired by a comment from Benan Tumkaya (benantumkaya at yahoo) - 14-Aug-2006 11:11
array
get_files_modified_since
(int $compare_ts, [bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
int
$compare_ts: Unix timestamp for date/time to compare against
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Get the file owner for a file
int|false
get_file_owner
(string $pathtofile)
Get the total size of all files in a directory in a human readable format
string
get_human_readable_dirsize
([bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the size
-
bool
$recursive: [optional] whether to include filesize of files in subdirectories
Get the filesize of a file in a human readable format
string|false
get_human_readable_filesize
(string $pathtofile)
Get a human readable file permission string for a file
string|false
get_human_readable_file_permissions
(string $pathtofile)
Get the last access timestamp of a file in a human readable format
string|false
get_human_readable_lastacc
(string $pathtofile, [string $datetime_format = null])
-
string
$pathtofile
-
string
$datetime_format: [optional]
Get the last modified timestamp of a file in a human readable format
string|false
get_human_readable_lastmod
(string $pathtofile, [string $datetime_format = null])
-
string
$pathtofile
-
string
$datetime_format: [optional]
Get the last access unix timestamp for a file
int|false
get_lastacc_unixts
(string $pathtofile)
Get the last modified unix timestamp for a file
int|false
get_lastmod_unixts
(string $pathtofile)
Get the mime content type of a file
string|false
get_mime_content_type
(string $pathtofile)
Retrieve the filename and last_modified date of the most recently modified file
Inspired by a comment from wookie at at no-way dot org - 14-Sep-2003 11:17
array
get_most_recent_file
([bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$use_selection: [optional] whether or not the last made selection should be used if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Retrieve a sorted (sub-)directory list
- Mainly useful for reverse sorting as the normal dirlist is already sorted in
ascending order
- Defaults to ascending sort order
- To sort descendingly, set $sort_asc to false
- The list sorting will always use case-insensitive natural sort order
- Retrieving a sorted list will not affect the order of the class 'remembered' dirlist
array
get_sorted_dirlist
([bool $sort_asc = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$sort_asc: [optional] set to false for reverse / descending sorted list
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on directories in subdirectories
Retrieve a sorted filelist
- Mainly useful for reverse sorting as the normal filelist is already sorted in
ascending order
- Defaults to ascending sort order
- To sort descendingly, set $sort_asc to false
- The list sorting will always use case-insensitive natural sort order
- Retrieving a sorted list will not affect the order of the class 'remembered' filelists
array
get_sorted_filelist
([bool $sort_asc = null], [bool $use_selection = null], [string $pathtodir = null], [bool $recursive = null])
-
bool
$sort_asc: [optional] set to false for reverse / descending sorted list
-
bool
$use_selection: [optional] whether or not the last made selection should be returned if available
-
string
$pathtodir: [optional] path to the directory for which to get the list
-
bool
$recursive: [optional] whether to retrieve information on files in subdirectories
Creates a human readable file size string
- Rounds bytes and kilobytes to the nearest integer
- Rounds anything else to one digit behind the decimal point
- Returns false is the passed parameter is not an integer or a numeric string
Examples:
the integer
1080 becomes the string
1 kB the integer
3000000 becomes the string
2.8 MB
string|false
human_readable_filesize
(int $filesize)
-
int
$filesize: filesize in bytes
Change the $datetime_format default
- Refer to $datetime_format for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_datetime_format
(string $datetime_format)
Change the $exts default
- Refer to $exts for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_default_exts
(array|string $exts)
Change the $mimetypes default
- Refer to $mimetypes for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_default_mimetypes
(array $mimetypes)
Change the $pathtodir default
- Refer to $pathtodir for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_default_path
(string $pathtodir)
Change the $safe_exts default
- Refer to $safe_exts for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_safe_exts
(bool $safe_exts)
Change the $strict default
- Refer to $strict for information on valid formats for the variable
- Returns boolean true / false to indicate whether the default was changed succesfully
bool
set_strict
(bool $strict)
Clears the file stat cache and checks whether the passed $pathtofile is a valid path to a file
bool
valid_pathtofile
(string $pathtofile)