2024.8.23
Loading...
Searching...
No Matches
Config Class Reference

Public Member Functions

 __construct ()
 
 getBrowser ()
 
 getDefaultLang ()
 
 getDownloadId ()
 
 getHostname ()
 
 getLang ()
 
 getLogsVerbose ()
 
 getMaxLogsArchives ()
 
 getNotepad ()
 
 getRaw ($key)
 
 getScriptsTimeout ()
 
 getTimezone ()
 
 isLaunchStartup ()
 
 isOnline ()
 
 replace ($key, $value)
 
 replaceAll ($params)
 

Data Fields

const CFG_BROWSER = 'browser'
 
const CFG_DEFAULT_LANG = 'defaultLang'
 
const CFG_HOSTNAME = 'hostname'
 
const CFG_LANG = 'lang'
 
const CFG_LAUNCH_STARTUP = 'launchStartup'
 
const CFG_LOGS_VERBOSE = 'logsVerbose'
 
const CFG_MAX_LOGS_ARCHIVES = 'maxLogsArchives'
 
const CFG_NOTEPAD = 'notepad'
 
const CFG_ONLINE = 'online'
 
const CFG_SCRIPTS_TIMEOUT = 'scriptsTimeout'
 
const CFG_TIMEZONE = 'timezone'
 
const DISABLED = 0
 
const DOWNLOAD_ID = 'DownloadId'
 
const ENABLED = 1
 
const VERBOSE_DEBUG = 2
 
const VERBOSE_REPORT = 1
 
const VERBOSE_SIMPLE = 0
 
const VERBOSE_TRACE = 3
 

Private Attributes

 $raw
 

Detailed Description

Class Config

This class handles the configuration settings for the Bearsampp application. It reads the configuration from an INI file and provides methods to access and modify these settings.

Definition at line 16 of file class.config.php.

Constructor & Destructor Documentation

◆ __construct()

Config::__construct ( )

Constructs a Config object and initializes the configuration settings. Reads the configuration from the INI file and sets the default timezone.

Definition at line 46 of file class.config.php.

47 {
48 global $bearsamppRoot;
49
50 // Set current timezone to match whats in .conf
51 $this->raw = parse_ini_file($bearsamppRoot->getConfigFilePath());
52 date_default_timezone_set($this->getTimezone());
53 }
global $bearsamppRoot

References $bearsamppRoot, and getTimezone().

Member Function Documentation

◆ getBrowser()

Config::getBrowser ( )

Retrieves the browser setting from the configuration.

Returns
string The browser setting.

Definition at line 162 of file class.config.php.

163 {
164 return $this->raw[self::CFG_BROWSER];
165 }
const CFG_BROWSER

References CFG_BROWSER.

◆ getDefaultLang()

Config::getDefaultLang ( )

Retrieves the default language setting from the configuration.

Returns
string The default language setting.

Definition at line 112 of file class.config.php.

113 {
114 return $this->raw[self::CFG_DEFAULT_LANG];
115 }
const CFG_DEFAULT_LANG

References CFG_DEFAULT_LANG.

◆ getDownloadId()

Config::getDownloadId ( )

Retrieves the license key from the configuration.

Returns
string The license key.

Definition at line 132 of file class.config.php.

133 {
134 return $this->raw[self::DOWNLOAD_ID];
135 }
const DOWNLOAD_ID

References DOWNLOAD_ID.

◆ getHostname()

Config::getHostname ( )

Retrieves the hostname setting from the configuration.

Returns
string The hostname setting.

Definition at line 172 of file class.config.php.

173 {
174 return $this->raw[self::CFG_HOSTNAME];
175 }
const CFG_HOSTNAME

References CFG_HOSTNAME.

◆ getLang()

Config::getLang ( )

Retrieves the language setting from the configuration.

Returns
string The language setting.

Definition at line 102 of file class.config.php.

103 {
104 return $this->raw[self::CFG_LANG];
105 }
const CFG_LANG

References CFG_LANG.

◆ getLogsVerbose()

Config::getLogsVerbose ( )

Retrieves the logs verbosity setting from the configuration.

Returns
int The logs verbosity setting.

Definition at line 202 of file class.config.php.

203 {
204 return intval($this->raw[self::CFG_LOGS_VERBOSE]);
205 }

◆ getMaxLogsArchives()

Config::getMaxLogsArchives ( )

Retrieves the maximum logs archives setting from the configuration.

Returns
int The maximum logs archives setting.

Definition at line 212 of file class.config.php.

213 {
214 return intval($this->raw[self::CFG_MAX_LOGS_ARCHIVES]);
215 }

◆ getNotepad()

Config::getNotepad ( )

Retrieves the notepad setting from the configuration.

Returns
string The notepad setting.

Definition at line 192 of file class.config.php.

193 {
194 return $this->raw[self::CFG_NOTEPAD];
195 }
const CFG_NOTEPAD

References CFG_NOTEPAD.

◆ getRaw()

Config::getRaw ( $key)

Retrieves the raw configuration value for the specified key.

Parameters
string$keyThe configuration key.
Returns
mixed The configuration value.

Definition at line 61 of file class.config.php.

62 {
63 return $this->raw[$key];
64 }

◆ getScriptsTimeout()

Config::getScriptsTimeout ( )

Retrieves the scripts timeout setting from the configuration.

Returns
int The scripts timeout setting.

Definition at line 182 of file class.config.php.

183 {
184 return intval($this->raw[self::CFG_SCRIPTS_TIMEOUT]);
185 }

◆ getTimezone()

Config::getTimezone ( )

Retrieves the timezone setting from the configuration.

Returns
string The timezone setting.

Definition at line 122 of file class.config.php.

123 {
124 return $this->raw[self::CFG_TIMEZONE];
125 }
const CFG_TIMEZONE

References CFG_TIMEZONE.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ isLaunchStartup()

Config::isLaunchStartup ( )

Checks if the application is set to launch at startup.

Returns
bool True if set to launch at startup, false otherwise.

Definition at line 152 of file class.config.php.

153 {
154 return $this->raw[self::CFG_LAUNCH_STARTUP] == self::ENABLED;
155 }
const ENABLED
const CFG_LAUNCH_STARTUP

References CFG_LAUNCH_STARTUP, and ENABLED.

◆ isOnline()

Config::isOnline ( )

Checks if the application is set to be online.

Returns
bool True if online, false otherwise.

Definition at line 142 of file class.config.php.

143 {
144 return $this->raw[self::CFG_ONLINE] == self::ENABLED;
145 }
const CFG_ONLINE

References CFG_ONLINE, and ENABLED.

◆ replace()

Config::replace ( $key,
$value )

Replaces a single configuration value with the specified key and value.

Parameters
string$keyThe configuration key.
mixed$valueThe new configuration value.

Definition at line 72 of file class.config.php.

73 {
74 $this->replaceAll(array($key => $value));
75 }
replaceAll($params)

References replaceAll().

◆ replaceAll()

Config::replaceAll ( $params)

Replaces multiple configuration values with the specified key-value pairs.

Parameters
array$paramsAn associative array of key-value pairs to replace.

Definition at line 82 of file class.config.php.

83 {
84 global $bearsamppRoot;
85
86 Util::logTrace('Replace config:');
87 $content = file_get_contents($bearsamppRoot->getConfigFilePath());
88 foreach ($params as $key => $value) {
89 $content = preg_replace('/^' . $key . '\s=\s.*/m', $key . ' = ' . '"' . $value.'"', $content, -1, $count);
90 Util::logTrace('## ' . $key . ': ' . $value . ' (' . $count . ' replacements done)');
91 $this->raw[$key] = $value;
92 }
93
94 file_put_contents($bearsamppRoot->getConfigFilePath(), $content);
95 }
static logTrace($data, $file=null)

References $bearsamppRoot, and Util\logTrace().

Referenced by replace().

+ Here is the caller graph for this function:

Field Documentation

◆ $raw

Config::$raw
private

Definition at line 40 of file class.config.php.

◆ CFG_BROWSER

const Config::CFG_BROWSER = 'browser'

◆ CFG_DEFAULT_LANG

const Config::CFG_DEFAULT_LANG = 'defaultLang'

Definition at line 26 of file class.config.php.

Referenced by getDefaultLang().

◆ CFG_HOSTNAME

const Config::CFG_HOSTNAME = 'hostname'

◆ CFG_LANG

const Config::CFG_LANG = 'lang'

Definition at line 20 of file class.config.php.

Referenced by ActionSwitchLang\__construct(), and getLang().

◆ CFG_LAUNCH_STARTUP

const Config::CFG_LAUNCH_STARTUP = 'launchStartup'

◆ CFG_LOGS_VERBOSE

const Config::CFG_LOGS_VERBOSE = 'logsVerbose'

Definition at line 19 of file class.config.php.

Referenced by ActionSwitchLogsVerbose\__construct().

◆ CFG_MAX_LOGS_ARCHIVES

const Config::CFG_MAX_LOGS_ARCHIVES = 'maxLogsArchives'

Definition at line 18 of file class.config.php.

◆ CFG_NOTEPAD

const Config::CFG_NOTEPAD = 'notepad'

Definition at line 22 of file class.config.php.

Referenced by getNotepad().

◆ CFG_ONLINE

const Config::CFG_ONLINE = 'online'

Definition at line 29 of file class.config.php.

Referenced by ActionSwitchOnline\__construct(), and isOnline().

◆ CFG_SCRIPTS_TIMEOUT

const Config::CFG_SCRIPTS_TIMEOUT = 'scriptsTimeout'

Definition at line 23 of file class.config.php.

◆ CFG_TIMEZONE

const Config::CFG_TIMEZONE = 'timezone'

Definition at line 21 of file class.config.php.

Referenced by getTimezone().

◆ DISABLED

◆ DOWNLOAD_ID

const Config::DOWNLOAD_ID = 'DownloadId'

Definition at line 24 of file class.config.php.

Referenced by getDownloadId().

◆ ENABLED

◆ VERBOSE_DEBUG

const Config::VERBOSE_DEBUG = 2

Definition at line 37 of file class.config.php.

Referenced by TplAppLogsVerbose\getMenuLogsVerbose(), and Util\log().

◆ VERBOSE_REPORT

const Config::VERBOSE_REPORT = 1

Definition at line 36 of file class.config.php.

Referenced by TplAppLogsVerbose\getMenuLogsVerbose(), and Util\log().

◆ VERBOSE_SIMPLE

const Config::VERBOSE_SIMPLE = 0

Definition at line 35 of file class.config.php.

Referenced by TplAppLogsVerbose\getMenuLogsVerbose(), and Util\log().

◆ VERBOSE_TRACE

const Config::VERBOSE_TRACE = 3

Definition at line 38 of file class.config.php.

Referenced by TplAppLogsVerbose\getMenuLogsVerbose(), and Util\log().


The documentation for this class was generated from the following file: