35 return $module->rootPath;
47 return $module->currentPath;
59 return $module->symlinkPath;
93 self::$rootPath = str_replace(
'\\',
'/', rtrim(
$rootPath,
'/\\'));
94 self::$corePath = str_replace(
'\\',
'/', rtrim(
$corePath,
'/\\'));
113 'windows_misses' => 0,
133 $cacheKey =
'w_' . $path;
134 if (isset(self::$pathFormatCache[$cacheKey])) {
135 self::$pathFormatStats[
'windows_hits']++;
137 return self::$pathFormatCache[$cacheKey];
140 self::$pathFormatStats[
'windows_misses']++;
142 $result = str_replace(
'/',
'\\', $path);
144 if (count(self::$pathFormatCache) < self::$pathFormatCacheMaxSize) {
145 self::$pathFormatCache[$cacheKey] =
$result;
147 $removeCount = (int)(self::$pathFormatCacheMaxSize * 0.1);
148 self::$pathFormatCache = array_slice(self::$pathFormatCache, $removeCount,
null,
true);
149 self::$pathFormatCache[$cacheKey] =
$result;
172 $cacheKey =
'u_' . $path;
173 if (isset(self::$pathFormatCache[$cacheKey])) {
174 self::$pathFormatStats[
'unix_hits']++;
176 return self::$pathFormatCache[$cacheKey];
179 self::$pathFormatStats[
'unix_misses']++;
181 $result = str_replace(
'\\',
'/', $path);
183 if (count(self::$pathFormatCache) < self::$pathFormatCacheMaxSize) {
184 self::$pathFormatCache[$cacheKey] =
$result;
186 $removeCount = (int)(self::$pathFormatCacheMaxSize * 0.1);
187 self::$pathFormatCache = array_slice(self::$pathFormatCache, $removeCount,
null,
true);
188 self::$pathFormatCache[$cacheKey] =
$result;
202 return self::$pathFormatStats;
218 'countChangedOcc' => 0,
219 'countChangedFiles' => 0
228 foreach ($filesToScan as $fileToScan) {
229 $tmpCountChangedOcc = 0;
230 $fileContentOr = file_get_contents($fileToScan);
232 if ($fileContentOr ===
false) {
233 Log::error(
"changePath(): Failed to read file: " . $fileToScan);
237 $fileContent = $fileContentOr;
240 if (stripos($fileContent, $unixOldPath) !==
false) {
241 $fileContent = str_ireplace($unixOldPath, $unixCurrentPath, $fileContent, $countChanged);
242 $tmpCountChangedOcc += $countChanged;
244 if (stripos($fileContent, $windowsOldPath) !==
false) {
245 $fileContent = str_ireplace($windowsOldPath, $windowsCurrentPath, $fileContent, $countChanged);
246 $tmpCountChangedOcc += $countChanged;
252 $tmpCountChangedOcc += $countChanged;
256 $tmpCountChangedOcc += $countChanged;
259 if ($fileContentOr != $fileContent) {
260 if (file_put_contents($fileToScan, $fileContent) !==
false) {
261 $result[
'countChangedOcc'] += $tmpCountChangedOcc;
262 $result[
'countChangedFiles'] += 1;
264 Log::error(
"changePath(): Failed to write to file: " . $fileToScan);
269 Log::debug(
'changePath() completed: ' .
$result[
'countChangedFiles'] .
' files changed, ' .
$result[
'countChangedOcc'] .
' total occurrences');
282 self::$pathFormatCache = [];
283 self::$pathFormatStats = [
287 'windows_misses' => 0,
298 return count(self::$pathFormatCache);
311 $path = str_replace(
$rootPath,
'', $path);
312 $path = ltrim(self::formatUnixPath($path),
'/');
314 return '%AeTrayMenuPath%' . $path;
433 $isHttps = (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] !==
'off');
434 $scheme = $isHttps ?
'https://' :
'http://';
435 $host = (isset($_SERVER[
'SERVER_NAME'])) ? $_SERVER[
'SERVER_NAME'] :
'localhost';
445 $portSuffix =
':' .
$port;
449 $portSuffix =
':' .
$port;
453 return $scheme . $host . $portSuffix . (!empty($request) ?
'/' . $request :
'');
643 public static function getLnExe($aetrayPath =
false)
733 if (isset($bearsamppTools)) {
734 if ($bearsamppTools->getComposer() && $bearsamppTools->getComposer()->isEnable()) {
738 if ($bearsamppTools->getGhostscript() && $bearsamppTools->getGhostscript()->isEnable()) {
741 if ($bearsamppTools->getGit() && $bearsamppTools->getGit()->isEnable()) {
744 if ($bearsamppTools->getNgrok() && $bearsamppTools->getNgrok()->isEnable()) {
747 if ($bearsamppTools->getPerl() && $bearsamppTools->getPerl()->isEnable()) {
752 if ($bearsamppTools->getPython() && $bearsamppTools->getPython()->isEnable()) {
755 if ($bearsamppTools->getRuby() && $bearsamppTools->getRuby()->isEnable()) {
855 if (is_dir(
'C:\Windows\System32\WindowsPowerShell')) {
856 return Util::findFile(
'C:\Windows\System32\WindowsPowerShell',
'powershell.exe');
883 if (is_file($name)) {
887 $baseName = basename($name);
888 $hasExtension = pathinfo($baseName, PATHINFO_EXTENSION) !=
'';
889 $pathExtensions = explode(
';', getenv(
'PATHEXT') !==
false ? getenv(
'PATHEXT') :
'.COM;.EXE;.BAT;.CMD');
890 $extensions = $hasExtension ? array(
'') : $pathExtensions;
893 global $bearsamppWinbinder;
894 if (isset($bearsamppWinbinder)) {
895 $found = $bearsamppWinbinder->findFile($baseName);
896 if ($found !==
false && is_file($found)) {
904 if (is_string($appPath) && trim($appPath) !=
'') {
906 $cleanPath = trim(str_replace(
'"',
'', $appPath));
907 $appPath = preg_match(
'/^.*\.exe\b/i', $cleanPath, $match) ? $match[0] : strtok($cleanPath,
" \t");
908 if (is_file($appPath)) {
915 $envPath = getenv(
'PATH');
916 if ($envPath !==
false) {
917 foreach (explode(
';', $envPath) as $dir) {
922 foreach ($extensions as $extension) {
923 $candidate = $dir .
'\\' . $baseName . $extension;
924 if (is_file($candidate)) {
932 $systemRoot = getenv(
'SystemRoot');
933 if ($systemRoot !==
false) {
934 foreach (array(
'\\System32\\',
'\\SysWOW64\\',
'\\') as $subDir) {
935 foreach ($extensions as $extension) {
936 $candidate = $systemRoot . $subDir . $baseName . $extension;
937 if (is_file($candidate)) {
992 return $startupPath ? $startupPath .
'/' .
APP_TITLE .
'.lnk' :
false;
1158 return 'rootCA.pem';
1212 $isHttps = (isset($_SERVER[
'HTTPS']) && $_SERVER[
'HTTPS'] !==
'off');
1213 $scheme = $isHttps ?
'https://' :
'http://';
1214 $host = (isset($_SERVER[
'SERVER_NAME'])) ? $_SERVER[
'SERVER_NAME'] :
'localhost';
1224 $portSuffix =
':' .
$port;
1228 $portSuffix =
':' .
$port;
1232 return $scheme . $host . $portSuffix . (!empty($request) ?
'/' . $request :
'');
const PATH_LIN_PLACEHOLDER
const PATH_WIN_PLACEHOLDER
static debug($data, $file=null)
static error($data, $file=null)
static getHomepageFilePath($aetrayPath=false)
static getNssmPath($aetrayPath=false)
static getScriptsPath($aetrayPath=false)
static getExeFilePath($aetrayPath=false)
static getBatchLogFilePath($aetrayPath=false)
static getPathFormatCacheSize()
static getSslConfPath($aetrayPath=false)
static clearPathFormatCache()
static getHostsEditorExe($aetrayPath=false)
static getAjaxPath($aetrayPath=false)
static findExecutable($name)
static getCorePath($aetrayPath=false)
static getWebResourcesPath()
static getHomepagePath($aetrayPath=false)
static getAliasPath($aetrayPath=false)
static getPwgenPath($aetrayPath=false)
static getSslPath($aetrayPath=false)
static getRootPath($aetrayPath=false)
static getLogFilePath($aetrayPath=false)
static getStartupLogFilePath($aetrayPath=false)
static getIconsPath($aetrayPath=false)
static getWebImagesPath()
static init($rootPath, $corePath)
static getServicesLogFilePath($aetrayPath=false)
static getToolsPath($aetrayPath=false)
static getSetEnvExe($aetrayPath=false)
static getOpenSslExe($aetrayPath=false)
static getLogsPath($aetrayPath=false)
static getResourcesPath($aetrayPath=false)
static getConfigFilePath($aetrayPath=false)
static getWebResourcesUrl()
static getMkcertExe($aetrayPath=false)
static getLocalUrl($request=null)
static getWwwPath($aetrayPath=false)
static formatWindowsPath($path)
static changePath($filesToScan, $rootPath=null)
static getVhostsPath($aetrayPath=false)
static getOpenSslPath($aetrayPath=false)
static getMkcertPath($aetrayPath=false)
static getNssmLogFilePath($aetrayPath=false)
static formatUnixPath($path)
static $pathFormatCacheMaxSize
static getPhpExe($aetrayPath=false)
static getRegistryLogFilePath($aetrayPath=false)
static getHostsEditorPath($aetrayPath=false)
static getModuleSymlinkPath($module)
static getPathFormatStats()
static getisRootFilePath($aetrayPath=false)
static getPearPath($aetrayPath=false)
static getOpenSslConf($aetrayPath=false)
static getBinPath($aetrayPath=false)
static getPwgenExe($aetrayPath=false)
static getTmpPath($aetrayPath=false)
static getLibsPath($aetrayPath=false)
static getLastPath($aetrayPath=false)
static getModuleCurrentPath($module)
static getHomepageLogFilePath($aetrayPath=false)
static getLnExe($aetrayPath=false)
static getLangsPath($aetrayPath=false)
static getSetEnvPath($aetrayPath=false)
static getModuleRootPath($module)
static getStartupLnkPath()
static getNssmExe($aetrayPath=false)
static getPhpPath($aetrayPath=false)
static getErrorLogFilePath($aetrayPath=false)
static getImagesPath($aetrayPath=false)
static getPowerShellPath()
static getAppsPath($aetrayPath=false)
static getMkcertRootCaName()
static getWinbinderLogFilePath($aetrayPath=false)
static getIniFilePath($aetrayPath=false)
static getLnPath($aetrayPath=false)
static findFile($startPath, $findFile)
static registryGetValue($hive, $key, $value='')
static getSpecialFolderPath($folderName)