66 $this->enable = $this->enable &&
$bearsamppConfig->getRaw( self::ROOT_CFG_ENABLE );
70 if ( $this->bearsamppConfRaw !==
false ) {
73 $this->uiPort = intval( $this->bearsamppConfRaw[self::LOCAL_CFG_UI_PORT] );
74 $this->smtpPort = intval( $this->bearsamppConfRaw[self::LOCAL_CFG_SMTP_PORT] );
78 if ( !$this->enable ) {
83 if ( !is_dir( $this->currentPath ) ) {
88 if ( !is_dir( $this->symlinkPath ) ) {
93 if ( !is_file( $this->bearsamppConf ) ) {
98 if ( !is_file( $this->exe ) ) {
103 if ( (empty( $this->webRoot ) && $this->webRoot !==
'' || is_numeric( $this->webRoot )) ) {
108 if ( empty( $this->uiPort ) ) {
113 if ( empty( $this->smtpPort ) ) {
118 if ( empty( $this->listen ) ) {
124 $nssm =
new Nssm( self::SERVICE_NAME );
126 $nssm->setBinPath( $this->exe );
127 $nssm->setParams( sprintf( self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot ) );
129 $nssm->setStdout(
$bearsamppRoot->getLogsPath() .
'/mailpit.out.log' );
130 $nssm->setStderr(
$bearsamppRoot->getLogsPath() .
'/mailpit.err.log' );
132 $this->service->setNssm( $nssm );
142 $content = file_get_contents( $this->bearsamppConf );
144 foreach ( $params as $key => $value ) {
145 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value .
'"', $content );
146 $this->bearsamppConfRaw[$key] = $value;
149 $this->uiPort = intval( $value );
152 $this->smtpPort = intval( $value );
157 file_put_contents( $this->bearsamppConf, $content );
167 global $bearsamppRegistry;
169 $exists = $bearsamppRegistry->exists(
171 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
175 return $bearsamppRegistry->setExpandStringValue(
177 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
179 sprintf( self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot )
307 if ( !$this->enable ) {
312 Util::logDebug( ($sub > 0 ? str_repeat(
' ', 2 * $sub ) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config' );
320 $bearsamppWinbinder->messageBoxError(
333 $bearsamppWinbinder->messageBoxError(
377 public function setEnable($enabled, $showWindow =
false)
384 $bearsamppWinbinder->messageBoxError(
397 if ( $this->enable ) {