60 $this->enable = $this->enable &&
$bearsamppConfig->getRaw(self::ROOT_CFG_ENABLE);
64 if ($this->bearsamppConfRaw !==
false) {
65 $this->exe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_EXE];
66 $this->memory = intval($this->bearsamppConfRaw[self::LOCAL_CFG_MEMORY]);
67 $this->port = intval($this->bearsamppConfRaw[self::LOCAL_CFG_PORT]);
74 if (!is_dir($this->currentPath)) {
78 if (!is_dir($this->symlinkPath)) {
82 if (!is_file($this->bearsamppConf)) {
86 if (!is_file($this->exe)) {
90 if (empty($this->memory)) {
94 if (empty($this->port)) {
99 $nssm =
new Nssm(self::SERVICE_NAME);
101 $nssm->setBinPath($this->exe);
102 $nssm->setParams(sprintf(self::SERVICE_PARAMS, $this->memory, $this->port));
104 $nssm->setStdout(
$bearsamppRoot->getLogsPath() .
'/memcached.out.log');
105 $nssm->setStderr(
$bearsamppRoot->getLogsPath() .
'/memcached.err.log');
107 $this->service->setNssm($nssm);
116 $content = file_get_contents($this->bearsamppConf);
118 foreach ($params as $key => $value) {
119 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value.
'"', $content);
120 $this->bearsamppConfRaw[$key] = $value;
122 case self::LOCAL_CFG_MEMORY:
123 $this->memory = intval($value);
125 case self::LOCAL_CFG_PORT:
126 $this->port = intval($value);
131 file_put_contents($this->bearsamppConf, $content);
140 global $bearsamppRegistry;
142 $exists = $bearsamppRegistry->exists(
144 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
148 return $bearsamppRegistry->setExpandStringValue(
150 'SYSTEM\CurrentControlSet\Services\\' . self::SERVICE_NAME .
'\Parameters',
152 sprintf(self::SERVICE_PARAMS, $this->memory, $this->port)
168 global $bearsamppWinbinder;
176 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
179 if (!$checkUsed || $isPortInUse ===
false) {
182 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
186 $bearsamppWinbinder->incrProgressBar($wbProgressBar);
212 $fp = @fsockopen(
'127.0.0.1',
$port, $errno, $errstr, 1);
215 @stream_set_timeout($fp, 1);
216 @fwrite($fp,
"version\r\n");
225 $bearsamppWinbinder->messageBoxInfo(
235 $bearsamppWinbinder->messageBoxWarning(
246 $bearsamppWinbinder->messageBoxError(
278 if (!$this->enable) {
283 Util::logDebug(($sub > 0 ? str_repeat(
' ', 2 * $sub) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config');
291 $bearsamppWinbinder->messageBoxError(
303 $bearsamppWinbinder->messageBoxError(
344 public function setEnable($enabled, $showWindow =
false) {
350 $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 removeService($service, $name)
static isValidPort($port)
static logInfo($data, $file=null)
static logDebug($data, $file=null)
static logReloadClass($classInstance)
static isPortInUse($port)