FILE.php
Table of Contents
- setHeaders() : mixed
- Set download headers
- readfile_chunked() : bool
- Download file to user
- createFileName() : array<string|int, mixed>
- create a fileName for this file. If directory based on session ID does not exist, create it.
- fileAttachUploadMaxSize() : int
- Get attachment max upload size in bytes
- imageUploadMaxSize() : int
- Get image max upload size in bytes
- fileUploadMaxSize() : int
- Get file max upload size in bytes
- return_bytes() : int
- Convert some ini values to numerical values (to bytes)
- dirToArray() : array<string|int, mixed>
- Enumerate files and subdirectories of a directory except . and .. subdirectories
- dirInDirToArray() : array<string|int, mixed>
- Enumerate subdirectories of a directory except . and .. subdirectories
- fileInDirToArray() : array<string|int, mixed>
- Enumerate files of a directory except . and .. subdirectories
- recurse_AbsoluteDirToArray() : array<string|int, mixed>
- Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
- recurse_fileInDirToArray() : array<string|int, mixed>
- Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
- recurse_ChangeDateOfFiles() : mixed
- Change recursively the last access/modification datetime of files and subdirectories of a directory
- recurse_dir_copy() : mixed
- Copy recursively a folder
- recurse_rmdir() : mixed
- Remove recursively a folder
- rmfile() : mixed
- Remove a file
- fileUpload() : array<string|int, mixed>
- Return filename, hash, type and size of an uploaded file or an array of such information for each file uploaded
- rearrangeFilesArray() : array<string|int, mixed>
- Rearrange the $_FILES array for multiple file uploads
- fileStore() : bool
- Store uploaded file in given directory with given name
- listFiles() : array<string|int, mixed>
- list and HTML format all files for sessionID
- tidyFiles() : mixed
- tidy up the files directory by removing all files and folders older than WIKINDX_FILE_DELETE_SECONDS
- zip() : mixed
- Zip up an array of files. File is stored in files dir.
- extractComponentPackage() : bool
- Extract a WIKINDX Component Package to a folder
- extractComponentPackageDefinition() : array<string|int, mixed>
- Extract the component.json file of a WIKINDX Component Package to an array
- createComponentPackageReproducible() : string
- Create a compressed package for the release of WIKINDX core, manual or one of its components
- createComponentPackageUnix() : string
- Create a compressed package for the release of WIKINDX core, manual or one of its components
- createComponentPackageBzip2Unix() : mixed
- Create a compressed package in .tar.bz2 format for the release of WIKINDX core, manual or one of its components
- createComponentPackageGzUnix() : mixed
- Create a compressed package in .tar.gz format for the release of WIKINDX core, manual or one of its components
- createComponentPackageZipUnix() : mixed
- Create a compressed package in .zip format for the release of WIKINDX core, manual or one of its components
- createComponentPackage() : string
- Create a compressed package for the release of WIKINDX core, manual or one of its components
- createComponentPackageBzip2() : mixed
- Create a compressed package in .tar.bz2 format for the release of WIKINDX core, manual or one of its components
- createComponentPackageGz() : mixed
- Create a compressed package in .tar.gz format for the release of WIKINDX core, manual or one of its components
- createComponentPackageZip() : mixed
- Create a compressed package in .zip format for the release of WIKINDX core, manual or one of its components
- createComponentPackageTar() : string
- Create a compressed package in .tar format for the release of WIKINDX core, manual or one of its components
- command_exists2() : bool
- Does an unix command exist?
- command_exists() : bool
- Does an unix command exist?
- suhosin_function_exists() : bool
- Does a function exist ou is enabled with or without the suhosin security extension?
- read_json_file() : null|mixed
- Read a JSON file to a data structure
- write_json_file() : int
- Write a data structure to a JSON file
- formatSize() : string
- Format a file size in bytes to the greater multiple for display
Functions
setHeaders()
Set download headers
setHeaders(string $type, int $size, string $filename, string $lastmodified[, string $charset = '' ]) : mixed
Parameters
- $type : string
- $size : int
- $filename : string
- $lastmodified : string
- $charset : string = ''
-
Default is ''
readfile_chunked()
Download file to user
readfile_chunked(string $file) : bool
From http://uk3.php.net/function.readfile
Parameters
- $file : string
createFileName()
create a fileName for this file. If directory based on session ID does not exist, create it.
createFileName(string $dirName, string $string, string $extension) : array<string|int, mixed>
Parameters
- $dirName : string
- $string : string
-
File contents
- $extension : string
-
File extension
fileAttachUploadMaxSize()
Get attachment max upload size in bytes
fileAttachUploadMaxSize() : int
WIKINDX_FILE_ATTACH_SIZE_UPPER_LIMIT is the upper limit
imageUploadMaxSize()
Get image max upload size in bytes
imageUploadMaxSize() : int
WIKINDX_IMG_SIZE_UPPER_LIMIT is the upper limit
fileUploadMaxSize()
Get file max upload size in bytes
fileUploadMaxSize() : int
1G is the upper limit
return_bytes()
Convert some ini values to numerical values (to bytes)
return_bytes(string $val) : int
Parameters
- $val : string
dirToArray()
Enumerate files and subdirectories of a directory except . and .. subdirectories
dirToArray(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
A directory to explore
dirInDirToArray()
Enumerate subdirectories of a directory except . and .. subdirectories
dirInDirToArray(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
A directory to explore
fileInDirToArray()
Enumerate files of a directory except . and .. subdirectories
fileInDirToArray(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
A directory to explore
recurse_AbsoluteDirToArray()
Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
recurse_AbsoluteDirToArray(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
A directory to explore
recurse_fileInDirToArray()
Enumerate recursively files and subdirectories of a directory except . and .. subdirectories
recurse_fileInDirToArray(string $dir) : array<string|int, mixed>
Parameters
- $dir : string
-
A directory to explore
recurse_ChangeDateOfFiles()
Change recursively the last access/modification datetime of files and subdirectories of a directory
recurse_ChangeDateOfFiles(string $dir, int $time) : mixed
Parameters
- $dir : string
-
A directory to explore
- $time : int
-
A Unix timestamp
recurse_dir_copy()
Copy recursively a folder
recurse_dir_copy(string $src, string $dst) : mixed
Parameters
- $src : string
-
Source directory
- $dst : string
-
Destination directory
recurse_rmdir()
Remove recursively a folder
recurse_rmdir(string $dir) : mixed
Parameters
- $dir : string
-
Target directory
rmfile()
Remove a file
rmfile(string $file) : mixed
Parameters
- $file : string
-
Target filename
fileUpload()
Return filename, hash, type and size of an uploaded file or an array of such information for each file uploaded
fileUpload([false|string $filename = FALSE ][, bool $multiple = FALSE ]) : array<string|int, mixed>
Parameters
- $filename : false|string = FALSE
- $multiple : bool = FALSE
-
multiple files (default FALSE)
rearrangeFilesArray()
Rearrange the $_FILES array for multiple file uploads
rearrangeFilesArray(array<string|int, mixed> $files) : array<string|int, mixed>
Parameters
- $files : array<string|int, mixed>
fileStore()
Store uploaded file in given directory with given name
fileStore(string $dirName, string $name[, false|int $index = FALSE ]) : bool
Parameters
- $dirName : string
- $name : string
- $index : false|int = FALSE
-
if moving multiple file uploads
listFiles()
list and HTML format all files for sessionID
listFiles() : array<string|int, mixed>
tidyFiles()
tidy up the files directory by removing all files and folders older than WIKINDX_FILE_DELETE_SECONDS
tidyFiles() : mixed
zip()
Zip up an array of files. File is stored in files dir.
zip(array<string|int, mixed> $files, string $path) : mixed
Parameters
- $files : array<string|int, mixed>
-
unqualified filenames (key is label of file, value is filename on disk)
- $path : string
-
file path
extractComponentPackage()
Extract a WIKINDX Component Package to a folder
extractComponentPackage(string $ComponentPackageFile, string $DestinationFolder) : bool
The .tar.gz and .tar.bz2 archives are decompressed in two stages and require the creation of a temporary .tar file in the same directory as the archive to uncompress.
If missing, the destination folder is created silently. otherwise its contents is overwritten and existing files that are not in the archive are deleted.
It is not necessary to delete the files of the previous component that occupies the same destination, which limits the loss of an already installed component if the operation does not complete.
However, it is always possible to end up in an inconsistent state if the operation failed between the decompression of two files. It should be very rare.
So a component should never create files and folders in its code directories otherwise they will be deleted. Use the private cache and data folders of a component for this task.*
BUGS: https://bugs.php.net/bug.php?id=79912 Phar crashs with an exception on Gzip/Bzip2 archives
Parameters
- $ComponentPackageFile : string
-
Absolute or relative path to an archive file created with \FILE\createComponentPackage
- $DestinationFolder : string
-
Absolute or relative path of a folder where the archive is extracted
extractComponentPackageDefinition()
Extract the component.json file of a WIKINDX Component Package to an array
extractComponentPackageDefinition(string $ComponentPackageFile) : array<string|int, mixed>
The .tar.gz and .tar.bz2 archives are decompressed in two stages and require the creation of a temporary .tar file in the same directory as the archive to uncompress.
The component.json file is read in memory before parsing.
Parameters
- $ComponentPackageFile : string
-
Absolute or relative path to an archive file created with \FILE\createComponentPackage
createComponentPackageReproducible()
Create a compressed package for the release of WIKINDX core, manual or one of its components
createComponentPackageReproducible(string $SrcDir, string $DstDir, string $Archive, string $Format) : string
This function is a wrapper that hide the specifics of compression formats.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstDir : string
-
Absolute or relative path to a destination directory
- $Archive : string
-
Name of the package file, without path and extension
- $Format : string
-
Code of a package format (ZIP, GZ, BZIP2)
createComponentPackageUnix()
Create a compressed package for the release of WIKINDX core, manual or one of its components
createComponentPackageUnix(string $SrcDir, string $DstDir, string $Archive, string $Format) : string
This function is a wrapper that hide the specifics of compression formats.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstDir : string
-
Absolute or relative path to a destination directory
- $Archive : string
-
Name of the package file, without path and extension
- $Format : string
-
Code of a package format (ZIP, GZ, BZIP2)
createComponentPackageBzip2Unix()
Create a compressed package in .tar.bz2 format for the release of WIKINDX core, manual or one of its components
createComponentPackageBzip2Unix(string $SrcDir, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackageGzUnix()
Create a compressed package in .tar.gz format for the release of WIKINDX core, manual or one of its components
createComponentPackageGzUnix(string $SrcDir, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackageZipUnix()
Create a compressed package in .zip format for the release of WIKINDX core, manual or one of its components
createComponentPackageZipUnix(string $SrcDir, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackage()
Create a compressed package for the release of WIKINDX core, manual or one of its components
createComponentPackage(string $SrcDir, string $DstDir, string $Archive, string $Format) : string
This function is a wrapper that hide the specifics of compression formats.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstDir : string
-
Absolute or relative path to a destination directory
- $Archive : string
-
Name of the package file, without path and extension
- $Format : string
-
Code of a package format (ZIP, GZ, BZIP2)
createComponentPackageBzip2()
Create a compressed package in .tar.bz2 format for the release of WIKINDX core, manual or one of its components
createComponentPackageBzip2(string $SrcFile, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcFile : string
-
Absolute or relative path to a source TAR file
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackageGz()
Create a compressed package in .tar.gz format for the release of WIKINDX core, manual or one of its components
createComponentPackageGz(string $SrcFile, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcFile : string
-
Absolute or relative path to a source TAR file
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackageZip()
Create a compressed package in .zip format for the release of WIKINDX core, manual or one of its components
createComponentPackageZip(string $SrcDir, string $DstFile) : mixed
This function must be called from createComponentPackage() only.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstFile : string
-
Absolute or relative path to a destination package file
createComponentPackageTar()
Create a compressed package in .tar format for the release of WIKINDX core, manual or one of its components
createComponentPackageTar(string $SrcDir, string $DstDir) : string
This function must be called from createComponentPackage() only.
Parameters
- $SrcDir : string
-
Absolute or relative path to a source directory
- $DstDir : string
-
Absolute or relative path to a destination directory
command_exists2()
Does an unix command exist?
command_exists2(string $command) : bool
Parameters
- $command : string
-
Command to test with the default shell
command_exists()
Does an unix command exist?
command_exists(string $command) : bool
Parameters
- $command : string
-
Command to test with the default shell
suhosin_function_exists()
Does a function exist ou is enabled with or without the suhosin security extension?
suhosin_function_exists(string $func) : bool
Parameters
- $func : string
-
Function name
Tags
read_json_file()
Read a JSON file to a data structure
read_json_file(string $file) : null|mixed
Read a JSON file and unserialize its content to a data structure with json_decode()
Parameters
- $file : string
-
An absolute or relative path to a file
Tags
write_json_file()
Write a data structure to a JSON file
write_json_file(string $file, mixed $data) : int
Serialize a data structure with json_encode() and write it in a file
Parameters
- $file : string
-
An absolute or relative path to a file
- $data : mixed
-
A data structure or a value
Tags
formatSize()
Format a file size in bytes to the greater multiple for display
formatSize(int $size) : string
Parameters
- $size : int
-
In bytes