FileAccess Orion

SessionCache extends Cache
in package

Implement session cache handler

Fileaccess objects need a mighty cache abstraction layer, this class provides it This class provides interfaces for cache handling related to login and sessions.

Tags
category

Interface function

author

Tobias Teichner webmaster@teichner.biz

since

File available since v0.1

Table of Contents

$affected  : array<string|int, mixed>
List of affected files and directories in recursion
$cdn  : ContentDeliveryNetwork
CDN interface Store the cdn interface instance
$igbinary  : bool|null
IGBinary available buffer test if "IGBinary" is available
$local_buffer  : array<string|int, mixed>
local object cache
$log_template  : string
The template for log messages in ::Log()
$prefix  : string
The cache prefix To differentiate between different environments use specific prefix in key.
$redis  : MemoryCache|null
Memory cache interface Buffer the memory cache interface
$search_interface  : array<string|int, mixed>
Store interface Store the search interface instance
$size_unit  : array<string|int, mixed>
Available file size short codes
AddLoginAttempt()  : Result
CalculateFolderSize()  : array<string|int, mixed>
Calculate size of a specific folder use a recursive working function to calculate a folder size
CallExecutable()  : Result
Execute a system command Uses installed executable to perform a system call
Chmod()  : bool
Change the permissions of a file
ClearAll()  : Result
delete all caches wrapper to delete all cache entries
ClearAllInFolder()  : Result
delete all caches wrapper to delete all cache entries in a specific section of the system
Connection()  : MemoryCache|null
Get the redis server connection Wrapper to get the redis instance and the client connection. This function is cached.
CopyFile()  : Result
Copy file Copy a single file with obtaining lock on index before
CopyFolder()  : Result
Copy folder contents
Debug()  : bool
log debug object writs a formatted log message including back trace to the global log file
DecodeJson()  : Result
Parse json from string to object or assoc
DecodeJsonFile()  : Result
Parse json from file to object or assoc
DeleteAllLoginAttempts()  : Result
DeleteFile()  : bool
Deletes single file This method deletes a single file, it will wait when the system is in git lock mode
DeleteLoginAttempts()  : Result
DeleteSession()  : Result
DropFolder()  : array<string|int, mixed>
Delete a full folder
EncodeJson()  : Result
Serialize a given input to json representation
ExtractExtension()  : bool|string
Extract file extension
ExtractFileName()  : string
Extract file name
ExtractFolder()  : string
Extract folder path from root
ExtractFolderName()  : string
Extract folder name from root
FetchAllKeys()  : array<string|int, mixed>|null
FetchData()  : Result
FetchOauthData()  : Result
FileExists()  : bool|string
Check if file exists
FilterFolderFilesByModificationTime()  : Result
Get a list of files that are either older or newer a certain time point
GetCdnInterface()  : ContentDeliveryNetwork
Get cdn interface get access to the cdn interface that was registered for this instance
GetLock()  : Result
Obtain lock try to obtain the lock indicated by lock file in var
GetLoginAttempts()  : int
GetObjectLock()  : bool
Get lock on certain object
GetPerformanceConfig()  : Result
Get performance configuration
GetPhpInfo()  : string
Get php info Execute phpinfo() and return the result as string without head and footer
GetRedisStorageSize()  : Result
Calculate size of this vhost
GetSearchInterface()  : Search|null
Get the search server connection Wrapper to get the instance and the client connection. This function is cached.
HasIgbinary()  : bool|null
Check if igbinary is available Returns true when igbinary is enabled and available. This function is cached.
IsEmptyDir()  : bool|null
Is empty folder
ListFiles()  : array<string|int, mixed>
list files Iterate over directory and list the found files
ListFolders()  : array<string|int, mixed>
List folder names in certain root folder
ListIdFiles()  : array<string|int, mixed>
Find file ids
Log()  : bool
log object writs a formatted log message including back trace to the global log file
LoginAttempts()  : array<string|int, mixed>
MemoryBytesReadable()  : string
Memory readable Convert size of bytes in human-readable units
MkFolder()  : string|null
Create folder path
ReadCsv()  : Result
Read a CSV file to local storage
ReadFile()  : Result
Read a single file
ReadFixedColumnFile()  : Result
Read file with fixed column width
ReadFolder()  : array<string|int, File>
Read folder
RecreateIndex()  : Result
Recreate the index
RenameFolderOrFile()  : Result
Rename folder or file
RevokeLock()  : Result
release lock try to release the lock indicated by lock file in var
RevokeObjectLock()  : Result
Revoke dedicated object lock
SelfLockedOrOpen()  : bool
Serialize()  : mixed
serialize a value abstraction layer for cache serialization
StoreData()  : Result
StoreEncodedJson()  : Result
Serialize a given input and store it
StoreOauthData()  : Result
StripQueryAndAnchor()  : string
Extract file name
SysLog()  : bool
Log message
TryGetLock()  : bool
Obtain lock with retry
UnSerialize()  : mixed
get a un serialized var deserialize a given string, use igbinary if possible
VersionStringToNumber()  : string
Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033
Warn()  : bool
warn level log object writs a formatted log message including back trace to the global log file
WriteCsv()  : Result
Write an array of entries to csv file
WriteFile()  : bool
Write string to file
delete()  : Result
Delete a cache file and if possible, remove from memory if available, delete a cache entry also in the memory cache and the cosmic cache
escapeId()  : int|string
escape an id remove all not suitable values from the id to enable folder creation
read()  : Result
read a cache file this function tries to fetch a stored data object from local caches, will use memory cache if it's possible
write()  : Result
save a cache file and if possible, store in memory if available, store a cache entry also in the local de serialize form as static object
CalculateFolderSizeRecurse()  : bool
Helper function to calculate size Recursively calculate size of a specific folder
decrypt()  : string
Decrypt data
DropFolderRecurse()  : bool
Delete a folder completely this method is the recursion helper for DropFolder()
encrypt()  : string
Encrypt data
parseKeyFile()  : string|array<string|int, mixed>|null

Properties

$affected

List of affected files and directories in recursion

private static array<string|int, mixed> $affected = array()

The list of paths

$igbinary

IGBinary available buffer test if "IGBinary" is available

private static bool|null $igbinary = null

IGBinary is available

$local_buffer

local object cache

private static array<string|int, mixed> $local_buffer = array()

$log_template

The template for log messages in ::Log()

private static string $log_template = "Called from LINE %s IN Script: %s\n"

The template

$prefix

The cache prefix To differentiate between different environments use specific prefix in key.

private static string $prefix = FAA_IDENTIFY . ':' . FAA_DATA_BRANCH . ':'

The cache key prefix

$redis

Memory cache interface Buffer the memory cache interface

private static MemoryCache|null $redis = null

A memory cache interface

$search_interface

Store interface Store the search interface instance

private static array<string|int, mixed> $search_interface = array()

A search interface buffer entry list

$size_unit

Available file size short codes

private static array<string|int, mixed> $size_unit = array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')

Used in the readable form

Methods

AddLoginAttempt()

public static AddLoginAttempt(mixed $ip) : Result
Parameters
$ip : mixed
Return values
Result

CalculateFolderSize()

Calculate size of a specific folder use a recursive working function to calculate a folder size

public static CalculateFolderSize(string $folder) : array<string|int, mixed>
Parameters
$folder : string

The path to calculate the size of

Return values
array<string|int, mixed>

An assoc structure holding the folder information

CallExecutable()

Execute a system command Uses installed executable to perform a system call

public static CallExecutable(string $cmd[, string $folder = '' ][, string $outfile = '' ]) : Result
Parameters
$cmd : string

The command to execute

$folder : string = ''

The working directory

$outfile : string = ''

Optional output file of the call result

Return values
Result

A system result object

Chmod()

Change the permissions of a file

public static Chmod(string $file, int $octal) : bool
Parameters
$file : string
$octal : int
Return values
bool

ClearAll()

delete all caches wrapper to delete all cache entries

public static ClearAll([bool $keep_cdn = false ][, bool $drop_all = false ]) : Result
Parameters
$keep_cdn : bool = false

Keep CDN contents when set to true

$drop_all : bool = false

Also delete the persistent caches

Return values
Result

A system result object

ClearAllInFolder()

delete all caches wrapper to delete all cache entries in a specific section of the system

public static ClearAllInFolder(string $cache_folder) : Result
Parameters
$cache_folder : string

The relative path to the cache files

Return values
Result

A default result object

Connection()

Get the redis server connection Wrapper to get the redis instance and the client connection. This function is cached.

public static Connection() : MemoryCache|null
Return values
MemoryCache|null

A memory cache interface

CopyFile()

Copy file Copy a single file with obtaining lock on index before

public static CopyFile(string $source, string $target[, bool $override = true ]) : Result
Parameters
$source : string

Absolute path to source

$target : string

Absolute path to target

$override : bool = true

Override forced even if file names are equal

Return values
Result

A system result object

CopyFolder()

Copy folder contents

public static CopyFolder(string $source, string $target[, bool $override = true ]) : Result

This method copies the source folder to the target folder path. The folder itself is not copied but all of its contents. This method creates the target folder if it is not present.

Parameters
$source : string

The source folder destination

$target : string

The target folder name

$override : bool = true

Override forced even if file names are equal

Return values
Result

A system result object

Debug()

log debug object writs a formatted log message including back trace to the global log file

public static Debug(mixed $object) : bool
Parameters
$object : mixed

The object to be logged

Return values
bool

DecodeJson()

Parse json from string to object or assoc

public static DecodeJson(string $data[, bool $mode = true ][, array<string|int, mixed>|string|null $crypt = null ]) : Result

Use the json parse function to decode a string to assoc or object It will use the given code in crypt to decrypt or fall back to system key

Parameters
$data : string

The payload to decode

$mode : bool = true

Parse as assoc or object, default is true and therefor assoc array

$crypt : array<string|int, mixed>|string|null = null

The key or, an array with cipher, key and the iv

Return values
Result

A default system result object

DecodeJsonFile()

Parse json from file to object or assoc

public static DecodeJsonFile(string $path[, bool $mode = true ][, string|null $crypt = null ]) : Result

Use the json parse to fetch text data from a given path and return it as object with assoc or object payload

Parameters
$path : string

The absolute path to a certain storage file

$mode : bool = true

Parse as assoc or object, default assoc

$crypt : string|null = null

Decrypt string before parsing

Return values
Result

A default system result object

DeleteFile()

Deletes single file This method deletes a single file, it will wait when the system is in git lock mode

public static DeleteFile(string $path) : bool
Parameters
$path : string

The target file path

Return values
bool

True on success otherwise false

DeleteLoginAttempts()

public static DeleteLoginAttempts(mixed $ip) : Result
Parameters
$ip : mixed
Return values
Result

DropFolder()

Delete a full folder

public static DropFolder(string $folder[, bool $full = false ]) : array<string|int, mixed>

this method clears or delete a folder recursively, side effect will fill list of delete folders and files

Parameters
$folder : string

The path to delete

$full : bool = false

Also remove the root folder

Return values
array<string|int, mixed>

List of deleted folders and files

EncodeJson()

Serialize a given input to json representation

public static EncodeJson(mixed $data[, int $mode = JSON_PRETTY_PRINT ][, array<string|int, mixed>|string|null $crypt = null ]) : Result

use the json parse function to decode an assoc or object

Parameters
$data : mixed

The payload to encode

$mode : int = JSON_PRETTY_PRINT

Serialize readable or not formatted

$crypt : array<string|int, mixed>|string|null = null

Encrypt key or, array with key cipher and iv

Return values
Result

A default system result object

ExtractExtension()

Extract file extension

public static ExtractExtension(string $path) : bool|string

May return false if no extension could be found

Parameters
$path : string

A complete file path

Return values
bool|string

The file extension or, false if not matched

ExtractFileName()

Extract file name

public static ExtractFileName(string $path[, bool $without_extension = false ]) : string
Parameters
$path : string

A complete file path

$without_extension : bool = false
Return values
string

The file name

ExtractFolder()

Extract folder path from root

public static ExtractFolder(string $path) : string

With input /var/www/school/test.json will result in /var/www/school/

Parameters
$path : string

A complete file path

Return values
string

The file root folder

ExtractFolderName()

Extract folder name from root

public static ExtractFolderName(string $path) : string
Parameters
$path : string

A complete file path

Return values
string

The file root folder

FetchAllKeys()

public static FetchAllKeys(int $max_age) : array<string|int, mixed>|null
Parameters
$max_age : int
Return values
array<string|int, mixed>|null

FileExists()

Check if file exists

public static FileExists(string $fileName[, bool $caseSensitive = true ]) : bool|string

Does check if a file is existing, will also check if the file exists as lower case by glob as fallback.

Parameters
$fileName : string

The path to the file

$caseSensitive : bool = true

Use case-sensitive path, defaults to true

Return values
bool|string

File exists

FilterFolderFilesByModificationTime()

Get a list of files that are either older or newer a certain time point

public static FilterFolderFilesByModificationTime(string $root, int $timestamp[, bool $older = true ]) : Result
Parameters
$root : string

The start point for the recursion

$timestamp : int

The time point to flip

$older : bool = true

When true result list files are older than the time stamp otherwise newer

Return values
Result

A system result object containing the files

GetLock()

Obtain lock try to obtain the lock indicated by lock file in var

public static GetLock() : Result
Return values
Result

A default system result object

GetLoginAttempts()

public static GetLoginAttempts(mixed $ip) : int
Parameters
$ip : mixed
Return values
int

GetObjectLock()

Get lock on certain object

public static GetObjectLock(BaseContent $content) : bool

Lock could be obtained, it will return true otherwise false. Uses the system default method "in memory"

Parameters
$content : BaseContent

A system content

Tags
codeCoverageIgnore
Return values
bool

GetPerformanceConfig()

Get performance configuration

public static GetPerformanceConfig() : Result
Return values
Result

A result object

GetRedisStorageSize()

Calculate size of this vhost

public static GetRedisStorageSize() : Result
Return values
Result

GetSearchInterface()

Get the search server connection Wrapper to get the instance and the client connection. This function is cached.

public static GetSearchInterface([string $name = FAA_APPLICATION_SEARCH_HANDLER ]) : Search|null
Parameters
$name : string = FAA_APPLICATION_SEARCH_HANDLER

Get interface of certain type

Return values
Search|null

The client or null when not available.

HasIgbinary()

Check if igbinary is available Returns true when igbinary is enabled and available. This function is cached.

public static HasIgbinary() : bool|null
Return values
bool|null

True when igbinary is available

IsEmptyDir()

Is empty folder

public static IsEmptyDir(string $dir) : bool|null
Parameters
$dir : string

Path to folder

Return values
bool|null

ListFiles()

list files Iterate over directory and list the found files

public static ListFiles(string $dir[, string $ext = '/^json$/' ][, bool $full = false ]) : array<string|int, mixed>
Parameters
$dir : string

The root folder path to search in

$ext : string = '/^json$/'

Filter by extension (can be empty, a string or a regex)

$full : bool = false

Check the full name of the file or just the extension when false

Return values
array<string|int, mixed>

A list containing the found files

ListFolders()

List folder names in certain root folder

public static ListFolders(string $path) : array<string|int, mixed>
Parameters
$path : string

The absolute path to the folder

Return values
array<string|int, mixed>

The found folder names that are children of the given folder

ListIdFiles()

Find file ids

public static ListIdFiles(string $dir[, string $ext = 'json' ][, bool $to_int = true ]) : array<string|int, mixed>

Fetch a list of file ids inside a folder and its subdirectories

Parameters
$dir : string

The root folder path to search in

$ext : string = 'json'

Filter by extension

$to_int : bool = true

Convert to integer when set to true

Return values
array<string|int, mixed>

A list containing the found id's

Log()

log object writs a formatted log message including back trace to the global log file

public static Log(mixed $object[, string|null $msg = null ]) : bool
Parameters
$object : mixed

The object to be logged

$msg : string|null = null

Additional message

Return values
bool

LoginAttempts()

public static LoginAttempts() : array<string|int, mixed>
Return values
array<string|int, mixed>

MemoryBytesReadable()

Memory readable Convert size of bytes in human-readable units

public static MemoryBytesReadable(int|float $size) : string
Parameters
$size : int|float

The size in bytes

Return values
string

The calculated size

MkFolder()

Create folder path

public static MkFolder(string $root, array<string|int, mixed> $components[, bool $make = true ]) : string|null

When the make argument set to true this function will try to create the folder Return the folder components without root part

Parameters
$root : string

The path to the base folder

$components : array<string|int, mixed>

The list of folder components

$make : bool = true

Try to create the folder

Return values
string|null

The combined relative path as string, includes tailing /

ReadCsv()

Read a CSV file to local storage

public static ReadCsv(string $path[, string $delimiter = ';' ][, string $enclosure = "'" ][, int $length = 100000 ][, string $escape = "\" ][, bool $check_head = true ]) : Result

Fetch the file and add it to a local result object file is parsed with php function to get csv from file, arguments of this method align with official one

Parameters
$path : string

The absolute path to file to open

$delimiter : string = ';'

Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter

$enclosure : string = "'"

Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure

$length : int = 100000

Have a look at http://php.net/manual/de/function.fgetcsv.php length

$escape : string = "\"

Have a look at http://php.net/manual/de/function.fgetcsv.php escape

$check_head : bool = true

When set, check the first line as head and validate following line lengths

Return values
Result

A system result object

ReadFile()

Read a single file

public static ReadFile(string $path) : Result
Parameters
$path : string

The absolute path to a certain storage file

Return values
Result

A default system result object

ReadFixedColumnFile()

Read file with fixed column width

public static ReadFixedColumnFile(string $path[, int $length = 10000 ]) : Result

Automatic file parser based on the heads and assuming a " " space is used to make the cols equal

Parameters
$path : string

Absolute link to the file to open

$length : int = 10000

Limiter for line length

Return values
Result

A system result object

ReadFolder()

Read folder

public static ReadFolder(string $dir) : array<string|int, File>

Will list all files and folders of a folder

Parameters
$dir : string

Path to root folder

Return values
array<string|int, File>

An array of file objects

RecreateIndex()

Recreate the index

public static RecreateIndex([bool $full = false ]) : Result

Recreate the index and clear the caches, this method can kill all values from search when configured true

Parameters
$full : bool = false

Delete all caches before recreation

Return values
Result

RenameFolderOrFile()

Rename folder or file

public static RenameFolderOrFile(string $source, string $target[, bool $skip_existing = true ]) : Result
Parameters
$source : string

Absolute path to source

$target : string

Absolute path to target

$skip_existing : bool = true
Return values
Result

A system result object

RevokeLock()

release lock try to release the lock indicated by lock file in var

public static RevokeLock([string|null $lockfile = null ][, bool $in_memory = true ]) : Result
Parameters
$lockfile : string|null = null
$in_memory : bool = true
Return values
Result

A default system result object

RevokeObjectLock()

Revoke dedicated object lock

public static RevokeObjectLock(BaseContent $content) : Result
Parameters
$content : BaseContent
Tags
codeCoverageIgnore
Return values
Result

SelfLockedOrOpen()

public static SelfLockedOrOpen( $pid[,  $path = null ]) : bool
Parameters
$pid :
$path : = null
Return values
bool

Serialize()

serialize a value abstraction layer for cache serialization

public static Serialize(mixed $values[, bool $raw = false ]) : mixed
Parameters
$values : mixed

The values to serialize

$raw : bool = false

Write as raw data

Return values
mixed

The serialized string

StoreData()

public static StoreData(mixed $id, mixed $data[, mixed $max_age = FAA_SESSION_LENGTH ]) : Result
Parameters
$id : mixed
$data : mixed
$max_age : mixed = FAA_SESSION_LENGTH
Return values
Result

StoreEncodedJson()

Serialize a given input and store it

public static StoreEncodedJson(string $path, mixed $data[, int $mode = JSON_PRETTY_PRINT ][, bool|null $crypt = false ]) : Result

use the json parse function to create json representation and store it in a certain file this method does an encryption also on demand, the .key file must exist for this to happen

Parameters
$path : string

The target file path

$data : mixed

The payload to encode

$mode : int = JSON_PRETTY_PRINT

Serialize readable or not formatted

$crypt : bool|null = false

Encrypt the result after serialisation

Return values
Result

A default system result object

StoreOauthData()

public static StoreOauthData(mixed $id, mixed $data) : Result
Parameters
$id : mixed
$data : mixed
Return values
Result

StripQueryAndAnchor()

Extract file name

public static StripQueryAndAnchor(string $path) : string
Parameters
$path : string

A complete file path

Return values
string

The file name without additional parts

SysLog()

Log message

public static SysLog(string $level, mixed $object[, string|null $prefix = null ][, bool $stack = true ]) : bool

Writs a formatted log message including back trace on severe levels to the global log file

Parameters
$level : string

Name of the log level

$object : mixed

The object to be logged

$prefix : string|null = null

Extra prefix

$stack : bool = true

Print with stack trace on demand

Return values
bool

Status if write to log worked

TryGetLock()

Obtain lock with retry

public static TryGetLock([string|null $path = null ][, string|int|null $pid = null ][, int $try_count = FAA_WRITE_RETRY ][, float $seconds = 0.25 ][, bool $in_memory = true ]) : bool

Try to obtain the lock indicated by lock file in var Additional lock level reliability with process id

Parameters
$path : string|null = null

The lock file path or null for default

$pid : string|int|null = null

The current process id locking the file

$try_count : int = FAA_WRITE_RETRY

Retry counter

$seconds : float = 0.25

Retry wait

$in_memory : bool = true

Instead of file system use redis as lock file storage

Tags
codeCoverageIgnore
Return values
bool

UnSerialize()

get a un serialized var deserialize a given string, use igbinary if possible

public static UnSerialize(mixed $str[, bool $raw = false ]) : mixed
Parameters
$str : mixed

The values to unserialize

$raw : bool = false

Write as raw data

Return values
mixed

The un serialized string

VersionStringToNumber()

Convert version number Converts the given number to a unified string e.g. 'v1.234.33' will become 102340033

public static VersionStringToNumber(string $number[, string $regex = '/[^0-9\.]/i' ][, string $replace = '' ][, int $pads = 4 ]) : string
Parameters
$number : string

The version number to calculate

$regex : string = '/[^0-9\.]/i'

Replacement expression to clear the number upfront

$replace : string = ''

Replacement string for regex_replace

$pads : int = 4

Add this amount of zeros to the left

Return values
string

The cleared version number

Warn()

warn level log object writs a formatted log message including back trace to the global log file

public static Warn(mixed $object[, bool $stack = true ]) : bool
Parameters
$object : mixed

The object to be logged

$stack : bool = true
Return values
bool

WriteCsv()

Write an array of entries to csv file

public static WriteCsv(string|null $path, array<string|int, mixed> $list[, string $delimiter = ';' ][, string $enclosure = "'" ][, string $escape = "\" ]) : Result
Parameters
$path : string|null

The absolute path to file to open

$list : array<string|int, mixed>

The source to write

$delimiter : string = ';'

Have a look at http://php.net/manual/de/function.fgetcsv.php delimiter

$enclosure : string = "'"

Have a look at http://php.net/manual/de/function.fgetcsv.php enclosure

$escape : string = "\"

Have a look at http://php.net/manual/de/function.fgetcsv.php escape

Return values
Result

The result

WriteFile()

Write string to file

public static WriteFile(string $path, scalar $data, int $flags) : bool

This method writes the given data to the defined file, it will wait when the system is in git lock mode. This method returns valid result also for writing empty strings unlike file put contents default behavior

Parameters
$path : string

The target file path

$data : scalar

The payload to store in the target file

$flags : int

File put content flags (http://php.net/manual/de/function.file-put-contents.php)

Return values
bool

True on success

delete()

Delete a cache file and if possible, remove from memory if available, delete a cache entry also in the memory cache and the cosmic cache

protected static delete(string $cache_file) : Result
Parameters
$cache_file : string

The path to the cache file

Return values
Result

A system result object

escapeId()

escape an id remove all not suitable values from the id to enable folder creation

protected static escapeId(int|string $id) : int|string
Parameters
$id : int|string

The id to escape

Return values
int|string

The cleared id

read()

read a cache file this function tries to fetch a stored data object from local caches, will use memory cache if it's possible

protected static read(string $cache_file[, bool $raw = false ][, bool $honor_ttl = false ][, bool $no_cosmic = false ]) : Result
Parameters
$cache_file : string

The path to the cache file, relative to cache folder root

$raw : bool = false

Read as raw data

$honor_ttl : bool = false
$no_cosmic : bool = false
Return values
Result

A default system result object

write()

save a cache file and if possible, store in memory if available, store a cache entry also in the local de serialize form as static object

protected static write(string $cache_file, mixed $data[, bool $raw = false ][, int $ttl = -1 ][, bool $no_cosmic = false ]) : Result
Parameters
$cache_file : string

The path to the cache file

$data : mixed

The data set to store

$raw : bool = false

Optional write as raw data

$ttl : int = -1

Optional time to live.

$no_cosmic : bool = false
Return values
Result

A default system result object

CalculateFolderSizeRecurse()

Helper function to calculate size Recursively calculate size of a specific folder

private static CalculateFolderSizeRecurse(string $folder, int &$file_count, int &$directory_count, int &$size) : bool
Parameters
$folder : string

The path to calculate the size of

$file_count : int

Pointer to file count

$directory_count : int

Pointer to folder count

$size : int

Pointer to file size

Return values
bool

The iteration result status

decrypt()

Decrypt data

private static decrypt(string $encrypted[, string|array<string|int, mixed> $mc_key = FAA_CODE ]) : string

will try to decrypt the given data with the system encryption code or a customer defined one The function does a blowfish decryption and a base64 conversion on demand

Parameters
$encrypted : string

The string to decrypt (must be base64 encoded)

$mc_key : string|array<string|int, mixed> = FAA_CODE

The key or, an array with cipher, key and the iv

Tags
throws
SodiumException
Return values
string

The decrypted string

DropFolderRecurse()

Delete a folder completely this method is the recursion helper for DropFolder()

private static DropFolderRecurse(string $folder[, bool $full = false ]) : bool
Parameters
$folder : string

The path to delete

$full : bool = false

Also remove the root folder

Return values
bool

The delete status

encrypt()

Encrypt data

private static encrypt(string $plain[, string|array<string|int, mixed> $mc_key = FAA_CODE ][, mixed &$tag = null ]) : string

Method will try to encrypt the given data with the system encryption code or a customer defined one The function does a blowfish encryption and a base64 conversion

Parameters
$plain : string

The string to encrypt

$mc_key : string|array<string|int, mixed> = FAA_CODE

The key or, an array with cipher, key and the iv

$tag : mixed = null
Tags
throws
SodiumException
Return values
string

The encrypted string base64 encoded

parseKeyFile()

private static parseKeyFile(string $path) : string|array<string|int, mixed>|null
Parameters
$path : string
Return values
string|array<string|int, mixed>|null

Search results