WIKINDX API 6.4.10

FILE

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
getMimeType()  : string
Return the mime-type of a file
getExtension()  : string
Return the extension of a file

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 ''

Return values
mixed

readfile_chunked()

Download file to user

readfile_chunked(string $file) : bool

From http://uk3.php.net/function.readfile

Parameters
$file : string
Return values
bool

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

Return values
array<string|int, mixed>

(filename, full filepath)

fileAttachUploadMaxSize()

Get attachment max upload size in bytes

fileAttachUploadMaxSize() : int

WIKINDX_FILE_ATTACH_SIZE_UPPER_LIMIT is the upper limit

Return values
int

imageUploadMaxSize()

Get image max upload size in bytes

imageUploadMaxSize() : int

WIKINDX_IMG_SIZE_UPPER_LIMIT is the upper limit

Return values
int

fileUploadMaxSize()

Get file max upload size in bytes

fileUploadMaxSize() : int

1G is the upper limit

Return values
int

return_bytes()

Convert some ini values to numerical values (to bytes)

return_bytes(int|string $val) : int
Parameters
$val : int|string
Return values
int

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

Return values
array<string|int, mixed>

An array of file and subdirectory names

dirInDirToArray()

Enumerate subdirectories of a directory except . and .. subdirectories

dirInDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of subdirectory names

fileInDirToArray()

Enumerate files of a directory except . and .. subdirectories

fileInDirToArray(string $dir) : array<string|int, mixed>
Parameters
$dir : string

A directory to explore

Return values
array<string|int, mixed>

An array of filenames

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

Return values
array<string|int, mixed>

An array of file and subdirectory absolute paths

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

Return values
array<string|int, mixed>

An array of file and subdirectory paths

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

Return values
mixed

recurse_dir_copy()

Copy recursively a folder

recurse_dir_copy(string $src, string $dst) : mixed
Parameters
$src : string

Source directory

$dst : string

Destination directory

Return values
mixed

recurse_rmdir()

Remove recursively a folder

recurse_rmdir(string $dir) : mixed
Parameters
$dir : string

Target directory

Return values
mixed

rmfile()

Remove a file

rmfile(string $file) : mixed
Parameters
$file : string

Target filename

Return values
mixed

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)

Return values
array<string|int, mixed>

(filename, hash, type, size) or array of these

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>
Return values
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

Return values
bool

listFiles()

list and HTML format all files for sessionID

listFiles() : array<string|int, mixed>
Return values
array<string|int, mixed>

(filesDir, fileDeleteSecs, fileArray)

tidyFiles()

tidy up the files directory by removing all files and folders older than WIKINDX_FILE_DELETE_SECONDS

tidyFiles() : mixed
Return values
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

Return values
mixed

unqualified SHA1'ed filename of zip or FALSE if failure

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

Return values
bool

TRUE on success, FALSE otherwise

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

Return values
array<string|int, mixed>

Structured definition of the component

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)

Return values
string

Absolute or relative path to the final package file with its extension

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)

Return values
string

Absolute or relative path to the final package file with its extension

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

Return values
mixed

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

Return values
mixed

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

Return values
mixed

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)

Return values
string

Absolute or relative path to the final package file with its extension

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

Return values
mixed

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

Return values
mixed

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

Return values
mixed

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

Return values
string

Absolute or relative path to an intermediate TAR file (generate a random name itself)

command_exists2()

Does an unix command exist?

command_exists2(string $command) : bool
Parameters
$command : string

Command to test with the default shell

Return values
bool

TRUE on success

command_exists()

Does an unix command exist?

command_exists(string $command) : bool
Parameters
$command : string

Command to test with the default shell

Return values
bool

TRUE on success

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
see
https://suhosin.org/stories/index.html
author

webmaster@mamo-net.de

Return values
bool

TRUE if the function is enabled

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
see
https://www.php.net/manual/en/function.json-decode.php
Return values
null|mixed

A value, a data structure, or NULL on error

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
see
https://www.php.net/manual/en/function.json-encode.php
Return values
int

JSON_ERROR_NONE on success, a JSON error constant on encoding error, or JSON_ERROR_NONE - 1 on file writing error

formatSize()

Format a file size in bytes to the greater multiple for display

formatSize(int $size) : string
Parameters
$size : int

In bytes

Return values
string

getMimeType()

Return the mime-type of a file

getMimeType(string $filepath[, string $altfilename = "" ]) : string

The PHP finfo() function doesn't always return the right mime-type, so it tries to read it from OCF containers and to fallback on file extension when the mime-type is obviously too generic (e.g. text/plain, text/xml).

You can provide an alternate filename to force the extension instead of taking the extension of filepath.

Parameters
$filepath : string

An absolute or relative file path

$altfilename : string = ""

Default is ""

Return values
string

A mime-type

getExtension()

Return the extension of a file

getExtension(string $filepath) : string
Parameters
$filepath : string

An absolute or relative file path

Return values
string

Search results