|
| array_flatten (array $array, $separator=".", $parent_key="") |
|
| array_expand (array $array, $separator=".") |
|
| array_sort_key (array &$array, $key) |
|
| array_filter_ex ($array, $key, $value) |
|
| array_keys_exists (array $keys, array $search, &$missing=NULL) |
|
| toArray ($object) |
|
| array_value (array $array, $key, $default=NULL) |
|
| array_rand_value (array $array, $num=1) |
|
| array_boolval (array $array, $key) |
|
| boolvalEx ($var) |
|
| is_uuid ($var) |
|
| is_fs_uuid ($var) |
|
| is_devicefile ($var) |
|
| is_devicefile_by ($var) |
|
| is_devicefile_by_uuid ($var) |
|
| is_devicefile_by_id ($var) |
|
| is_devicefile_by_label ($var) |
|
| is_devicefile_by_path ($var) |
|
| is_block ($filename, $dereference=TRUE) |
|
| is_json ($var) |
|
| is_ipaddr ($var) |
|
| is_ipaddr4 ($var) |
|
| is_ipaddr6 ($var) |
|
| is_multi_array ($var) |
|
| is_multiarray ($var) |
|
| is_assoc_array ($var) |
|
| is_assoc ($var) |
|
| is_64bits () |
|
| json_validate ($data, $schema, &$errors=NULL) |
|
| json_encode_safe ($value, $options=0) |
|
| json_decode_safe ($json, $assoc=false, $depth=512, $options=0) |
|
if(!function_exists('json_last_error_msg')) | binary_format ($number, $options=NULL) |
|
| binary_convert ($number, $fromPrefix, $toPrefix, $decimalPlaces=0) |
|
| strpdate ($date, $format) |
|
| build_path ($separator,... $parts) |
|
| listdir ($directory, $extension="", $sortFlags=SORT_NATURAL) |
|
| mkdtemp ($prefix="", $mode=0700) |
|
| inet_getnetmask ($bits, $forceipv6=FALSE) |
|
| in_range ($var, $min, $max) |
|
| uuid_equals ($uuid1, $uuid2) |
|
| fs_uuid_equals ($uuid1, $uuid2) |
|
| get_declared_subclasses ($class) |
|
| posix_kill_ex ($pid, $sig) |
|
This file is part of OpenMediaVault.
- License:
- http://www.gnu.org/licenses/gpl.html GPL Version 3
- Author
- Volker Theile volke.nosp@m.r.th.nosp@m.eile@.nosp@m.open.nosp@m.media.nosp@m.vaul.nosp@m.t.org
- Copyright
- Copyright (c) 2009-2018 Volker Theile
OpenMediaVault is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
OpenMediaVault is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with OpenMediaVault. If not, see http://www.gnu.org/licenses/.
◆ array_boolval()
array_boolval |
( |
array |
$array, |
|
|
|
$key |
|
) |
| |
Get boolean value of an array element.
- Parameters
-
array | $array | An array with keys. |
string | $key | The key of the element. |
- Returns
- Returns the boolean value of the given key.
◆ array_expand()
array_expand |
( |
array |
$array, |
|
|
|
$separator = "." |
|
) |
| |
Expands a flat array to a multi-dimensional array.
- Parameters
-
array | $array | The array to expand. |
string | $separator | The character used as separator. Defaults to '.'. |
- Returns
- A multi-dimensional array.
◆ array_filter_ex()
array_filter_ex |
( |
|
$array, |
|
|
|
$key, |
|
|
|
$value |
|
) |
| |
Filter an array of by key and values.
- Parameters
-
array | $array | The array to process. |
string | $key | The key used as filter criteria. |
string | $value | The value used as filter criteria. |
- Returns
- Returns the filtered array.
◆ array_flatten()
array_flatten |
( |
array |
$array, |
|
|
|
$separator = "." , |
|
|
|
$parent_key = "" |
|
) |
| |
This file is part of OpenMediaVault.
- License:
- http://www.gnu.org/licenses/gpl.html GPL Version 3
- Author
- Volker Theile volke.nosp@m.r.th.nosp@m.eile@.nosp@m.open.nosp@m.media.nosp@m.vaul.nosp@m.t.org
- Copyright
- Copyright (c) 2009-2018 Volker Theile
OpenMediaVault is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
OpenMediaVault is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with OpenMediaVault. If not, see http://www.gnu.org/licenses/. Collapses a multi-dimensional array into a single dimension using dot notation.
- Parameters
-
array | $array | The array to flatten. |
string | $separator | The character used as separator. Defaults to '.'. |
string | $parent_key | The parent key. Defaults to empty. |
- Returns
- A single-dimensional array.
◆ array_keys_exists()
array_keys_exists |
( |
array |
$keys, |
|
|
array |
$search, |
|
|
& |
$missing = NULL |
|
) |
| |
Checks if the given keys or index exists in the array.
- Parameters
-
array | $keys | An array containing the keys to check. |
array | $search | An array with keys to check. |
mixed | $missing | An array that contains the missing keys if the function fails. Defaults to NULL. |
- Returns
- Returns TRUE on success or FALSE on failure.
◆ array_rand_value()
array_rand_value |
( |
array |
$array, |
|
|
|
$num = 1 |
|
) |
| |
Pick one or more random entries out of an array.
- Parameters
-
array | $array | The input array. |
int | $num | Specifies how many entries should be picked. Defaults to 1. |
- Returns
- When picking only one entry, the function returns the value for a random entry. Otherwise, an array of values for the random entries is returned. Trying to pick more elements than there are in the array NULL will be returned.
◆ array_sort_key()
array_sort_key |
( |
array & |
$array, |
|
|
|
$key |
|
) |
| |
Sort an array by values using a user-defined key.
- Parameters
-
array | The array to sort. |
key | The key used as sort criteria. |
- Returns
- Returns TRUE on success or FALSE on failure.
◆ array_value()
array_value |
( |
array |
$array, |
|
|
|
$key, |
|
|
|
$default = NULL |
|
) |
| |
Get an array value.
- Parameters
-
array | $array | The array. |
string | $key | The key of the element. |
mixed | $default | The default value. Defaults to NULL. |
- Returns
- The value of the given key or the default value if the key does not exist.
◆ binary_convert()
binary_convert |
( |
|
$number, |
|
|
|
$fromPrefix, |
|
|
|
$toPrefix, |
|
|
|
$decimalPlaces = 0 |
|
) |
| |
Convert a number to bytes using binary multiples.
- Parameters
-
mixed | $number | The number to convert. |
string | $fromPrefix | The binary prefix name number is in, e.g. 'KiB'. |
string | $toPrefix | The binary prefix name to convert number to, e.g. 'TiB'. |
int | $decimalPlaces | The number of decimal places. Defaults to 0. |
- Returns
- The converted number as string or FALSE on failure.
◆ binary_format()
if (!function_exists( 'json_last_error_msg')) binary_format |
( |
|
$number, |
|
|
|
$options = NULL |
|
) |
| |
Returns the error string of the last JSON API call.
- Returns
- Returns the error message on success or NULL with wrong parameters. Convert a number into the highest possible binary unit.
- Parameters
-
mixed | $value | The number to convert (per default this is in Bytes). |
mixed | $options | An array of additional options. Defaults to NULL. |
- Returns
- The converted string value including the unit or an indexed array with the fields value and unit.
◆ boolvalEx()
Get the boolean value of a variable. A boolean TRUE will be returned for the values 1, '1', 'on', 'yes', 'y' and 'true'.
- Parameters
-
mixed | $var | The scalar value being converted to a boolean. |
- Returns
- Returns the boolean value of the given value.
◆ build_path()
build_path |
( |
|
$separator, |
|
|
|
$parts |
|
) |
| |
Creates a path from a series of parts using separator as the separator between parts. At the boundary between two parts, any trailing occurrences of separator in the first part, or leading occurrences of separator in the second part are removed and exactly one copy of the separator is inserted.
- Parameters
-
string | $separator | The directory seperator, e.g. DIRECTORY_SEPARATOR. |
string | $parts | The path elements to be concatenated. |
- Returns
- A string path built from the given parts.
◆ fs_uuid_equals()
fs_uuid_equals |
( |
|
$uuid1, |
|
|
|
$uuid2 |
|
) |
| |
Compare two file system UUID strings.
- See also
- http://wiki.ubuntuusers.de/UUID
- Parameters
-
string | $uuid1 | The first file system UUID. |
string | $uuid2 | The second file system UUID. |
- Returns
- Returns TRUE when the two strings are equal, FALSE otherwise.
◆ get_declared_subclasses()
get_declared_subclasses |
( |
|
$class | ) |
|
Returns an array with the name of the defined classes that are a subclass of the specified class.
- Parameters
-
string | $class | The class name being checked against. |
- Returns
- Returns an array of the names of the declared classes in the current script that match the specified criteria.
◆ in_range()
in_range |
( |
|
$var, |
|
|
|
$min, |
|
|
|
$max |
|
) |
| |
Check if the given integer value is in the range min <= var <= max.
- Parameters
-
mixed | $var | The value to check. |
int | $min | The minimum value of the sequence. |
int | $max | The maximum value of the sequence. |
- Returns
- TRUE if the value is within the range, otherwise FALSE.
◆ inet_getnetmask()
inet_getnetmask |
( |
|
$bits, |
|
|
|
$forceipv6 = FALSE |
|
) |
| |
Build a netmask based on the given number of bits.
- Parameters
-
int | $bits | The number of bits to be set in the desired netmask. |
bool | $forceipv6 | Set to TRUE to force an IPv6 netmask, even if bits <= 32. Defaults to FALSE which auto-detects the address family. |
- Returns
- The netmask as string.
◆ is_64bits()
Check if the platform is 64bit.
- Returns
- TRUE if 64bit, otherwise FALSE.
◆ is_assoc()
Finds out whether a variable is an associative array.
- Deprecated:
- Parameters
-
mixed | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an associative array, otherwise FALSE.
◆ is_assoc_array()
Finds out whether a variable is an associative array.
- Parameters
-
mixed | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an associative array, otherwise FALSE.
◆ is_block()
is_block |
( |
|
$filename, |
|
|
|
$dereference = TRUE |
|
) |
| |
Tells whether the given file is a block device.
- Parameters
-
string | $filename | Path to the file. |
bool | $dereference | Follow links. Defaults to TRUE. |
- Returns
- Returns TRUE if the file is a block device, FALSE otherwise.
◆ is_devicefile()
Finds out whether a variable describes a device file, e.g.
/dev/sda1.
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_devicefile_by()
Finds out whether a variable describes a device file disk/by-xxx, e.g.
/dev/disk/by-uuid/ad3ee177-777c-4ad3-8353-9562f85c0895
- /dev/disk/by-id/usb-Kingston_DataTraveler_G2_001CC0EC21ADF011C6A20E35-0:0-part1
- /dev/disk/by-label/data
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_devicefile_by_id()
is_devicefile_by_id |
( |
|
$var | ) |
|
Finds out whether a variable describes a device file, e.g.
/dev/disk/by-id/usb-Kingston_DataTraveler_G2_001CC0EC21ADF011C6A20E35-0:0-part1
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_devicefile_by_label()
is_devicefile_by_label |
( |
|
$var | ) |
|
Finds out whether a variable describes a device file, e.g.
/dev/disk/by-label/data
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_devicefile_by_path()
is_devicefile_by_path |
( |
|
$var | ) |
|
Finds out whether a variable describes a device file, e.g.
/dev/disk/by-path/pci-0000:00:17.0-ata-3
- /dev/disk/by-path/pci-0000:00:17.0-ata-3-part2
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_devicefile_by_uuid()
is_devicefile_by_uuid |
( |
|
$var | ) |
|
Finds out whether a variable describes a device file, e.g.
/dev/disk/by-uuid/ad3ee177-777c-4ad3-8353-9562f85c0895
- /dev/disk/by-uuid/2ED43920D438EC29 (NTFS)
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable describes a device file, otherwise FALSE.
◆ is_fs_uuid()
Finds out whether a variable is a filesystem UUID, e.g.
78b669c1-9183-4ca3-a32c-80a4e2c61e2d (EXT2/3/4, JFS, XFS)
- 7A48-BA97 (FAT)
- 2ED43920D438EC29 (NTFS)
- 2015-01-13-21-48-46-00 (ISO9660)
- See also
- http://wiki.ubuntuusers.de/UUID
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is a filesystem UUID, otherwise FALSE.
◆ is_ipaddr()
Finds out whether a variable is an IP address.
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an IP address, otherwise FALSE.
◆ is_ipaddr4()
Finds out whether a variable is an IPv4 address.
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an IPv4 address, otherwise FALSE.
◆ is_ipaddr6()
Finds out whether a variable is an IPv6 address.
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an IPv6 address, otherwise FALSE.
◆ is_json()
Finds out whether a variable is JSON.
- Parameters
-
mixed | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is JSON, otherwise FALSE.
◆ is_multi_array()
Finds out whether a variable is a multidimensional array.
- Parameters
-
mixed | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is a multidimensional array, otherwise FALSE.
◆ is_multiarray()
Finds out whether a variable is a multidimensional array.
- Deprecated:
- Parameters
-
mixed | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is a multidimensional array, otherwise FALSE.
◆ is_uuid()
Finds out whether a variable is an UUID v4.
- Parameters
-
string | $var | The variable being evaluated. |
- Returns
- TRUE if the variable is an UUID, otherwise FALSE.
◆ json_decode_safe()
json_decode_safe |
( |
|
$json, |
|
|
|
$assoc = false , |
|
|
|
$depth = 512 , |
|
|
|
$options = 0 |
|
) |
| |
Decodes a JSON string. The JSON string being decoded will be encoded to UTF-8 before.
- Parameters
-
string | $json | The JSON string being decoded. |
bool | $assoc | When TRUE, returned objects will be converted into associative arrays. Defaults to FALSE. |
int | $depth | User specified recursion depth. Defaults to 512. |
int | $options | Bitmask of JSON decode options. Defaults to 0. |
- Returns
- Returns the value encoded in json in appropriate PHP type. NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit.
◆ json_encode_safe()
json_encode_safe |
( |
|
$value, |
|
|
|
$options = 0 |
|
) |
| |
Returns the JSON representation of a value. All strings will be encoded to UTF-8 before, thus json_encode should not throw an exception like 'Invalid UTF-8 sequence in argument' (Mantis 0000355).
- Parameters
-
mixed | $value | The value being encoded. |
int | $options | Bitmask, see PHP json_encode manual pages. Defaults to 0. |
- Returns
- Returns a string containing the JSON representation of value.
◆ json_validate()
json_validate |
( |
|
$data, |
|
|
|
$schema, |
|
|
& |
$errors = NULL |
|
) |
| |
Validate JSON data via JSON schema.
- Parameters
-
string | $data | The JSON string to validate. |
mixed | $schema | The JSON schema to use for validation. This can be a string or an associative array. |
mixed | $errors | Optional parameter which will contain the error messages if validation fails. Defaults to NULL. |
- Returns
- TRUE if successful, otherwise FALSE.
◆ listdir()
listdir |
( |
|
$directory, |
|
|
|
$extension = "" , |
|
|
|
$sortFlags = SORT_NATURAL |
|
) |
| |
List files inside the specified path.
- Parameters
-
string | $directory | The directory that will be scanned. |
string | $extension | The file extension of the files to search for. |
int | $sortFlags | Modify the sorting behavior. Defaults to SORT_NATURAL. |
- Returns
- Returns an array of files from the directory.
◆ mkdtemp()
mkdtemp |
( |
|
$prefix = "" , |
|
|
|
$mode = 0700 |
|
) |
| |
Create a directory with unique file name.
- Parameters
-
string | $prefix | The prefix of the generated temporary directory. Defaults to empty. |
int | $mode | The mode of the temporary directory. Defaults to 0700. |
- Returns
- Returns the full path of the created directory, or FALSE on failure.
◆ posix_kill_ex()
posix_kill_ex |
( |
|
$pid, |
|
|
|
$sig |
|
) |
| |
Send a signal to a process and its children.
- Parameters
-
pid | The process identifier. |
sig | One of the PCNTL signals constants. |
- Returns
- Returns TRUE on success or FALSE on failure.
◆ strpdate()
strpdate |
( |
|
$date, |
|
|
|
$format |
|
) |
| |
Convert any time/date into a Unix timestamp according to the specified format.
- Parameters
-
string | $date | A date/time string to parse. |
string | $format | The format used in date. |
- Returns
- Returns a Unix timestamp on success, FALSE otherwise.
◆ toArray()
Convert an object to an array.
- Parameters
-
object | $object | The object instance. |
- Returns
- Returns an associative array of defined object accessible non-static properties for the specified object in scope.
◆ uuid_equals()
uuid_equals |
( |
|
$uuid1, |
|
|
|
$uuid2 |
|
) |
| |
Compare two UUID v4 strings.
- Parameters
-
string | $uuid1 | The first UUID v4. |
string | $uuid2 | The second UUID v4. |
- Returns
- Returns TRUE when the two strings are equal, FALSE otherwise.