Bearsampp 2026.9.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 ()
 getId ()
 getName ()
 getRelease ()
 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
 $currentPath
 $rootPath
 $symlinkPath

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

Static Public Member Functions inherited from Module
static clearMemoryCache ()
static invalidateConfigCacheForPath ($sourcePath)
Protected Attributes inherited from Module
 $bearsamppConf
 $bearsamppConfRaw
 $enable
 $name
 $release = 'N/A'
 $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 148 of file class.bin.apache.php.

149 {
150 Log::initClass($this);
151 $this->reload($id, $type);
152 }
reload($id=null, $type=null)
static initClass($classInstance)

References Module\$id, Module\$type, Log\initClass(), and reload().

Here is the call graph for this function:

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 281 of file class.bin.apache.php.

282 {
283 global $bearsamppWinbinder;
284
285 if (!Util::isValidPort($port)) {
286 Log::error($this->getName() . ' port not valid: ' . $port);
287
288 return false;
289 }
290
291 $port = intval($port);
292 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
293
294 $isPortInUse = ServiceHelper::isPortInUse($port);
295 if (!$checkUsed || $isPortInUse === false) {
296 // bearsampp.conf
297 $this->setPort($port);
298 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
299
300 // conf
301 $this->update();
302 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
303
304 return true;
305 }
306
307 Log::debug($this->getName() . ' port in used: ' . $port . ' - ' . $isPortInUse);
308
309 return $isPortInUse;
310 }
static debug($data, $file=null)
static error($data, $file=null)
update($sub=0, $showWindow=false)
static isPortInUse($port)
static isValidPort($port)

References $port, Log\debug(), Log\error(), Module\getName(), ServiceHelper\isPortInUse(), Util\isValidPort(), setPort(), and Module\update().

Here is the call graph for this function:

◆ 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 321 of file class.bin.apache.php.

322 {
323 global $bearsamppLang, $bearsamppWinbinder;
324 $boxTitle = sprintf($bearsamppLang->getValue(Lang::CHECK_PORT_TITLE), $this->getName(), $port);
325
326 if (!Util::isValidPort($port)) {
327 Log::error($this->getName() . ' port not valid: ' . $port);
328
329 return false;
330 }
331
332 // $verify = false: this pings the app's own Apache on localhost, which uses a local
333 // self-signed certificate. Certificate verification stays on for all remote fetches.
334 $headers = HttpClient::getHttpHeaders('http' . ($ssl ? 's' : '') . '://localhost:' . $port . '/' . Path::getWebResourcesPath() . '/ping.php', false);
335 if (!empty($headers)) {
336 foreach ($headers as $row) {
337 if (UtilString::startWith($row, 'Server: ') || UtilString::startWith($row, 'server: ')) {
339 $this->getName() . ' port ' . $port . ' is used by: ' . $this->getName() . ' ' . str_replace('Server: ', '', str_replace('server: ', '', trim($row)))
340 );
341 if ($showWindow) {
342 $bearsamppWinbinder->messageBoxInfo(
343 sprintf($bearsamppLang->getValue(Lang::PORT_USED_BY), $port, str_replace('Server: ', '', str_replace('server: ', '', trim($row)))),
344 $boxTitle
345 );
346 }
347
348 return true;
349 }
350 }
351 Log::debug($this->getName() . ' port ' . $port . ' is used by another application');
352 if ($showWindow) {
353 $bearsamppWinbinder->messageBoxWarning(
354 sprintf($bearsamppLang->getValue(Lang::PORT_NOT_USED_BY), $port),
355 $boxTitle
356 );
357 }
358 } else {
359 Log::debug($this->getName() . ' port ' . $port . ' is not used');
360 if ($showWindow) {
361 $bearsamppWinbinder->messageBoxError(
362 sprintf($bearsamppLang->getValue(Lang::PORT_NOT_USED), $port),
363 $boxTitle
364 );
365 }
366 }
367
368 return false;
369 }
global $bearsamppLang
static getHttpHeaders($pingUrl, $verify=true)
const PORT_NOT_USED
const PORT_NOT_USED_BY
const CHECK_PORT_TITLE
const PORT_USED_BY
static getWebResourcesPath()
static startWith($string, $search)

References $bearsamppLang, $port, Lang\CHECK_PORT_TITLE, Log\debug(), Log\error(), HttpClient\getHttpHeaders(), Module\getName(), Path\getWebResourcesPath(), Util\isValidPort(), Lang\PORT_NOT_USED, Lang\PORT_NOT_USED_BY, Lang\PORT_USED_BY, and UtilString\startWith().

Here is the call graph for this function:

◆ getAccessLog()

getAccessLog ( )

Gets the access log file path.

Returns
string The access log file path.

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

1067 {
1068 return $this->accessLog;
1069 }

References $accessLog.

◆ getAlias()

getAlias ( )

Retrieves the list of alias configurations.

Returns
array The list of alias configurations.

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

609 {
610 global $bearsamppRoot;
611 $result = array();
612
613 $handle = @opendir(Path::getAliasPath());
614 if (!$handle) {
615 return $result;
616 }
617
618 while (false !== ($file = readdir($handle))) {
619 if ($file != '.' && $file != '..' && UtilString::endWith($file, '.conf')) {
620 $result[] = str_replace('.conf', '', $file);
621 }
622 }
623
624 closedir($handle);
625 ksort($result);
626
627 return $result;
628 }
$result
global $bearsamppRoot
static getAliasPath($aetrayPath=false)
static endWith($string, $search)

References $bearsamppRoot, $result, UtilString\endWith(), and Path\getAliasPath().

Referenced by refreshAlias().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 809 of file class.bin.apache.php.

810 {
811 $dest = Path::formatUnixPath($dest);
812
813 return 'Alias /' . $name . ' "' . $dest . '"' . PHP_EOL . PHP_EOL .
814 '<Directory "' . $dest . '">' . PHP_EOL .
815 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
816 ' AllowOverride all' . PHP_EOL .
817 $this->getRequiredContent() . PHP_EOL .
818 '</Directory>' . PHP_EOL;
819 }
getRequiredContent($version=null)
static formatUnixPath($path)

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

Here is the call graph for this function:

◆ 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 721 of file class.bin.apache.php.

722 {
723 $result = array(
724 'syntaxOk' => false,
725 'content' => null,
726 );
727
728 if (file_exists($this->getExe())) {
729 $tmpResult = Batch::exec('apacheGetCmdLineOutput', '"' . $this->getExe() . '" ' . $cmd);
730 if ($tmpResult !== false && is_array($tmpResult)) {
731 $result['syntaxOk'] = trim($tmpResult[count($tmpResult) - 1]) == 'Syntax OK';
732 if ($result['syntaxOk']) {
733 unset($tmpResult[count($tmpResult) - 1]);
734 }
735 $result['content'] = implode(PHP_EOL, $tmpResult);
736 }
737 }
738
739 return $result;
740 }
static exec($basename, $content, $timeout=true, $catchOutput=true, $standalone=false, $silent=true, $rebuild=true)

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

Here is the call graph for this function:

◆ getConf()

getConf ( )

Gets the configuration file path.

Returns
string The configuration file path.

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

1107 {
1108 return $this->conf;
1109 }

References $conf.

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

Here is the caller graph for this function:

◆ getErrorLog()

getErrorLog ( )

Gets the error log file path.

Returns
string The error log file path.

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

1087 {
1088 return $this->errorLog;
1089 }

References $errorLog.

◆ getExe()

getExe ( )

Gets the executable file path.

Returns
string The executable file path.

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

1097 {
1098 return $this->exe;
1099 }

References $exe.

Referenced by getCmdLineOutput().

Here is the caller graph for this function:

◆ 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 511 of file class.bin.apache.php.

512 {
513 $fromFolder = $this->getModulesFromFolder();
514 $fromConf = $this->getModulesFromConf();
515 $result = array_merge($fromFolder, $fromConf);
516 ksort($result);
517
518 return $result;
519 }

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

Here is the call graph for this function:

◆ getModulesFromConf()

getModulesFromConf ( )

Retrieves the list of modules from the configuration file.

Returns
array The list of modules from the configuration file.

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

527 {
528 $result = array();
529
530 if (!$this->enable) {
531 return $result;
532 }
533
534 $confContent = file($this->getConf());
535 foreach ($confContent as $row) {
536 $modMatch = array();
537 if (preg_match('/^(#)?LoadModule\s*([a-z0-9_-]+)\s*"?(.*)"?/i', $row, $modMatch)) {
538 $name = $modMatch[2];
539 //$path = $modMatch[3];
540 if (!UtilString::startWith($name, 'php')) {
541 if ($modMatch[1] == '#') {
543 } else {
545 }
546 }
547 }
548 }
549
550 ksort($result);
551
552 return $result;
553 }

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

Referenced by getModules(), and getModulesLoaded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 577 of file class.bin.apache.php.

578 {
579 $result = array();
580
581 if (!$this->enable) {
582 return $result;
583 }
584
585 $handle = @opendir($this->getModulesPath());
586 if (!$handle) {
587 return $result;
588 }
589
590 while (false !== ($file = readdir($handle))) {
591 if ($file != '.' && $file != '..' && UtilString::startWith($file, 'mod_') && (UtilString::endWith($file, '.so') || UtilString::endWith($file, '.dll'))) {
592 $name = str_replace(array('mod_', '.so', '.dll'), '', $file) . '_module';
594 }
595 }
596
597 closedir($handle);
598 ksort($result);
599
600 return $result;
601 }

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

Referenced by getModules().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getModulesLoaded()

getModulesLoaded ( )

Retrieves the list of loaded modules from the configuration file.

Returns
array The list of loaded modules.

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

561 {
562 $result = array();
563 foreach ($this->getModulesFromConf() as $name => $status) {
565 $result[] = $name;
566 }
567 }
568
569 return $result;
570 }

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

Here is the call graph for this function:

◆ getModulesPath()

getModulesPath ( )

Gets the path to the modules.

Returns
string The path to the modules.

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

1047 {
1048 return $this->modulesPath;
1049 }

References $modulesPath.

Referenced by getModulesFromFolder().

Here is the caller graph for this function:

◆ 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 771 of file class.bin.apache.php.

772 {
773 $version = $version != null ? $version : $this->getVersion();
774 $result = self::TAG_START_SWITCHONLINE . PHP_EOL;
775
776 if (UtilString::startWith($version, '2.4')) {
777 $result .= 'Require local' . PHP_EOL;
778 } else {
779 $result .= 'Order Deny,Allow' . PHP_EOL .
780 'Deny from all' . PHP_EOL .
781 'Allow from ' . APP_LOCALHOST . ' ::1' . PHP_EOL;
782 }
783
784 return $result . self::TAG_END_SWITCHONLINE;
785 }
const APP_LOCALHOST
Definition root.php:21

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 749 of file class.bin.apache.php.

750 {
751 $version = $version != null ? $version : $this->getVersion();
752 $result = self::TAG_START_SWITCHONLINE . PHP_EOL;
753
754 if (UtilString::startWith($version, '2.4')) {
755 $result .= 'Require all granted' . PHP_EOL;
756 } else {
757 $result .= 'Order Allow,Deny' . PHP_EOL .
758 'Allow from all' . PHP_EOL;
759 }
760
761 return $result . self::TAG_END_SWITCHONLINE;
762 }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOpensslExe()

getOpensslExe ( )

Gets the OpenSSL executable file path.

Returns
string The OpenSSL executable file path.

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

1161 {
1162 return $this->opensslExe;
1163 }

References $opensslExe.

◆ getPort()

getPort ( )

Gets the port number.

Returns
int The port number.

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

1117 {
1118 return $this->port;
1119 }

References $port.

Referenced by getVhostContent().

Here is the caller graph for this function:

◆ 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 794 of file class.bin.apache.php.

795 {
796 global $bearsamppConfig;
797
798 return $bearsamppConfig->isOnline() ? $this->getOnlineContent($version) : $this->getOfflineContent($version);
799 }
getOnlineContent($version=null)
getOfflineContent($version=null)
global $bearsamppConfig
Definition homepage.php:46

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

Referenced by getAliasContent(), and getVhostContent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRewriteLog()

getRewriteLog ( )

Gets the rewrite log file path.

Returns
string The rewrite log file path.

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

1077 {
1078 return $this->rewriteLog;
1079 }

References $rewriteLog.

◆ getService()

getService ( )

Gets the service associated with the module.

Returns
string The service associated with the module.

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

1037 {
1038 return $this->service;
1039 }

References $service.

◆ getSslConf()

getSslConf ( )

Gets the SSL configuration file path.

Returns
string The SSL configuration file path.

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

1057 {
1058 return $this->sslConf;
1059 }

References $sslConf.

Referenced by refreshConf().

Here is the caller graph for this function:

◆ getSslPort()

getSslPort ( )

Gets the SSL port number.

Returns
int The SSL port number.

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

1139 {
1140 return $this->sslPort;
1141 }

References $sslPort.

Referenced by getVhostContent().

Here is the caller graph for this function:

◆ 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 829 of file class.bin.apache.php.

830 {
831 global $bearsamppRoot;
832
833 $documentRoot = Path::formatUnixPath($documentRoot);
834
835 return '<VirtualHost *:' . $this->getPort() . '>' . PHP_EOL .
836 ' ServerAdmin webmaster@' . $serverName . PHP_EOL .
837 ' DocumentRoot "' . $documentRoot . '"' . PHP_EOL .
838 ' ServerName ' . $serverName . PHP_EOL .
839 ' ErrorLog "' . Path::getLogsPath() . '/' . $serverName . '_error.log"' . PHP_EOL .
840 ' CustomLog "' . Path::getLogsPath() . '/' . $serverName . '_access.log" combined' . PHP_EOL . PHP_EOL .
841 ' <Directory "' . $documentRoot . '">' . PHP_EOL .
842 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
843 ' AllowOverride all' . PHP_EOL .
844 $this->getRequiredContent() . PHP_EOL .
845 ' </Directory>' . PHP_EOL .
846 '</VirtualHost>' . PHP_EOL . PHP_EOL .
847 '<IfModule ssl_module>' . PHP_EOL .
848 '<VirtualHost *:' . $this->getSslPort() . '> #SSL' . PHP_EOL .
849 ' DocumentRoot "' . $documentRoot . '"' . PHP_EOL .
850 ' ServerName ' . $serverName . PHP_EOL .
851 ' ServerAdmin webmaster@' . $serverName . PHP_EOL .
852 ' ErrorLog "' . Path::getLogsPath() . '/' . $serverName . '_error.log"' . PHP_EOL .
853 ' TransferLog "' . Path::getLogsPath() . '/' . $serverName . '_access.log"' . PHP_EOL . PHP_EOL .
854 ' SSLEngine on' . PHP_EOL .
855 ' SSLProtocol all -SSLv2' . PHP_EOL .
856 ' SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5' . PHP_EOL .
857 ' SSLCertificateFile "' . Path::getSslPath() . '/' . $serverName . '.crt"' . PHP_EOL .
858 ' SSLCertificateKeyFile "' . Path::getSslPath() . '/' . $serverName . '.ppk"' . PHP_EOL .
859 ' BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0' . PHP_EOL .
860 ' CustomLog "' . Path::getLogsPath() . '/' . $serverName . '_sslreq.log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"' . PHP_EOL . PHP_EOL .
861 ' <Directory "' . $documentRoot . '">' . PHP_EOL .
862 ' SSLOptions +StdEnvVars' . PHP_EOL .
863 ' Options Indexes FollowSymLinks MultiViews' . PHP_EOL .
864 ' AllowOverride all' . PHP_EOL .
865 $this->getRequiredContent() . PHP_EOL .
866 ' </Directory>' . PHP_EOL .
867 '</VirtualHost>' . PHP_EOL .
868 '</IfModule>' . PHP_EOL;
869 }
static getSslPath($aetrayPath=false)
static getLogsPath($aetrayPath=false)

References $bearsamppRoot, Path\formatUnixPath(), Path\getLogsPath(), getPort(), getRequiredContent(), Path\getSslPath(), and getSslPort().

Here is the call graph for this function:

◆ getVhosts()

getVhosts ( )

Retrieves the list of virtual hosts configurations.

Returns
array The list of virtual hosts configurations.

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

636 {
637 global $bearsamppRoot;
638 $result = array();
639
640 $handle = @opendir(Path::getVhostsPath());
641 if (!$handle) {
642 return $result;
643 }
644
645 while (false !== ($file = readdir($handle))) {
646 if ($file != '.' && $file != '..' && UtilString::endWith($file, '.conf')) {
647 $result[] = str_replace('.conf', '', $file);
648 }
649 }
650
651 closedir($handle);
652 ksort($result);
653
654 return $result;
655 }
static getVhostsPath($aetrayPath=false)

References $bearsamppRoot, $result, UtilString\endWith(), and Path\getVhostsPath().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVhostsUrl()

getVhostsUrl ( )

Retrieves the URLs of the virtual hosts.

Returns
array The list of virtual hosts URLs.

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

663 {
664 global $bearsamppRoot;
665 $result = array();
666
667 foreach ($this->getVhosts() as $vhost) {
668 $vhostContent = file(Path::getVhostsPath() . '/' . $vhost . '.conf');
669 foreach ($vhostContent as $vhostLine) {
670 $vhostLine = trim($vhostLine);
671 $enabled = !UtilString::startWith($vhostLine, '#');
672 if (preg_match_all('/ServerName\s+(.*)/', $vhostLine, $matches)) {
673 foreach ($matches as $match) {
674 $found = isset($match[1]) ? trim($match[1]) : trim($match[0]);
675 if (filter_var('http://' . $found, FILTER_VALIDATE_URL) !== false) {
676 $result[$found] = $enabled;
677 break 2;
678 }
679 }
680 }
681 }
682 }
683
684 return $result;
685 }

References $bearsamppRoot, $result, getVhosts(), Path\getVhostsPath(), and UtilString\startWith().

Here is the call graph for this function:

◆ getWwwDirectories()

getWwwDirectories ( )

Retrieves the list of directories in the www folder.

Returns
array The list of directories in the www folder.

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

693 {
694 global $bearsamppRoot;
695 $result = array();
696
697 $handle = @opendir(Path::getWwwPath());
698 if (!$handle) {
699 return $result;
700 }
701
702 while (false !== ($file = readdir($handle))) {
703 if ($file != '.' && $file != '..' && is_dir(Path::getWwwPath() . '/' . $file)) {
704 $result[] = $file;
705 }
706 }
707
708 closedir($handle);
709 ksort($result);
710
711 return $result;
712 }
static getWwwPath($aetrayPath=false)

References $bearsamppRoot, $result, and Path\getWwwPath().

Here is the call graph for this function:

◆ 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 917 of file class.bin.apache.php.

918 {
920
921 if (!$this->enable) {
922 return;
923 }
924
925 $onlineContent = $this->getOnlineContent();
926 $offlineContent = $this->getOfflineContent();
927
928 foreach ($this->getAlias() as $alias) {
929 $aliasConf = file_get_contents(Path::getAliasPath() . '/' . $alias . '.conf');
930 Log::trace('refreshAlias ' . Path::getAliasPath() . '/' . $alias . '.conf');
931 preg_match('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $aliasConf, $matches);
932 Log::trace(isset($matches[1]) ? print_r($matches[1], true) : 'N/A');
933
934 if ($putOnline) {
935 $aliasConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $aliasConf, -1, $count);
936 } else {
937 $aliasConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $aliasConf, -1, $count);
938 }
939 file_put_contents(Path::getAliasPath() . '/' . $alias . '.conf', $aliasConf);
940 Log::debug('Refresh ' . Path::getAliasPath() . '/' . $alias . '.conf: ' . $count . ' occurrence(s) replaced');
941 }
942
943 // Homepage
944 $bearsamppHomepage->refreshAliasContent();
945 }
static trace($data, $file=null)
global $bearsamppHomepage
Definition homepage.php:46

References $bearsamppHomepage, $bearsamppRoot, Log\debug(), getAlias(), Path\getAliasPath(), getOfflineContent(), getOnlineContent(), and Log\trace().

Here is the call graph for this function:

◆ 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 876 of file class.bin.apache.php.

877 {
878 if (!$this->enable) {
879 return;
880 }
881
882 $onlineContent = $this->getOnlineContent();
883 $offlineContent = $this->getOfflineContent();
884
885 $conf = file_get_contents($this->getConf());
886 Log::trace('refreshConf ' . $this->getConf());
887 preg_match('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $conf, $matches);
888 Log::trace(isset($matches[1]) ? print_r($matches[1], true) : 'N/A');
889
890 if ($putOnline) {
891 $conf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $conf, -1, $count);
892 } else {
893 $conf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $conf, -1, $count);
894 }
895 file_put_contents($this->getConf(), $conf);
896 Log::debug('Refresh ' . $this->getConf() . ': ' . $count . ' occurrence(s) replaced');
897
898 $sslConf = file_get_contents($this->getSslConf());
899 Log::trace('refreshConf ' . $this->getSslConf());
900 preg_match('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $sslConf, $matches);
901 Log::trace(isset($matches[1]) ? print_r($matches[1], true) : 'N/A');
902
903 if ($putOnline) {
904 $sslConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $sslConf, -1, $count);
905 } else {
906 $sslConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $sslConf, -1, $count);
907 }
908 file_put_contents($this->getSslConf(), $sslConf);
909 Log::debug('Refresh ' . $this->getSslConf() . ': ' . $count . ' occurrence(s) replaced');
910 }

References $conf, $sslConf, Log\debug(), getConf(), getOfflineContent(), getOnlineContent(), getSslConf(), and Log\trace().

Here is the call graph for this function:

◆ 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 952 of file class.bin.apache.php.

953 {
954 global $bearsamppRoot;
955
956 if (!$this->enable) {
957 return;
958 }
959
960 $onlineContent = $this->getOnlineContent();
961 $offlineContent = $this->getOfflineContent();
962
963 foreach ($this->getVhosts() as $vhost) {
964 $vhostConf = file_get_contents(Path::getVhostsPath() . '/' . $vhost . '.conf');
965 Log::trace('refreshVhost ' . Path::getVhostsPath() . '/' . $vhost . '.conf');
966 preg_match('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $vhostConf, $matches);
967 Log::trace(isset($matches[1]) ? print_r($matches[1], true) : 'N/A');
968
969 if ($putOnline) {
970 $vhostConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $onlineContent, $vhostConf, -1, $count);
971 } else {
972 $vhostConf = preg_replace('/' . self::TAG_START_SWITCHONLINE . '(.*?)' . self::TAG_END_SWITCHONLINE . '/s', $offlineContent, $vhostConf, -1, $count);
973 }
974 file_put_contents(Path::getVhostsPath() . '/' . $vhost . '.conf', $vhostConf);
975 Log::debug('Refresh ' . Path::getVhostsPath() . '/' . $vhost . '.conf: ' . $count . ' occurrence(s) replaced');
976 }
977 }

References $bearsamppRoot, Log\debug(), getOfflineContent(), getOnlineContent(), getVhosts(), Path\getVhostsPath(), and Log\trace().

Here is the call graph for this function:

◆ 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 160 of file class.bin.apache.php.

161 {
163 Log::reloadClass($this);
164
165 $this->name = $bearsamppLang->getValue(Lang::APACHE);
166 $this->version = $bearsamppConfig->getRaw(self::ROOT_CFG_VERSION);
167 parent::reload($id, $type);
168
169 $this->enable = $this->enable && $bearsamppConfig->getRaw(self::ROOT_CFG_ENABLE);
170 $this->service = new Win32Service(self::SERVICE_NAME);
171 $this->modulesPath = $this->symlinkPath . '/modules';
172 $this->sslConf = $this->symlinkPath . '/conf/extra/httpd-ssl.conf';
173 $this->accessLog = Path::getLogsPath() . '/apache_access.log';
174 $this->rewriteLog = Path::getLogsPath() . '/apache_rewrite.log';
175 $this->errorLog = Path::getLogsPath() . '/apache_error.log';
176
177 if ($this->bearsamppConfRaw !== false) {
178 $this->exe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
179 $this->conf = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
180 $this->port = $this->bearsamppConfRaw[self::LOCAL_CFG_PORT];
181 $this->sslPort = $this->bearsamppConfRaw[self::LOCAL_CFG_SSL_PORT];
182 $this->opensslExe = $this->symlinkPath . '/' . $this->bearsamppConfRaw[self::LOCAL_CFG_OPENSSL_EXE];
183 }
184
185 if (!$this->enable) {
186 Log::info($this->name . ' is not enabled!');
187
188 return;
189 }
190 if (!is_dir($this->currentPath)) {
191 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
192
193 return;
194 }
195 if (!is_dir($this->symlinkPath)) {
196 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
197
198 return;
199 }
200 if (!is_file($this->bearsamppConf)) {
201 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
202
203 return;
204 }
205 if (!is_file($this->sslConf)) {
206 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->sslConf));
207
208 return;
209 }
210 if (!is_file($this->exe)) {
211 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->exe));
212
213 return;
214 }
215 if (!is_file($this->conf)) {
216 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
217
218 return;
219 }
220 if (!is_numeric($this->port) || $this->port <= 0) {
221 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_PORT, $this->port));
222
223 return;
224 }
225 if (!is_numeric($this->sslPort) || $this->sslPort <= 0) {
226 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_INVALID_PARAMETER), self::LOCAL_CFG_SSL_PORT, $this->sslPort));
227
228 return;
229 }
230 if (!is_file($this->opensslExe)) {
231 Log::error(sprintf($bearsamppLang->getValue(Lang::ERROR_EXE_NOT_FOUND), $this->name . ' ' . $this->version, $this->opensslExe));
232
233 return;
234 }
235
236 $nssm = new Nssm(self::SERVICE_NAME);
237 $nssm->setDisplayName(APP_TITLE . ' ' . $this->getName());
238 $nssm->setBinPath($this->exe);
239 $nssm->setParams('');
240 $nssm->setStart(Nssm::SERVICE_DEMAND_START);
241
242 $this->service->setNssm($nssm);
243 }
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const APACHE
const ERROR_INVALID_PARAMETER
const ERROR_FILE_NOT_FOUND
static info($data, $file=null)
static reloadClass($classInstance)
const SERVICE_DEMAND_START
const APP_TITLE
Definition root.php:19

References $bearsamppConfig, $bearsamppLang, $bearsamppRoot, Module\$id, Module\$type, Lang\APACHE, APP_TITLE, Log\error(), Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_EXE_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Lang\ERROR_INVALID_PARAMETER, Path\getLogsPath(), Module\getName(), Log\info(), Log\reloadClass(), and Nssm\SERVICE_DEMAND_START.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 250 of file class.bin.apache.php.

251 {
252 $content = file_get_contents($this->bearsamppConf);
253
254 foreach ($params as $key => $value) {
255 $content = preg_replace('|' . $key . ' = .*|', $key . ' = ' . '"' . $value . '"', $content);
256 $this->bearsamppConfRaw[$key] = $value;
257 switch ($key) {
258 case self::LOCAL_CFG_PORT:
259 $this->port = $value;
260 break;
261 case self::LOCAL_CFG_SSL_PORT:
262 $this->sslPort = $value;
263 break;
264 }
265 }
266
267 file_put_contents($this->bearsamppConf, $content);
268
269 self::invalidateConfigCacheForPath($this->bearsamppConf);
270 }
static invalidateConfigCacheForPath($sourcePath)

References Module\invalidateConfigCacheForPath().

Here is the call graph for this function:

◆ 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 989 of file class.bin.apache.php.

990 {
991 global $bearsamppConfig, $bearsamppLang, $bearsamppWinbinder;
992
993 if ($enabled == Config::ENABLED && !is_dir($this->currentPath)) {
994 Log::debug($this->getName() . ' cannot be enabled because bundle ' . $this->getVersion() . ' does not exist in ' . $this->currentPath);
995 if ($showWindow) {
996 $bearsamppWinbinder->messageBoxError(
997 sprintf($bearsamppLang->getValue(Lang::ENABLE_BUNDLE_NOT_EXIST), $this->getName(), $this->getVersion(), $this->currentPath),
998 sprintf($bearsamppLang->getValue(Lang::ENABLE_TITLE), $this->getName())
999 );
1000 }
1001 $enabled = Config::DISABLED;
1002 }
1003
1004 Log::info($this->getName() . ' switched to ' . ($enabled == Config::ENABLED ? 'enabled' : 'disabled'));
1005 $this->enable = $enabled == Config::ENABLED;
1006 $bearsamppConfig->replace(self::ROOT_CFG_ENABLE, $enabled);
1007
1008 $this->reload();
1009 if ($this->enable) {
1010 ServiceHelper::installService($this, $this->port, self::CMD_SYNTAX_CHECK, $showWindow);
1011 } else {
1012 ServiceHelper::removeService($this->service, $this->name);
1013 }
1014 }
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, Log\debug(), Config\DISABLED, Lang\ENABLE_BUNDLE_NOT_EXIST, Lang\ENABLE_TITLE, Config\ENABLED, Module\getName(), Module\getVersion(), Log\info(), ServiceHelper\installService(), reload(), and ServiceHelper\removeService().

Here is the call graph for this function:

◆ 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 1128 of file class.bin.apache.php.

1129 {
1130 $this->replace(self::LOCAL_CFG_PORT, $port);
1131 }
replace($key, $value)

References $port, and Module\replace().

Referenced by changePort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 1150 of file class.bin.apache.php.

1151 {
1152 $this->replace(self::LOCAL_CFG_SSL_PORT, $sslPort);
1153 }

References $sslPort, and Module\replace().

Here is the call graph for this function:

◆ 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 1023 of file class.bin.apache.php.

1024 {
1025 global $bearsamppConfig;
1026 $this->version = $version;
1027 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
1028 $this->reload();
1029 }

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

Referenced by updateConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 379 of file class.bin.apache.php.

380 {
381 Log::debug('Switch ' . $this->name . ' version to ' . $version);
382
383 return $this->updateConfig($version, 0, $showWindow);
384 }
updateConfig($version=null, $sub=0, $showWindow=false)

References Module\$version, Log\debug(), and updateConfig().

Here is the call graph for this function:

◆ 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 395 of file class.bin.apache.php.

396 {
397 global $bearsamppRoot, $bearsamppLang, $bearsamppBins, $bearsamppWinbinder;
398
399 if (!$this->enable) {
400 return true;
401 }
402
403 $version = $version == null ? $this->version : $version;
404 Log::debug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'Update ' . $this->name . ' ' . $version . ' config');
405
406 $boxTitle = sprintf($bearsamppLang->getValue(Lang::SWITCH_VERSION_TITLE), $this->getName(), $version);
407
408 $conf = str_replace('apache' . $this->getVersion(), 'apache' . $version, $this->getConf());
409 $bearsamppConf = str_replace('apache' . $this->getVersion(), 'apache' . $version, $this->bearsamppConf);
410
411 $tsDll = $bearsamppBins->getPhp()->getTsDll();
412
413 $apachePhpModuleName = null;
414 if ($tsDll !== false) {
415 $apachemoduleNamePrefix = substr($tsDll, 0, 4);
416 $apachePhpModuleName = ($apachemoduleNamePrefix == 'php8' ? 'php' : $apachemoduleNamePrefix) . '_module';
417 }
418 $apachePhpModulePath = $bearsamppBins->getPhp()->getApacheModule($version);
419 $apachePhpModuleDll = basename($apachePhpModulePath);
420
421 Log::debug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'PHP TsDll found: ' . $tsDll);
422 Log::debug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'PHP Apache module found: ' . $apachePhpModulePath);
423
424 if (!file_exists($conf) || !file_exists($bearsamppConf)) {
425 Log::error('bearsampp config files not found for ' . $this->getName() . ' ' . $version);
426 if ($showWindow) {
427 $bearsamppWinbinder->messageBoxError(
428 sprintf($bearsamppLang->getValue(Lang::BEARSAMPP_CONF_NOT_FOUND_ERROR), $this->getName() . ' ' . $version),
429 $boxTitle
430 );
431 }
432
433 return false;
434 }
435
436 $bearsamppConfRaw = parse_ini_file($bearsamppConf);
437 if ($bearsamppConfRaw === false || !isset($bearsamppConfRaw[self::ROOT_CFG_VERSION]) || $bearsamppConfRaw[self::ROOT_CFG_VERSION] != $version) {
438 Log::error('bearsampp config file malformed for ' . $this->getName() . ' ' . $version);
439 if ($showWindow) {
440 $bearsamppWinbinder->messageBoxError(
441 sprintf($bearsamppLang->getValue(Lang::BEARSAMPP_CONF_MALFORMED_ERROR), $this->getName() . ' ' . $version),
442 $boxTitle
443 );
444 }
445
446 return false;
447 }
448
449 if ($tsDll === false || $apachePhpModulePath === false) {
450 Log::debug($this->getName() . ' ' . $version . ' does not seem to be compatible with PHP ' . $bearsamppBins->getPhp()->getVersion());
451 if ($showWindow) {
452 $bearsamppWinbinder->messageBoxError(
453 sprintf($bearsamppLang->getValue(Lang::APACHE_INCPT), $version, $bearsamppBins->getPhp()->getVersion()),
454 $boxTitle
455 );
456 }
457
458 return false;
459 }
460
461 // httpd.conf
462 $this->setVersion($version);
463
464 // conf
465 Log::debug('httpd.conf = ' . $conf);
467 // PHP module
468 '/^#?PHPIniDir\s.*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . 'PHPIniDir "' . Path::getModuleSymlinkPath(
469 $bearsamppBins->getPhp()
470 ) . '"',
471 '/^#?LoadFile\s.*php.ts\.dll.*/' => ($bearsamppBins->getPhp()->isEnable() ? '' : '#') . (!file_exists(
472 Path::getModuleSymlinkPath($bearsamppBins->getPhp()) . '/' . $tsDll
473 ) ? '#' : '') . 'LoadFile "' . Path::getModuleSymlinkPath($bearsamppBins->getPhp()) . '/' . $tsDll . '"',
474 '/^#?LoadModule\sphp.*/' => ($bearsamppBins->getPhp()
475 ->isEnable() ? '' : '#') . 'LoadModule ' . $apachePhpModuleName . ' "' . Path::getModuleSymlinkPath(
476 $bearsamppBins->getPhp()
477 ) . '/' . $apachePhpModuleDll . '"',
478 '/^#?LoadModule\sphp_*/' => ($bearsamppBins->getPhp()
479 ->isEnable() ? '' : '#') . 'LoadModule ' . $apachePhpModuleName . ' "' . Path::getModuleSymlinkPath(
480 $bearsamppBins->getPhp()
481 ) . '/' . $apachePhpModuleDll . '"',
482
483
484 // Port
485 '/^Listen\s(\d+)/' => 'Listen ' . $this->port,
486 '/^ServerName\s+([a-zA-Z0-9.]+):(\d+)/' => 'ServerName {{1}}:' . $this->port,
487 '/^NameVirtualHost\s+([a-zA-Z0-9.*]+):(\d+)/' => 'NameVirtualHost {{1}}:' . $this->port,
488 '/^<VirtualHost\s+([a-zA-Z0-9.*]+):(\d+)>/' => '<VirtualHost {{1}}:' . $this->port . '>'
489 ));
490
491 // vhosts
492 foreach ($this->getVhosts() as $vhost) {
493 Util::replaceInFile(Path::getVhostsPath() . '/' . $vhost . '.conf', array(
494 '/^<VirtualHost\s+([a-zA-Z0-9.*]+):(\d+)>$/' => '<VirtualHost {{1}}:' . $this->port . '>$'
495 ));
496 }
497
498 // www .htaccess
499 Util::replaceInFile(Path::getWwwPath() . '/.htaccess', array(
500 '/(.*)http:\/\/localhost(.*)/' => '{{1}}http://localhost' . ($this->port != 80 ? ':' . $this->port : '') . '/$1 [QSA,R=301,L]',
501 ));
502
503 return true;
504 }
global $bearsamppBins
setVersion($version)
const BEARSAMPP_CONF_MALFORMED_ERROR
const APACHE_INCPT
const BEARSAMPP_CONF_NOT_FOUND_ERROR
const SWITCH_VERSION_TITLE
static getModuleSymlinkPath($module)
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, Log\debug(), Log\error(), getConf(), Path\getModuleSymlinkPath(), Module\getName(), Module\getVersion(), getVhosts(), Path\getVhostsPath(), Path\getWwwPath(), Util\replaceInFile(), setVersion(), and Lang\SWITCH_VERSION_TITLE.

Referenced by switchVersion().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ $accessLog

$accessLog
private

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

Referenced by getAccessLog().

◆ $conf

$conf
private

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

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

◆ $errorLog

$errorLog
private

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

Referenced by getErrorLog().

◆ $exe

$exe
private

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

Referenced by getExe().

◆ $modulesPath

$modulesPath
private

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

Referenced by getModulesPath().

◆ $opensslExe

$opensslExe
private

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

Referenced by getOpensslExe().

◆ $port

$port
private

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

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

◆ $rewriteLog

$rewriteLog
private

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

Referenced by getRewriteLog().

◆ $service

$service
private

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

Referenced by getService().

◆ $sslConf

$sslConf
private

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

Referenced by getSslConf(), and refreshConf().

◆ $sslPort

$sslPort
private

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

Referenced by getSslPort(), and setSslPort().

◆ CMD_COMPILE_SETTINGS

const CMD_COMPILE_SETTINGS = '-V'

Command line option to display Apache compile settings.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ CMD_COMPILED_MODULES

const CMD_COMPILED_MODULES = '-l'

Command line option to display compiled Apache modules.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ CMD_CONFIG_DIRECTIVES

const CMD_CONFIG_DIRECTIVES = '-L'

Command line option to display Apache configuration directives.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ CMD_LOADED_MODULES

const CMD_LOADED_MODULES = '-M'

Command line option to display loaded Apache modules.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ CMD_SYNTAX_CHECK

const CMD_SYNTAX_CHECK = '-t'

◆ CMD_VERSION_NUMBER

const CMD_VERSION_NUMBER = '-v'

Command line option to display the Apache version number.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ CMD_VHOSTS_SETTINGS

const CMD_VHOSTS_SETTINGS = '-S'

Command line option to display Apache virtual host settings.

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

Referenced by ActionDebugApache\getCommandMapping(), and TplAppApache\getMenuApacheDebug().

◆ LOCAL_CFG_CONF

const LOCAL_CFG_CONF = 'apacheConf'

Configuration key for the Apache configuration file in the local configuration.

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

◆ LOCAL_CFG_EXE

const LOCAL_CFG_EXE = 'apacheExe'

Configuration key for the Apache executable in the local configuration.

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

◆ LOCAL_CFG_OPENSSL_EXE

const LOCAL_CFG_OPENSSL_EXE = 'apacheOpensslExe'

Configuration key for the Apache OpenSSL executable in the local configuration.

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

◆ LOCAL_CFG_PORT

const LOCAL_CFG_PORT = 'apachePort'

Configuration key for the Apache port in the local configuration.

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

◆ LOCAL_CFG_SSL_PORT

const LOCAL_CFG_SSL_PORT = 'apacheSslPort'

Configuration key for the Apache SSL port in the local configuration.

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

◆ ROOT_CFG_ENABLE

const ROOT_CFG_ENABLE = 'apacheEnable'

Configuration key for the Apache enable flag in the root configuration.

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

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'apacheVersion'

Configuration key for the Apache version in the root configuration.

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

◆ SERVICE_NAME

◆ SERVICE_PARAMS

const SERVICE_PARAMS = '-k runservice'

The command line parameters passed to the Apache service.

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

◆ TAG_END_SWITCHONLINE

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

The end tag marker for the switchOnline section in the configuration file.

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

◆ TAG_START_SWITCHONLINE

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

The start tag marker for the switchOnline section in the configuration file.

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


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