Core
class Core (View source)
Core functions used all over the scripts.
Methods
Removes insecure parts in a path; used before include() or require() when a part of the path comes from an insecure source like a cookie or form.
Returns a link to the PHP documentation
Warn or fail on missing extension.
Converts numbers like 10M into bytes Used with permission from Moodle (https://moodle.org) by Martin Dougiamas (renamed with PMA prefix to avoid double definition when embedded in Moodle)
Checks if the given $page is index.php and returns true if valid.
Tries to find the value for the given environment variable name
Returns application/json headers. This includes no caching.
No description
Sends header indicating file download.
Returns value of an element in $array given by $path.
Stores value in an array
Removes value from an array
Returns link to (possibly) external site using defined redirector.
Checks whether domain of URL is an allowed domain or not.
Replace some html-unfriendly stuff
Displays SQL query before executing.
recursively check if variable is empty
Gets the "true" IP address of the current user
Sanitizes MySQL hostname
Sanitizes MySQL username
Safe unserializer wrapper
Sign the sql query using hmac using the session token
Check that the sql query has a valid hmac signature
Details
static string
securePath(string $path)
Removes insecure parts in a path; used before include() or require() when a part of the path comes from an insecure source like a cookie or form.
static string
getPHPDocLink(string $target)
Returns a link to the PHP documentation
static void
warnMissingExtension(string $extension, bool $fatal = false, string $extra = '')
Warn or fail on missing extension.
static int
getRealSize(string|int $size = 0)
Converts numbers like 10M into bytes Used with permission from Moodle (https://moodle.org) by Martin Dougiamas (renamed with PMA prefix to avoid double definition when embedded in Moodle)
static bool
checkPageValidity(string $page)
Checks if the given $page is index.php and returns true if valid.
It ignores query parameters in $page (script.php?ignored)
static string
getEnv(string $variableName)
Tries to find the value for the given environment variable name
Searches in $_SERVER, $_ENV then tries getenv() and apache_getenv() in this order.
static array
headerJSON()
Returns application/json headers. This includes no caching.
static array
getNoCacheHeaders()
No description
static void
downloadHeader(string $filename, string $mimetype, int $length = 0, bool $noCache = true)
Sends header indicating file download.
static mixed
arrayRead(string $path, array $array, mixed $default = null)
Returns value of an element in $array given by $path.
$path is a string describing position of an element in an associative array, eg. Servers/1/host refers to $array[Servers][1][host]
static void
arrayWrite(string $path, array $array, mixed $value)
Stores value in an array
static void
arrayRemove(string $path, array $array)
Removes value from an array
static string
linkURL(string $url)
Returns link to (possibly) external site using defined redirector.
static bool
isAllowedDomain(string $url)
Checks whether domain of URL is an allowed domain or not.
Use only for URLs of external sites.
static string
mimeDefaultFunction(string $buffer)
Replace some html-unfriendly stuff
static void
previewSQL(array|string $queryData)
Displays SQL query before executing.
static bool
emptyRecursive(mixed $value)
recursively check if variable is empty
static string|bool
getIp()
Gets the "true" IP address of the current user
static string
sanitizeMySQLHost(string $name)
Sanitizes MySQL hostname
- strips p: prefix(es)
static string
sanitizeMySQLUser(string $name)
Sanitizes MySQL username
- strips part behind null byte
static mixed
safeUnserialize(string $data)
Safe unserializer wrapper
It does not unserialize data containing objects
static string
signSqlQuery(string $sqlQuery)
Sign the sql query using hmac using the session token
static bool
checkSqlQuerySignature(string $sqlQuery, string $signature)
Check that the sql query has a valid hmac signature
static ServerRequest
populateRequestWithEncryptedQueryParams(ServerRequest $request)
No description