61 if ( extension_loaded(
'winbinder' ) ) {
62 require_once $this->
getLibsPath() .
'/winbinder/winbinder.php';
119 return $bearsamppCore->getResourcesPath( $aetrayPath ) .
'/img/icons';
196 if ( !is_file( $filePath ) ) {
202 return trim( file_get_contents( $filePath ) );
246 file_put_contents( $this->
getExec(), $action );
268 file_put_contents( $this->
getLoadingPid(), $pid . PHP_EOL, FILE_APPEND );
304 return $this->
getLibsPath( $aetrayPath ) .
'/setenv';
328 return $this->
getLibsPath( $aetrayPath ) .
'/nssm';
352 return $this->
getLibsPath( $aetrayPath ) .
'/openssl';
388 return $this->
getLibsPath( $aetrayPath ) .
'/hostseditor';
436 return $this->
getLibsPath( $aetrayPath ) .
'/pwgen';
458 return 'core object';
478 public function unzipFile($filePath, $destination, $progressCallback =
null)
482 $sevenZipPath = $this->
getLibsPath() .
'/7zip/7za.exe';
484 if ( !file_exists( $sevenZipPath ) ) {
491 $testCommand = escapeshellarg( $sevenZipPath ) .
' t ' . escapeshellarg( $filePath ) .
' -y -bsp1';
492 $testOutput = shell_exec( $testCommand );
495 preg_match(
'/Files: (\d+)/', $testOutput, $matches );
496 $numFiles = isset( $matches[1] ) ? (int) $matches[1] : 0;
497 Util::logDebug(
'Number of files to be extracted: ' . $numFiles );
500 $command = escapeshellarg( $sevenZipPath ) .
' x ' . escapeshellarg( $filePath ) .
' -y -bb1 -o' . escapeshellarg( $destination );
503 $process = popen( $command,
'rb' );
509 while ( !feof( $process ) ) {
510 $buffer .= fread( $process, 8192 );
512 while ( ($newlinePos = strpos( $buffer,
"\n" )) !==
false ) {
513 $line = substr( $buffer, 0, $newlinePos + 1 );
514 $buffer = substr( $buffer, $newlinePos + 1 );
516 if ( $progressCallback && preg_match(
'/^- (.+)$/', $line, $matches ) ) {
517 $fileName = trim( $matches[1] );
520 if ( substr( $fileName, -1 ) !==
'\\' ) {
522 if ( $filesExtracted <= $numFiles ) {
523 call_user_func( $progressCallback, $filesExtracted, $numFiles );
530 $returnVar = pclose( $process );
533 if ( $returnVar === 0 ) {
534 Util::logDebug(
'Successfully unzipped file to: ' . $destination );
536 return [
'success' =>
true,
'numFiles' => $numFiles];
539 Util::logError(
'Failed to unzip file. Command return value: ' . $returnVar );
541 return [
'error' =>
'Failed to unzip file',
'numFiles' => $numFiles];
545 Util::logError(
'Failed to open process for command: ' . $command );
547 return [
'error' =>
'Failed to open process',
'numFiles' => $numFiles];
565 public function getFileFromUrl(
string $moduleUrl,
string $filePath, $progressBar =
false)
568 $inputStream = @fopen( $moduleUrl,
'rb' );
569 if ( $inputStream ===
false ) {
570 Util::logError(
'Error fetching content from URL: ' . $moduleUrl );
572 return [
'error' =>
'Error fetching module'];
576 $outputStream = @fopen( $filePath,
'wb' );
577 if ( $outputStream ===
false ) {
579 fclose( $inputStream );
581 return [
'error' =>
'Error saving module'];
588 while ( !feof( $inputStream ) ) {
589 $buffer = fread( $inputStream, $bufferSize );
590 fwrite( $outputStream, $buffer );
594 if ( $progressBar ) {
595 $progress = $chunksRead;
596 echo json_encode( [
'progress' => $progress] );
599 if ( ob_get_length() !==
false ) {
606 fclose( $inputStream );
607 fclose( $outputStream );
609 return [
'success' =>
true];
getLnPath($aetrayPath=false)
getAjaxPath($aetrayPath=false)
getNssmPath($aetrayPath=false)
getScriptsPath($aetrayPath=false)
getResourcesPath($aetrayPath=false)
getSetEnvExe($aetrayPath=false)
getPwgenExe($aetrayPath=false)
getOpenSslPath($aetrayPath=false)
getPhpPath($aetrayPath=false)
getFileFromUrl(string $moduleUrl, string $filePath, $progressBar=false)
const HOSTSEDITOR_VERSION
getHostsEditorExe($aetrayPath=false)
getPwgenPath($aetrayPath=false)
getSetEnvPath($aetrayPath=false)
getTmpPath($aetrayPath=false)
unzipFile($filePath, $destination, $progressCallback=null)
getIconsPath($aetrayPath=false)
const PATH_WIN_PLACEHOLDER
getHomepagePath($aetrayPath=false)
getNssmExe($aetrayPath=false)
getHostsEditorPath($aetrayPath=false)
getisRootFilePath($aetrayPath=false)
getLoadingPid($aetrayPath=false)
getLibsPath($aetrayPath=false)
getLnExe($aetrayPath=false)
getOpenSslExe($aetrayPath=false)
getExec($aetrayPath=false)
getPhpExe($aetrayPath=false)
getLastPath($aetrayPath=false)
getOpenSslConf($aetrayPath=false)
const PATH_LIN_PLACEHOLDER
getLangsPath($aetrayPath=false)
const ERROR_CONF_NOT_FOUND
static logError($data, $file=null)
static logDebug($data, $file=null)
static logTrace($data, $file=null)