![]() |
Bearsampp 2026.9.23
|
Public Member Functions | |
| __construct () | |
| __toString () | |
| addLoadingPid ($pid) | |
| getAppVersion () | |
| getExec ($aetrayPath=false) | |
| getLastPathContent () | |
| getLoadingPid ($aetrayPath=false) | |
| getPreviousExec () | |
| setExec ($action) | |
| unzipFile ($filePath, $destination, $progressCallback=null) | |
Data Fields | |
| const | APP_VERSION = 'version.dat' |
| const | EXEC = 'exec.dat' |
| const | HOSTSEDITOR_EXE = 'hEdit_x64.exe' |
| const | isRoot_FILE = 'root.php' |
| const | LAST_PATH = 'lastPath.dat' |
| const | LN_EXE = 'ln.exe' |
| const | LOADING_PID = 'loading.pid' |
| const | NSSM_EXE = 'nssm.exe' |
| const | OPENSSL_CONF = 'openssl.cfg' |
| const | OPENSSL_EXE = 'openssl.exe' |
| const | PATH_LIN_PLACEHOLDER = '~BEARSAMPP_LIN_PATH~' |
| const | PATH_WIN_PLACEHOLDER = '~BEARSAMPP_WIN_PATH~' |
| const | PHP_EXE = 'php-win.exe' |
| const | PWGEN_EXE = "PwTech.exe" |
| const | SETENV_EXE = 'SetEnv.exe' |
Static Private Member Functions | |
| static | isSafeDestinationFileList ($sevenZipPath, $filePath) |
| static | isUnsafeArchiveEntryPath ($entryPath) |
Class Core
This class provides core functionalities and constants for the Bearsampp application. It includes methods for retrieving paths, managing application versions, and handling various executable files and configurations.
Definition at line 18 of file class.core.php.
| __construct | ( | ) |
Core constructor.
Loads the WinBinder extension if available.
Definition at line 44 of file class.core.php.
References Path\getLibsPath().
| __toString | ( | ) |
Provides a string representation of the core object.
Definition at line 144 of file class.core.php.
| addLoadingPid | ( | $pid | ) |
Adds a PID to the loading PID file.
| int | $pid | The PID to add. |
Definition at line 134 of file class.core.php.
References getLoadingPid().
| getAppVersion | ( | ) |
Retrieves the application version.
Definition at line 56 of file class.core.php.
References $bearsamppLang, APP_TITLE, Log\error(), Lang\ERROR_CONF_NOT_FOUND, and Path\getResourcesPath().
| getExec | ( | $aetrayPath = false | ) |
Retrieves the path to the exec file.
| bool | $aetrayPath | Whether to format the path for AeTrayMenu. |
Definition at line 102 of file class.core.php.
References Path\getTmpPath().
Referenced by getPreviousExec(), and setExec().
| getLastPathContent | ( | ) |
Retrieves the content of the last path file.
Definition at line 75 of file class.core.php.
References Path\getLastPath().
| getLoadingPid | ( | $aetrayPath = false | ) |
Retrieves the path to the loading PID file.
| bool | $aetrayPath | Whether to format the path for AeTrayMenu. |
Definition at line 124 of file class.core.php.
References Path\getResourcesPath().
Referenced by addLoadingPid().
| getPreviousExec | ( | ) |
Retrieves the content of the exec file without unlinking it.
Definition at line 85 of file class.core.php.
References getExec().
|
staticprivate |
Parses 7z l -slt output and verifies every listed entry path is safe to extract relative to the destination, returning the number of valid entries.
The listing is captured to a temp file (avoiding a slow pipe capture) and split into one block per entry on blank-line separators, each block containing a Path = <value> line. We extract each entry path individually and reject any that is empty, is absolute (drive-letter or rooted path), or contains a parent-directory (..) traversal. Banner/header blocks (including the header's reference to the archive itself) are skipped, and directories are validated but not counted, matching the Files: count of 7z t. This must fail closed: a failure to list the archive, or discovering no file entries or any unsafe entry, returns false so extraction is aborted rather than performed on an unverified archive.
Definition at line 272 of file class.core.php.
References Log\error(), CommandRunner\execToFile(), and Path\getTmpPath().
Referenced by unzipFile().
|
staticprivate |
Determines whether a single archive entry path is unsafe to extract.
A path is considered unsafe if it is empty, contains a parent-directory (..) token, or is absolute (a Windows drive path such as C:\... or a rooted path beginning with / or \\endiskip).
| string | $entryPath | The entry path extracted from the archive listing. |
Definition at line 365 of file class.core.php.
| setExec | ( | $action | ) |
Sets the content of the exec file.
| string | $action | The content to set in the exec file. |
Definition at line 112 of file class.core.php.
References getExec().
| unzipFile | ( | $filePath, | |
| $destination, | |||
| $progressCallback = null ) |
Unzips a file to the specified directory and provides progress updates.
This method uses the 7-Zip command-line tool to extract the contents of a zip file. It first validates the archive's entry paths (and counts its files) via a structured listing, then proceeds with the extraction while providing progress updates via a callback function.
| string | $filePath | The path to the zip file. |
| string | $destination | The directory to extract the files to. |
| callable | null | $progressCallback | A callback function to report progress. The callback receives two parameters:
|
Definition at line 170 of file class.core.php.
References $bearsamppRoot, Log\debug(), Log\error(), Path\getLibsPath(), isSafeDestinationFileList(), CommandRunner\stream(), and Log\trace().
| const APP_VERSION = 'version.dat' |
Definition at line 34 of file class.core.php.
| const EXEC = 'exec.dat' |
Definition at line 36 of file class.core.php.
| const HOSTSEDITOR_EXE = 'hEdit_x64.exe' |
Definition at line 30 of file class.core.php.
Referenced by Path\getHostsEditorExe().
| const isRoot_FILE = 'root.php' |
Definition at line 21 of file class.core.php.
Referenced by Batch\exitApp(), TplApp\getActionRun(), Path\getisRootFilePath(), QuickPick\installModule(), and Util\startLoading().
| const LAST_PATH = 'lastPath.dat' |
Definition at line 35 of file class.core.php.
Referenced by Path\getLastPath().
| const LN_EXE = 'ln.exe' |
Definition at line 31 of file class.core.php.
Referenced by Path\getLnExe().
| const LOADING_PID = 'loading.pid' |
Definition at line 37 of file class.core.php.
| const NSSM_EXE = 'nssm.exe' |
Definition at line 27 of file class.core.php.
Referenced by Path\getNssmExe().
| const OPENSSL_CONF = 'openssl.cfg' |
Definition at line 29 of file class.core.php.
Referenced by Path\getOpenSslConf().
| const OPENSSL_EXE = 'openssl.exe' |
Definition at line 28 of file class.core.php.
Referenced by Path\getOpenSslExe().
| const PATH_LIN_PLACEHOLDER = '~BEARSAMPP_LIN_PATH~' |
Definition at line 23 of file class.core.php.
Referenced by Path\changePath().
| const PATH_WIN_PLACEHOLDER = '~BEARSAMPP_WIN_PATH~' |
Definition at line 22 of file class.core.php.
Referenced by Path\changePath().
| const PHP_EXE = 'php-win.exe' |
Definition at line 25 of file class.core.php.
Referenced by Path\getPhpExe().
| const PWGEN_EXE = "PwTech.exe" |
Definition at line 32 of file class.core.php.
Referenced by Path\getPwgenExe().
| const SETENV_EXE = 'SetEnv.exe' |
Definition at line 26 of file class.core.php.
Referenced by Path\getSetEnvExe().