class Config (View source)

Configuration class

Properties

string $defaultSource
array $default
array $baseSettings
array $settings
string $source
int $sourceMtime
int $defaultSourceMtime
int $setMtime
bool $errorConfigFile
bool $errorConfigDefaultFile
array $defaultServer
bool $done

Methods

__construct(string|null $source = null)

No description

void
checkSystem()

sets system and application settings

void
checkOutputCompression()

whether to use gzip output compression or not

void
checkClient()

Determines platform (OS), browser and version of the user Based on a phpBuilder article:

void
checkGd2()

Whether GD2 is present

void
checkWebServer()

Whether the Web server php is running on is IIS

void
checkWebServerOs()

Whether the os php is running on is windows or not

bool
loadDefaults()

loads default values from default source

bool
load(string|null $source = null)

loads configuration from $source, usually the config file should be called on object creation

void
loadUserPreferences()

Loads user preferences and merges them with current config must be called after control connection has been established

true|Message
setUserValue(string|null $cookie_name, string $cfg_path, string $new_cfg_value, string|null $default_value = null)

Sets config value which is stored in user preferences (if available) or in a cookie.

mixed
getUserValue(string $cookie_name, mixed $cfg_value)

Reads value stored by setUserValue()

void
setSource(string $source)

set source

bool
checkConfigSource()

check config source

void
checkPermissions()

verifies the permissions on config file (if asked by configuration) (must be called after config.inc.php has been merged)

void
checkErrors()

Checks for errors (must be called after config.inc.php has been merged)

mixed|null
get(string $setting)

returns specific config setting

void
set(string $setting, mixed $value)

sets configuration variable

string
getSource()

returns source for current config

void
checkUpload()

checks if upload is enabled

void
checkUploadSize()

Maximum upload size as limited by PHP Used with permission from Moodle (https://moodle.org/) by Martin Dougiamas

bool
isHttps()

Checks if protocol is https

string
getRootPath()

Get phpMyAdmin root path

void
enableBc()

enables backward compatibility

bool
removeCookie(string $cookieName)

removes cookie

bool
setCookie(string $cookie, string $value, string|null $default = null, int|null $validity = null, bool $httponly = true)

sets cookie if value is different from current cookie value, or removes if value is equal to default

mixed|null
getCookie(string $cookieName)

get cookie

string
getCookieName(string $cookieName)

Get the real cookie name

bool
issetCookie(string $cookieName)

isset cookie

static void
fatalErrorHandler()

Error handler to catch fatal errors when loading configuration file

static string
renderFooter()

Renders user configured footer

static string
renderHeader()

Renders user configured footer

string|null
getTempDir(string $name)

Returns temporary dir path

string|null
getUploadTempDir()

Returns temporary directory

int
selectServer()

Selects server based on request parameters.

void
checkServers()

Checks whether Servers configuration is valid and possibly apply fixups.

static array
getConnectionParams(int $mode, array|null $server = null)

Return connection parameters for the database server

void
getLoginCookieValidityFromCache(int $server)

Get LoginCookieValidity from preferences cache.

Details

__construct(string|null $source = null)

No description

Parameters

string|null $source

source to read config from

void checkSystem()

sets system and application settings

Return Value

void

void checkOutputCompression()

whether to use gzip output compression or not

Return Value

void

void checkClient()

Determines platform (OS), browser and version of the user Based on a phpBuilder article:

void checkGd2()

Whether GD2 is present

Return Value

void

void checkWebServer()

Whether the Web server php is running on is IIS

Return Value

void

void checkWebServerOs()

Whether the os php is running on is windows or not

Return Value

void

bool loadDefaults()

loads default values from default source

Return Value

bool

success

bool load(string|null $source = null)

loads configuration from $source, usually the config file should be called on object creation

Parameters

string|null $source

config file

Return Value

bool

void loadUserPreferences()

Loads user preferences and merges them with current config must be called after control connection has been established

Return Value

void

true|Message setUserValue(string|null $cookie_name, string $cfg_path, string $new_cfg_value, string|null $default_value = null)

Sets config value which is stored in user preferences (if available) or in a cookie.

If user preferences are not yet initialized, option is applied to global config and added to a update queue, which is processed by loadUserPreferences()

Parameters

string|null $cookie_name

can be null

string $cfg_path

configuration path

string $new_cfg_value

new value

string|null $default_value

default value

Return Value

true|Message

mixed getUserValue(string $cookie_name, mixed $cfg_value)

Reads value stored by setUserValue()

Parameters

string $cookie_name

cookie name

mixed $cfg_value

config value

Return Value

mixed

void setSource(string $source)

set source

Parameters

string $source

source

Return Value

void

bool checkConfigSource()

check config source

Return Value

bool

whether source is valid or not

void checkPermissions()

verifies the permissions on config file (if asked by configuration) (must be called after config.inc.php has been merged)

Return Value

void

void checkErrors()

Checks for errors (must be called after config.inc.php has been merged)

Return Value

void

mixed|null get(string $setting)

returns specific config setting

Parameters

string $setting

config setting

Return Value

mixed|null

value

void set(string $setting, mixed $value)

sets configuration variable

Parameters

string $setting

configuration option

mixed $value

new value for configuration option

Return Value

void

string getSource()

returns source for current config

Return Value

string

config source

void checkUpload()

checks if upload is enabled

Return Value

void

void checkUploadSize()

Maximum upload size as limited by PHP Used with permission from Moodle (https://moodle.org/) by Martin Dougiamas

this section generates $max_upload_size in bytes

Return Value

void

bool isHttps()

Checks if protocol is https

This function checks if the https protocol on the active connection.

Return Value

bool

string getRootPath()

Get phpMyAdmin root path

Return Value

string

void enableBc()

enables backward compatibility

Return Value

void

bool removeCookie(string $cookieName)

removes cookie

Parameters

string $cookieName

name of cookie to remove

Return Value

bool

result of setcookie()

bool setCookie(string $cookie, string $value, string|null $default = null, int|null $validity = null, bool $httponly = true)

sets cookie if value is different from current cookie value, or removes if value is equal to default

Parameters

string $cookie

name of cookie to remove

string $value

new cookie value

string|null $default

default value

int|null $validity

validity of cookie in seconds (default is one month)

bool $httponly

whether cookie is only for HTTP (and not for scripts)

Return Value

bool

result of setcookie()

mixed|null getCookie(string $cookieName)

get cookie

Parameters

string $cookieName

The name of the cookie to get

Return Value

mixed|null

result of getCookie()

string getCookieName(string $cookieName)

Get the real cookie name

Parameters

string $cookieName

The name of the cookie

Return Value

string

bool issetCookie(string $cookieName)

isset cookie

Parameters

string $cookieName

The name of the cookie to check

Return Value

bool

result of issetCookie()

static void fatalErrorHandler()

Error handler to catch fatal errors when loading configuration file

Return Value

void

static string renderFooter()

Renders user configured footer

Return Value

string

static string renderHeader()

Renders user configured footer

Return Value

string

string|null getTempDir(string $name)

Returns temporary dir path

Parameters

string $name

Directory name

Return Value

string|null

string|null getUploadTempDir()

Returns temporary directory

Return Value

string|null

int selectServer()

Selects server based on request parameters.

Return Value

int

void checkServers()

Checks whether Servers configuration is valid and possibly apply fixups.

Return Value

void

static array getConnectionParams(int $mode, array|null $server = null)

Return connection parameters for the database server

Parameters

int $mode

Connection mode on of CONNECT_USER, CONNECT_CONTROL or CONNECT_AUXILIARY.

array|null $server

Server information like host/port/socket/persistent

Return Value

array

user, host and server settings array

void getLoginCookieValidityFromCache(int $server)

Get LoginCookieValidity from preferences cache.

No generic solution for loading preferences from cache as some settings need to be kept for processing in loadUserPreferences().

Parameters

int $server

Return Value

void

See also

loadUserPreferences()