52 public static function cleanArgv($name, $type =
'text')
54 if ( isset( $_SERVER[
'argv'] ) ) {
55 if ( $type ==
'text' ) {
56 return (isset( $_SERVER[
'argv'][$name] ) && !empty( $_SERVER[
'argv'][$name] )) ? trim( $_SERVER[
'argv'][$name] ) :
'';
58 elseif ( $type ==
'numeric' ) {
59 return (isset( $_SERVER[
'argv'][$name] ) && is_numeric( $_SERVER[
'argv'][$name] )) ? intval( $_SERVER[
'argv'][$name] ) :
'';
61 elseif ( $type ==
'boolean' ) {
62 return (isset( $_SERVER[
'argv'][$name] )) ? true :
false;
64 elseif ( $type ==
'array' ) {
65 return (isset( $_SERVER[
'argv'][$name] ) && is_array( $_SERVER[
'argv'][$name] )) ? $_SERVER[
'argv'][$name] : array();
82 if ( is_string( $name ) ) {
83 if ( $type ==
'text' ) {
84 return (isset( $_GET[$name] ) && !empty( $_GET[$name] )) ? stripslashes( $_GET[$name] ) :
'';
86 elseif ( $type ==
'numeric' ) {
87 return (isset( $_GET[$name] ) && is_numeric( $_GET[$name] )) ? intval( $_GET[$name] ) :
'';
89 elseif ( $type ==
'boolean' ) {
90 return (isset( $_GET[$name] )) ? true :
false;
92 elseif ( $type ==
'array' ) {
93 return (isset( $_GET[$name] ) && is_array( $_GET[$name] )) ? $_GET[$name] : array();
110 if ( is_string( $name ) ) {
111 if ( $type ==
'text' ) {
112 return (isset( $_POST[$name] ) && !empty( $_POST[$name] )) ? stripslashes( trim( $_POST[$name] ) ) :
'';
114 elseif ( $type ==
'number' ) {
115 return (isset( $_POST[$name] ) && is_numeric( $_POST[$name] )) ? intval( $_POST[$name] ) :
'';
117 elseif ( $type ==
'float' ) {
118 return (isset( $_POST[$name] ) && is_numeric( $_POST[$name] )) ? floatval( $_POST[$name] ) :
'';
120 elseif ( $type ==
'boolean' ) {
121 return (isset( $_POST[$name] )) ? true :
false;
123 elseif ( $type ==
'array' ) {
124 return (isset( $_POST[$name] ) && is_array( $_POST[$name] )) ? $_POST[$name] : array();
126 elseif ( $type ==
'content' ) {
127 return (isset( $_POST[$name] ) && !empty( $_POST[$name] )) ? trim( $_POST[$name] ) :
'';
144 if ( !empty( $string ) && !empty( $search ) ) {
145 $result = stripos( $string, $search );
168 $length = strlen( $search );
170 return (substr( $string, 0, $length ) === $search);
184 public static function endWith($string, $search)
186 $length = strlen( $search );
187 $start = $length * -1;
189 return (substr( $string, $start ) === $search);
200 public static function random($length = 32, $withNumeric =
true)
202 $characters =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
203 if ( $withNumeric ) {
204 $characters .=
'0123456789';
208 for ( $i = 0; $i < $length; $i++ ) {
209 $randomString .= $characters[rand( 0, strlen( $characters ) - 1 )];
212 return $randomString;
226 foreach ( $paths as $path ) {
247 $handle = @opendir( $path );
252 while (
false !== ($file = readdir( $handle )) ) {
253 if ( $file ==
'.' || $file ==
'..' || in_array( $file, $exclude ) ) {
256 if ( is_dir( $path .
'/' . $file ) ) {
265 $r = @unlink( $path .
'/' . $file );
289 if ( is_dir( $path ) ) {
290 if ( substr( $path, strlen( $path ) - 1, 1 ) !=
'/' ) {
293 $files = glob( $path .
'*', GLOB_MARK );
294 foreach ( $files as $file ) {
295 if ( is_dir( $file ) ) {
314 private static function findFile($startPath, $findFile)
318 $handle = @opendir( $startPath );
323 while (
false !== ($file = readdir( $handle )) ) {
324 if ( $file ==
'.' || $file ==
'..' ) {
327 if ( is_dir( $startPath .
'/' . $file ) ) {
333 elseif ( $file == $findFile ) {
353 return filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 )
354 || filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 );
379 '/^define\((.*?)' . $var .
'(.*?),/' =>
'define(\'' . $var .
'\',
' . (is_int( $value ) ? $value : '\
'' . $value .
'\'') .
');'
391 if ( file_exists( $path ) ) {
392 $lines = file( $path );
393 $fp = fopen( $path,
'w' );
394 foreach ( $lines as $nb => $line ) {
395 $replaceDone =
false;
396 foreach ( $replaceList as $regex => $replace ) {
397 if ( preg_match( $regex, $line, $matches ) ) {
398 $countParams = preg_match_all(
'/{{(\d+)}}/', $replace, $paramsMatches );
399 if ( $countParams > 0 && $countParams <= count( $matches ) ) {
400 foreach ( $paramsMatches[1] as $paramsMatch ) {
401 $replace = str_replace(
'{{' . $paramsMatch .
'}}', $matches[$paramsMatch], $replace );
408 fwrite( $fp, $replace . PHP_EOL );
414 if ( !$replaceDone ) {
415 fwrite( $fp, $line );
433 $handle = @opendir( $path );
438 while (
false !== ($file = readdir( $handle )) ) {
439 $filePath = $path .
'/' . $file;
440 if ( $file !=
"." && $file !=
".." && is_dir( $filePath ) && $file !=
'current' ) {
441 $result[] = str_replace( basename( $path ),
'', $file );
458 list( $usec, $sec ) = explode(
" ", microtime() );
460 return ((
float) $usec + (
float) $sec);
465 global $bearsamppRegistry;
467 if ( $fromRegistry ) {
468 $value = $bearsamppRegistry->getValue(
479 $value .=
$bearsamppBins->getApache()->getSymlinkPath() .
'/bin;';
485 $value .=
$bearsamppBins->getPhp()->getSymlinkPath() .
'/imagick;';
490 if ( $bearsamppTools->getComposer()->isEnable() ) {
491 $value .= $bearsamppTools->getComposer()->getSymlinkPath() .
';';
492 $value .= $bearsamppTools->getComposer()->getSymlinkPath() .
'/vendor/bin;';
494 if ( $bearsamppTools->getGhostscript()->isEnable() ) {
495 $value .= $bearsamppTools->getGhostscript()->getSymlinkPath() .
'/bin;';
497 if ( $bearsamppTools->getGit()->isEnable() ) {
498 $value .= $bearsamppTools->getGit()->getSymlinkPath() .
'/bin;';
500 if ( $bearsamppTools->getNgrok()->isEnable() ) {
501 $value .= $bearsamppTools->getNgrok()->getSymlinkPath() .
';';
503 if ( $bearsamppTools->getPerl()->isEnable() ) {
504 $value .= $bearsamppTools->getPerl()->getSymlinkPath() .
'/perl/site/bin;';
505 $value .= $bearsamppTools->getPerl()->getSymlinkPath() .
'/perl/bin;';
506 $value .= $bearsamppTools->getPerl()->getSymlinkPath() .
'/c/bin;';
508 if ( $bearsamppTools->getPython()->isEnable() ) {
509 $value .= $bearsamppTools->getPython()->getSymlinkPath() .
'/bin;';
511 if ( $bearsamppTools->getRuby()->isEnable() ) {
512 $value .= $bearsamppTools->getRuby()->getSymlinkPath() .
'/bin;';
514 if ( $bearsamppTools->getYarn()->isEnable() ) {
515 $value .= $bearsamppTools->getYarn()->getSymlinkPath() .
';';
516 $value .= $bearsamppTools->getYarn()->getSymlinkPath() .
'/global/bin;';
534 global $bearsamppRegistry;
536 return $bearsamppRegistry->setStringValue(
551 global $bearsamppRegistry;
553 return $bearsamppRegistry->getValue(
569 global $bearsamppRegistry;
571 return $bearsamppRegistry->setStringValue(
586 global $bearsamppRegistry;
588 return $bearsamppRegistry->getValue(
604 global $bearsamppRegistry;
606 return $bearsamppRegistry->setExpandStringValue(
621 global $bearsamppRegistry;
623 return $bearsamppRegistry->getValue(
647 return file_exists( self::getStartupLnkPath() );
667 return @unlink( self::getStartupLnkPath() );
677 private static function log($data, $type, $file =
null)
708 '[' . date(
'Y-m-d H:i:s', time() ) .
'] # ' .
APP_TITLE .
' ' .
$bearsamppCore->getAppVersion() .
' # ' . $type .
': ' . $data . PHP_EOL,
735 $separator =
'========================================================================================' . PHP_EOL;
736 foreach ( $logs as $log ) {
737 if ( !file_exists( $log ) ) {
740 $logContent = @file_get_contents( $log );
741 if ( $logContent !==
false && !self::endWith( $logContent, $separator ) ) {
742 file_put_contents( $log, $separator, FILE_APPEND );
754 public static function logTrace($data, $file =
null)
756 self::log( $data, self::LOG_TRACE, $file );
766 public static function logDebug($data, $file =
null)
768 self::log( $data, self::LOG_DEBUG, $file );
778 public static function logInfo($data, $file =
null)
780 self::log( $data, self::LOG_INFO, $file );
792 self::log( $data, self::LOG_WARNING, $file );
802 public static function logError($data, $file =
null)
804 self::log( $data, self::LOG_ERROR, $file );
834 if ( is_dir(
'C:\Windows\System32\WindowsPowerShell' ) ) {
835 return self::findFile(
'C:\Windows\System32\WindowsPowerShell',
'powershell.exe' );
851 public static function findRepos($initPath, $startPath, $checkFile, $maxDepth = 1)
853 $depth = substr_count( str_replace( $initPath,
'', $startPath ),
'/' );
856 $handle = @opendir( $startPath );
861 while (
false !== ($file = readdir( $handle )) ) {
862 if ( $file ==
'.' || $file ==
'..' ) {
865 if ( is_dir( $startPath .
'/' . $file ) && ($initPath == $startPath || $depth <= $maxDepth) ) {
866 $tmpResults =
self::findRepos( $initPath, $startPath .
'/' . $file, $checkFile, $maxDepth );
867 foreach ( $tmpResults as $tmpResult ) {
871 elseif ( is_file( $startPath .
'/' . $checkFile ) && !in_array( $startPath,
$result ) ) {
890 return str_replace(
'/',
'\\', $path );
902 return str_replace(
'\\',
'/', $path );
914 $type = pathinfo( $path, PATHINFO_EXTENSION );
915 $data = file_get_contents( $path );
917 return 'data:image/' . $type .
';base64,' . base64_encode( $data );
929 return iconv(
"UTF-8",
"WINDOWS-1252//IGNORE", $data );
941 return iconv(
"WINDOWS-1252",
"UTF-8//IGNORE", $data );
961 foreach ( $pids as $pid ) {
979 foreach ( $pathsToScan as $pathToScan ) {
981 $findFiles =
self::findFiles( $pathToScan[
'path'], $pathToScan[
'includes'], $pathToScan[
'recursive'] );
982 foreach ( $findFiles as $findFile ) {
985 self::logDebug( $pathToScan[
'path'] .
' scanned in ' . round( self::getMicrotime() - $startTime, 3 ) .
's' );
1023 'includes' => array(
''),
1024 'recursive' =>
false
1030 'includes' => array(
''),
1031 'recursive' =>
false
1037 'includes' => array(
'openssl.cfg'),
1038 'recursive' =>
false
1044 'includes' => array(
'alias.conf'),
1045 'recursive' =>
false
1050 foreach ( $folderList as $folder ) {
1052 'path' =>
$bearsamppBins->getApache()->getRootPath() .
'/' . $folder,
1053 'includes' => array(
'.ini',
'.conf'),
1060 foreach ( $folderList as $folder ) {
1062 'path' =>
$bearsamppBins->getPhp()->getRootPath() .
'/' . $folder,
1063 'includes' => array(
'.php',
'.bat',
'.ini',
'.reg',
'.inc'),
1070 foreach ( $folderList as $folder ) {
1072 'path' =>
$bearsamppBins->getMysql()->getRootPath() .
'/' . $folder,
1073 'includes' => array(
'my.ini'),
1074 'recursive' =>
false
1080 foreach ( $folderList as $folder ) {
1082 'path' =>
$bearsamppBins->getMariadb()->getRootPath() .
'/' . $folder,
1083 'includes' => array(
'my.ini'),
1084 'recursive' =>
false
1090 foreach ( $folderList as $folder ) {
1092 'path' =>
$bearsamppBins->getPostgresql()->getRootPath() .
'/' . $folder,
1093 'includes' => array(
'.ber',
'.conf',
'.bat'),
1100 foreach ( $folderList as $folder ) {
1102 'path' =>
$bearsamppBins->getNodejs()->getRootPath() .
'/' . $folder .
'/etc',
1103 'includes' => array(
'npmrc'),
1107 'path' =>
$bearsamppBins->getNodejs()->getRootPath() .
'/' . $folder .
'/node_modules/npm',
1108 'includes' => array(
'npmrc'),
1109 'recursive' =>
false
1115 foreach ( $folderList as $folder ) {
1117 'path' =>
$bearsamppBins->getFilezilla()->getRootPath() .
'/' . $folder,
1118 'includes' => array(
'.xml'),
1125 foreach ( $folderList as $folder ) {
1127 'path' => $bearsamppTools->getComposer()->getRootPath() .
'/' . $folder,
1128 'includes' => array(
'giscus.json'),
1129 'recursive' =>
false
1135 foreach ( $folderList as $folder ) {
1137 'path' => $bearsamppTools->getConsoleZ()->getRootPath() .
'/' . $folder,
1138 'includes' => array(
'console.xml',
'.ini',
'.btm'),
1145 foreach ( $folderList as $folder ) {
1147 'path' => $bearsamppTools->getPython()->getRootPath() .
'/' . $folder .
'/bin',
1148 'includes' => array(
'.bat'),
1149 'recursive' =>
false
1152 'path' => $bearsamppTools->getPython()->getRootPath() .
'/' . $folder .
'/settings',
1153 'includes' => array(
'winpython.ini'),
1154 'recursive' =>
false
1160 foreach ( $folderList as $folder ) {
1162 'path' => $bearsamppTools->getRuby()->getRootPath() .
'/' . $folder .
'/bin',
1163 'includes' => array(
'!.dll',
'!.exe'),
1164 'recursive' =>
false
1170 foreach ( $folderList as $folder ) {
1172 'path' => $bearsamppTools->getYarn()->getRootPath() .
'/' . $folder,
1173 'includes' => array(
'yarn.bat'),
1174 'recursive' =>
false
1177 'path' => $bearsamppTools->getYarn()->getRootPath() .
'/' . $folder .
'/global/bin',
1178 'includes' => array(
'.bat'),
1179 'recursive' =>
false
1182 'path' => $bearsamppTools->getYarn()->getRootPath() .
'/' . $folder .
'/nodejs/etc',
1183 'includes' => array(
'npmrc'),
1187 'path' => $bearsamppTools->getYarn()->getRootPath() .
'/' . $folder .
'/nodejs/node_modules/npm',
1188 'includes' => array(
'npmrc'),
1189 'recursive' =>
false
1205 private static function findFiles($startPath, $includes = array(
''), $recursive =
true)
1209 $handle = @opendir( $startPath );
1214 while (
false !== ($file = readdir( $handle )) ) {
1215 if ( $file ==
'.' || $file ==
'..' ) {
1218 if ( is_dir( $startPath .
'/' . $file ) && $recursive ) {
1220 foreach ( $tmpResults as $tmpResult ) {
1224 elseif ( is_file( $startPath .
'/' . $file ) ) {
1225 foreach ( $includes as $include ) {
1226 if ( self::startWith( $include,
'!' ) ) {
1227 $include = ltrim( $include,
'!' );
1228 if ( self::startWith( $file,
'.' ) && !self::endWith( $file, $include ) ) {
1231 elseif ( $file != $include ) {
1235 elseif ( self::endWith( $file, $include ) || $file == $include || empty( $include ) ) {
1242 closedir( $handle );
1255 public static function changePath($filesToScan, $rootPath =
null)
1260 'countChangedOcc' => 0,
1261 'countChangedFiles' => 0
1264 $rootPath = $rootPath !=
null ? $rootPath :
$bearsamppRoot->getRootPath();
1270 foreach ( $filesToScan as $fileToScan ) {
1271 $tmpCountChangedOcc = 0;
1272 $fileContentOr = file_get_contents( $fileToScan );
1273 $fileContent = $fileContentOr;
1276 preg_match(
'#' . $unixOldPath .
'#i', $fileContent, $unixMatches );
1277 if ( !empty( $unixMatches ) ) {
1278 $fileContent = str_replace( $unixOldPath, $unixCurrentPath, $fileContent, $countChanged );
1279 $tmpCountChangedOcc += $countChanged;
1281 preg_match(
'#' . str_replace(
'\\',
'\\\\', $windowsOldPath ) .
'#i', $fileContent, $windowsMatches );
1282 if ( !empty( $windowsMatches ) ) {
1283 $fileContent = str_replace( $windowsOldPath, $windowsCurrentPath, $fileContent, $countChanged );
1284 $tmpCountChangedOcc += $countChanged;
1289 if ( !empty( $unixMatches ) ) {
1291 $tmpCountChangedOcc += $countChanged;
1294 if ( !empty( $windowsMatches ) ) {
1296 $tmpCountChangedOcc += $countChanged;
1299 if ( $fileContentOr != $fileContent ) {
1300 $result[
'countChangedOcc'] += $tmpCountChangedOcc;
1301 $result[
'countChangedFiles'] += 1;
1302 file_put_contents( $fileToScan, $fileContent );
1325 $resultArray = json_decode(
$result,
true );
1326 if ( isset( $resultArray[
'tag_name'] ) && isset( $resultArray[
'assets'][0][
'browser_download_url'] ) ) {
1327 $tagName = $resultArray[
'tag_name'];
1328 $downloadUrl = $resultArray[
'assets'][0][
'browser_download_url'];
1329 $name = $resultArray[
'name'];
1334 return [
'version' => $tagName,
'html_url' => $downloadUrl,
'name' => $name];
1365 public static function getWebsiteUrl($path =
'', $fragment =
'', $utmSource =
true)
1370 if ( !empty( $path ) ) {
1371 $url .=
'/' . ltrim( $path,
'/' );
1374 $url = rtrim( $url,
'/' ) .
'/?utm_source=bearsampp-' .
$bearsamppCore->getAppVersion();
1376 if ( !empty( $fragment ) ) {
1407 $data = get_headers( $url,
true );
1408 if ( isset( $data[
'Content-Length'] ) ) {
1409 $size = intval( $data[
'Content-Length'] );
1425 if ( (!$unit && $size >= 1 << 30) || $unit ==
'GB' ) {
1426 return number_format( $size / (1 << 30), 2 ) .
'GB';
1428 if ( (!$unit && $size >= 1 << 20) || $unit ==
'MB' ) {
1429 return number_format( $size / (1 << 20), 2 ) .
'MB';
1431 if ( (!$unit && $size >= 1 << 10) || $unit ==
'KB' ) {
1432 return number_format( $size / (1 << 10), 2 ) .
'KB';
1435 return number_format( $size ) .
' bytes';
1459 if ( function_exists(
'curl_version' ) ) {
1467 $rebuildResult = array();
1469 $row = trim( $row );
1470 if ( !empty( $row ) ) {
1471 $rebuildResult[] = $row;
1477 foreach (
$result as $header ) {
1500 $context = stream_context_create( array(
1502 'verify_peer' =>
false,
1503 'verify_peer_name' =>
false,
1504 'allow_self_signed' =>
true,
1508 $fp = @fopen( $url,
'r',
false, $context );
1510 $meta = stream_get_meta_data( $fp );
1511 $result = isset( $meta[
'wrapper_data'] ) ? $meta[
'wrapper_data'] :
$result;
1534 curl_setopt( $ch, CURLOPT_RETURNTRANSFER,
true );
1535 curl_setopt( $ch, CURLOPT_VERBOSE,
true );
1536 curl_setopt( $ch, CURLOPT_HEADER,
true );
1537 curl_setopt( $ch, CURLOPT_URL, $url );
1538 curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER,
false );
1546 $responseHeaders = explode(
"\r\n\r\n",
$response, 2 );
1547 if ( !isset( $responseHeaders[0] ) || empty( $responseHeaders[0] ) ) {
1551 return explode(
"\n", $responseHeaders[0] );
1570 $context = stream_context_create( array(
1572 'verify_peer' =>
false,
1573 'verify_peer_name' =>
false,
1574 'allow_self_signed' =>
true,
1578 $fp = @stream_socket_client( ($ssl ?
'ssl://' :
'') . $host .
':' .
$port, $errno, $errstr, 5, STREAM_CLIENT_CONNECT, $context );
1580 $out = fgets( $fp );
1581 $result = explode( PHP_EOL, $out );
1586 $rebuildResult = array();
1588 $row = trim( $row );
1589 if ( !empty( $row ) ) {
1590 $rebuildResult[] = $row;
1596 foreach (
$result as $header ) {
1616 curl_setopt( $ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2 );
1617 curl_setopt( $ch, CURLOPT_RETURNTRANSFER,
true );
1618 curl_setopt( $ch, CURLOPT_VERBOSE,
true );
1619 curl_setopt( $ch, CURLOPT_URL, $url );
1620 curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER,
false );
1621 curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
1622 $data = curl_exec( $ch );
1623 if ( curl_errno( $ch ) ) {
1628 return trim( $data );
1645 $localIP = getHostByName( getHostName() );
1647 $connection = @fsockopen( $localIP,
$port );
1649 if ( is_resource( $connection ) ) {
1650 fclose( $connection );
1653 return $process !=
null ? $process :
'N/A';
1668 return preg_match(
'/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $domainName )
1669 && preg_match(
'/^.{1,253}$/', $domainName )
1670 && preg_match(
'/^[^\.]{1,63}(\.[^\.]{1,63})*$/', $domainName );
1682 return ctype_alnum( $string );
1698 $name = $bin->getName();
1699 $service = $bin->getService();
1703 if ( $isPortInUse ===
false ) {
1704 if ( !$service->isInstalled() ) {
1706 if ( $service->start() ) {
1707 self::logInfo( sprintf(
'%s service successfully installed. (name: %s ; port: %s)', $name, $service->getName(),
$port ) );
1708 if ( $showWindow ) {
1709 $bearsamppWinbinder->messageBoxInfo(
1719 $serviceErrorLog = sprintf(
'Error during the installation of %s service', $name );
1720 if ( !empty( $syntaxCheckCmd ) ) {
1721 $cmdSyntaxCheck = $bin->getCmdLineOutput( $syntaxCheckCmd );
1722 if ( !$cmdSyntaxCheck[
'syntaxOk'] ) {
1724 $serviceErrorLog .= sprintf(
' (conf errors detected : %s)', $cmdSyntaxCheck[
'content'] );
1728 if ( $showWindow ) {
1729 $bearsamppWinbinder->messageBoxError( $serviceError, $boxTitle );
1735 if ( $showWindow ) {
1736 $bearsamppWinbinder->messageBoxWarning(
1745 elseif ( $service->isRunning() ) {
1746 self::logWarning( sprintf(
'%s service already installed and running', $name ) );
1747 if ( $showWindow ) {
1748 $bearsamppWinbinder->messageBoxWarning(
1757 self::logError( sprintf(
'Port %s is used by an other application : %s', $name ) );
1758 if ( $showWindow ) {
1759 $bearsamppWinbinder->messageBoxError(
1785 if ( $service->isInstalled() ) {
1786 if ( $service->delete() ) {
1787 self::logInfo( sprintf(
'%s service successfully removed', $name ) );
1792 self::logError( sprintf(
'Error during the uninstallation of %s service', $name ) );
1813 public static function startService($bin, $syntaxCheckCmd, $showWindow =
false)
1816 $name = $bin->getName();
1817 $service = $bin->getService();
1820 if ( !$service->start() ) {
1822 $serviceErrorLog = sprintf(
'Error while starting the %s service', $name );
1823 if ( !empty( $syntaxCheckCmd ) ) {
1824 $cmdSyntaxCheck = $bin->getCmdLineOutput( $syntaxCheckCmd );
1825 if ( !$cmdSyntaxCheck[
'syntaxOk'] ) {
1827 $serviceErrorLog .= sprintf(
' (conf errors detected : %s)', $cmdSyntaxCheck[
'content'] );
1831 if ( $showWindow ) {
1832 $bearsamppWinbinder->messageBoxError( $serviceError, $boxTitle );
1850 $part = !empty( $part ) ?
'/' . $part :
null;
1864 $part = !empty( $part ) ?
'/' . $part :
null;
1878 $file = !empty( $file ) ?
'/' . $file :
null;
1894 $handle = @opendir( $path );
1899 while (
false !== ($file = readdir( $handle )) ) {
1900 $filePath = $path .
'/' . $file;
1901 if ( $file !=
"." && $file !=
".." && is_dir( $filePath ) && $file !=
'current' ) {
1906 closedir( $handle );
1924 $nssmEnvPathsFile =
$bearsamppRoot->getRootPath() .
'/nssmEnvPaths.dat';
1926 if ( is_file( $nssmEnvPathsFile ) ) {
1927 $paths = explode( PHP_EOL, file_get_contents( $nssmEnvPathsFile ) );
1928 foreach ( $paths as $path ) {
1929 $path = trim( $path );
1930 if ( stripos( $path,
':' ) ===
false ) {
1933 if ( is_dir( $path ) ) {
1961 if ( !is_dir( $folderPath ) ) {
1962 mkdir( $folderPath, 0777,
true );
1966 file_put_contents( $filepath, $content );
1968 $bearsamppWinbinder->exec(
$bearsamppConfig->getNotepad(),
'"' . $filepath .
'"' );
1984 $stringfile =
$bearsamppCore->getResourcesPath() .
'/string.dat';
1985 $encryptedFile =
$bearsamppCore->getResourcesPath() .
'/github.dat';
1986 $method =
'AES-256-CBC';
1989 $stringPhrase = file_get_contents( $stringfile );
1990 if ( $stringPhrase ===
false ) {
1991 Util::logDebug(
"Failed to read the file at path: {$stringfile}" );
1996 $stringKey = convert_uudecode( $stringPhrase );
1999 $encryptedData = file_get_contents( $encryptedFile );
2000 if ( $encryptedData ===
false ) {
2001 Util::logDebug(
"Failed to read the file at path: {$encryptedFile}" );
2007 $data = base64_decode( $encryptedData );
2008 if ( $data ===
false ) {
2009 Util::logDebug(
"Failed to decode the data from path: {$encryptedFile}" );
2015 $ivLength = openssl_cipher_iv_length( $method );
2016 $iv = substr( $data, 0, $ivLength );
2017 $encrypted = substr( $data, $ivLength );
2020 $decrypted = openssl_decrypt( $encrypted, $method, $stringKey, 0, $iv );
2021 if ( $decrypted ===
false ) {
2022 Util::logDebug(
"Decryption failed for data from path: {$encryptedFile}" );
2043 'Accept: application/vnd.github+json',
2044 'Authorization: Token ' . $Token,
2046 'X-GitHub-Api-Version: 2022-11-28'
2060 $connected = @fsockopen(
"www.google.com", 80 );
2062 fclose( $connected );
static getProcessUsingPort($port)
const PATH_WIN_PLACEHOLDER
const PATH_LIN_PLACEHOLDER
const SERVICE_ALREADY_INSTALLED
const START_SERVICE_TITLE
const START_SERVICE_ERROR
const SERVICE_INSTALL_ERROR
const STARTUP_SERVICE_SYNTAX_ERROR
const INSTALL_SERVICE_TITLE
const PROCESSOR_REG_ENTRY
const PROCESSOR_REG_SUBKEY
static getFolderList($path)
static getRemoteFilesize($url, $humanFileSize=true)
static findFiles($startPath, $includes=array(''), $recursive=true)
static getVersionList($path)
static getProcessorRegKey()
static startWith($string, $search)
static getPowerShellPath()
static getGithubUserUrl($part=null)
static getWebsiteUrlNoUtm($path='', $fragment='')
static setSysPathRegKey($value)
static logReloadClass($classInstance)
static getHttpHeaders($pingUrl)
static findRepos($initPath, $startPath, $checkFile, $maxDepth=1)
static openFileContent($caption, $content)
static replaceInFile($path, $replaceList)
static getHeaders($host, $port, $ssl=false)
static cleanGetVar($name, $type='text')
static deleteFolder($path)
static contains($string, $search)
static logError($data, $file=null)
static getFilesToScan($path=null)
static endWith($string, $search)
static isValidPort($port)
static clearFolders($paths, $exclude=array())
static random($length=32, $withNumeric=true)
static getSysPathRegKey()
static cp1252ToUtf8($data)
static getChangelogUrl($utmSource=true)
static isAlphanumeric($string)
static getLatestVersion($url)
static getStartupLnkPath()
static formatUnixPath($path)
static getFopenHttpHeaders($url)
static changePath($filesToScan, $rootPath=null)
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)
static getGithubRawUrl($file)
static findFile($startPath, $findFile)
static isValidDomainName($domainName)
static enableLaunchStartup()
static setAppPathRegKey($value)
static removeService($service, $name)
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
static logDebug($data, $file=null)
static getAppPathRegKey()
static startService($bin, $syntaxCheckCmd, $showWindow=false)
static logInitClass($classInstance)
static cleanArgv($name, $type='text')
static isPortInUse($port)
static getGithubUrl($part=null)
static humanFileSize($size, $unit='')
static setAppBinsRegKey($value)
static replaceDefine($path, $var, $value)
static utf8ToCp1252($data)
static logInfo($data, $file=null)
static disableLaunchStartup()
static logWarning($data, $file=null)
static log($data, $type, $file=null)
static imgToBase64($path)
static clearFolder($path, $exclude=array())
static cleanPostVar($name, $type='text')
static formatWindowsPath($path)
static checkInternetState()
static logTrace($data, $file=null)
static setupCurlHeaderWithToken()
static getAppBinsRegKey($fromRegistry=true)
static getCurlHttpHeaders($url)
static getStartupPath($file=null)
static createShortcut($savePath)
const APP_GITHUB_USERAGENT