2024.8.23
Loading...
Searching...
No Matches
BinApache Class Reference
+ Inheritance diagram for BinApache:
+ Collaboration 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 16 of file class.bin.apache.php.

Constructor & Destructor Documentation

◆ __construct()

BinApache::__construct ( $id,
$type )

Constructor for the BinApache class.

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

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

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

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

Member Function Documentation

◆ changePort()

BinApache::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 190 of file class.bin.apache.php.

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

BinApache::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 230 of file class.bin.apache.php.

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

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()

BinApache::getAccessLog ( )

Gets the access log file path.

Returns
string The access log file path.

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

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

References $accessLog.

◆ getAlias()

BinApache::getAlias ( )

Retrieves the list of alias configurations.

Returns
array The list of alias configurations.

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

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

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

Referenced by refreshAlias().

+ Here is the caller graph for this function:

◆ getAliasContent()

BinApache::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 708 of file class.bin.apache.php.

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

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

◆ getCmdLineOutput()

BinApache::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 618 of file class.bin.apache.php.

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

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

◆ getConf()

BinApache::getConf ( )

Gets the configuration file path.

Returns
string The configuration file path.

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

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

References $conf.

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

+ Here is the caller graph for this function:

◆ getErrorLog()

BinApache::getErrorLog ( )

Gets the error log file path.

Returns
string The error log file path.

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

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

References $errorLog.

◆ getExe()

BinApache::getExe ( )

Gets the executable file path.

Returns
string The executable file path.

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

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

References $exe.

Referenced by getCmdLineOutput().

+ Here is the caller graph for this function:

◆ getModules()

BinApache::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 407 of file class.bin.apache.php.

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

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

◆ getModulesFromConf()

BinApache::getModulesFromConf ( )

Retrieves the list of modules from the configuration file.

Returns
array The list of modules from the configuration file.

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

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

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

Referenced by getModules(), and getModulesLoaded().

+ Here is the caller graph for this function:

◆ getModulesFromFolder()

BinApache::getModulesFromFolder ( )
private

Retrieves the list of modules from the modules folder.

Returns
array The list of modules from the modules folder.

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

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

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

Referenced by getModules().

+ Here is the caller graph for this function:

◆ getModulesLoaded()

BinApache::getModulesLoaded ( )

Retrieves the list of loaded modules from the configuration file.

Returns
array The list of loaded modules.

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

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

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

◆ getModulesPath()

BinApache::getModulesPath ( )

Gets the path to the modules.

Returns
string The path to the modules.

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

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

References $modulesPath.

Referenced by getModulesFromFolder().

+ Here is the caller graph for this function:

◆ getOfflineContent()

BinApache::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 669 of file class.bin.apache.php.

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

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

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

+ Here is the caller graph for this function:

◆ getOnlineContent()

BinApache::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 646 of file class.bin.apache.php.

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

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

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

+ Here is the caller graph for this function:

◆ getOpensslExe()

BinApache::getOpensslExe ( )

Gets the OpenSSL executable file path.

Returns
string The OpenSSL executable file path.

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

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

References $opensslExe.

◆ getPort()

BinApache::getPort ( )

Gets the port number.

Returns
int The port number.

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

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

References $port.

Referenced by getVhostContent().

+ Here is the caller graph for this function:

◆ getRequiredContent()

BinApache::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 693 of file class.bin.apache.php.

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

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

Referenced by getAliasContent(), and getVhostContent().

+ Here is the caller graph for this function:

◆ getRewriteLog()

BinApache::getRewriteLog ( )

Gets the rewrite log file path.

Returns
string The rewrite log file path.

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

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

References $rewriteLog.

◆ getService()

BinApache::getService ( )

Gets the service associated with the module.

Returns
string The service associated with the module.

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

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

References $service.

◆ getSslConf()

BinApache::getSslConf ( )

Gets the SSL configuration file path.

Returns
string The SSL configuration file path.

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

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

References $sslConf.

Referenced by refreshConf().

+ Here is the caller graph for this function:

◆ getSslPort()

BinApache::getSslPort ( )

Gets the SSL port number.

Returns
int The SSL port number.

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

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

References $sslPort.

Referenced by getVhostContent().

+ Here is the caller graph for this function:

◆ getVhostContent()

BinApache::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 728 of file class.bin.apache.php.

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

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

◆ getVhosts()

BinApache::getVhosts ( )

Retrieves the list of virtual hosts configurations.

Returns
array The list of virtual hosts configurations.

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

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

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

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

+ Here is the caller graph for this function:

◆ getVhostsUrl()

BinApache::getVhostsUrl ( )

Retrieves the URLs of the virtual hosts.

Returns
array The list of virtual hosts URLs.

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

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

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

◆ getWwwDirectories()

BinApache::getWwwDirectories ( )

Retrieves the list of directories in the www folder.

Returns
array The list of directories in the www folder.

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

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

References $bearsamppRoot, and $result.

◆ refreshAlias()

BinApache::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 818 of file class.bin.apache.php.

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

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

◆ refreshConf()

BinApache::refreshConf ( $putOnline)

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

Parameters
bool$putOnlineWhether to put the configuration online.

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

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

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

◆ refreshVhosts()

BinApache::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 854 of file class.bin.apache.php.

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

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

◆ reload()

BinApache::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 72 of file class.bin.apache.php.

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

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(), LOCAL_CFG_CONF, LOCAL_CFG_EXE, LOCAL_CFG_OPENSSL_EXE, LOCAL_CFG_PORT, LOCAL_CFG_SSL_PORT, Util\logError(), Util\logInfo(), Util\logReloadClass(), and Nssm\SERVICE_DEMAND_START.

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

+ Here is the caller graph for this function:

◆ replaceAll()

BinApache::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 161 of file class.bin.apache.php.

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

References LOCAL_CFG_PORT, and LOCAL_CFG_SSL_PORT.

◆ setEnable()

BinApache::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 892 of file class.bin.apache.php.

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

BinApache::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 1032 of file class.bin.apache.php.

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

References $port, and Module\replace().

Referenced by changePort().

+ Here is the caller graph for this function:

◆ setSslPort()

BinApache::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 1054 of file class.bin.apache.php.

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

References $sslPort, and Module\replace().

◆ setVersion()

BinApache::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 927 of file class.bin.apache.php.

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

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

Referenced by updateConfig().

+ Here is the caller graph for this function:

◆ switchVersion()

BinApache::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 285 of file class.bin.apache.php.

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

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

◆ updateConfig()

BinApache::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 301 of file class.bin.apache.php.

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

References $bearsamppBins, Module\$bearsamppConf, Module\$bearsamppConfRaw, $bearsamppLang, $bearsamppRoot, $conf, $port, 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().

+ Here is the caller graph for this function:

Field Documentation

◆ $accessLog

BinApache::$accessLog
private

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

Referenced by getAccessLog().

◆ $conf

BinApache::$conf
private

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

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

◆ $errorLog

BinApache::$errorLog
private

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

Referenced by getErrorLog().

◆ $exe

BinApache::$exe
private

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

Referenced by getExe().

◆ $modulesPath

BinApache::$modulesPath
private

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

Referenced by getModulesPath().

◆ $opensslExe

BinApache::$opensslExe
private

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

Referenced by getOpensslExe().

◆ $port

BinApache::$port
private

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

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

◆ $rewriteLog

BinApache::$rewriteLog
private

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

Referenced by getRewriteLog().

◆ $service

BinApache::$service
private

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

Referenced by getService().

◆ $sslConf

BinApache::$sslConf
private

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

Referenced by getSslConf(), and refreshConf().

◆ $sslPort

BinApache::$sslPort
private

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

Referenced by getSslPort(), and setSslPort().

◆ CMD_COMPILE_SETTINGS

const BinApache::CMD_COMPILE_SETTINGS = '-V'

◆ CMD_COMPILED_MODULES

const BinApache::CMD_COMPILED_MODULES = '-l'

◆ CMD_CONFIG_DIRECTIVES

const BinApache::CMD_CONFIG_DIRECTIVES = '-L'

◆ CMD_LOADED_MODULES

const BinApache::CMD_LOADED_MODULES = '-M'

◆ CMD_SYNTAX_CHECK

◆ CMD_VERSION_NUMBER

const BinApache::CMD_VERSION_NUMBER = '-v'

◆ CMD_VHOSTS_SETTINGS

const BinApache::CMD_VHOSTS_SETTINGS = '-S'

◆ LOCAL_CFG_CONF

const BinApache::LOCAL_CFG_CONF = 'apacheConf'

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

Referenced by reload().

◆ LOCAL_CFG_EXE

const BinApache::LOCAL_CFG_EXE = 'apacheExe'

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

Referenced by reload().

◆ LOCAL_CFG_OPENSSL_EXE

const BinApache::LOCAL_CFG_OPENSSL_EXE = 'apacheOpensslExe'

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

Referenced by reload().

◆ LOCAL_CFG_PORT

const BinApache::LOCAL_CFG_PORT = 'apachePort'

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

Referenced by reload(), and replaceAll().

◆ LOCAL_CFG_SSL_PORT

const BinApache::LOCAL_CFG_SSL_PORT = 'apacheSslPort'

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

Referenced by reload(), and replaceAll().

◆ ROOT_CFG_ENABLE

const BinApache::ROOT_CFG_ENABLE = 'apacheEnable'

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

◆ ROOT_CFG_VERSION

const BinApache::ROOT_CFG_VERSION = 'apacheVersion'

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

◆ SERVICE_NAME

◆ SERVICE_PARAMS

const BinApache::SERVICE_PARAMS = '-k runservice'

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

◆ TAG_END_SWITCHONLINE

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

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

Referenced by getOfflineContent(), and getOnlineContent().

◆ TAG_START_SWITCHONLINE

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

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


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