Bearsampp 2025.8.29
Loading...
Searching...
No Matches
BinApache Class Reference
Inheritance diagram for BinApache:

Public Member Functions

 __construct ($id, $type)
 changePort ($port, $checkUsed=false, $wbProgressBar=null)
 checkPort ($port, $ssl=false, $showWindow=false)
 getAccessLog ()
 getAlias ()
 getAliasContent ($name, $dest)
 getCmdLineOutput ($cmd)
 getConf ()
 getErrorLog ()
 getExe ()
 getModules ()
 getModulesFromConf ()
 getModulesLoaded ()
 getModulesPath ()
 getOpensslExe ()
 getPort ()
 getRewriteLog ()
 getService ()
 getSslConf ()
 getSslPort ()
 getVhostContent ($serverName, $documentRoot)
 getVhosts ()
 getVhostsUrl ()
 getWwwDirectories ()
 refreshAlias ($putOnline)
 refreshConf ($putOnline)
 refreshVhosts ($putOnline)
 reload ($id=null, $type=null)
 setEnable ($enabled, $showWindow=false)
 setPort ($port)
 setSslPort ($sslPort)
 setVersion ($version)
 switchVersion ($version, $showWindow=false)
Public Member Functions inherited from Module
 __toString ()
 getCurrentPath ()
 getId ()
 getName ()
 getRelease ()
 getRootPath ()
 getSymlinkPath ()
 getType ()
 getVersion ()
 getVersionList ()
 isEnable ()
 update ($sub=0, $showWindow=false)

Data Fields

const CMD_COMPILE_SETTINGS = '-V'
const CMD_COMPILED_MODULES = '-l'
const CMD_CONFIG_DIRECTIVES = '-L'
const CMD_LOADED_MODULES = '-M'
const CMD_SYNTAX_CHECK = '-t'
const CMD_VERSION_NUMBER = '-v'
const CMD_VHOSTS_SETTINGS = '-S'
const LOCAL_CFG_CONF = 'apacheConf'
const LOCAL_CFG_EXE = 'apacheExe'
const LOCAL_CFG_OPENSSL_EXE = 'apacheOpensslExe'
const LOCAL_CFG_PORT = 'apachePort'
const LOCAL_CFG_SSL_PORT = 'apacheSslPort'
const ROOT_CFG_ENABLE = 'apacheEnable'
const ROOT_CFG_VERSION = 'apacheVersion'
const SERVICE_NAME = 'bearsamppapache'
const SERVICE_PARAMS = '-k runservice'
const TAG_END_SWITCHONLINE = '# END switchOnline tag - Do not replace!'
const TAG_START_SWITCHONLINE = '# START switchOnline tag - Do not replace!'
Data Fields inherited from Module
const BUNDLE_RELEASE = 'bundleRelease'

Protected Member Functions

 replaceAll ($params)
 updateConfig ($version=null, $sub=0, $showWindow=false)
Protected Member Functions inherited from Module
 __construct ()
 replace ($key, $value)

Private Member Functions

 getModulesFromFolder ()
 getOfflineContent ($version=null)
 getOnlineContent ($version=null)
 getRequiredContent ($version=null)

Private Attributes

 $accessLog
 $conf
 $errorLog
 $exe
 $modulesPath
 $opensslExe
 $port
 $rewriteLog
 $service
 $sslConf
 $sslPort

Additional Inherited Members

Protected Attributes inherited from Module
 $bearsamppConf
 $bearsamppConfRaw
 $currentPath
 $enable
 $name
 $release = 'N/A'
 $rootPath
 $symlinkPath
 $version

Detailed Description

Class BinApache

This class represents the Apache module in the Bearsampp application. It provides functionalities to manage Apache services, configurations, and modules.

Definition at line 17 of file class.bin.apache.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $id,
$type )

Constructor for the BinApache class.

Parameters
string$idThe ID of the module.
string$typeThe type of the module.

Definition at line 61 of file class.bin.apache.php.

62 {
63 Util::logInitClass( $this );
64 $this->reload( $id, $type );
65 }
reload($id=null, $type=null)
static logInitClass($classInstance)

References Module\$id, Module\$type, Util\logInitClass(), and reload().

Member Function Documentation

◆ changePort()

changePort ( $port,
$checkUsed = false,
$wbProgressBar = null )

Changes the port for the Apache service.

Parameters
int$portThe new port number.
bool$checkUsedWhether to check if the port is already in use.
mixed$wbProgressBarThe progress bar object for updating progress.
Returns
bool|string True if the port was changed successfully, or the process using the port if it is in use.

Definition at line 191 of file class.bin.apache.php.

192 {
193 global $bearsamppWinbinder;
194
195 if ( !Util::isValidPort( $port ) ) {
196 Util::logError( $this->getName() . ' port not valid: ' . $port );
197
198 return false;
199 }
200
201 $port = intval( $port );
202 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
203
204 $isPortInUse = Util::isPortInUse( $port );
205 if ( !$checkUsed || $isPortInUse === false ) {
206 // bearsampp.conf
207 $this->setPort( $port );
208 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
209
210 // conf
211 $this->update();
212 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
213
214 return true;
215 }
216
217 Util::logDebug( $this->getName() . ' port in used: ' . $port . ' - ' . $isPortInUse );
218
219 return $isPortInUse;
220 }
update($sub=0, $showWindow=false)
static logError($data, $file=null)
static isValidPort($port)
static logDebug($data, $file=null)
static isPortInUse($port)

References $port, Module\getName(), Util\isPortInUse(), Util\isValidPort(), Util\logDebug(), Util\logError(), setPort(), and Module\update().

◆ checkPort()

checkPort ( $port,
$ssl = false,
$showWindow = false )

Checks if a specific port is being used by the Apache service.

Parameters
int$portThe port number to check.
bool$sslWhether to check for SSL.
bool$showWindowWhether to show a window with the result.
Returns
bool True if the port is used by Apache, false otherwise.

Definition at line 231 of file class.bin.apache.php.

232 {
233 global $bearsamppLang, $bearsamppWinbinder, $bearsamppHomepage;
234 $boxTitle = sprintf( $bearsamppLang->getValue( Lang::CHECK_PORT_TITLE ), $this->getName(), $port );
235
236 if ( !Util::isValidPort( $port ) ) {
237 Util::logError( $this->getName() . ' port not valid: ' . $port );
238
239 return false;
240 }
241
242 $headers = Util::getHttpHeaders( 'http' . ($ssl ? 's' : '') . '://localhost:' . $port . '/' . $bearsamppHomepage->getResourcesPath() . '/ping.php' );
243 if ( !empty( $headers ) ) {
244 foreach ( $headers as $row ) {
245 if ( Util::startWith( $row, 'Server: ' ) || Util::startWith( $row, 'server: ' ) ) {
246 Util::logDebug( $this->getName() . ' port ' . $port . ' is used by: ' . $this->getName() . ' ' . str_replace( 'Server: ', '', str_replace( 'server: ', '', trim( $row ) ) ) );
247 if ( $showWindow ) {
248 $bearsamppWinbinder->messageBoxInfo(
249 sprintf( $bearsamppLang->getValue( Lang::PORT_USED_BY ), $port, str_replace( 'Server: ', '', str_replace( 'server: ', '', trim( $row ) ) ) ),
250 $boxTitle
251 );
252 }
253
254 return true;
255 }
256 }
257 Util::logDebug( $this->getName() . ' port ' . $port . ' is used by another application' );
258 if ( $showWindow ) {
259 $bearsamppWinbinder->messageBoxWarning(
260 sprintf( $bearsamppLang->getValue( Lang::PORT_NOT_USED_BY ), $port ),
261 $boxTitle
262 );
263 }
264 }
265 else {
266 Util::logDebug( $this->getName() . ' port ' . $port . ' is not used' );
267 if ( $showWindow ) {
268 $bearsamppWinbinder->messageBoxError(
269 sprintf( $bearsamppLang->getValue( Lang::PORT_NOT_USED ), $port ),
270 $boxTitle
271 );
272 }
273 }
274
275 return false;
276 }
global $bearsamppLang
const PORT_NOT_USED
const PORT_NOT_USED_BY
const CHECK_PORT_TITLE
const PORT_USED_BY
static getHttpHeaders($pingUrl)
static startWith($string, $search)
global $bearsamppHomepage
Definition homepage.php:27

References $bearsamppHomepage, $bearsamppLang, $port, Lang\CHECK_PORT_TITLE, Util\getHttpHeaders(), Module\getName(), Util\isValidPort(), Util\logDebug(), Util\logError(), Lang\PORT_NOT_USED, Lang\PORT_NOT_USED_BY, Lang\PORT_USED_BY, and Util\startWith().

◆ getAccessLog()

getAccessLog ( )

Gets the access log file path.

Returns
string The access log file path.

Definition at line 971 of file class.bin.apache.php.

972 {
973 return $this->accessLog;
974 }

References $accessLog.

◆ getAlias()

getAlias ( )

Retrieves the list of alias configurations.

Returns
array The list of alias configurations.

Definition at line 506 of file class.bin.apache.php.

507 {
508 global $bearsamppRoot;
509 $result = array();
510
511 $handle = @opendir( $bearsamppRoot->getAliasPath() );
512 if ( !$handle ) {
513 return $result;
514 }
515
516 while ( false !== ($file = readdir( $handle )) ) {
517 if ( $file != '.' && $file != '..' && Util::endWith( $file, '.conf' ) ) {
518 $result[] = str_replace( '.conf', '', $file );
519 }
520 }
521
522 closedir( $handle );
523 ksort( $result );
524
525 return $result;
526 }
$result
global $bearsamppRoot
static endWith($string, $search)

References $bearsamppRoot, $result, and Util\endWith().

Referenced by refreshAlias().

◆ getAliasContent()

getAliasContent ( $name,
$dest )

Generates the alias content for the configuration file.

Parameters
string$nameThe name of the alias.
string$destThe destination path of the alias.
Returns
string The alias content.

Definition at line 709 of file class.bin.apache.php.

710 {
711 $dest = Util::formatUnixPath( $dest );
712
713 return 'Alias /' . $name . ' "' . $dest . '"' . PHP_EOL . PHP_EOL .
714 '<Directory "' . $dest . '">' . PHP_EOL .
715 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
716 ' AllowOverride all' . PHP_EOL .
717 $this->getRequiredContent() . PHP_EOL .
718 '</Directory>' . PHP_EOL;
719 }
getRequiredContent($version=null)
static formatUnixPath($path)

References Module\$name, Util\formatUnixPath(), and getRequiredContent().

◆ getCmdLineOutput()

getCmdLineOutput ( $cmd)

Executes a command line and retrieves the output.

Parameters
string$cmdThe command to execute.
Returns
array The output of the command.

Definition at line 619 of file class.bin.apache.php.

620 {
621 $result = array(
622 'syntaxOk' => false,
623 'content' => null,
624 );
625
626 if ( file_exists( $this->getExe() ) ) {
627 $tmpResult = Batch::exec( 'apacheGetCmdLineOutput', '"' . $this->getExe() . '" ' . $cmd );
628 if ( $tmpResult !== false && is_array( $tmpResult ) ) {
629 $result['syntaxOk'] = trim( $tmpResult[count( $tmpResult ) - 1] ) == 'Syntax OK';
630 if ( $result['syntaxOk'] ) {
631 unset( $tmpResult[count( $tmpResult ) - 1] );
632 }
633 $result['content'] = implode( PHP_EOL, $tmpResult );
634 }
635 }
636
637 return $result;
638 }
static exec($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true)

References $result, Batch\exec(), and getExe().

◆ getConf()

getConf ( )

Gets the configuration file path.

Returns
string The configuration file path.

Definition at line 1011 of file class.bin.apache.php.

1012 {
1013 return $this->conf;
1014 }

References $conf.

Referenced by getModulesFromConf(), refreshConf(), and updateConfig().

◆ getErrorLog()

getErrorLog ( )

Gets the error log file path.

Returns
string The error log file path.

Definition at line 991 of file class.bin.apache.php.

992 {
993 return $this->errorLog;
994 }

References $errorLog.

◆ getExe()

getExe ( )

Gets the executable file path.

Returns
string The executable file path.

Definition at line 1001 of file class.bin.apache.php.

1002 {
1003 return $this->exe;
1004 }

References $exe.

Referenced by getCmdLineOutput().

◆ getModules()

getModules ( )

Retrieves the list of modules by merging the modules from the folder and the configuration file.

Returns
array The list of modules.

Definition at line 408 of file class.bin.apache.php.

409 {
410 $fromFolder = $this->getModulesFromFolder();
411 $fromConf = $this->getModulesFromConf();
412 $result = array_merge( $fromFolder, $fromConf );
413 ksort( $result );
414
415 return $result;
416 }

References $result, getModulesFromConf(), and getModulesFromFolder().

◆ getModulesFromConf()

getModulesFromConf ( )

Retrieves the list of modules from the configuration file.

Returns
array The list of modules from the configuration file.

Definition at line 423 of file class.bin.apache.php.

424 {
425 $result = array();
426
427 if ( !$this->enable ) {
428 return $result;
429 }
430
431 $confContent = file( $this->getConf() );
432 foreach ( $confContent as $row ) {
433 $modMatch = array();
434 if ( preg_match( '/^(#)?LoadModule\s*([a-z0-9_-]+)\s*"?(.*)"?/i', $row, $modMatch ) ) {
435 $name = $modMatch[2];
436 //$path = $modMatch[3];
437 if ( !Util::startWith( $name, 'php' ) ) {
438 if ( $modMatch[1] == '#' ) {
440 }
441 else {
443 }
444 }
445 }
446 }
447
448 ksort( $result );
449
450 return $result;
451 }

References Module\$name, $result, getConf(), Util\startWith(), ActionSwitchApacheModule\SWITCH_OFF, and ActionSwitchApacheModule\SWITCH_ON.

Referenced by getModules(), and getModulesLoaded().

◆ getModulesFromFolder()

getModulesFromFolder ( )
private

Retrieves the list of modules from the modules folder.

Returns
array The list of modules from the modules folder.

Definition at line 475 of file class.bin.apache.php.

476 {
477 $result = array();
478
479 if ( !$this->enable ) {
480 return $result;
481 }
482
483 $handle = @opendir( $this->getModulesPath() );
484 if ( !$handle ) {
485 return $result;
486 }
487
488 while ( false !== ($file = readdir( $handle )) ) {
489 if ( $file != '.' && $file != '..' && Util::startWith( $file, 'mod_' ) && (Util::endWith( $file, '.so' ) || Util::endWith( $file, '.dll' )) ) {
490 $name = str_replace( array('mod_', '.so', '.dll'), '', $file ) . '_module';
492 }
493 }
494
495 closedir( $handle );
496 ksort( $result );
497
498 return $result;
499 }

References Module\$name, $result, Util\endWith(), getModulesPath(), Util\startWith(), and ActionSwitchApacheModule\SWITCH_OFF.

Referenced by getModules().

◆ getModulesLoaded()

getModulesLoaded ( )

Retrieves the list of loaded modules from the configuration file.

Returns
array The list of loaded modules.

Definition at line 458 of file class.bin.apache.php.

459 {
460 $result = array();
461 foreach ( $this->getModulesFromConf() as $name => $status ) {
462 if ( $status == ActionSwitchApacheModule::SWITCH_ON ) {
463 $result[] = $name;
464 }
465 }
466
467 return $result;
468 }

References Module\$name, $result, getModulesFromConf(), and ActionSwitchApacheModule\SWITCH_ON.

◆ getModulesPath()

getModulesPath ( )

Gets the path to the modules.

Returns
string The path to the modules.

Definition at line 951 of file class.bin.apache.php.

952 {
953 return $this->modulesPath;
954 }

References $modulesPath.

Referenced by getModulesFromFolder().

◆ getOfflineContent()

getOfflineContent ( $version = null)
private

Generates the offline content for the configuration file.

Parameters
string | null$versionThe version of the configuration.
Returns
string The offline content.

Definition at line 670 of file class.bin.apache.php.

671 {
672 $version = $version != null ? $version : $this->getVersion();
673 $result = self::TAG_START_SWITCHONLINE . PHP_EOL;
674
675 if ( Util::startWith( $version, '2.4' ) ) {
676 $result .= 'Require local' . PHP_EOL;
677 }
678 else {
679 $result .= 'Order Deny,Allow' . PHP_EOL .
680 'Deny from all' . PHP_EOL .
681 'Allow from 127.0.0.1 ::1' . PHP_EOL;
682 }
683
684 return $result . self::TAG_END_SWITCHONLINE;
685 }

References $result, Module\$version, Module\getVersion(), and Util\startWith().

Referenced by getRequiredContent(), refreshAlias(), refreshConf(), and refreshVhosts().

◆ getOnlineContent()

getOnlineContent ( $version = null)
private

Generates the online content for the configuration file.

Parameters
string | null$versionThe version of the configuration.
Returns
string The online content.

Definition at line 647 of file class.bin.apache.php.

648 {
649 $version = $version != null ? $version : $this->getVersion();
650 $result = self::TAG_START_SWITCHONLINE . PHP_EOL;
651
652 if ( Util::startWith( $version, '2.4' ) ) {
653 $result .= 'Require all granted' . PHP_EOL;
654 }
655 else {
656 $result .= 'Order Allow,Deny' . PHP_EOL .
657 'Allow from all' . PHP_EOL;
658 }
659
660 return $result . self::TAG_END_SWITCHONLINE;
661 }

References $result, Module\$version, Module\getVersion(), and Util\startWith().

Referenced by getRequiredContent(), refreshAlias(), refreshConf(), and refreshVhosts().

◆ getOpensslExe()

getOpensslExe ( )

Gets the OpenSSL executable file path.

Returns
string The OpenSSL executable file path.

Definition at line 1065 of file class.bin.apache.php.

1066 {
1067 return $this->opensslExe;
1068 }

References $opensslExe.

◆ getPort()

getPort ( )

Gets the port number.

Returns
int The port number.

Definition at line 1021 of file class.bin.apache.php.

1022 {
1023 return $this->port;
1024 }

References $port.

Referenced by getVhostContent().

◆ getRequiredContent()

getRequiredContent ( $version = null)
private

Generates the required content for the configuration file based on the online status.

Parameters
string | null$versionThe version of the configuration.
Returns
string The required content.

Definition at line 694 of file class.bin.apache.php.

695 {
696 global $bearsamppConfig;
697
698 return $bearsamppConfig->isOnline() ? $this->getOnlineContent( $version ) : $this->getOfflineContent( $version );
699 }
getOnlineContent($version=null)
getOfflineContent($version=null)
global $bearsamppConfig
Definition homepage.php:27

References $bearsamppConfig, Module\$version, getOfflineContent(), and getOnlineContent().

Referenced by getAliasContent(), and getVhostContent().

◆ getRewriteLog()

getRewriteLog ( )

Gets the rewrite log file path.

Returns
string The rewrite log file path.

Definition at line 981 of file class.bin.apache.php.

982 {
983 return $this->rewriteLog;
984 }

References $rewriteLog.

◆ getService()

getService ( )

Gets the service associated with the module.

Returns
string The service associated with the module.

Definition at line 941 of file class.bin.apache.php.

942 {
943 return $this->service;
944 }

References $service.

◆ getSslConf()

getSslConf ( )

Gets the SSL configuration file path.

Returns
string The SSL configuration file path.

Definition at line 961 of file class.bin.apache.php.

962 {
963 return $this->sslConf;
964 }

References $sslConf.

Referenced by refreshConf().

◆ getSslPort()

getSslPort ( )

Gets the SSL port number.

Returns
int The SSL port number.

Definition at line 1043 of file class.bin.apache.php.

1044 {
1045 return $this->sslPort;
1046 }

References $sslPort.

Referenced by getVhostContent().

◆ getVhostContent()

getVhostContent ( $serverName,
$documentRoot )

Generates the virtual host content for the configuration file.

Parameters
string$serverNameThe server name of the virtual host.
string$documentRootThe document root of the virtual host.
Returns
string The virtual host content.

Definition at line 729 of file class.bin.apache.php.

730 {
731 global $bearsamppRoot;
732
733 $documentRoot = Util::formatUnixPath( $documentRoot );
734
735 return '<VirtualHost *:' . $this->getPort() . '>' . PHP_EOL .
736 ' ServerAdmin webmaster@' . $serverName . PHP_EOL .
737 ' DocumentRoot "' . $documentRoot . '"' . PHP_EOL .
738 ' ServerName ' . $serverName . PHP_EOL .
739 ' ErrorLog "' . $bearsamppRoot->getLogsPath() . '/' . $serverName . '_error.log"' . PHP_EOL .
740 ' CustomLog "' . $bearsamppRoot->getLogsPath() . '/' . $serverName . '_access.log" combined' . PHP_EOL . PHP_EOL .
741 ' <Directory "' . $documentRoot . '">' . PHP_EOL .
742 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
743 ' AllowOverride all' . PHP_EOL .
744 $this->getRequiredContent() . PHP_EOL .
745 ' </Directory>' . PHP_EOL .
746 '</VirtualHost>' . PHP_EOL . PHP_EOL .
747 '<IfModule ssl_module>' . PHP_EOL .
748 '<VirtualHost *:' . $this->getSslPort() . '> #SSL' . PHP_EOL .
749 ' DocumentRoot "' . $documentRoot . '"' . PHP_EOL .
750 ' ServerName ' . $serverName . PHP_EOL .
751 ' ServerAdmin webmaster@' . $serverName . PHP_EOL .
752 ' ErrorLog "' . $bearsamppRoot->getLogsPath() . '/' . $serverName . '_error.log"' . PHP_EOL .
753 ' TransferLog "' . $bearsamppRoot->getLogsPath() . '/' . $serverName . '_access.log"' . PHP_EOL . PHP_EOL .
754 ' SSLEngine on' . PHP_EOL .
755 ' SSLProtocol all -SSLv2' . PHP_EOL .
756 ' SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5' . PHP_EOL .
757 ' SSLCertificateFile "' . $bearsamppRoot->getSslPath() . '/' . $serverName . '.crt"' . PHP_EOL .
758 ' SSLCertificateKeyFile "' . $bearsamppRoot->getSslPath() . '/' . $serverName . '.pub"' . PHP_EOL .
759 ' BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0' . PHP_EOL .
760 ' CustomLog "' . $bearsamppRoot->getLogsPath() . '/' . $serverName . '_sslreq.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"' . PHP_EOL . PHP_EOL .
761 ' <Directory "' . $documentRoot . '">' . PHP_EOL .
762 ' SSLOptions +StdEnvVars' . PHP_EOL .
763 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
764 ' AllowOverride all' . PHP_EOL .
765 $this->getRequiredContent() . PHP_EOL .
766 ' </Directory>' . PHP_EOL .
767 '</VirtualHost>' . PHP_EOL .
768 '</IfModule>' . PHP_EOL;
769 }

References $bearsamppRoot, Util\formatUnixPath(), getPort(), getRequiredContent(), and getSslPort().

◆ getVhosts()

getVhosts ( )

Retrieves the list of virtual hosts configurations.

Returns
array The list of virtual hosts configurations.

Definition at line 533 of file class.bin.apache.php.

534 {
535 global $bearsamppRoot;
536 $result = array();
537
538 $handle = @opendir( $bearsamppRoot->getVhostsPath() );
539 if ( !$handle ) {
540 return $result;
541 }
542
543 while ( false !== ($file = readdir( $handle )) ) {
544 if ( $file != '.' && $file != '..' && Util::endWith( $file, '.conf' ) ) {
545 $result[] = str_replace( '.conf', '', $file );
546 }
547 }
548
549 closedir( $handle );
550 ksort( $result );
551
552 return $result;
553 }

References $bearsamppRoot, $result, and Util\endWith().

Referenced by getVhostsUrl(), refreshVhosts(), and updateConfig().

◆ getVhostsUrl()

getVhostsUrl ( )

Retrieves the URLs of the virtual hosts.

Returns
array The list of virtual hosts URLs.

Definition at line 560 of file class.bin.apache.php.

561 {
562 global $bearsamppRoot;
563 $result = array();
564
565 foreach ( $this->getVhosts() as $vhost ) {
566 $vhostContent = file( $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf' );
567 foreach ( $vhostContent as $vhostLine ) {
568 $vhostLine = trim( $vhostLine );
569 $enabled = !Util::startWith( $vhostLine, '#' );
570 if ( preg_match_all( '/ServerName\s+(.*)/', $vhostLine, $matches ) ) {
571 foreach ( $matches as $match ) {
572 $found = isset( $match[1] ) ? trim( $match[1] ) : trim( $match[0] );
573 if ( filter_var( 'http://' . $found, FILTER_VALIDATE_URL ) !== false ) {
574 $result[$found] = $enabled;
575 break 2;
576 }
577 }
578 }
579 }
580 }
581
582 return $result;
583 }

References $bearsamppRoot, $result, getVhosts(), and Util\startWith().

◆ getWwwDirectories()

getWwwDirectories ( )

Retrieves the list of directories in the www folder.

Returns
array The list of directories in the www folder.

Definition at line 590 of file class.bin.apache.php.

591 {
592 global $bearsamppRoot;
593 $result = array();
594
595 $handle = @opendir( $bearsamppRoot->getWwwPath() );
596 if ( !$handle ) {
597 return $result;
598 }
599
600 while ( false !== ($file = readdir( $handle )) ) {
601 if ( $file != '.' && $file != '..' && is_dir( $bearsamppRoot->getWwwPath() . '/' . $file ) ) {
602 $result[] = $file;
603 }
604 }
605
606 closedir( $handle );
607 ksort( $result );
608
609 return $result;
610 }

References $bearsamppRoot, and $result.

◆ refreshAlias()

refreshAlias ( $putOnline)

Refreshes the alias configurations to switch between online and offline modes.

Parameters
bool$putOnlineWhether to put the alias configurations online.

Definition at line 819 of file class.bin.apache.php.

820 {
822
823 if ( !$this->enable ) {
824 return;
825 }
826
827 $onlineContent = $this->getOnlineContent();
828 $offlineContent = $this->getOfflineContent();
829
830 foreach ( $this->getAlias() as $alias ) {
831 $aliasConf = file_get_contents( $bearsamppRoot->getAliasPath() . '/' . $alias . '.conf' );
832 Util::logTrace( 'refreshAlias ' . $bearsamppRoot->getAliasPath() . '/' . $alias . '.conf' );
833 preg_match( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $aliasConf, $matches );
834 Util::logTrace( isset( $matches[1] ) ? print_r( $matches[1], true ) : 'N/A' );
835
836 if ( $putOnline ) {
837 $aliasConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $aliasConf, -1, $count );
838 }
839 else {
840 $aliasConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $aliasConf, -1, $count );
841 }
842 file_put_contents( $bearsamppRoot->getAliasPath() . '/' . $alias . '.conf', $aliasConf );
843 Util::logDebug( 'Refresh ' . $bearsamppRoot->getAliasPath() . '/' . $alias . '.conf: ' . $count . ' occurrence(s) replaced' );
844 }
845
846 // Homepage
847 $bearsamppHomepage->refreshAliasContent();
848 }
static logTrace($data, $file=null)

References $bearsamppHomepage, $bearsamppRoot, getAlias(), getOfflineContent(), getOnlineContent(), Util\logDebug(), and Util\logTrace().

◆ refreshConf()

refreshConf ( $putOnline)

Refreshes the configuration file to switch between online and offline modes.

Parameters
bool$putOnlineWhether to put the configuration online.

Definition at line 776 of file class.bin.apache.php.

777 {
778 if ( !$this->enable ) {
779 return;
780 }
781
782 $onlineContent = $this->getOnlineContent();
783 $offlineContent = $this->getOfflineContent();
784
785 $conf = file_get_contents( $this->getConf() );
786 Util::logTrace( 'refreshConf ' . $this->getConf() );
787 preg_match( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $conf, $matches );
788 Util::logTrace( isset( $matches[1] ) ? print_r( $matches[1], true ) : 'N/A' );
789
790 if ( $putOnline ) {
791 $conf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $conf, -1, $count );
792 }
793 else {
794 $conf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $conf, -1, $count );
795 }
796 file_put_contents( $this->getConf(), $conf );
797 Util::logDebug( 'Refresh ' . $this->getConf() . ': ' . $count . ' occurrence(s) replaced' );
798
799 $sslConf = file_get_contents( $this->getSslConf() );
800 Util::logTrace( 'refreshConf ' . $this->getSslConf() );
801 preg_match( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $sslConf, $matches );
802 Util::logTrace( isset( $matches[1] ) ? print_r( $matches[1], true ) : 'N/A' );
803
804 if ( $putOnline ) {
805 $sslConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $sslConf, -1, $count );
806 }
807 else {
808 $sslConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $sslConf, -1, $count );
809 }
810 file_put_contents( $this->getSslConf(), $sslConf );
811 Util::logDebug( 'Refresh ' . $this->getSslConf() . ': ' . $count . ' occurrence(s) replaced' );
812 }

References $conf, $sslConf, getConf(), getOfflineContent(), getOnlineContent(), getSslConf(), Util\logDebug(), and Util\logTrace().

◆ refreshVhosts()

refreshVhosts ( $putOnline)

Refreshes the virtual host configurations to switch between online and offline modes.

Parameters
bool$putOnlineWhether to put the virtual host configurations online.

Definition at line 855 of file class.bin.apache.php.

856 {
857 global $bearsamppRoot;
858
859 if ( !$this->enable ) {
860 return;
861 }
862
863 $onlineContent = $this->getOnlineContent();
864 $offlineContent = $this->getOfflineContent();
865
866 foreach ( $this->getVhosts() as $vhost ) {
867 $vhostConf = file_get_contents( $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf' );
868 Util::logTrace( 'refreshVhost ' . $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf' );
869 preg_match( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $vhostConf, $matches );
870 Util::logTrace( isset( $matches[1] ) ? print_r( $matches[1], true ) : 'N/A' );
871
872 if ( $putOnline ) {
873 $vhostConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $vhostConf, -1, $count );
874 }
875 else {
876 $vhostConf = preg_replace( '/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $vhostConf, -1, $count );
877 }
878 file_put_contents( $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf', $vhostConf );
879 Util::logDebug( 'Refresh ' . $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf: ' . $count . ' occurrence(s) replaced' );
880 }
881 }

References $bearsamppRoot, getOfflineContent(), getOnlineContent(), getVhosts(), Util\logDebug(), and Util\logTrace().

◆ reload()

reload ( $id = null,
$type = null )

Reloads the module configuration based on the provided ID and type.

Parameters
string | null$idThe ID of the module. If null, the current ID is used.
string | null$typeThe type of the module. If null, the current type is used.

Reimplemented from Module.

Definition at line 73 of file class.bin.apache.php.

74 {
76 Util::logReloadClass( $this );
77
78 $this->name = $bearsamppLang->getValue( Lang::APACHE );
79 $this->version = $bearsamppConfig->getRaw( self::ROOT_CFG_VERSION );
80 parent::reload( $id, $type );
81
82 $this->enable = $this->enable && $bearsamppConfig->getRaw( self::ROOT_CFG_ENABLE );
83 $this->service = new Win32Service( self::SERVICE_NAME );
84 $this->modulesPath = $this->symlinkPath . '/modules';
85 $this->sslConf = $this->symlinkPath . '/conf/extra/httpd-ssl.conf';
86 $this->accessLog = $bearsamppRoot->getLogsPath() . '/apache_access.log';
87 $this->rewriteLog = $bearsamppRoot->getLogsPath() . '/apache_rewrite.log';
88 $this->errorLog = $bearsamppRoot->getLogsPath() . '/apache_error.log';
89
90 if ( $this->bearsamppConfRaw !== false ) {
91 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
92 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
93 $this->port = $this->bearsamppConfRaw[self::LOCAL_CFG_PORT];
94 $this->sslPort = $this->bearsamppConfRaw[self::LOCAL_CFG_SSL_PORT];
95 $this->opensslExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_OPENSSL_EXE];
96 }
97
98 if ( !$this->enable ) {
99 Util::logInfo( $this->name . ' is not enabled!' );
100
101 return;
102 }
103 if ( !is_dir( $this->currentPath ) ) {
104 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_FILE_NOT_FOUND ), $this->name . ' ' . $this->version, $this->currentPath ) );
105
106 return;
107 }
108 if ( !is_dir( $this->symlinkPath ) ) {
109 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_FILE_NOT_FOUND ), $this->name . ' ' . $this->version, $this->symlinkPath ) );
110
111 return;
112 }
113 if ( !is_file( $this->bearsamppConf ) ) {
114 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_CONF_NOT_FOUND ), $this->name . ' ' . $this->version, $this->bearsamppConf ) );
115
116 return;
117 }
118 if ( !is_file( $this->sslConf ) ) {
119 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_CONF_NOT_FOUND ), $this->name . ' ' . $this->version, $this->sslConf ) );
120
121 return;
122 }
123 if ( !is_file( $this->exe ) ) {
124 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_EXE_NOT_FOUND ), $this->name . ' ' . $this->version, $this->exe ) );
125
126 return;
127 }
128 if ( !is_file( $this->conf ) ) {
129 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_CONF_NOT_FOUND ), $this->name . ' ' . $this->version, $this->conf ) );
130
131 return;
132 }
133 if ( !is_numeric( $this->port ) || $this->port <= 0 ) {
134 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_INVALID_PARAMETER ), self::LOCAL_CFG_PORT, $this->port ) );
135
136 return;
137 }
138 if ( !is_numeric( $this->sslPort ) || $this->sslPort <= 0 ) {
139 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_INVALID_PARAMETER ), self::LOCAL_CFG_SSL_PORT, $this->sslPort ) );
140
141 return;
142 }
143 if ( !is_file( $this->opensslExe ) ) {
144 Util::logError( sprintf( $bearsamppLang->getValue( Lang::ERROR_EXE_NOT_FOUND ), $this->name . ' ' . $this->version, $this->opensslExe ) );
145
146 return;
147 }
148
149 $nssm = new Nssm( self::SERVICE_NAME );
150 $nssm->setDisplayName( APP_TITLE . ' ' . $this->getName() );
151 $nssm->setBinPath( $this->exe );
152 $nssm->setStart( Nssm::SERVICE_DEMAND_START );
153
154 $this->service->setNssm( $nssm );
155 }
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const APACHE
const ERROR_INVALID_PARAMETER
const ERROR_FILE_NOT_FOUND
const SERVICE_DEMAND_START
static logInfo($data, $file=null)
static logReloadClass($classInstance)
const APP_TITLE
Definition root.php:13

References $bearsamppConfig, $bearsamppLang, $bearsamppRoot, Module\$id, Module\$type, Lang\APACHE, APP_TITLE, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Lang\ERROR_INVALID_PARAMETER, Module\getName(), Util\logError(), Util\logInfo(), Util\logReloadClass(), and Nssm\SERVICE_DEMAND_START.

Referenced by __construct(), setEnable(), and setVersion().

◆ replaceAll()

replaceAll ( $params)
protected

Replaces multiple key-value pairs in the configuration file.

Parameters
array$paramsAn associative array of key-value pairs to replace.

Reimplemented from Module.

Definition at line 162 of file class.bin.apache.php.

163 {
164 $content = file_get_contents( $this->bearsamppConf );
165
166 foreach ( $params as $key => $value ) {
167 $content = preg_replace( '|' . $key . ' = .*|', $key . ' = ' . '"' . $value . '"', $content );
168 $this->bearsamppConfRaw[$key] = $value;
169 switch ( $key ) {
170 case self::LOCAL_CFG_PORT:
171 $this->port = $value;
172 break;
173 case self::LOCAL_CFG_SSL_PORT:
174 $this->sslPort = $value;
175 break;
176 }
177 }
178
179 file_put_contents( $this->bearsamppConf, $content );
180 }

◆ setEnable()

setEnable ( $enabled,
$showWindow = false )

Sets the enable status of the module.

This method enables or disables the module based on the provided parameter. If enabling the module and the current path does not exist, it logs an error and optionally shows an error message window.

Parameters
bool$enabledWhether to enable or disable the module.
bool$showWindowWhether to show an error message window if enabling fails.

Definition at line 893 of file class.bin.apache.php.

894 {
895 global $bearsamppConfig, $bearsamppLang, $bearsamppWinbinder;
896
897 if ( $enabled == Config::ENABLED && !is_dir( $this->currentPath ) ) {
898 Util::logDebug( $this->getName() . ' cannot be enabled because bundle ' . $this->getVersion() . ' does not exist in ' . $this->currentPath );
899 if ( $showWindow ) {
900 $bearsamppWinbinder->messageBoxError(
901 sprintf( $bearsamppLang->getValue( Lang::ENABLE_BUNDLE_NOT_EXIST ), $this->getName(), $this->getVersion(), $this->currentPath ),
902 sprintf( $bearsamppLang->getValue( Lang::ENABLE_TITLE ), $this->getName() )
903 );
904 }
905 $enabled = Config::DISABLED;
906 }
907
908 Util::logInfo( $this->getName() . ' switched to ' . ($enabled == Config::ENABLED ? 'enabled' : 'disabled') );
909 $this->enable = $enabled == Config::ENABLED;
910 $bearsamppConfig->replace( self::ROOT_CFG_ENABLE, $enabled );
911
912 $this->reload();
913 if ( $this->enable ) {
914 Util::installService( $this, $this->port, self::CMD_SYNTAX_CHECK, $showWindow );
915 }
916 else {
917 Util::removeService( $this->service, $this->name );
918 }
919 }
const DISABLED
const ENABLED
const ENABLE_BUNDLE_NOT_EXIST
const ENABLE_TITLE
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)
static removeService($service, $name)

References $bearsamppConfig, $bearsamppLang, Config\DISABLED, Lang\ENABLE_BUNDLE_NOT_EXIST, Lang\ENABLE_TITLE, Config\ENABLED, Module\getName(), Module\getVersion(), Util\installService(), Util\logDebug(), Util\logInfo(), reload(), and Util\removeService().

◆ setPort()

setPort ( $port)

Sets the port number.

This method updates the port number in the configuration.

Parameters
int$portThe port number to set.

Definition at line 1033 of file class.bin.apache.php.

1034 {
1035 $this->replace( self::LOCAL_CFG_PORT, $port );
1036 }
replace($key, $value)

References $port, and Module\replace().

Referenced by changePort().

◆ setSslPort()

setSslPort ( $sslPort)

Sets the SSL port number.

This method updates the SSL port number in the configuration.

Parameters
int$sslPortThe SSL port number to set.

Definition at line 1055 of file class.bin.apache.php.

1056 {
1057 $this->replace( self::LOCAL_CFG_SSL_PORT, $sslPort );
1058 }

References $sslPort, and Module\replace().

◆ setVersion()

setVersion ( $version)

Sets the version of the module.

This method updates the version of the module and reloads its configuration.

Parameters
string$versionThe version to set for the module.

Reimplemented from Module.

Definition at line 928 of file class.bin.apache.php.

929 {
930 global $bearsamppConfig;
931 $this->version = $version;
932 $bearsamppConfig->replace( self::ROOT_CFG_VERSION, $version );
933 $this->reload();
934 }

References $bearsamppConfig, Module\$version, and reload().

Referenced by updateConfig().

◆ switchVersion()

switchVersion ( $version,
$showWindow = false )

Switches the Apache version.

Parameters
string$versionThe version to switch to.
bool$showWindowWhether to show a window with the result.
Returns
bool True if the version was switched successfully, false otherwise.

Definition at line 286 of file class.bin.apache.php.

287 {
288 Util::logDebug( 'Switch ' . $this->name . ' version to ' . $version );
289
290 return $this->updateConfig( $version, 0, $showWindow );
291 }
updateConfig($version=null, $sub=0, $showWindow=false)

References Module\$version, Util\logDebug(), and updateConfig().

◆ updateConfig()

updateConfig ( $version = null,
$sub = 0,
$showWindow = false )
protected

Updates the Apache configuration with a specific version.

Parameters
string | null$versionThe version to update to. If null, the current version is used.
int$subThe sub-level for logging indentation.
bool$showWindowWhether to show a window during the update process.
Returns
bool True if the configuration was updated successfully, false otherwise.

Reimplemented from Module.

Definition at line 302 of file class.bin.apache.php.

303 {
304 global $bearsamppRoot, $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
305
306 if ( !$this->enable ) {
307 return true;
308 }
309
310 $version = $version == null ? $this->version : $version;
311 Util::logDebug( ($sub > 0 ? str_repeat( ' ', 2 * $sub ) : '') . 'Update ' . $this->name . ' ' . $version . ' config' );
312
313 $boxTitle = sprintf( $bearsamppLang->getValue( Lang::SWITCH_VERSION_TITLE ), $this->getName(), $version );
314
315 $conf = str_replace( 'apache' . $this->getVersion(), 'apache' . $version, $this->getConf() );
316 $bearsamppConf = str_replace( 'apache' . $this->getVersion(), 'apache' . $version, $this->bearsamppConf );
317
318 $tsDll = $bearsamppBins->getPhp()->getTsDll();
319
320 $apachePhpModuleName = null;
321 if ( $tsDll !== false ) {
322 $apachemoduleNamePrefix = substr( $tsDll, 0, 4 );
323 $apachePhpModuleName = ($apachemoduleNamePrefix == 'php8' ? 'php' : $apachemoduleNamePrefix) . '_module';
324 }
325 $apachePhpModulePath = $bearsamppBins->getPhp()->getApacheModule( $version );
326 $apachePhpModuleDll = basename( $apachePhpModulePath );
327
328 Util::logDebug( ($sub > 0 ? str_repeat( ' ', 2 * $sub ) : '') . 'PHP TsDll found: ' . $tsDll );
329 Util::logDebug( ($sub > 0 ? str_repeat( ' ', 2 * $sub ) : '') . 'PHP Apache module found: ' . $apachePhpModulePath );
330
331 if ( !file_exists( $conf ) || !file_exists( $bearsamppConf ) ) {
332 Util::logError( 'bearsampp config files not found for ' . $this->getName() . ' ' . $version );
333 if ( $showWindow ) {
334 $bearsamppWinbinder->messageBoxError(
335 sprintf( $bearsamppLang->getValue( Lang::BEARSAMPP_CONF_NOT_FOUND_ERROR ), $this->getName() . ' ' . $version ),
336 $boxTitle
337 );
338 }
339
340 return false;
341 }
342
343 $bearsamppConfRaw = parse_ini_file( $bearsamppConf );
344 if ( $bearsamppConfRaw === false || !isset( $bearsamppConfRaw[self::ROOT_CFG_VERSION] ) || $bearsamppConfRaw[self::ROOT_CFG_VERSION] != $version ) {
345 Util::logError( 'bearsampp config file malformed for ' . $this->getName() . ' ' . $version );
346 if ( $showWindow ) {
347 $bearsamppWinbinder->messageBoxError(
348 sprintf( $bearsamppLang->getValue( Lang::BEARSAMPP_CONF_MALFORMED_ERROR ), $this->getName() . ' ' . $version ),
349 $boxTitle
350 );
351 }
352
353 return false;
354 }
355
356 if ( $tsDll === false || $apachePhpModulePath === false ) {
357 Util::logDebug( $this->getName() . ' ' . $version . ' does not seem to be compatible with PHP ' . $bearsamppBins->getPhp()->getVersion() );
358 if ( $showWindow ) {
359 $bearsamppWinbinder->messageBoxError(
360 sprintf( $bearsamppLang->getValue( Lang::APACHE_INCPT ), $version, $bearsamppBins->getPhp()->getVersion() ),
361 $boxTitle
362 );
363 }
364
365 return false;
366 }
367
368 // httpd.conf
369 $this->setVersion( $version );
370
371 // conf
372 Util::logDebug( 'httpd.conf = ' . $conf );
374 // PHP module
375 '/^#?PHPIniDir\s.*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . 'PHPIniDir "' . $bearsamppBins->getPhp()->getSymlinkPath() . '"',
376 '/^#?LoadFile\s.*php.ts\.dll.*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . (!file_exists( $bearsamppBins->getPhp()->getSymlinkPath() . '/' . $tsDll ) ? '#' : '') . 'LoadFile "' . $bearsamppBins->getPhp()->getSymlinkPath() . '/' . $tsDll . '"',
377 '/^#?LoadModule\sphp.*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . 'LoadModule ' . $apachePhpModuleName . ' "' . $bearsamppBins->getPhp()->getSymlinkPath() . '/' . $apachePhpModuleDll . '"',
378 '/^#?LoadModule\sphp_*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . 'LoadModule ' . $apachePhpModuleName . ' "' . $bearsamppBins->getPhp()->getSymlinkPath() . '/' . $apachePhpModuleDll . '"',
379
380
381 // Port
382 '/^Listen\s(\d+)/' => 'Listen ' . $this->port,
383 '/^ServerName\s+([a-zA-Z0-9.]+):(\d+)/' => 'ServerName {{1}}:' . $this->port,
384 '/^NameVirtualHost\s+([a-zA-Z0-9.*]+):(\d+)/' => 'NameVirtualHost {{1}}:' . $this->port,
385 '/^<VirtualHost\s+([a-zA-Z0-9.*]+):(\d+)>/' => '<VirtualHost {{1}}:' . $this->port . '>'
386 ) );
387
388 // vhosts
389 foreach ( $this->getVhosts() as $vhost ) {
390 Util::replaceInFile( $bearsamppRoot->getVhostsPath() . '/' . $vhost . '.conf', array(
391 '/^<VirtualHost\s+([a-zA-Z0-9.*]+):(\d+)>$/' => '<VirtualHost {{1}}:' . $this->port . '>$'
392 ) );
393 }
394
395 // www .htaccess
396 Util::replaceInFile( $bearsamppRoot->getWwwPath() . '/.htaccess', array(
397 '/(.*)http:\/\/localhost(.*)/' => '{{1}}http://localhost' . ($this->port != 80 ? ':' . $this->port : '') . '/$1 [QSA,R=301,L]',
398 ) );
399
400 return true;
401 }
global $bearsamppBins
setVersion($version)
const BEARSAMPP_CONF_MALFORMED_ERROR
const APACHE_INCPT
const BEARSAMPP_CONF_NOT_FOUND_ERROR
const SWITCH_VERSION_TITLE
static replaceInFile($path, $replaceList)

References $bearsamppBins, Module\$bearsamppConf, Module\$bearsamppConfRaw, $bearsamppLang, $bearsamppRoot, $conf, Module\$version, Lang\APACHE_INCPT, Lang\BEARSAMPP_CONF_MALFORMED_ERROR, Lang\BEARSAMPP_CONF_NOT_FOUND_ERROR, getConf(), Module\getName(), Module\getVersion(), getVhosts(), Util\logDebug(), Util\logError(), Util\replaceInFile(), setVersion(), and Lang\SWITCH_VERSION_TITLE.

Referenced by switchVersion().

Field Documentation

◆ $accessLog

$accessLog
private

Definition at line 45 of file class.bin.apache.php.

Referenced by getAccessLog().

◆ $conf

$conf
private

Definition at line 50 of file class.bin.apache.php.

Referenced by getConf(), refreshConf(), and updateConfig().

◆ $errorLog

$errorLog
private

Definition at line 47 of file class.bin.apache.php.

Referenced by getErrorLog().

◆ $exe

$exe
private

Definition at line 49 of file class.bin.apache.php.

Referenced by getExe().

◆ $modulesPath

$modulesPath
private

Definition at line 43 of file class.bin.apache.php.

Referenced by getModulesPath().

◆ $opensslExe

$opensslExe
private

Definition at line 53 of file class.bin.apache.php.

Referenced by getOpensslExe().

◆ $port

$port
private

Definition at line 51 of file class.bin.apache.php.

Referenced by changePort(), checkPort(), getPort(), and setPort().

◆ $rewriteLog

$rewriteLog
private

Definition at line 46 of file class.bin.apache.php.

Referenced by getRewriteLog().

◆ $service

$service
private

Definition at line 42 of file class.bin.apache.php.

Referenced by getService().

◆ $sslConf

$sslConf
private

Definition at line 44 of file class.bin.apache.php.

Referenced by getSslConf(), and refreshConf().

◆ $sslPort

$sslPort
private

Definition at line 52 of file class.bin.apache.php.

Referenced by getSslPort(), and setSslPort().

◆ CMD_COMPILE_SETTINGS

const CMD_COMPILE_SETTINGS = '-V'

◆ CMD_COMPILED_MODULES

const CMD_COMPILED_MODULES = '-l'

◆ CMD_CONFIG_DIRECTIVES

const CMD_CONFIG_DIRECTIVES = '-L'

◆ CMD_LOADED_MODULES

const CMD_LOADED_MODULES = '-M'

◆ CMD_SYNTAX_CHECK

◆ CMD_VERSION_NUMBER

const CMD_VERSION_NUMBER = '-v'

◆ CMD_VHOSTS_SETTINGS

const CMD_VHOSTS_SETTINGS = '-S'

◆ LOCAL_CFG_CONF

const LOCAL_CFG_CONF = 'apacheConf'

Definition at line 26 of file class.bin.apache.php.

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'apacheExe'

Definition at line 25 of file class.bin.apache.php.

◆ LOCAL_CFG_OPENSSL_EXE

const LOCAL_CFG_OPENSSL_EXE = 'apacheOpensslExe'

Definition at line 29 of file class.bin.apache.php.

◆ LOCAL_CFG_PORT

const LOCAL_CFG_PORT = 'apachePort'

Definition at line 27 of file class.bin.apache.php.

◆ LOCAL_CFG_SSL_PORT

const LOCAL_CFG_SSL_PORT = 'apacheSslPort'

Definition at line 28 of file class.bin.apache.php.

◆ ROOT_CFG_ENABLE

const ROOT_CFG_ENABLE = 'apacheEnable'

Definition at line 22 of file class.bin.apache.php.

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'apacheVersion'

Definition at line 23 of file class.bin.apache.php.

◆ SERVICE_NAME

◆ SERVICE_PARAMS

const SERVICE_PARAMS = '-k runservice'

Definition at line 20 of file class.bin.apache.php.

◆ TAG_END_SWITCHONLINE

const TAG_END_SWITCHONLINE = '# END switchOnline tag - Do not replace!'

Definition at line 40 of file class.bin.apache.php.

◆ TAG_START_SWITCHONLINE

const TAG_START_SWITCHONLINE = '# START switchOnline tag - Do not replace!'

Definition at line 39 of file class.bin.apache.php.


The documentation for this class was generated from the following file: