Bearsampp 2025.8.29
Loading...
Searching...
No Matches
Config Class Reference

Public Member Functions

 __construct ()
 getBrowser ()
 getDefaultLang ()
 getDownloadId ()
 getHostname ()
 getIncludePr ()
 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_INCLUDE_PR = 'IncludePR'
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 17 of file class.config.php.

Constructor & Destructor Documentation

◆ __construct()

__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 48 of file class.config.php.

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

References $bearsamppRoot, and getTimezone().

Member Function Documentation

◆ getBrowser()

getBrowser ( )

Retrieves the browser setting from the configuration.

Returns
string The browser setting.

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

165 {
166 return $this->raw[self::CFG_BROWSER];
167 }

◆ getDefaultLang()

getDefaultLang ( )

Retrieves the default language setting from the configuration.

Returns
string The default language setting.

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

115 {
116 return $this->raw[self::CFG_DEFAULT_LANG];
117 }

◆ getDownloadId()

getDownloadId ( )

Retrieves the license key from the configuration.

Returns
string The license key.

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

135 {
136 return $this->raw[self::DOWNLOAD_ID];
137 }

◆ getHostname()

getHostname ( )

Retrieves the hostname setting from the configuration.

Returns
string The hostname setting.

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

175 {
176 return $this->raw[self::CFG_HOSTNAME];
177 }

◆ getIncludePr()

getIncludePr ( )

Retrieves the IncludePr setting from the configuration.

Returns
int 1 if PR should be included, 0 otherwise

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

225 {
226 return isset($this->raw[self::CFG_INCLUDE_PR]) ? intval($this->raw[self::CFG_INCLUDE_PR]) : 0;
227 }

◆ getLang()

getLang ( )

Retrieves the language setting from the configuration.

Returns
string The language setting.

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

105 {
106 return $this->raw[self::CFG_LANG];
107 }

◆ getLogsVerbose()

getLogsVerbose ( )

Retrieves the logs verbosity setting from the configuration.

Returns
int The logs verbosity setting.

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

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

◆ getMaxLogsArchives()

getMaxLogsArchives ( )

Retrieves the maximum logs archives setting from the configuration.

Returns
int The maximum logs archives setting.

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

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

◆ getNotepad()

getNotepad ( )

Retrieves the notepad setting from the configuration.

Returns
string The notepad setting.

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

195 {
196 return $this->raw[self::CFG_NOTEPAD];
197 }

◆ getRaw()

getRaw ( $key)

Retrieves the raw configuration value for the specified key.

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

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

64 {
65 return $this->raw[$key];
66 }

◆ getScriptsTimeout()

getScriptsTimeout ( )

Retrieves the scripts timeout setting from the configuration.

Returns
int The scripts timeout setting.

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

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

◆ getTimezone()

getTimezone ( )

Retrieves the timezone setting from the configuration.

Returns
string The timezone setting.

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

125 {
126 return $this->raw[self::CFG_TIMEZONE];
127 }

Referenced by __construct().

◆ isLaunchStartup()

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 154 of file class.config.php.

155 {
156 return $this->raw[self::CFG_LAUNCH_STARTUP] == self::ENABLED;
157 }

◆ isOnline()

isOnline ( )

Checks if the application is set to be online.

Returns
bool True if online, false otherwise.

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

145 {
146 return $this->raw[self::CFG_ONLINE] == self::ENABLED;
147 }

◆ replace()

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 74 of file class.config.php.

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

References replaceAll().

◆ replaceAll()

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 84 of file class.config.php.

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

References $bearsamppRoot, and Util\logTrace().

Referenced by replace().

Field Documentation

◆ $raw

$raw
private

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

◆ CFG_BROWSER

const CFG_BROWSER = 'browser'

◆ CFG_DEFAULT_LANG

const CFG_DEFAULT_LANG = 'defaultLang'

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

◆ CFG_HOSTNAME

const CFG_HOSTNAME = 'hostname'

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

Referenced by ActionReload\__construct(), and ActionStartup\refreshHostname().

◆ CFG_INCLUDE_PR

const CFG_INCLUDE_PR = 'IncludePR'

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

◆ CFG_LANG

const CFG_LANG = 'lang'

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

Referenced by ActionSwitchLang\__construct().

◆ CFG_LAUNCH_STARTUP

const CFG_LAUNCH_STARTUP = 'launchStartup'

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

Referenced by ActionLaunchStartup\__construct(), and ActionReload\__construct().

◆ CFG_LOGS_VERBOSE

const CFG_LOGS_VERBOSE = 'logsVerbose'

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

Referenced by ActionSwitchLogsVerbose\__construct().

◆ CFG_MAX_LOGS_ARCHIVES

const CFG_MAX_LOGS_ARCHIVES = 'maxLogsArchives'

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

◆ CFG_NOTEPAD

const CFG_NOTEPAD = 'notepad'

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

◆ CFG_ONLINE

const CFG_ONLINE = 'online'

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

Referenced by ActionSwitchOnline\__construct().

◆ CFG_SCRIPTS_TIMEOUT

const CFG_SCRIPTS_TIMEOUT = 'scriptsTimeout'

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

◆ CFG_TIMEZONE

const CFG_TIMEZONE = 'timezone'

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

◆ DISABLED

◆ DOWNLOAD_ID

const DOWNLOAD_ID = 'DownloadId'

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

◆ ENABLED

◆ VERBOSE_DEBUG

const VERBOSE_DEBUG = 2

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

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

◆ VERBOSE_REPORT

const VERBOSE_REPORT = 1

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

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

◆ VERBOSE_SIMPLE

const VERBOSE_SIMPLE = 0

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

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

◆ VERBOSE_TRACE

const VERBOSE_TRACE = 3

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

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


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