Bearsampp 2026.9.23
Loading...
Searching...
No Matches
class.util.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
34class Util
35{
36
45 public static function clearFolders($paths, $exclude = array())
46 {
47 $result = array();
48 foreach ($paths as $path) {
49 $result[$path] = self::clearFolder($path, $exclude);
50 }
51
52 return $result;
53 }
54
63 public static function clearFolder($path, $exclude = array())
64 {
65 $result = array();
66 $result['return'] = true;
67 $result['nb_files'] = 0;
68
69 $handle = @opendir($path);
70 if (!$handle) {
71 return null;
72 }
73
74 while (false !== ($file = readdir($handle))) {
75 if ($file == '.' || $file == '..' || in_array($file, $exclude)) {
76 continue;
77 }
78 if (is_dir($path . '/' . $file)) {
79 $r = self::clearFolder($path . '/' . $file);
80 if (!$r) {
81 $result['return'] = false;
82
83 return $result;
84 }
85 } else {
86 $r = @unlink($path . '/' . $file);
87 if ($r) {
88 $result['nb_files']++;
89 } else {
90 $result['return'] = false;
91
92 return $result;
93 }
94 }
95 }
96
97 closedir($handle);
98
99 return $result;
100 }
101
109 public static function deleteFolder($path)
110 {
111 if (is_dir($path)) {
112 $path = rtrim($path, '/\\') . '/';
113 $files = glob($path . '*', GLOB_MARK);
114
115 if ($files === false) {
116 Log::error("deleteFolder(): Failed to glob path: " . $path);
117
118 return;
119 }
120
121 foreach ($files as $file) {
122 $normalizedFile = rtrim($file, '/\\');
123
124 if (is_link($normalizedFile)) {
125 if (!@unlink($normalizedFile) && !@rmdir($normalizedFile)) {
126 Log::error("deleteFolder(): Failed to unlink symlink: " . $normalizedFile);
127 }
128 } elseif (is_dir($file)) {
129 self::deleteFolder($file);
130 } else {
131 if (!@unlink($normalizedFile)) {
132 Log::error("deleteFolder(): Failed to unlink file: " . $normalizedFile);
133 }
134 }
135 }
136
137 if (!@rmdir($path)) {
138 // Only log error if directory still exists (might have been deleted by recursion)
139 if (is_dir($path)) {
140 Log::error("deleteFolder(): Failed to remove directory: " . $path);
141 }
142 }
143 }
144 }
145
154 public static function findFile($startPath, $findFile)
155 {
156 $result = false;
157
158 $handle = @opendir($startPath);
159 if (!$handle) {
160 return false;
161 }
162
163 while (false !== ($file = readdir($handle))) {
164 if ($file == '.' || $file == '..') {
165 continue;
166 }
167 if (is_dir($startPath . '/' . $file)) {
168 $result = self::findFile($startPath . '/' . $file, $findFile);
169 if ($result !== false) {
170 break;
171 }
172 } elseif ($file == $findFile) {
173 $result = Path::formatUnixPath($startPath . '/' . $file);
174 break;
175 }
176 }
177
178 closedir($handle);
179
180 return $result;
181 }
182
190 public static function isValidIp($ip)
191 {
192 return filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)
193 || filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
194 }
195
203 public static function isValidPort($port)
204 {
205 return is_numeric($port) && ($port > 0 && $port <= 65535);
206 }
207
214 public static function isAdmin()
215 {
216 // Only applicable on Windows
217 if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
218 // On non-Windows systems, check if running as root
219 if (function_exists('posix_geteuid')) {
220 return posix_geteuid() === 0;
221 }
222
223 // If we can't determine on non-Windows, assume true to avoid blocking
224 return true;
225 }
226
227 // Method 1: Try using shell_exec with 'net session' command
228 // This command only succeeds when run with admin privileges
229 $output = CommandRunner::shellExec('net session 2>&1');
230 if ($output !== null) {
231 // Check for access denied errors
232 if (stripos($output, 'Access is denied') !== false ||
233 stripos($output, 'System error 5') !== false ||
234 stripos($output, 'Zugriff verweigert') !== false) { // German
235 // Explicitly denied - not admin
236 return false;
237 }
238
239 // If we got output without errors, we likely have admin rights
240 if (stripos($output, 'There are no entries') !== false ||
241 stripos($output, 'These workstations') !== false ||
242 preg_match('/\\\\\\\\/', $output)) {
243 return true;
244 }
245 }
246
247 // Method 2: Check using whoami command (Windows Vista and later)
248 $output = CommandRunner::shellExec('whoami /groups 2>&1');
249 if ($output !== null && !empty($output)) {
250 // Look for the Administrators group or High Mandatory Level
251 if (stripos($output, 'S-1-16-12288') !== false || // High Mandatory Level
252 stripos($output, 'S-1-5-32-544') !== false) { // Administrators group
253 return true;
254 }
255
256 // If we got output but no admin indicators, we're not admin
257 if (stripos($output, 'S-1-16-8192') !== false) { // Medium Mandatory Level (not admin)
258 return false;
259 }
260 }
261
262 // Method 3: Try to write to a system directory
263 // This is a fallback method that checks if we can write to Windows directory
264 $testFile = getenv('SystemRoot') . '\\Temp\\bearsampp_admin_test_' . uniqid() . '.tmp';
265 $result = @file_put_contents($testFile, 'test');
266 if ($result !== false) {
267 @unlink($testFile);
268
269 return true;
270 }
271
272 // If all methods fail or indicate no admin, return false
273 return false;
274 }
275
285 public static function replaceDefine($path, $var, $value)
286 {
287 self::replaceInFile($path, array(
288 '/^define\‍((.*?)' . $var . '(.*?),/' => 'define(\'' . $var . '\', ' . (is_int($value) ? $value : '\'' . $value . '\'') . ');'
289 ));
290 }
291
300 public static function replaceInFile($path, $replaceList)
301 {
302 if (file_exists($path)) {
303 $lines = file($path);
304 $fp = fopen($path, 'w');
305 foreach ($lines as $nb => $line) {
306 $replaceDone = false;
307 foreach ($replaceList as $regex => $replace) {
308 if (preg_match($regex, $line, $matches)) {
309 $currentReplace = $replace;
310 $countParams = preg_match_all('/{{(\d+)}}/', $currentReplace, $paramsMatches);
311 if ($countParams > 0 && $countParams <= count($matches)) {
312 foreach ($paramsMatches[1] as $paramsMatch) {
313 $currentReplace = str_replace('{{' . $paramsMatch . '}}', $matches[$paramsMatch], $currentReplace);
314 }
315 }
316 Log::trace('Replace in file ' . $path . ' :');
317 Log::trace('## line_num: ' . trim($nb));
318 Log::trace('## old: ' . trim($line));
319 Log::trace('## new: ' . trim($currentReplace));
320
321 // Preserve original line ending if present in $line
322 $ending = (preg_match("/\r\n$/", $line)) ? "\r\n" : (preg_match("/\n$/", $line) ? "\n" : "");
323 fwrite($fp, rtrim($currentReplace) . $ending);
324
325 $replaceDone = true;
326 break;
327 }
328 }
329 if (!$replaceDone) {
330 fwrite($fp, $line);
331 }
332 }
333 fclose($fp);
334 }
335 }
336
345 public static function getVersionList($path)
346 {
347 $result = array();
348
349 $handle = @opendir($path);
350 if (!$handle) {
351 return false;
352 }
353
354 $prefix = basename($path);
355
356 while (false !== ($file = readdir($handle))) {
357 $filePath = $path . '/' . $file;
358 if ($file != '.' && $file != '..' && is_dir($filePath) && $file != 'current') {
359 if (strpos($file, $prefix) === 0) {
360 $version = substr($file, strlen($prefix));
361 } else {
362 $version = $file;
363 }
364 $result[] = $version;
365 }
366 }
367
368 closedir($handle);
369 natcasesort($result);
370
371 return $result;
372 }
373
379 public static function getMicrotime()
380 {
381 list($usec, $sec) = explode(' ', microtime());
382
383 return ((float)$usec + (float)$sec);
384 }
385
386
392 public static function isLaunchStartup()
393 {
395
396 return $lnk ? file_exists($lnk) : false;
397 }
398
404 public static function enableLaunchStartup()
405 {
407
408 $shortcutPath = Path::getStartupLnkPath();
409 if (!$shortcutPath) {
410 return false;
411 }
412
413 $targetPath = Path::getExeFilePath();
414 $workingDir = Path::getRootPath();
415 $description = APP_TITLE . ' ' . $bearsamppCore->getAppVersion();
416 $iconPath = Path::getIconsPath() . '/app.ico';
417
418 return Win32Native::createShortcut($shortcutPath, $targetPath, $workingDir, $description, $iconPath);
419 }
420
426 public static function disableLaunchStartup()
427 {
428 $startupLnkPath = Path::getStartupLnkPath();
429
430 // Check if file exists before attempting to delete
431 if (file_exists($startupLnkPath)) {
432 return @unlink($startupLnkPath);
433 }
434
435 // Return true if the file doesn't exist (already disabled)
436 return true;
437 }
438
439
450 public static function findRepos($initPath, $startPath, $checkFile, $maxDepth = 1)
451 {
452 $depth = substr_count(str_replace($initPath, '', $startPath), '/');
453 $result = array();
454
455 $handle = @opendir($startPath);
456 if (!$handle) {
457 return $result;
458 }
459
460 while (false !== ($file = readdir($handle))) {
461 if ($file == '.' || $file == '..') {
462 continue;
463 }
464 if (is_dir($startPath . '/' . $file) && ($initPath == $startPath || $depth <= $maxDepth)) {
465 $tmpResults = self::findRepos($initPath, $startPath . '/' . $file, $checkFile, $maxDepth);
466 foreach ($tmpResults as $tmpResult) {
467 $result[] = $tmpResult;
468 }
469 } elseif (is_file($startPath . '/' . $checkFile) && !in_array($startPath, $result)) {
470 $result[] = Path::formatUnixPath($startPath);
471 }
472 }
473
474 closedir($handle);
475
476 return $result;
477 }
478
486 public static function imgToBase64($path)
487 {
488 $type = pathinfo($path, PATHINFO_EXTENSION);
489 $data = file_get_contents($path);
490
491 return 'data:image/' . $type . ';base64,' . base64_encode($data);
492 }
493
502 public static function convertEncoding($data, $direction = 'to_cp1252')
503 {
504 if ($direction === 'to_utf8') {
505 return self::cp1252ToUtf8($data);
506 } else {
507 return self::utf8ToCp1252($data);
508 }
509 }
510
518 public static function utf8ToCp1252($data)
519 {
520 return iconv('UTF-8', 'WINDOWS-1252//IGNORE', $data);
521 }
522
530 public static function cp1252ToUtf8($data)
531 {
532 return iconv('WINDOWS-1252', 'UTF-8//IGNORE', $data);
533 }
534
540 public static function startLoading()
541 {
542 global $bearsamppCore, $bearsamppWinbinder;
543
544 Log::trace('startLoading() called');
545 Log::trace('PHP executable: ' . Path::getPhpExe());
546 Log::trace('Root file: ' . Core::isRoot_FILE);
547 Log::trace('Action: ' . Action::LOADING);
548
549 Log::trace('Executing command: ' . Path::getPhpExe() . ' ' . Core::isRoot_FILE . ' ' . Action::LOADING);
550
551 $result = $bearsamppWinbinder->exec(Path::getPhpExe(), [Core::isRoot_FILE, Action::LOADING], true, false);
552 Log::trace('exec() returned: ' . var_export($result, true));
553
554 Log::trace('startLoading() completed');
555 }
556
562 public static function stopLoading()
563 {
564 global $bearsamppCore;
565 if (file_exists($bearsamppCore->getLoadingPid())) {
566 $pids = file($bearsamppCore->getLoadingPid());
567 foreach ($pids as $pid) {
568 Win32Ps::kill($pid);
569 }
570 @unlink($bearsamppCore->getLoadingPid());
571 }
572
573 // Clean up status file
575 }
576
585 public static function updateLoadingText($text)
586 {
587 global $bearsamppCore;
588
589 $statusFile = Path::getTmpPath() . '/loading_status.txt';
590 file_put_contents($statusFile, json_encode(['text' => $text]));
591 }
592
598 public static function clearLoadingText()
599 {
600 global $bearsamppCore;
601
602 $statusFile = Path::getTmpPath() . '/loading_status.txt';
603 if (file_exists($statusFile)) {
604 @unlink($statusFile);
605 }
606 }
607
618 public static function getFilesToScan($path = null, $useCache = true, $forceRefresh = false)
619 {
620 // Generate cache key based on path parameter
621 $cacheKey = md5(serialize($path));
622
623 // Try to get from cache if enabled and not forcing refresh
624 if ($useCache && !$forceRefresh) {
625 $cachedResult = Cache::get($cacheKey);
626 if ($cachedResult !== false) {
628 Log::debug('File scan cache HIT (saved expensive scan operation)');
629
630 return $cachedResult;
631 }
632 }
633
635 Log::debug('File scan cache MISS (performing full scan)');
636
637 // Perform the actual scan
638 $startTime = self::getMicrotime();
639 $result = array();
640 $pathsToScan = !empty($path) ? $path : self::getPathsToScan();
641
642 foreach ($pathsToScan as $pathToScan) {
643 $pathStartTime = self::getMicrotime();
644 $findFiles = self::findFiles($pathToScan['path'], $pathToScan['includes'], $pathToScan['recursive']);
645 foreach ($findFiles as $findFile) {
646 $result[] = $findFile;
647 }
648 Log::debug($pathToScan['path'] . ' scanned in ' . round(self::getMicrotime() - $pathStartTime, 3) . 's');
649 }
650
651 $totalTime = round(self::getMicrotime() - $startTime, 3);
652 Log::info('Full file scan completed in ' . $totalTime . 's (' . count($result) . ' files found)');
653
654 // Store in cache if enabled
655 if ($useCache) {
656 Cache::set($cacheKey, $result);
657 }
658
659 return $result;
660 }
661
662
687 private static function getPathsToScan()
688 {
689 global $bearsamppRoot, $bearsamppCore, $bearsamppBins, $bearsamppApps, $bearsamppTools;
690 $paths = array();
691
692 // Alias
693 $paths[] = array(
694 'path' => Path::getAliasPath(),
695 'includes' => array(''),
696 'recursive' => false
697 );
698
699 // Vhosts
700 $paths[] = array(
701 'path' => Path::getVhostsPath(),
702 'includes' => array(''),
703 'recursive' => false
704 );
705
706 // OpenSSL
707 $paths[] = array(
708 'path' => Path::getOpenSslPath(),
709 'includes' => array('openssl.cfg'),
710 'recursive' => false
711 );
712
713 // Homepage
714 $paths[] = array(
715 'path' => Path::getResourcesPath() . '/homepage',
716 'includes' => array('alias.conf'),
717 'recursive' => false
718 );
719
720 // Apache
722 foreach ($folderList as $folder) {
723 $paths[] = array(
724 'path' => Path::getModuleRootPath($bearsamppBins->getApache()) . '/' . $folder,
725 'includes' => array('.ini', '.conf'),
726 'recursive' => true
727 );
728 }
729
730 // PHP
732 foreach ($folderList as $folder) {
733 $paths[] = array(
734 'path' => Path::getModuleRootPath($bearsamppBins->getPhp()) . '/' . $folder,
735 'includes' => array('.php', '.bat', '.ini', '.reg', '.inc'),
736 'recursive' => true
737 );
738 }
739
740 // MySQL
742 foreach ($folderList as $folder) {
743 $paths[] = array(
744 'path' => Path::getModuleRootPath($bearsamppBins->getMysql()) . '/' . $folder,
745 'includes' => array('my.ini'),
746 'recursive' => false
747 );
748 }
749
750 // MariaDB
751 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppBins->getMariadb()));
752 foreach ($folderList as $folder) {
753 $paths[] = array(
754 'path' => Path::getModuleRootPath($bearsamppBins->getMariadb()) . '/' . $folder,
755 'includes' => array('my.ini'),
756 'recursive' => false
757 );
758 // Also scan data directory for my.ini (created during initialization)
759 $dataPath = Path::getModuleRootPath($bearsamppBins->getMariadb()) . '/' . $folder . '/data';
760 if (is_dir($dataPath)) {
761 $paths[] = array(
762 'path' => $dataPath,
763 'includes' => array('my.ini'),
764 'recursive' => false
765 );
766 }
767 }
768
769 // PostgreSQL
770 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppBins->getPostgresql()));
771 foreach ($folderList as $folder) {
772 $paths[] = array(
773 'path' => Path::getModuleRootPath($bearsamppBins->getPostgresql()) . '/' . $folder,
774 'includes' => array('.conf', '.bat', '.ber'),
775 'recursive' => true
776 );
777 }
778
779 // Node.js
781 foreach ($folderList as $folder) {
782 $paths[] = array(
783 'path' => Path::getModuleRootPath($bearsamppBins->getNodejs()) . '/' . $folder . '/etc',
784 'includes' => array('npmrc'),
785 'recursive' => true
786 );
787 $paths[] = array(
788 'path' => Path::getModuleRootPath($bearsamppBins->getNodejs()) . '/' . $folder . '/node_modules/npm',
789 'includes' => array('npmrc'),
790 'recursive' => false
791 );
792 }
793
794 // Composer
795 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppTools->getComposer()));
796 foreach ($folderList as $folder) {
797 $paths[] = array(
798 'path' => Path::getModuleRootPath($bearsamppTools->getComposer()) . '/' . $folder,
799 'includes' => array('giscus.json'),
800 'recursive' => false
801 );
802 }
803
804 // PowerShell
805 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppTools->getPowerShell()));
806 foreach ($folderList as $folder) {
807 $paths[] = array(
808 'path' => Path::getModuleRootPath($bearsamppTools->getPowerShell()) . '/' . $folder,
809 'includes' => array('console.xml', '.ini', '.btm'),
810 'recursive' => true
811 );
812 }
813
814 // Python
815 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppTools->getPython()));
816 foreach ($folderList as $folder) {
817 $paths[] = array(
818 'path' => Path::getModuleRootPath($bearsamppTools->getPython()) . '/' . $folder . '/bin',
819 'includes' => array('.bat'),
820 'recursive' => false
821 );
822 $paths[] = array(
823 'path' => Path::getModuleRootPath($bearsamppTools->getPython()) . '/' . $folder . '/settings',
824 'includes' => array('winpython.ini'),
825 'recursive' => false
826 );
827 }
828
829 // Ruby
830 $folderList = self::getFolderList(Path::getModuleRootPath($bearsamppTools->getRuby()));
831 foreach ($folderList as $folder) {
832 $paths[] = array(
833 'path' => Path::getModuleRootPath($bearsamppTools->getRuby()) . '/' . $folder . '/bin',
834 'includes' => array('!.dll', '!.exe'),
835 'recursive' => false
836 );
837 }
838
839 return $paths;
840 }
841
851 private static function findFiles($startPath, $includes = array(''), $recursive = true)
852 {
853 $result = array();
854
855 $handle = @opendir($startPath);
856 if (!$handle) {
857 return $result;
858 }
859
860 while (false !== ($file = readdir($handle))) {
861 if ($file == '.' || $file == '..') {
862 continue;
863 }
864 if (is_dir($startPath . '/' . $file) && $recursive) {
865 $tmpResults = self::findFiles($startPath . '/' . $file, $includes);
866 foreach ($tmpResults as $tmpResult) {
867 $result[] = $tmpResult;
868 }
869 } elseif (is_file($startPath . '/' . $file)) {
870 foreach ($includes as $include) {
871 if (UtilString::startWith($include, '!')) {
872 $include = ltrim($include, '!');
873 if (UtilString::startWith($file, '.') && !UtilString::endWith($file, $include)) {
874 $result[] = Path::formatUnixPath($startPath . '/' . $file);
875 } elseif ($file != $include) {
876 $result[] = Path::formatUnixPath($startPath . '/' . $file);
877 }
878 } elseif (UtilString::endWith($file, $include) || $file == $include || empty($include)) {
879 $result[] = Path::formatUnixPath($startPath . '/' . $file);
880 }
881 }
882 }
883 }
884
885 closedir($handle);
886
887 return $result;
888 }
889
890
898 public static function getLatestVersion($url)
899 {
900 Log::trace('[VCHK-3] getLatestVersion() START - fetching latest version from: ' . $url);
901
903 if (empty($result)) {
904 Log::error('Cannot retrieve latest github info for: ' . $result . ' RESULT');
905 Log::trace('[VCHK-3] getLatestVersion() EXIT - empty response received');
906
907 return null;
908 }
909
910 $resultArray = json_decode($result, true);
911 if (isset($resultArray['tag_name']) && isset($resultArray['assets'][0]['browser_download_url'])) {
912 $tagName = $resultArray['tag_name'];
913 $downloadUrl = $resultArray['assets'][0]['browser_download_url'];
914 $name = $resultArray['name'];
915 Log::trace('Latest version tag name: ' . $tagName);
916 Log::trace('Download URL: ' . $downloadUrl);
917 Log::trace('Name: ' . $name);
918 Log::trace('[VCHK-3] getLatestVersion() SUCCESS - version found: ' . $tagName);
919
920 return ['version' => $tagName, 'html_url' => $downloadUrl, 'name' => $name];
921 } else {
922 Log::error('Tag name, download URL, or name not found in the response: ' . $result);
923 Log::trace('[VCHK-3] getLatestVersion() EXIT - tag_name/download_url missing in JSON response');
924
925 return null;
926 }
927 }
928
941 public static function humanFileSize(int $size, string $unit = ''): string
942 {
943 // Forced unit mode
944 if ($unit !== '') {
945 return match ($unit) {
946 'GB' => number_format($size / (1 << 30), 2) . 'GB',
947 'MB' => number_format($size / (1 << 20), 2) . 'MB',
948 'KB' => number_format($size / (1 << 10), 2) . 'KB',
949 default => number_format($size) . ' bytes',
950 };
951 }
952
953 // Native PHP auto-selection when the function is available
954 if (function_exists('human_readable_size')) {
955 return human_readable_size($size, precision: 2);
956 }
957
958 // Manual fallback
959 $units = array('B', 'KB', 'MB', 'GB', 'TB');
960 $power = $size > 0 ? (int)floor(log($size, 1024)) : 0;
961 $power = min($power, count($units) - 1);
962
963 return number_format($size / (1024 ** $power), 2) . $units[$power];
964 }
965
971 public static function is32BitsOs()
972 {
973 global $bearsamppRegistry;
974 $processor = $bearsamppRegistry->getProcessorRegKey();
975
976 return UtilString::contains($processor, 'x86');
977 }
978
986 public static function isValidDomainName($domainName)
987 {
988 return filter_var($domainName, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) !== false;
989 }
990
998 public static function getFolderList($path)
999 {
1000 $result = array();
1001
1002 $handle = @opendir($path);
1003 if (!$handle) {
1004 return false;
1005 }
1006
1007 while (false !== ($file = readdir($handle))) {
1008 $filePath = $path . '/' . $file;
1009 if ($file != '.' && $file != '..' && is_dir($filePath) && $file != 'current') {
1010 $result[] = $file;
1011 }
1012 }
1013
1014 closedir($handle);
1015 natcasesort($result);
1016
1017 return $result;
1018 }
1019
1020
1029 public static function openFileContent($caption, $content)
1030 {
1031 global $bearsamppWinbinder, $bearsamppConfig;
1032
1033 $caption = preg_replace('/[<>:"\/\\\\|?*\x00-\x1F]|\.$/', '', trim($caption));
1034 $tmpFile = Path::getTmpPath() . '/' . $caption . '.txt';
1035 file_put_contents($tmpFile, $content);
1036
1037 // Open the file with the editor configured in bearsampp.conf
1038 $editor = $bearsamppConfig->getNotepad();
1039 if ($editor == null || trim($editor) == '') {
1040 $editor = 'notepad.exe';
1041 }
1042
1043 $editor = Path::findExecutable($editor);
1044 if ($editor === false) {
1045 $editor = getenv('SystemRoot') . '\System32\notepad.exe';
1046 }
1047
1048 $bearsamppWinbinder->exec($editor, '"' . $tmpFile . '"', false, true, true);
1049 }
1050}
$result
global $bearsamppBins
global $bearsamppRoot
$port
global $bearsamppCore
const LOADING
static recordHit()
static set($cacheKey, $data)
static recordMiss()
static get($cacheKey)
static shellExec(string $command)
const isRoot_FILE
static getApiJson($url, $verify=true)
static info($data, $file=null)
static debug($data, $file=null)
static trace($data, $file=null)
static error($data, $file=null)
static getExeFilePath($aetrayPath=false)
static findExecutable($name)
static getAliasPath($aetrayPath=false)
static getRootPath($aetrayPath=false)
static getIconsPath($aetrayPath=false)
static getResourcesPath($aetrayPath=false)
static getVhostsPath($aetrayPath=false)
static getOpenSslPath($aetrayPath=false)
static formatUnixPath($path)
static getPhpExe($aetrayPath=false)
static getTmpPath($aetrayPath=false)
static getModuleRootPath($module)
static getStartupLnkPath()
static findRepos($initPath, $startPath, $checkFile, $maxDepth=1)
static isLaunchStartup()
static disableLaunchStartup()
static getMicrotime()
static deleteFolder($path)
static isValidPort($port)
static cp1252ToUtf8($data)
static imgToBase64($path)
static getVersionList($path)
static utf8ToCp1252($data)
static isValidDomainName($domainName)
static getLatestVersion($url)
static getFolderList($path)
static humanFileSize(int $size, string $unit='')
static openFileContent($caption, $content)
static clearLoadingText()
static getPathsToScan()
static startLoading()
static isAdmin()
static findFiles($startPath, $includes=array(''), $recursive=true)
static getFilesToScan($path=null, $useCache=true, $forceRefresh=false)
static replaceDefine($path, $var, $value)
static clearFolder($path, $exclude=array())
static isValidIp($ip)
static convertEncoding($data, $direction='to_cp1252')
static stopLoading()
static is32BitsOs()
static clearFolders($paths, $exclude=array())
static findFile($startPath, $findFile)
static updateLoadingText($text)
static enableLaunchStartup()
static replaceInFile($path, $replaceList)
static contains($string, $search)
static startWith($string, $search)
static endWith($string, $search)
static createShortcut($shortcutPath, $targetPath, $workingDir='', $description='', $iconPath='')
static kill($pid)
global $bearsamppConfig
Definition homepage.php:46
const APP_TITLE
Definition root.php:19