![]() |
Bearsampp 2025.8.29
|
Static Public Member Functions | |
static | changePath ($filesToScan, $rootPath=null) |
static | checkInternetState () |
static | cleanArgv ($name, $type='text') |
static | cleanGetVar ($name, $type='text') |
static | cleanPostVar ($name, $type='text') |
static | clearFolder ($path, $exclude=array()) |
static | clearFolders ($paths, $exclude=array()) |
static | contains ($string, $search) |
static | cp1252ToUtf8 ($data) |
static | decryptFile () |
static | deleteFolder ($path) |
static | disableLaunchStartup () |
static | enableLaunchStartup () |
static | endWith ($string, $search) |
static | findRepos ($initPath, $startPath, $checkFile, $maxDepth=1) |
static | formatUnixPath ($path) |
static | formatWindowsPath ($path) |
static | getApiJson ($url) |
static | getAppBinsRegKey ($fromRegistry=true) |
static | getAppPathRegKey () |
static | getChangelogUrl ($utmSource=true) |
static | getCurlHttpHeaders ($url) |
static | getFilesToScan ($path=null) |
static | getFolderList ($path) |
static | getFopenHttpHeaders ($url) |
static | getGithubRawUrl ($file) |
static | getGithubUrl ($part=null) |
static | getGithubUserUrl ($part=null) |
static | getHeaders ($host, $port, $ssl=false) |
static | getHttpHeaders ($pingUrl) |
static | getLatestVersion ($url) |
static | getMicrotime () |
static | getNssmEnvPaths () |
static | getPowerShellPath () |
static | getProcessorRegKey () |
static | getRemoteFilesize ($url, $humanFileSize=true) |
static | getStartupLnkPath () |
static | getSysPathRegKey () |
static | getVersionList ($path) |
static | getWebsiteUrl ($path='', $fragment='', $utmSource=true) |
static | getWebsiteUrlNoUtm ($path='', $fragment='') |
static | humanFileSize ($size, $unit='') |
static | imgToBase64 ($path) |
static | installService ($bin, $port, $syntaxCheckCmd, $showWindow=false) |
static | is32BitsOs () |
static | isAlphanumeric ($string) |
static | isLaunchStartup () |
static | isPortInUse ($port) |
static | isValidDomainName ($domainName) |
static | isValidIp ($ip) |
static | isValidPort ($port) |
static | logDebug ($data, $file=null) |
static | logError ($data, $file=null) |
static | logInfo ($data, $file=null) |
static | logInitClass ($classInstance) |
static | logReloadClass ($classInstance) |
static | logSeparator () |
static | logTrace ($data, $file=null) |
static | logWarning ($data, $file=null) |
static | openFileContent ($caption, $content) |
static | random ($length=32, $withNumeric=true) |
static | removeService ($service, $name) |
static | replaceDefine ($path, $var, $value) |
static | replaceInFile ($path, $replaceList) |
static | setAppBinsRegKey ($value) |
static | setAppPathRegKey ($value) |
static | setSysPathRegKey ($value) |
static | setupCurlHeaderWithToken () |
static | startLoading () |
static | startService ($bin, $syntaxCheckCmd, $showWindow=false) |
static | startWith ($string, $search) |
static | stopLoading () |
static | utf8ToCp1252 ($data) |
Data Fields | |
const | LOG_DEBUG = 'DEBUG' |
const | LOG_ERROR = 'ERROR' |
const | LOG_INFO = 'INFO' |
const | LOG_TRACE = 'TRACE' |
const | LOG_WARNING = 'WARNING' |
Static Private Member Functions | |
static | findFile ($startPath, $findFile) |
static | findFiles ($startPath, $includes=array(''), $recursive=true) |
static | getPathsToScan () |
static | log ($data, $type, $file=null) |
Utility class providing a wide range of static methods for various purposes including:
This class is designed to be used as a helper or utility class where methods are accessed statically. This means you do not need to instantiate it to use the methods, but can simply call them using the Util::methodName() syntax.
Usage Example:
Each method is self-contained and provides specific functionality, making this class a central point for common utility operations needed across a PHP application, especially in environments like web servers or command-line interfaces.
Definition at line 34 of file class.util.php.
|
static |
Replaces old path references with new path references in the specified files.
array | $filesToScan | Array of file paths to scan and modify. |
string | null | $rootPath | The new root path to replace the old one. If null, uses a default root path. |
Definition at line 1205 of file class.util.php.
References $bearsamppCore, $bearsamppRoot, $result, formatUnixPath(), formatWindowsPath(), Core\PATH_LIN_PLACEHOLDER, and Core\PATH_WIN_PLACEHOLDER.
Referenced by ActionStartup\changePath(), and ActionSwitchVersion\processWindow().
|
static |
Checks the current state of the internet connection.
This method attempts to reach a well-known website (e.g., www.google.com) to determine the state of the internet connection. It returns true if the connection is successful, otherwise it returns false.
Definition at line 1999 of file class.util.php.
Referenced by QuickPick\getQuickpickMenu(), and QuickPick\installModule().
|
static |
Cleans and returns a specific command line argument based on the type specified.
string | $name | The index of the argument in the $_SERVER['argv'] array. |
string | $type | The type of the argument to return: 'text', 'numeric', 'boolean', or 'array'. |
Definition at line 53 of file class.util.php.
Referenced by Action\process().
|
static |
Cleans and returns a specific $_GET variable based on the type specified.
string | $name | The name of the $_GET variable. |
string | $type | The type of the variable to return: 'text', 'numeric', 'boolean', or 'array'. |
Definition at line 78 of file class.util.php.
Referenced by Homepage\__construct().
|
static |
Cleans and returns a specific $_POST variable based on the type specified.
string | $name | The name of the $_POST variable. |
string | $type | The type of the variable to return: 'text', 'number', 'float', 'boolean', 'array', or 'content'. |
Definition at line 103 of file class.util.php.
|
static |
Recursively clears all files and directories within a specified directory, excluding specified items.
string | $path | The path of the directory to clear. |
array | $exclude | An array of filenames to exclude from deletion. |
Definition at line 234 of file class.util.php.
References $result, and clearFolder().
Referenced by ActionClearFolders\__construct(), ActionStartup\cleanTmpFolders(), clearFolder(), and clearFolders().
|
static |
Recursively deletes files from a specified directory while excluding certain files.
string | $path | The path to the directory to clear. |
array | $exclude | An array of filenames to exclude from deletion. |
Definition at line 216 of file class.util.php.
References $result, and clearFolder().
|
static |
Checks if a string contains a specified substring.
string | $string | The string to search in. |
string | $search | The substring to search for. |
Definition at line 132 of file class.util.php.
References $result.
Referenced by BinMailpit\checkPort(), BinXlight\checkPort(), BinMariadb\getCmdLineOutput(), BinMysql\getCmdLineOutput(), is32BitsOs(), and Win32Ps\killBins().
|
static |
Converts Windows-1252 encoded data to UTF-8 encoding.
string | $data | The Windows-1252 encoded data. |
Definition at line 927 of file class.util.php.
|
static |
Decrypts a file encrypted with a specified method and returns the content.
Definition at line 1922 of file class.util.php.
References $bearsamppConfig, $bearsamppCore, and logDebug().
Referenced by setupCurlHeaderWithToken().
|
static |
Recursively deletes a directory and all its contents.
string | $path | The path of the directory to delete. |
Definition at line 278 of file class.util.php.
References deleteFolder().
Referenced by deleteFolder(), and ActionStartup\rotationLogs().
|
static |
Disables launching the application at startup by removing the shortcut from the startup folder.
Definition at line 649 of file class.util.php.
References getStartupLnkPath().
Referenced by ActionLaunchStartup\__construct(), and ActionStartup\checkLaunchStartup().
|
static |
Enables launching the application at startup by creating a shortcut in the startup folder.
Definition at line 639 of file class.util.php.
References Vbs\createShortcut().
Referenced by ActionLaunchStartup\__construct(), and ActionStartup\checkLaunchStartup().
|
static |
Checks if a string ends with a specified substring.
This method trims the right side whitespace of the input string before checking if it ends with the specified search substring.
string | $string | The string to check. |
string | $search | The substring to look for at the end of the string. |
Definition at line 177 of file class.util.php.
Referenced by Batch\exec(), BinApache\getAlias(), BinPhp\getExtensionsFromFolder(), LangProc\getList(), TplAppLogs\getMenuLogs(), BinApache\getModulesFromFolder(), Batch\getProcessUsingPort(), and BinApache\getVhosts().
|
staticprivate |
Recursively searches for a file starting from a specified directory.
string | $startPath | The directory path to start the search. |
string | $findFile | The filename to search for. |
Definition at line 304 of file class.util.php.
References $result, findFile(), and formatUnixPath().
Referenced by findFile(), and getPowerShellPath().
|
staticprivate |
Recursively finds files in a directory that match a set of inclusion patterns.
string | $startPath | The directory path to start the search from. |
array | $includes | An array of file patterns to include in the search. Patterns starting with '!' are excluded. |
bool | $recursive | Determines whether the search should be recursive. |
Definition at line 1158 of file class.util.php.
References $result, findFiles(), and formatUnixPath().
Referenced by findFiles(), and getFilesToScan().
|
static |
Recursively searches for repositories starting from a given path up to a specified depth.
string | $initPath | The initial path from where the search begins. |
string | $startPath | The current path from where to search. |
string | $checkFile | The file name to check for in the directory to consider it a repository. |
int | $maxDepth | The maximum depth of directories to search into. |
Definition at line 840 of file class.util.php.
References $result, findRepos(), and formatUnixPath().
Referenced by ToolGit\findRepos(), and findRepos().
|
static |
Converts a Windows-style path to a Unix-style path.
string | $path | The Windows-style path to convert. |
Definition at line 888 of file class.util.php.
Referenced by changePath(), Root\errorHandler(), Win32Ps\findByPath(), findFile(), findFiles(), findRepos(), BinApache\getAliasContent(), getNssmEnvPaths(), Vbs\getSpecialPath(), BinApache\getVhostContent(), Win32Ps\killBins(), ActionStartup\killOldInstances(), ActionGenSslCertificate\processWindow(), ActionStartup\processWindow(), and ToolGit\reload().
|
static |
Converts a Unix-style path to a Windows-style path.
string | $path | The Unix-style path to convert. |
Definition at line 876 of file class.util.php.
Referenced by ActionAddVhost\__construct(), ActionEditAlias\__construct(), ActionEditVhost\__construct(), ActionGenSslCertificate\__construct(), changePath(), ActionStartup\checkPathRegKey(), Batch\createSymlink(), Module\createSymlink(), getAppBinsRegKey(), ToolConsoleZ\getShell(), Batch\getTmpFile(), Batch\installPostgresqlService(), openFileContent(), Batch\refreshEnvVars(), Batch\removeSymlink(), Nssm\setBinPath(), Win32Service\setBinPath(), Nssm\setEnvironmentExtra(), and Batch\uninstallPostgresqlService().
|
static |
Sends a GET request to the specified URL and returns the response.
string | $url | The URL to send the GET request to. |
Definition at line 1559 of file class.util.php.
References logError(), and setupCurlHeaderWithToken().
Referenced by getLatestVersion().
|
static |
Definition at line 452 of file class.util.php.
References $bearsamppBins, Registry\APP_BINS_REG_ENTRY, Registry\ENV_KEY, formatWindowsPath(), Registry\HKEY_LOCAL_MACHINE, and logDebug().
Referenced by ActionStartup\checkBinsRegKey(), Win32Service\create(), and ActionSwitchVersion\processWindow().
|
static |
Retrieves the application path from the registry.
Definition at line 533 of file class.util.php.
References Registry\APP_PATH_REG_ENTRY, Registry\ENV_KEY, and Registry\HKEY_LOCAL_MACHINE.
Referenced by ActionStartup\checkPathRegKey().
|
static |
Constructs the URL to the changelog page, optionally including UTM parameters.
bool | $utmSource | Whether to include UTM source parameters. |
Definition at line 1339 of file class.util.php.
References getWebsiteUrl().
|
static |
Retrieves HTTP headers from a given URL using cURL.
This method initializes a cURL session, sets various options to fetch headers including disabling SSL peer verification, and executes the request. It logs the raw response for debugging purposes and parses the headers from the response.
string | $url | The URL from which to fetch the headers. |
Definition at line 1477 of file class.util.php.
References $response, $result, and logTrace().
Referenced by getHttpHeaders().
|
static |
Retrieves a list of files to scan from specified paths or default paths.
string | null | $path | Optional. The path to start scanning from. If null, uses default paths. |
Definition at line 963 of file class.util.php.
References $result, findFiles(), getMicrotime(), getPathsToScan(), and logDebug().
Referenced by ActionSwitchVersion\processWindow(), and ActionStartup\scanFolders().
|
static |
Retrieves a list of folders from a specified directory, excluding certain directories.
string | $path | The directory path from which to list folders. |
Definition at line 1837 of file class.util.php.
References $result.
Referenced by ActionSwitchVersion\__construct(), and getPathsToScan().
|
static |
Retrieves HTTP headers from a given URL using the fopen function.
This method creates a stream context to disable SSL peer and peer name verification, which allows self-signed certificates. It attempts to open the URL and read the HTTP response headers.
string | $url | The URL from which to fetch the headers. |
Definition at line 1444 of file class.util.php.
References $result.
Referenced by getHttpHeaders().
|
static |
Constructs a URL for raw content from a GitHub repository.
string | $file | The file path to append to the base URL. |
Definition at line 1823 of file class.util.php.
References APP_GITHUB_REPO, and APP_GITHUB_USER.
|
static |
Constructs a GitHub repository URL with an optional path.
string | null | $part | Optional path to append to the URL. |
Definition at line 1809 of file class.util.php.
References APP_GITHUB_REPO, and getGithubUserUrl().
|
static |
Constructs a GitHub user URL with an optional path.
string | null | $part | Optional path to append to the URL. |
Definition at line 1795 of file class.util.php.
References APP_GITHUB_USER.
Referenced by ActionAbout\__construct(), getGithubUrl(), and ActionAbout\processWindow().
|
static |
Retrieves the initial response line from a specified host and port using a socket connection.
This method optionally uses SSL and creates a stream context similar to getFopenHttpHeaders. It attempts to connect to the host and port, reads the first line of the response, and parses it. Detailed debug information is logged for each header line received.
string | $host | The host name or IP address to connect to. |
int | $port | The port number to connect to. |
bool | $ssl | Whether to use SSL (defaults to false). |
Definition at line 1515 of file class.util.php.
References $port, $result, and logDebug().
Referenced by BinMailpit\checkPort(), and BinXlight\checkPort().
|
static |
Retrieves HTTP headers from a given URL using either cURL or fopen, depending on availability.
string | $pingUrl | The URL to ping for headers. |
Definition at line 1406 of file class.util.php.
References $result, getCurlHttpHeaders(), getFopenHttpHeaders(), and logDebug().
Referenced by BinApache\checkPort().
|
static |
Fetches the latest version information from a given URL.
string | $url | The URL to fetch version information from. |
Definition at line 1266 of file class.util.php.
References $result, getApiJson(), logDebug(), and logError().
Referenced by ActionCheckVersion\__construct(), and ActionCheckVersion\processWindow().
|
static |
Gets the current Unix timestamp with microseconds.
Definition at line 445 of file class.util.php.
Referenced by ActionStartup\__construct(), getFilesToScan(), ActionStartup\installServices(), and ActionStartup\processWindow().
|
static |
Retrieves and formats environment paths from a data file. Paths are verified to be directories and formatted to Unix style. Warnings are logged for paths that do not exist.
Definition at line 1866 of file class.util.php.
References $bearsamppRoot, $result, formatUnixPath(), and logWarning().
Referenced by Win32Service\create().
|
staticprivate |
Retrieves a list of directories and file types to scan within the BEARSAMPP environment.
This method compiles an array of paths from various components of the BEARSAMPP stack, including Apache, PHP, MySQL, MariaDB, PostgreSQL, Node.js, Composer, ConsoleZ, Python and Ruby. Each path entry includes the directory path, file types to include in the scan, and whether the scan should be recursive.
The method uses global variables to access the root paths of each component. It then dynamically fetches specific subdirectories using the getFolderList method (which is assumed to be defined elsewhere in this class or in the global scope) and constructs an array of path specifications.
Each path specification is an associative array with the following keys:
The method is designed to be used for setting up scans of configuration files and other important files within the BEARSAMPP environment, possibly for purposes like configuration management, backup, or security auditing.
Definition at line 1003 of file class.util.php.
References $bearsamppBins, $bearsamppCore, $bearsamppRoot, and getFolderList().
Referenced by getFilesToScan().
|
static |
Finds the path to the PowerShell executable in the Windows System32 directory.
Definition at line 821 of file class.util.php.
References findFile().
Referenced by TplConsoleZ\getTabPowerShellSection().
|
static |
Retrieves the processor identifier from the registry.
Definition at line 603 of file class.util.php.
References Registry\HKEY_LOCAL_MACHINE, Registry\PROCESSOR_REG_ENTRY, and Registry\PROCESSOR_REG_SUBKEY.
Referenced by is32BitsOs().
|
static |
Retrieves the file size of a remote file.
string | $url | The URL of the remote file. |
bool | $humanFileSize | Whether to return the size in a human-readable format. |
Definition at line 1352 of file class.util.php.
References humanFileSize().
|
static |
Retrieves the path for the startup link file.
Definition at line 619 of file class.util.php.
References APP_TITLE, and Vbs\getStartupPath().
Referenced by disableLaunchStartup().
|
static |
Retrieves the system path from the registry.
Definition at line 568 of file class.util.php.
References Registry\ENV_KEY, Registry\HKEY_LOCAL_MACHINE, and Registry\SYSPATH_REG_ENTRY.
Referenced by ActionStartup\checkSystemPathRegKey().
|
static |
Retrieves a list of version directories within a specified path.
string | $path | The path to search for version directories. |
Definition at line 418 of file class.util.php.
References $result.
Referenced by Module\getVersionList().
|
static |
Constructs a complete website URL with optional path, fragment, and UTM source parameters.
string | $path | Optional path to append to the base URL. |
string | $fragment | Optional fragment to append to the URL. |
bool | $utmSource | Whether to include UTM source parameters. |
Definition at line 1314 of file class.util.php.
References $bearsamppCore, and APP_WEBSITE.
Referenced by getChangelogUrl(), TplAppApache\getMenuApache(), TplAppMailpit\getMenuMailpit(), TplAppMariadb\getMenuMariadb(), TplAppMemcached\getMenuMemcached(), TplAppMysql\getMenuMysql(), TplAppNodejs\getMenuNodejs(), TplAppPhp\getMenuPhp(), TplAppPostgresql\getMenuPostgresql(), TplAppXlight\getMenuXlight(), QuickPick\getQuickpickMenu(), TplApp\getSectionMenuRight(), getWebsiteUrlNoUtm(), and ActionAbout\processWindow().
|
static |
Constructs a website URL without UTM parameters.
string | $path | Optional path to append to the base URL. |
string | $fragment | Optional fragment to append to the URL. |
Definition at line 1300 of file class.util.php.
References getWebsiteUrl().
Referenced by ActionAbout\__construct().
|
static |
Converts a file size in bytes to a human-readable format.
int | $size | The file size in bytes. |
string | $unit | The unit to convert to ('GB', 'MB', 'KB', or ''). If empty, auto-selects the unit. |
Definition at line 1372 of file class.util.php.
Referenced by getRemoteFilesize().
|
static |
Converts an image file to a base64 encoded string.
string | $path | The path to the image file. |
Definition at line 900 of file class.util.php.
|
static |
Attempts to install and start a service on a specific port, with optional syntax checking and user notifications.
object | $bin | An object containing the binary information and methods related to the service. |
int | $port | The port number on which the service should run. |
string | $syntaxCheckCmd | The command to execute for syntax checking of the service configuration. |
bool | $showWindow | Optional. Whether to show message boxes for information, warnings, and errors. Defaults to false. |
Definition at line 1648 of file class.util.php.
References $bearsamppLang, $port, Lang\INSTALL_SERVICE_TITLE, isPortInUse(), logError(), logInfo(), logWarning(), Lang\PORT_NOT_USED_BY, Lang\SERVICE_ALREADY_INSTALLED, Lang\SERVICE_INSTALL_ERROR, Lang\SERVICE_INSTALLED, and Lang\STARTUP_SERVICE_SYNTAX_ERROR.
Referenced by ActionService\install(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinPostgresql\setEnable(), and BinXlight\setEnable().
|
static |
Checks if the operating system is 32-bit.
Definition at line 1392 of file class.util.php.
References contains(), and getProcessorRegKey().
|
static |
Checks if a string is alphanumeric.
string | $string | The string to check. |
Definition at line 1633 of file class.util.php.
|
static |
Checks if the application is set to launch at startup.
Definition at line 629 of file class.util.php.
Referenced by ActionReload\__construct(), and TplAppLaunchStartup\process().
|
static |
Checks if a specific port is in use.
int | $port | The port number to check |
Definition at line 1586 of file class.util.php.
References $port, and Batch\getProcessUsingPort().
Referenced by BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), BinPostgresql\handleNonPostgresUsage(), installService(), and ActionStartup\installServices().
|
static |
Validates a domain name based on specific criteria.
string | $domainName | The domain name to validate. |
Definition at line 1619 of file class.util.php.
Referenced by ActionAddVhost\processWindow(), and ActionEditVhost\processWindow().
|
static |
Validates an IP address.
string | $ip | The IP address to validate. |
Definition at line 340 of file class.util.php.
|
static |
Validates a port number.
int | $port | The port number to validate. |
Definition at line 353 of file class.util.php.
References $port.
Referenced by BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), BinApache\checkPort(), BinMailpit\checkPort(), BinMariadb\checkPort(), BinMemcached\checkPort(), BinMysql\checkPort(), BinPostgresql\checkPort(), and BinXlight\checkPort().
|
staticprivate |
Logs a message to a specified file or default log file based on the log type.
string | $data | The message to log. |
string | $type | The type of log message: 'ERROR', 'WARNING', 'INFO', 'DEBUG', or 'TRACE'. |
string | null | $file | The file path to write the log message to. If null, uses default log file based on type. |
Definition at line 669 of file class.util.php.
References $bearsamppConfig, $bearsamppCore, $bearsamppRoot, APP_TITLE, Config\VERBOSE_DEBUG, Config\VERBOSE_REPORT, Config\VERBOSE_SIMPLE, and Config\VERBOSE_TRACE.
Referenced by logDebug(), logError(), logInfo(), logTrace(), and logWarning().
|
static |
Logs debug information. This function is a wrapper around the generic log function for debug-level messages.
mixed | $data | The data to log. |
string | null | $file | Optional. The file path to log to. If not provided, a default path is used. |
Definition at line 755 of file class.util.php.
References log().
Referenced by Action\call(), BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), QuickPick\checkDownloadId(), BinApache\checkPort(), BinMailpit\checkPort(), BinMariadb\checkPort(), BinMemcached\checkPort(), BinMysql\checkPort(), BinPostgresql\checkPort(), BinXlight\checkPort(), decryptFile(), Symlinks\deleteCurrentSymlinks(), QuickPick\fetchAndUnzipModule(), getAppBinsRegKey(), getFilesToScan(), getHeaders(), getHttpHeaders(), getLatestVersion(), QuickPick\getModuleUrl(), QuickPick\getVersions(), BinPostgresql\handleNonPostgresUsage(), QuickPick\installModule(), Vbs\killProc(), QuickPick\logHeaders(), Action\process(), QuickPick\rebuildQuickpickJson(), BinApache\refreshAlias(), BinApache\refreshConf(), BinApache\refreshVhosts(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinNodejs\setEnable(), BinPhp\setEnable(), BinPostgresql\setEnable(), BinXlight\setEnable(), Win32Service\start(), BinApache\switchVersion(), BinMailpit\switchVersion(), BinMariadb\switchVersion(), BinMemcached\switchVersion(), BinMysql\switchVersion(), BinNodejs\switchVersion(), BinPhp\switchVersion(), BinPostgresql\switchVersion(), BinXlight\switchVersion(), Core\unzipFile(), AppPhpmyadmin\updateConfig(), AppPhppgadmin\updateConfig(), BinApache\updateConfig(), BinMailpit\updateConfig(), BinMariadb\updateConfig(), BinMemcached\updateConfig(), BinMysql\updateConfig(), BinNodejs\updateConfig(), BinPhp\updateConfig(), BinPostgresql\updateConfig(), BinXlight\updateConfig(), Module\updateConfig(), ToolGit\updateConfig(), ActionStartup\writeLog(), Batch\writeLog(), Nssm\writeLog(), Registry\writeLog(), Vbs\writeLog(), Win32Service\writeLog(), and WinBinder\writeLog().
|
static |
Logs error messages. This function is a wrapper around the generic log function for error-level messages.
mixed | $data | The data to log. |
string | null | $file | Optional. The file path to log to. If not provided, a default path is used. |
Definition at line 791 of file class.util.php.
References log().
Referenced by BinApache\changePort(), BinMailpit\changePort(), BinMariadb\changePort(), BinMemcached\changePort(), BinMysql\changePort(), BinPostgresql\changePort(), BinXlight\changePort(), QuickPick\checkDownloadId(), BinApache\checkPort(), BinMailpit\checkPort(), BinMariadb\checkPort(), BinMemcached\checkPort(), BinMysql\checkPort(), BinPostgresql\checkPort(), BinXlight\checkPort(), Vbs\createShortcut(), Module\createSymlink(), Symlinks\deleteCurrentSymlinks(), QuickPick\fetchAndUnzipModule(), getApiJson(), Core\getAppVersion(), Core\getFileFromUrl(), getLatestVersion(), QuickPick\getModuleUrl(), QuickPick\getQuickpickJson(), QuickPick\getVersions(), QuickPick\installModule(), installService(), ActionCheckVersion\processWindow(), AppPhpmyadmin\reload(), AppPhppgadmin\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolConsoleZ\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPython\reload(), ToolRuby\reload(), removeService(), Win32Service\start(), startService(), TplAppReload\triggerReload(), Core\unzipFile(), AppPhpmyadmin\updateConfig(), AppPhppgadmin\updateConfig(), BinApache\updateConfig(), BinMailpit\updateConfig(), BinMariadb\updateConfig(), BinMemcached\updateConfig(), BinMysql\updateConfig(), BinNodejs\updateConfig(), BinPhp\updateConfig(), BinPostgresql\updateConfig(), BinXlight\updateConfig(), and Nssm\writeLogError().
|
static |
Logs informational messages. This function is a wrapper around the generic log function for informational messages.
mixed | $data | The data to log. |
string | null | $file | Optional. The file path to log to. If not provided, a default path is used. |
Definition at line 767 of file class.util.php.
References log().
Referenced by Batch\exitApp(), installService(), AppPhpmyadmin\reload(), AppPhppgadmin\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), Bins\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolConsoleZ\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPython\reload(), ToolRuby\reload(), removeService(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinNodejs\setEnable(), BinPhp\setEnable(), BinPostgresql\setEnable(), BinXlight\setEnable(), Win32Service\start(), Apps\update(), Bins\update(), Tools\update(), and Nssm\writeLogInfo().
|
static |
Logs the initialization of a class instance.
object | $classInstance | The instance of the class to log. |
Definition at line 801 of file class.util.php.
References logTrace().
Referenced by AppPhpmyadmin\__construct(), AppPhppgadmin\__construct(), BinApache\__construct(), BinMailpit\__construct(), BinMariadb\__construct(), BinMemcached\__construct(), BinMysql\__construct(), BinNodejs\__construct(), BinPhp\__construct(), BinPostgresql\__construct(), Bins\__construct(), BinXlight\__construct(), Homepage\__construct(), Nssm\__construct(), Registry\__construct(), Splash\__construct(), ToolBruno\__construct(), ToolComposer\__construct(), ToolConsoleZ\__construct(), ToolGhostscript\__construct(), ToolGit\__construct(), ToolNgrok\__construct(), ToolPerl\__construct(), ToolPython\__construct(), ToolRuby\__construct(), Win32Service\__construct(), and WinBinder\__construct().
|
static |
Logs the reloading of a class instance.
object | $classInstance | The instance of the class to log. |
Definition at line 811 of file class.util.php.
References logTrace().
Referenced by AppPhpmyadmin\reload(), AppPhppgadmin\reload(), BinApache\reload(), BinMailpit\reload(), BinMariadb\reload(), BinMemcached\reload(), BinMysql\reload(), BinNodejs\reload(), BinPhp\reload(), BinPostgresql\reload(), BinXlight\reload(), ToolBruno\reload(), ToolComposer\reload(), ToolConsoleZ\reload(), ToolGhostscript\reload(), ToolGit\reload(), ToolNgrok\reload(), ToolPerl\reload(), ToolPython\reload(), and ToolRuby\reload().
|
static |
Appends a separator line to multiple log files if they do not already end with it. This function ensures that each log file ends with a clear separator for better readability.
@global object $bearsamppRoot An object that provides paths to various log files.
Definition at line 709 of file class.util.php.
References $bearsamppRoot.
Referenced by Root\register().
|
static |
Logs trace information. This function is a wrapper around the generic log function for trace-level messages.
mixed | $data | The data to log. |
string | null | $file | Optional. The file path to log to. If not provided, a default path is used. |
Definition at line 743 of file class.util.php.
References log().
Referenced by ActionExec\__construct(), ActionManualRestart\__construct(), ActionRebuildini\__construct(), Win32Service\callWin32Service(), BinMysql\changeRootPassword(), ActionLoading\checkAllServicesStarted(), ActionStartup\checkApacheServiceWithTimeout(), ActionStartup\checkMySQLServiceWithTimeout(), BinMysql\checkPort(), BinMysql\checkRootPassword(), Win32Service\create(), OpenSsl\createCrt(), Win32Service\delete(), getCurlHttpHeaders(), Win32Service\infos(), BinMysql\initData(), ActionStartup\installServices(), Win32Service\isInstalled(), Win32Service\isPaused(), Win32Service\isPending(), Win32Service\isRunning(), Win32Service\isStopped(), logInitClass(), logReloadClass(), ActionLoading\processLoading(), ActionStartup\processWindow(), ActionSwitchVersion\processWindow(), BinMailpit\rebuildConf(), BinApache\refreshAlias(), BinApache\refreshConf(), BinApache\refreshVhosts(), Config\replaceAll(), replaceInFile(), ActionStartup\rotationLogs(), BinPhp\setVersion(), Win32Service\status(), Win32Service\stop(), ActionQuit\terminatePhpProcesses(), TplAppReload\triggerReload(), Core\unzipFile(), BinPhp\updateConfig(), and ActionSwitchVersion\updateConfigVersion().
|
static |
Logs warning messages. This function is a wrapper around the generic log function for warning-level messages.
mixed | $data | The data to log. |
string | null | $file | Optional. The file path to log to. If not provided, a default path is used. |
Definition at line 779 of file class.util.php.
References log().
Referenced by getNssmEnvPaths(), Batch\initializeMysql(), Batch\initializePostgresql(), installService(), ToolGit\reload(), and removeService().
|
static |
Opens a file with a given caption and content in the default text editor. The file is created in a temporary directory with a unique name.
string | $caption | The filename to use when saving the content. |
string | $content | The content to write to the file. |
@global object $bearsamppRoot Global object to access temporary path. @global object $bearsamppConfig Global configuration object. @global object $bearsamppWinbinder Global object to execute external programs.
Definition at line 1902 of file class.util.php.
References $bearsamppConfig, $bearsamppRoot, formatWindowsPath(), and random().
Referenced by ActionDebugApache\__construct(), ActionDebugMariadb\__construct(), ActionDebugMysql\__construct(), and ActionDebugPostgresql\__construct().
|
static |
Generates a random string of specified length and character set.
int | $length | The length of the random string to generate. |
bool | $withNumeric | Whether to include numeric characters in the random string. |
Definition at line 193 of file class.util.php.
Referenced by OpenSsl\createCrt(), Batch\getTmpFile(), and openFileContent().
|
static |
Removes a service if it is installed.
Win32Service | $service | The service object to be removed. |
string | $name | The name of the service. |
Definition at line 1726 of file class.util.php.
References logError(), logInfo(), and logWarning().
Referenced by ActionService\remove(), BinApache\setEnable(), BinMailpit\setEnable(), BinMariadb\setEnable(), BinMemcached\setEnable(), BinMysql\setEnable(), BinPostgresql\setEnable(), and BinXlight\setEnable().
|
static |
Replaces a defined constant in a file with a new value.
string | $path | The file path where the constant is defined. |
string | $var | The name of the constant. |
mixed | $value | The new value for the constant. |
Definition at line 365 of file class.util.php.
References replaceInFile().
|
static |
Performs replacements in a file based on a list of regular expression patterns.
string | $path | The path to the file where replacements are to be made. |
array | $replaceList | An associative array where keys are regex patterns and values are replacement strings. |
Definition at line 378 of file class.util.php.
References logTrace().
Referenced by BinPostgresql\rebuildConf(), Homepage\refreshCommonsJsContent(), replaceDefine(), ToolGit\setScanStartup(), AppPhpmyadmin\updateConfig(), AppPhppgadmin\updateConfig(), BinApache\updateConfig(), BinMariadb\updateConfig(), BinMysql\updateConfig(), BinPhp\updateConfig(), and BinPostgresql\updateConfig().
|
static |
Retrieves or generates the application binaries registry key.
bool | $fromRegistry | Determines whether to retrieve the key from the registry or generate it. |
Definition at line 516 of file class.util.php.
References Registry\APP_BINS_REG_ENTRY, Registry\ENV_KEY, and Registry\HKEY_LOCAL_MACHINE.
Referenced by ActionStartup\checkBinsRegKey(), and ActionSwitchVersion\processWindow().
|
static |
Sets the application path in the registry.
string | $value | The new value for the application path. |
Definition at line 551 of file class.util.php.
References Registry\APP_PATH_REG_ENTRY, Registry\ENV_KEY, and Registry\HKEY_LOCAL_MACHINE.
Referenced by ActionStartup\checkPathRegKey().
|
static |
Sets the system path in the registry.
string | $value | The new value for the system path. |
Definition at line 586 of file class.util.php.
References Registry\ENV_KEY, Registry\HKEY_LOCAL_MACHINE, and Registry\SYSPATH_REG_ENTRY.
Referenced by ActionStartup\checkSystemPathRegKey().
|
static |
Sets up a cURL header array using a decrypted GitHub Personal Access Token.
Definition at line 1977 of file class.util.php.
References $bearsamppConfig, $bearsamppCore, APP_GITHUB_USERAGENT, and decryptFile().
Referenced by getApiJson().
|
static |
Initiates a loading process using external components.
Definition at line 935 of file class.util.php.
References $bearsamppCore, Core\isRoot_FILE, and Action\LOADING.
Referenced by ActionCheckVersion\__construct(), ActionEnable\__construct(), ActionLaunchStartup\__construct(), ActionManualRestart\__construct(), ActionRefreshRepos\__construct(), ActionReload\__construct(), ActionService\__construct(), ActionSwitchOnline\__construct(), and ActionStartup\processWindow().
|
static |
Attempts to start a service and performs a syntax check if required.
object | $bin | An object containing service details. |
string | $syntaxCheckCmd | Command to check syntax errors. |
bool | $showWindow | Whether to show error messages in a window. |
Definition at line 1760 of file class.util.php.
References $bearsamppLang, logError(), Lang\START_SERVICE_ERROR, Lang\START_SERVICE_TITLE, and Lang\STARTUP_SERVICE_SYNTAX_ERROR.
Referenced by BinPhp\setEnable(), and ActionService\start().
|
static |
Checks if a string starts with a specified substring.
string | $string | The string to check. |
string | $search | The substring to look for at the start of the string. |
Definition at line 154 of file class.util.php.
Referenced by BinApache\checkPort(), BinMariadb\checkPort(), BinMysql\checkPort(), BinApache\getModulesFromConf(), BinApache\getModulesFromFolder(), BinApache\getOfflineContent(), BinApache\getOnlineContent(), Batch\getOsInfo(), Batch\getPearVersion(), Batch\getProcessUsingPort(), Registry\getValue(), BinApache\getVhostsUrl(), Win32Ps\killBins(), Autoloader\load(), and Registry\setValue().
|
static |
Stops a previously started loading process and cleans up related resources.
Definition at line 944 of file class.util.php.
References $bearsamppCore, and Win32Ps\kill().
Referenced by ActionManualRestart\__construct(), ActionService\__construct(), ActionCheckVersion\showVersionOkMessageBox(), and ActionCheckVersion\showVersionUpdateWindow().
|
static |
Converts UTF-8 encoded data to Windows-1252 encoding.
string | $data | The UTF-8 encoded data. |
Definition at line 915 of file class.util.php.
Referenced by ActionReload\__construct().
const LOG_DEBUG = 'DEBUG' |
Definition at line 42 of file class.util.php.
const LOG_ERROR = 'ERROR' |
This code snippet defines constants for logging levels.
Definition at line 39 of file class.util.php.
const LOG_INFO = 'INFO' |
Definition at line 41 of file class.util.php.
const LOG_TRACE = 'TRACE' |
Definition at line 43 of file class.util.php.
const LOG_WARNING = 'WARNING' |
Definition at line 40 of file class.util.php.