115 $this->enable = $this->enable &&
$bearsamppConfig->getRaw(self::ROOT_CFG_ENABLE);
119 if ($this->bearsamppConfRaw !==
false) {
120 $this->exe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
121 $this->webRoot = $this->bearsamppConfRaw[self::LOCAL_CFG_WEB_ROOT];
122 $this->uiPort = intval($this->bearsamppConfRaw[self::LOCAL_CFG_UI_PORT]);
123 $this->smtpPort = intval($this->bearsamppConfRaw[self::LOCAL_CFG_SMTP_PORT]);
124 $this->listen = $this->bearsamppConfRaw[self::LOCAL_CFG_LISTEN];
127 if (!$this->enable) {
128 Log::info($this->name .
' is not enabled!');
132 if (!is_dir($this->currentPath)) {
137 if (!is_dir($this->symlinkPath)) {
142 if (!is_file($this->bearsamppConf)) {
147 if (!is_file($this->exe)) {
152 if ((empty($this->webRoot) && $this->webRoot !==
'' || is_numeric($this->webRoot))) {
157 if (empty($this->uiPort)) {
162 if (empty($this->smtpPort)) {
167 if (empty($this->listen)) {
173 $nssm =
new Nssm(self::SERVICE_NAME);
175 $nssm->setBinPath($this->exe);
176 $nssm->setParams(sprintf(self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot));
181 $this->service->setNssm($nssm);
191 $content = file_get_contents($this->bearsamppConf);
193 foreach ($params as $key => $value) {
194 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value .
'"', $content);
195 $this->bearsamppConfRaw[$key] = $value;
197 case self::LOCAL_CFG_UI_PORT:
198 $this->uiPort = intval($value);
200 case self::LOCAL_CFG_SMTP_PORT:
201 $this->smtpPort = intval($value);
206 file_put_contents($this->bearsamppConf, $content);
218 global $bearsamppRegistry;
220 Log::trace(
"Starting rebuildConf for Mailpit service");
221 Log::trace(
"Checking if registry key exists for Mailpit service parameters");
223 $registryPath =
'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters';
224 Log::trace(
"Registry path: " . $registryPath);
226 $exists = $bearsamppRegistry->exists(
233 Log::trace(
"Registry key exists, updating service parameters");
235 $serviceParams = sprintf(self::SERVICE_PARAMS, $this->listen, $this->uiPort, $this->listen, $this->smtpPort, $this->webRoot);
236 Log::trace(
"Service parameters: " . $serviceParams);
238 $result = $bearsamppRegistry->setExpandStringValue(
250 Log::trace(
"Registry key does not exist for Mailpit service parameters");
449 public function setEnable($enabled, $showWindow =
false)
454 Log::debug($this->
getName() .
' cannot be enabled because bundle ' . $this->
getVersion() .
' does not exist in ' . $this->currentPath);
456 $bearsamppWinbinder->messageBoxError(