61 $this->enable = $this->enable &&
$bearsamppConfig->getRaw(self::ROOT_CFG_ENABLE);
65 if ($this->bearsamppConfRaw !==
false) {
66 $this->exe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
67 $this->SslPort = intval($this->bearsamppConfRaw[self::LOCAL_CFG_SSL_PORT]);
68 $this->port = intval($this->bearsamppConfRaw[self::LOCAL_CFG_PORT]);
75 if (!is_dir($this->currentPath)) {
79 if (!is_dir($this->symlinkPath)) {
83 if (!is_file($this->bearsamppConf)) {
87 if (!is_file($this->exe)) {
91 if (empty($this->SslPort)) {
95 if (empty($this->port)) {
100 $nssm =
new Nssm(self::SERVICE_NAME);
102 $nssm->setBinPath($this->exe);
103 $nssm->setParams(sprintf(self::SERVICE_PARAMS, $this->SslPort, $this->port));
106 $nssm->setStderr(
$bearsamppRoot->getLogsPath() .
'/xlight.error.log');
108 $this->service->setNssm($nssm);
117 $content = file_get_contents($this->bearsamppConf);
119 foreach ($params as $key => $value) {
120 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value.
'"', $content);
121 $this->bearsamppConfRaw[$key] = $value;
123 case self::LOCAL_CFG_SSL_PORT:
124 $this->SslPort = intval($value);
126 case self::LOCAL_CFG_PORT:
127 $this->port = intval($value);
132 file_put_contents($this->bearsamppConf, $content);
141 global $bearsamppRegistry;
143 $exists = $bearsamppRegistry->exists(
145 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
149 return $bearsamppRegistry->setExpandStringValue(
151 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
153 sprintf(self::SERVICE_PARAMS, $this->SslPort, $this->port)
169 global $bearsamppWinbinder;
177 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
180 if (!$checkUsed || $isPortInUse ===
false) {
183 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
187 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
213 if (!empty($headers)) {
217 $bearsamppWinbinder->messageBoxInfo(
226 $bearsamppWinbinder->messageBoxWarning(
234 $bearsamppWinbinder->messageBoxError(
267 if (!$this->enable) {
272 Util::logDebug(($sub > 0 ? str_repeat(
' ', 2 * $sub) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config');
280 $bearsamppWinbinder->messageBoxError(
292 $bearsamppWinbinder->messageBoxError(
333 public function setEnable($enabled, $showWindow =
false) {
339 $bearsamppWinbinder->messageBoxError(
updateConfig($version=null, $sub=0, $showWindow=false)
switchVersion($version, $showWindow=false)
checkPort($port, $showWindow=false)
changePort($port, $checkUsed=false, $wbProgressBar=null)
setEnable($enabled, $showWindow=false)
reload($id=null, $type=null)
const ENABLE_BUNDLE_NOT_EXIST
const BEARSAMPP_CONF_MALFORMED_ERROR
const ERROR_EXE_NOT_FOUND
const ERROR_CONF_NOT_FOUND
const BEARSAMPP_CONF_NOT_FOUND_ERROR
const ERROR_INVALID_PARAMETER
const SWITCH_VERSION_TITLE
const ERROR_FILE_NOT_FOUND
update($sub=0, $showWindow=false)
const INFO_APP_PARAMETERS
const SERVICE_DEMAND_START
static logError($data, $file=null)
static installService($bin, $port, $syntaxCheckCmd, $showWindow=false)
static logInitClass($classInstance)
static getHeaders($host, $port, $ssl=false)
static removeService($service, $name)
static isValidPort($port)
static logInfo($data, $file=null)
static contains($string, $search)
static logDebug($data, $file=null)
static logReloadClass($classInstance)
static isPortInUse($port)