Bearsampp 2026.5.5
Loading...
Searching...
No Matches
Root Class Reference

Public Member Functions

 __construct ($rootPath)
 errorHandler ($errno, $errstr, $errfile, $errline)
 getAliasPath ($aetrayPath=false)
 getAppsPath ($aetrayPath=false)
 getBatchLogFilePath ($aetrayPath=false)
 getBinPath ($aetrayPath=false)
 getConfigFilePath ($aetrayPath=false)
 getCorePath ($aetrayPath=false)
 getErrorLogFilePath ($aetrayPath=false)
 getExeFilePath ($aetrayPath=false)
 getHomepageFilePath ($aetrayPath=false)
 getHomepageLogFilePath ($aetrayPath=false)
 getIniFilePath ($aetrayPath=false)
 getLocalUrl ($request=null)
 getLogFilePath ($aetrayPath=false)
 getLogsPath ($aetrayPath=false)
 getNssmLogFilePath ($aetrayPath=false)
 getProcessName ()
 getProcs ()
 getRegistryLogFilePath ($aetrayPath=false)
 getRootPath ($aetrayPath=false)
 getServicesLogFilePath ($aetrayPath=false)
 getSslConfPath ($aetrayPath=false)
 getSslPath ($aetrayPath=false)
 getStartupLogFilePath ($aetrayPath=false)
 getTmpPath ($aetrayPath=false)
 getToolsPath ($aetrayPath=false)
 getVhostsPath ($aetrayPath=false)
 getWinbinderLogFilePath ($aetrayPath=false)
 getWwwPath ($aetrayPath=false)
 initErrorHandling ()
 isRoot ()
 register ()
 removeErrorHandling ()

Static Public Member Functions

static loadApps ()
static loadBins ()
static loadConfig ()
static loadCore ()
static loadHomepage ()
static loadLang ()
static loadOpenSsl ()
static loadRegistry ()
static loadTools ()
static loadWinbinder ()

Data Fields

 $path
const ERROR_HANDLER = 'errorHandler'

Private Member Functions

 aetrayPath ($path)

Static Private Member Functions

static debugStringBacktrace ()

Private Attributes

 $isRoot
 $procs

Detailed Description

Class Root

This class represents the root of the Bearsampp application. It handles the initialization, configuration, and management of various components and settings within the application.

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( $rootPath)

Constructs a Root object with the specified root path.

Parameters
string$rootPathThe root path of the application.

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

30 {
31 $this->path = str_replace('\\', '/', rtrim($rootPath, '/\\'));
32 $this->isRoot = $_SERVER['PHP_SELF'] == 'root.php';
33 }

References isRoot().

Member Function Documentation

◆ aetrayPath()

aetrayPath ( $path)
private

Formats a path for AeTrayMenu.

Parameters
string$pathThe path to format.
Returns
string The formatted path.

Definition at line 141 of file class.root.php.

142 {
143 $path = str_replace($this->getRootPath(), '', $path);
144 return '%AeTrayMenuPath%' . substr($path, 1, strlen($path));
145 }
getRootPath($aetrayPath=false)

References $path, and getRootPath().

Referenced by getCorePath(), and getRootPath().

◆ debugStringBacktrace()

debugStringBacktrace ( )
staticprivate

Generates a debug backtrace string.

Returns
string The debug backtrace.

Definition at line 579 of file class.root.php.

580 {
581 ob_start();
582 debug_print_backtrace();
583 $trace = ob_get_contents();
584 ob_end_clean();
585
586 $trace = preg_replace('/^#0\s+Root::debugStringBacktrace[^\n]*\n/', '', $trace, 1);
587 $trace = preg_replace('/^#1\s+isRoot->errorHandler[^\n]*\n/', '', $trace, 1);
588 $trace = preg_replace_callback('/^#(\d+)/m', 'debugStringPregReplace', $trace);
589 return $trace;
590 }

Referenced by errorHandler().

◆ errorHandler()

errorHandler ( $errno,
$errstr,
$errfile,
$errline )

Handles errors and logs them to the error log file.

Parameters
int$errnoThe level of the error raised.
string$errstrThe error message.
string$errfileThe filename that the error was raised in.
int$errlineThe line number the error was raised at.

Definition at line 536 of file class.root.php.

537 {
538 if (error_reporting() === 0) {
539 return;
540 }
541
542 $errfile = UtilPath::formatUnixPath($errfile);
543 $errfile = str_replace($this->getRootPath(), '', $errfile);
544
545 if (!defined('E_DEPRECATED')) {
546 define('E_DEPRECATED', 8192);
547 }
548
549 $errNames = array(
550 E_ERROR => 'E_ERROR',
551 E_WARNING => 'E_WARNING',
552 E_PARSE => 'E_PARSE',
553 E_NOTICE => 'E_NOTICE',
554 E_CORE_ERROR => 'E_CORE_ERROR',
555 E_CORE_WARNING => 'E_CORE_WARNING',
556 E_COMPILE_ERROR => 'E_COMPILE_ERROR',
557 E_COMPILE_WARNING => 'E_COMPILE_WARNING',
558 E_USER_ERROR => 'E_USER_ERROR',
559 E_USER_WARNING => 'E_USER_WARNING',
560 E_USER_NOTICE => 'E_USER_NOTICE',
561 E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
562 E_DEPRECATED => 'E_DEPRECATED',
563 );
564
565 $content = '[' . date('Y-m-d H:i:s', time()) . '] ';
566 $content .= $errNames[$errno] . ' ';
567 $content .= $errstr . ' in ' . $errfile;
568 $content .= ' on line ' . $errline . PHP_EOL;
569 $content .= self::debugStringBacktrace() . PHP_EOL;
570
571 file_put_contents($this->getErrorLogFilePath(), $content, FILE_APPEND);
572 }
static debugStringBacktrace()
getErrorLogFilePath($aetrayPath=false)
static formatUnixPath($path)
if(!extension_loaded('winbinder')) if(!dl('php_winbinder.dll')) trigger_error("WinBinder extension could not be loaded.\n" E_USER_ERROR
Definition winbinder.php:14

References debugStringBacktrace(), E_USER_ERROR, UtilPath\formatUnixPath(), getErrorLogFilePath(), and getRootPath().

◆ getAliasPath()

getAliasPath ( $aetrayPath = false)

Gets the path to the alias directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The alias path.

Definition at line 153 of file class.root.php.

154 {
155 return $this->getRootPath($aetrayPath) . '/alias';
156 }

References getRootPath().

◆ getAppsPath()

getAppsPath ( $aetrayPath = false)

Gets the path to the apps directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The apps path.

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

165 {
166 return $this->getRootPath($aetrayPath) . '/apps';
167 }

References getRootPath().

◆ getBatchLogFilePath()

getBatchLogFilePath ( $aetrayPath = false)

Gets the path to the batch log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The batch log file path.

Definition at line 373 of file class.root.php.

374 {
375 return $this->getLogsPath($aetrayPath) . '/bearsampp-batch.log';
376 }
getLogsPath($aetrayPath=false)

References getLogsPath().

◆ getBinPath()

getBinPath ( $aetrayPath = false)

Gets the path to the bin directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The bin path.

Definition at line 175 of file class.root.php.

176 {
177 return $this->getRootPath($aetrayPath) . '/bin';
178 }

References getRootPath().

◆ getConfigFilePath()

getConfigFilePath ( $aetrayPath = false)

Gets the path to the configuration file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The configuration file path.

Definition at line 274 of file class.root.php.

275 {
276 return $this->getRootPath($aetrayPath) . '/bearsampp.conf';
277 }

References getRootPath().

◆ getCorePath()

getCorePath ( $aetrayPath = false)

Gets the path to the core directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The core path.

Definition at line 186 of file class.root.php.

187 {
188 return $aetrayPath ? $this->aetrayPath($this->path) : $this->path;
189 }
aetrayPath($path)

References $path, and aetrayPath().

Referenced by register().

◆ getErrorLogFilePath()

getErrorLogFilePath ( $aetrayPath = false)

Gets the path to the error log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The error log file path.

Definition at line 318 of file class.root.php.

319 {
320 return $this->getLogsPath($aetrayPath) . '/bearsampp-error.log';
321 }

References getLogsPath().

Referenced by errorHandler(), and initErrorHandling().

◆ getExeFilePath()

getExeFilePath ( $aetrayPath = false)

Gets the path to the executable file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The executable file path.

Definition at line 263 of file class.root.php.

264 {
265 return $this->getRootPath($aetrayPath) . '/bearsampp.exe';
266 }

References getRootPath().

◆ getHomepageFilePath()

getHomepageFilePath ( $aetrayPath = false)

Gets the path to the homepage file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The homepage file path.

Definition at line 406 of file class.root.php.

407 {
408 return $this->getWwwPath($aetrayPath) . '/index.php';
409 }
getWwwPath($aetrayPath=false)

References getWwwPath().

◆ getHomepageLogFilePath()

getHomepageLogFilePath ( $aetrayPath = false)

Gets the path to the homepage log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The homepage log file path.

Definition at line 329 of file class.root.php.

330 {
331 return $this->getLogsPath($aetrayPath) . '/bearsampp-homepage.log';
332 }

References getLogsPath().

◆ getIniFilePath()

getIniFilePath ( $aetrayPath = false)

Gets the path to the INI file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The INI file path.

Definition at line 285 of file class.root.php.

286 {
287 return $this->getRootPath($aetrayPath) . '/bearsampp.ini';
288 }

References getRootPath().

◆ getLocalUrl()

getLocalUrl ( $request = null)

Constructs a local URL with the specified request.

Parameters
string | null$requestThe specific request to append to the URL.
Returns
string The constructed local URL.

Definition at line 427 of file class.root.php.

428 {
429 global $bearsamppBins;
430 return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') .
431 (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost') .
432 ($bearsamppBins->getApache()->getPort() != 80 && !isset($_SERVER['HTTPS']) ? ':' . $bearsamppBins->getApache()->getPort() : '') .
433 (!empty($request) ? '/' . $request : '');
434 }
global $bearsamppBins

References $bearsamppBins.

◆ getLogFilePath()

getLogFilePath ( $aetrayPath = false)

Gets the path to the log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The log file path.

Definition at line 307 of file class.root.php.

308 {
309 return $this->getLogsPath($aetrayPath) . '/bearsampp.log';
310 }

References getLogsPath().

◆ getLogsPath()

getLogsPath ( $aetrayPath = false)

Gets the path to the logs directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The logs path.

Definition at line 197 of file class.root.php.

198 {
199 return $this->getRootPath($aetrayPath) . '/logs';
200 }

References getRootPath().

Referenced by getBatchLogFilePath(), getErrorLogFilePath(), getHomepageLogFilePath(), getLogFilePath(), getNssmLogFilePath(), getRegistryLogFilePath(), getServicesLogFilePath(), getStartupLogFilePath(), and getWinbinderLogFilePath().

◆ getNssmLogFilePath()

getNssmLogFilePath ( $aetrayPath = false)

Gets the path to the NSSM log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The NSSM log file path.

Definition at line 395 of file class.root.php.

396 {
397 return $this->getLogsPath($aetrayPath) . '/bearsampp-nssm.log';
398 }

References getLogsPath().

◆ getProcessName()

getProcessName ( )

Gets the name of the process.

Returns
string The process name.

Definition at line 416 of file class.root.php.

417 {
418 return 'bearsampp';
419 }

◆ getProcs()

getProcs ( )

Retrieves the list of processes.

Returns
array The list of processes.

Definition at line 108 of file class.root.php.

109 {
110 return $this->procs;
111 }

References $procs.

◆ getRegistryLogFilePath()

getRegistryLogFilePath ( $aetrayPath = false)

Gets the path to the registry log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The registry log file path.

Definition at line 351 of file class.root.php.

352 {
353 return $this->getLogsPath($aetrayPath) . '/bearsampp-registry.log';
354 }

References getLogsPath().

◆ getRootPath()

getRootPath ( $aetrayPath = false)

Gets the root path, optionally formatted for AeTrayMenu.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The root path.

Definition at line 129 of file class.root.php.

130 {
131 $path = dirname($this->path);
132 return $aetrayPath ? $this->aetrayPath($path) : $path;
133 }

References $path, and aetrayPath().

Referenced by aetrayPath(), errorHandler(), getAliasPath(), getAppsPath(), getBinPath(), getConfigFilePath(), getExeFilePath(), getIniFilePath(), getLogsPath(), getSslPath(), getTmpPath(), getToolsPath(), getVhostsPath(), and getWwwPath().

◆ getServicesLogFilePath()

getServicesLogFilePath ( $aetrayPath = false)

Gets the path to the services log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The services log file path.

Definition at line 340 of file class.root.php.

341 {
342 return $this->getLogsPath($aetrayPath) . '/bearsampp-services.log';
343 }

References getLogsPath().

◆ getSslConfPath()

getSslConfPath ( $aetrayPath = false)

Gets the path to the SSL configuration file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The SSL configuration file path.

Definition at line 296 of file class.root.php.

297 {
298 return $this->getSslPath($aetrayPath) . '/openssl.cnf';
299 }
getSslPath($aetrayPath=false)

References getSslPath().

◆ getSslPath()

getSslPath ( $aetrayPath = false)

Gets the path to the SSL directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The SSL path.

Definition at line 208 of file class.root.php.

209 {
210 return $this->getRootPath($aetrayPath) . '/ssl';
211 }

References getRootPath().

Referenced by getSslConfPath().

◆ getStartupLogFilePath()

getStartupLogFilePath ( $aetrayPath = false)

Gets the path to the startup log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The startup log file path.

Definition at line 362 of file class.root.php.

363 {
364 return $this->getLogsPath($aetrayPath) . '/bearsampp-startup.log';
365 }

References getLogsPath().

◆ getTmpPath()

getTmpPath ( $aetrayPath = false)

Gets the path to the temporary directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The temporary path.

Definition at line 219 of file class.root.php.

220 {
221 return $this->getRootPath($aetrayPath) . '/tmp';
222 }

References getRootPath().

◆ getToolsPath()

getToolsPath ( $aetrayPath = false)

Gets the path to the tools directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The tools path.

Definition at line 230 of file class.root.php.

231 {
232 return $this->getRootPath($aetrayPath) . '/tools';
233 }

References getRootPath().

◆ getVhostsPath()

getVhostsPath ( $aetrayPath = false)

Gets the path to the virtual hosts directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The virtual hosts path.

Definition at line 241 of file class.root.php.

242 {
243 return $this->getRootPath($aetrayPath) . '/vhosts';
244 }

References getRootPath().

◆ getWinbinderLogFilePath()

getWinbinderLogFilePath ( $aetrayPath = false)

Gets the path to the Winbinder log file.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The Winbinder log file path.

Definition at line 384 of file class.root.php.

385 {
386 return $this->getLogsPath($aetrayPath) . '/bearsampp-winbinder.log';
387 }

References getLogsPath().

◆ getWwwPath()

getWwwPath ( $aetrayPath = false)

Gets the path to the WWW directory.

Parameters
bool$aetrayPathWhether to format the path for AeTrayMenu.
Returns
string The WWW path.

Definition at line 252 of file class.root.php.

253 {
254 return $this->getRootPath($aetrayPath) . '/www';
255 }

References getRootPath().

Referenced by getHomepageFilePath().

◆ initErrorHandling()

initErrorHandling ( )

Initializes error handling settings for the application.

Definition at line 84 of file class.root.php.

85 {
86 error_reporting(-1);
87 ini_set('error_log', $this->getErrorLogFilePath());
88 ini_set('display_errors', '1');
89 set_error_handler(array($this, self::ERROR_HANDLER));
90 }

References getErrorLogFilePath().

Referenced by register().

◆ isRoot()

isRoot ( )

Checks if the current script is executed from the root path.

Returns
bool True if executed from the root, false otherwise.

Definition at line 118 of file class.root.php.

119 {
120 return $this->isRoot;
121 }

References $isRoot.

Referenced by __construct(), and register().

◆ loadApps()

loadApps ( )
static

Loads the apps components of the application.

Definition at line 493 of file class.root.php.

494 {
495 global $bearsamppApps;
496 $bearsamppApps = new Apps();
497 }

Referenced by register().

◆ loadBins()

loadBins ( )
static

Loads the binary components of the application.

Definition at line 475 of file class.root.php.

476 {
477 global $bearsamppBins;
478 $bearsamppBins = new Bins();
479 }

References $bearsamppBins.

Referenced by register().

◆ loadConfig()

loadConfig ( )
static

Loads the configuration settings of the application.

Definition at line 448 of file class.root.php.

449 {
450 global $bearsamppConfig;
451 $bearsamppConfig = new Config();
452 }
global $bearsamppConfig
Definition homepage.php:41

References $bearsamppConfig.

Referenced by ActionSwitchVersion\processWindow(), and register().

◆ loadCore()

loadCore ( )
static

Loads the core components of the application.

Definition at line 439 of file class.root.php.

440 {
441 global $bearsamppCore;
442 $bearsamppCore = new Core();
443 }
global $bearsamppCore

References $bearsamppCore.

Referenced by register().

◆ loadHomepage()

loadHomepage ( )
static

Loads the homepage settings of the application.

Definition at line 522 of file class.root.php.

523 {
524 global $bearsamppHomepage;
525 $bearsamppHomepage = new Homepage();
526 }
global $bearsamppHomepage
Definition homepage.php:41

References $bearsamppHomepage.

Referenced by register().

◆ loadLang()

loadLang ( )
static

Loads the language settings of the application.

Definition at line 457 of file class.root.php.

458 {
459 global $bearsamppLang;
460 $bearsamppLang = new LangProc();
461 }
global $bearsamppLang

References $bearsamppLang.

Referenced by register().

◆ loadOpenSsl()

loadOpenSsl ( )
static

Loads the OpenSSL settings of the application.

Definition at line 466 of file class.root.php.

467 {
468 global $bearsamppOpenSsl;
469 $bearsamppOpenSsl = new OpenSsl();
470 }

Referenced by register().

◆ loadRegistry()

loadRegistry ( )
static

Loads the registry settings of the application.

Definition at line 513 of file class.root.php.

514 {
515 global $bearsamppRegistry;
516 $bearsamppRegistry = new Registry();
517 }

Referenced by register().

◆ loadTools()

loadTools ( )
static

Loads the tools components of the application.

Definition at line 484 of file class.root.php.

485 {
486 global $bearsamppTools;
487 $bearsamppTools = new Tools();
488 }

Referenced by register().

◆ loadWinbinder()

loadWinbinder ( )
static

Loads the Winbinder extension if available.

Definition at line 502 of file class.root.php.

503 {
504 global $bearsamppWinbinder;
505 if (extension_loaded('winbinder')) {
506 $bearsamppWinbinder = new WinBinder();
507 }
508 }

Referenced by register().

◆ register()

register ( )

Registers the application components and initializes error handling.

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

39 {
40 // Params
41 set_time_limit(0);
42 clearstatcache();
43
44 // External classes required for error handling and path utilities
45 require_once $this->getCorePath() . '/classes/class.util.path.php';
46
47 // Error log
48 $this->initErrorHandling();
49
50 // External classes
51 require_once $this->getCorePath() . '/classes/class.log.php';
52 require_once $this->getCorePath() . '/classes/class.util.php';
53 require_once $this->getCorePath() . '/classes/class.util.string.php';
54 require_once $this->getCorePath() . '/classes/class.httpclient.php';
55 Log::init();
56
57 // Autoloader
58 require_once $this->getCorePath() . '/classes/class.autoloader.php';
59 $bearsamppAutoloader = new Autoloader();
60 $bearsamppAutoloader->register();
61
62 // Load
74
75 // Init
76 if ($this->isRoot) {
77 $this->procs = Win32Ps::getListProcs();
78 }
79 }
static init()
Definition class.log.php:58
static separator()
static loadBins()
static loadOpenSsl()
static loadLang()
static loadApps()
static loadTools()
static loadWinbinder()
static loadHomepage()
getCorePath($aetrayPath=false)
static loadCore()
static loadConfig()
static loadRegistry()
initErrorHandling()
static getListProcs()

References getCorePath(), Win32Ps\getListProcs(), Log\init(), initErrorHandling(), isRoot(), loadApps(), loadBins(), loadConfig(), loadCore(), loadHomepage(), loadLang(), loadOpenSsl(), loadRegistry(), loadTools(), loadWinbinder(), and Log\separator().

◆ removeErrorHandling()

removeErrorHandling ( )

Removes the custom error handling, reverting to the default PHP error handling.

Definition at line 95 of file class.root.php.

96 {
97 error_reporting(0);
98 ini_set('error_log', null);
99 ini_set('display_errors', '0');
100 restore_error_handler();
101 }

Field Documentation

◆ $isRoot

$isRoot
private

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

Referenced by isRoot().

◆ $path

$path

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

Referenced by aetrayPath(), getCorePath(), and getRootPath().

◆ $procs

$procs
private

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

Referenced by getProcs().

◆ ERROR_HANDLER

const ERROR_HANDLER = 'errorHandler'

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


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