Bearsampp 2025.8.29
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)
 getVbsLogFilePath ($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 134 of file class.root.php.

135 {
136 $path = str_replace($this->getRootPath(), '', $path);
137 return '%AeTrayMenuPath%' . substr($path, 1, strlen($path));
138 }
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 583 of file class.root.php.

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

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 540 of file class.root.php.

541 {
542 if (error_reporting() === 0) {
543 return;
544 }
545
546 $errfile = Util::formatUnixPath($errfile);
547 $errfile = str_replace($this->getRootPath(), '', $errfile);
548
549 if (!defined('E_DEPRECATED')) {
550 define('E_DEPRECATED', 8192);
551 }
552
553 $errNames = array(
554 E_ERROR => 'E_ERROR',
555 E_WARNING => 'E_WARNING',
556 E_PARSE => 'E_PARSE',
557 E_NOTICE => 'E_NOTICE',
558 E_CORE_ERROR => 'E_CORE_ERROR',
559 E_CORE_WARNING => 'E_CORE_WARNING',
560 E_COMPILE_ERROR => 'E_COMPILE_ERROR',
561 E_COMPILE_WARNING => 'E_COMPILE_WARNING',
562 E_USER_ERROR => 'E_USER_ERROR',
563 E_USER_WARNING => 'E_USER_WARNING',
564 E_USER_NOTICE => 'E_USER_NOTICE',
565 E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
566 E_DEPRECATED => 'E_DEPRECATED',
567 );
568
569 $content = '[' . date('Y-m-d H:i:s', time()) . '] ';
570 $content .= $errNames[$errno] . ' ';
571 $content .= $errstr . ' in ' . $errfile;
572 $content .= ' on line ' . $errline . PHP_EOL;
573 $content .= self::debugStringBacktrace() . PHP_EOL;
574
575 file_put_contents($this->getErrorLogFilePath(), $content, FILE_APPEND);
576 }
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, Util\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 146 of file class.root.php.

147 {
148 return $this->getRootPath($aetrayPath) . '/alias';
149 }

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 157 of file class.root.php.

158 {
159 return $this->getRootPath($aetrayPath) . '/apps';
160 }

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 366 of file class.root.php.

367 {
368 return $this->getLogsPath($aetrayPath) . '/bearsampp-batch.log';
369 }
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 168 of file class.root.php.

169 {
170 return $this->getRootPath($aetrayPath) . '/bin';
171 }

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 267 of file class.root.php.

268 {
269 return $this->getRootPath($aetrayPath) . '/bearsampp.conf';
270 }

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 179 of file class.root.php.

180 {
181 return $aetrayPath ? $this->aetrayPath($this->path) : $this->path;
182 }
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 311 of file class.root.php.

312 {
313 return $this->getLogsPath($aetrayPath) . '/bearsampp-error.log';
314 }

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 256 of file class.root.php.

257 {
258 return $this->getRootPath($aetrayPath) . '/bearsampp.exe';
259 }

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 410 of file class.root.php.

411 {
412 return $this->getWwwPath($aetrayPath) . '/index.php';
413 }
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 322 of file class.root.php.

323 {
324 return $this->getLogsPath($aetrayPath) . '/bearsampp-homepage.log';
325 }

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 278 of file class.root.php.

279 {
280 return $this->getRootPath($aetrayPath) . '/bearsampp.ini';
281 }

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 431 of file class.root.php.

432 {
433 global $bearsamppBins;
434 return (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') .
435 (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost') .
436 ($bearsamppBins->getApache()->getPort() != 80 && !isset($_SERVER['HTTPS']) ? ':' . $bearsamppBins->getApache()->getPort() : '') .
437 (!empty($request) ? '/' . $request : '');
438 }
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 300 of file class.root.php.

301 {
302 return $this->getLogsPath($aetrayPath) . '/bearsampp.log';
303 }

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 190 of file class.root.php.

191 {
192 return $this->getRootPath($aetrayPath) . '/logs';
193 }

References getRootPath().

Referenced by getBatchLogFilePath(), getErrorLogFilePath(), getHomepageLogFilePath(), getLogFilePath(), getNssmLogFilePath(), getRegistryLogFilePath(), getServicesLogFilePath(), getStartupLogFilePath(), getVbsLogFilePath(), 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 399 of file class.root.php.

400 {
401 return $this->getLogsPath($aetrayPath) . '/bearsampp-nssm.log';
402 }

References getLogsPath().

◆ getProcessName()

getProcessName ( )

Gets the name of the process.

Returns
string The process name.

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

421 {
422 return 'bearsampp';
423 }

◆ getProcs()

getProcs ( )

Retrieves the list of processes.

Returns
array The list of processes.

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

102 {
103 return $this->procs;
104 }

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 344 of file class.root.php.

345 {
346 return $this->getLogsPath($aetrayPath) . '/bearsampp-registry.log';
347 }

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 122 of file class.root.php.

123 {
124 $path = dirname($this->path);
125 return $aetrayPath ? $this->aetrayPath($path) : $path;
126 }

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 333 of file class.root.php.

334 {
335 return $this->getLogsPath($aetrayPath) . '/bearsampp-services.log';
336 }

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 289 of file class.root.php.

290 {
291 return $this->getSslPath($aetrayPath) . '/openssl.cnf';
292 }
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 201 of file class.root.php.

202 {
203 return $this->getRootPath($aetrayPath) . '/ssl';
204 }

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 355 of file class.root.php.

356 {
357 return $this->getLogsPath($aetrayPath) . '/bearsampp-startup.log';
358 }

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 212 of file class.root.php.

213 {
214 return $this->getRootPath($aetrayPath) . '/tmp';
215 }

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 223 of file class.root.php.

224 {
225 return $this->getRootPath($aetrayPath) . '/tools';
226 }

References getRootPath().

◆ getVbsLogFilePath()

getVbsLogFilePath ( $aetrayPath = false)

Gets the path to the VBS log file.

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

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

378 {
379 return $this->getLogsPath($aetrayPath) . '/bearsampp-vbs.log';
380 }

References getLogsPath().

◆ 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 234 of file class.root.php.

235 {
236 return $this->getRootPath($aetrayPath) . '/vhosts';
237 }

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 388 of file class.root.php.

389 {
390 return $this->getLogsPath($aetrayPath) . '/bearsampp-winbinder.log';
391 }

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 245 of file class.root.php.

246 {
247 return $this->getRootPath($aetrayPath) . '/www';
248 }

References getRootPath().

Referenced by getHomepageFilePath().

◆ initErrorHandling()

initErrorHandling ( )

Initializes error handling settings for the application.

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

78 {
79 error_reporting(-1);
80 ini_set('error_log', $this->getErrorLogFilePath());
81 ini_set('display_errors', '1');
82 set_error_handler(array($this, self::ERROR_HANDLER));
83 }

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 111 of file class.root.php.

112 {
113 return $this->isRoot;
114 }

References $isRoot.

Referenced by __construct(), and register().

◆ loadApps()

loadApps ( )
static

Loads the apps components of the application.

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

498 {
499 global $bearsamppApps;
500 $bearsamppApps = new Apps();
501 }

Referenced by register().

◆ loadBins()

loadBins ( )
static

Loads the binary components of the application.

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

480 {
481 global $bearsamppBins;
482 $bearsamppBins = new Bins();
483 }

References $bearsamppBins.

Referenced by register().

◆ loadConfig()

loadConfig ( )
static

Loads the configuration settings of the application.

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

453 {
454 global $bearsamppConfig;
455 $bearsamppConfig = new Config();
456 }
global $bearsamppConfig
Definition homepage.php:27

References $bearsamppConfig.

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

◆ loadCore()

loadCore ( )
static

Loads the core components of the application.

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

444 {
445 global $bearsamppCore;
446 $bearsamppCore = new Core();
447 }
global $bearsamppCore

References $bearsamppCore.

Referenced by register().

◆ loadHomepage()

loadHomepage ( )
static

Loads the homepage settings of the application.

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

527 {
528 global $bearsamppHomepage;
529 $bearsamppHomepage = new Homepage();
530 }
global $bearsamppHomepage
Definition homepage.php:27

References $bearsamppHomepage.

Referenced by register().

◆ loadLang()

loadLang ( )
static

Loads the language settings of the application.

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

462 {
463 global $bearsamppLang;
464 $bearsamppLang = new LangProc();
465 }
global $bearsamppLang

References $bearsamppLang.

Referenced by register().

◆ loadOpenSsl()

loadOpenSsl ( )
static

Loads the OpenSSL settings of the application.

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

471 {
472 global $bearsamppOpenSsl;
473 $bearsamppOpenSsl = new OpenSsl();
474 }

Referenced by register().

◆ loadRegistry()

loadRegistry ( )
static

Loads the registry settings of the application.

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

518 {
519 global $bearsamppRegistry;
520 $bearsamppRegistry = new Registry();
521 }

Referenced by register().

◆ loadTools()

loadTools ( )
static

Loads the tools components of the application.

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

489 {
490 global $bearsamppTools;
491 $bearsamppTools = new Tools();
492 }

Referenced by register().

◆ loadWinbinder()

loadWinbinder ( )
static

Loads the Winbinder extension if available.

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

507 {
508 global $bearsamppWinbinder;
509 if (extension_loaded('winbinder')) {
510 $bearsamppWinbinder = new WinBinder();
511 }
512 }

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 // Error log
45 $this->initErrorHandling();
46
47 // External classes
48 require_once $this->getCorePath() . '/classes/class.util.php';
50
51 // Autoloader
52 require_once $this->getCorePath() . '/classes/class.autoloader.php';
53 $bearsamppAutoloader = new Autoloader();
54 $bearsamppAutoloader->register();
55
56 // Load
67
68 // Init
69 if ($this->isRoot) {
70 $this->procs = Win32Ps::getListProcs();
71 }
72 }
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 logSeparator()
static getListProcs()

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

◆ removeErrorHandling()

removeErrorHandling ( )

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

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

89 {
90 error_reporting(0);
91 ini_set('error_log', null);
92 ini_set('display_errors', '0');
93 restore_error_handler();
94 }

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: