42 if (isset($args[0]) && !empty($args[0])) {
43 $filePath =
$bearsamppRoot->getVhostsPath() .
'/' . $args[0] .
'.conf';
44 $fileContent = file_get_contents($filePath);
45 if (preg_match(
'/ServerName\s+(.*)/', $fileContent, $matchServerName) && preg_match(
'/DocumentRoot\s+"(.*)"/', $fileContent, $matchDocumentRoot)) {
46 $this->initServerName = trim($matchServerName[1]);
49 $bearsamppWinbinder->reset();
50 $this->wbWindow = $bearsamppWinbinder->createAppWindow(sprintf(
$bearsamppLang->getValue(
Lang::EDIT_VHOST_TITLE), $this->initServerName), 490, 200, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
53 $this->wbInputServerName = $bearsamppWinbinder->createInputText($this->wbWindow, $this->initServerName, 105, 13, 150,
null);
56 $this->wbInputDocRoot = $bearsamppWinbinder->createInputText($this->wbWindow, $initDocumentRoot, 105, 43, 190,
null,
null, WBC_READONLY);
59 $this->wbLabelExp = $bearsamppWinbinder->createLabel($this->wbWindow, sprintf(
$bearsamppLang->getValue(
Lang::VHOST_EXP_LABEL), $this->initServerName, $initDocumentRoot), 15, 80, 470, 50);
61 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE + 1, 15, 137, 190);
66 $bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processWindow');
67 $bearsamppWinbinder->mainLoop();
68 $bearsamppWinbinder->reset();
91 $bearsamppWinbinder->setText(
95 $bearsamppWinbinder->setEnabled($this->wbBtnSave[
WinBinder::CTRL_OBJ], empty($serverName) ?
false :
true);
99 if ($documentRoot && is_dir($documentRoot)) {
100 $bearsamppWinbinder->setText($this->wbInputDocRoot[
WinBinder::CTRL_OBJ], $documentRoot .
'\\');
101 $bearsamppWinbinder->setText(
110 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
111 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
114 $bearsamppWinbinder->messageBoxError(
117 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
121 if ($serverName != $this->initServerName && is_file(
$bearsamppRoot->getVhostsPath() .
'/' . $serverName .
'.conf')) {
122 $bearsamppWinbinder->messageBoxError(
125 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
130 $bearsamppOpenSsl->removeCrt($this->initServerName);
131 @unlink(
$bearsamppRoot->getVhostsPath() .
'/' . $this->initServerName .
'.conf');
133 if ($bearsamppOpenSsl->createCrt($serverName) && file_put_contents(
$bearsamppRoot->getVhostsPath() .
'/' . $serverName .
'.conf',
$bearsamppBins->getApache()->getVhostContent($serverName, $documentRoot)) !==
false) {
134 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
137 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
139 $bearsamppWinbinder->messageBoxInfo(
142 $bearsamppWinbinder->destroyWindow($window);
144 $bearsamppWinbinder->messageBoxError(
147 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
154 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_DELETE + 1);
157 $confirm = $bearsamppWinbinder->messageBoxYesNo(
161 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
164 if ($bearsamppOpenSsl->removeCrt($this->initServerName) && @unlink(
$bearsamppRoot->getVhostsPath() .
'/' . $this->initServerName .
'.conf')) {
165 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
168 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
170 $bearsamppWinbinder->messageBoxInfo(
173 $bearsamppWinbinder->destroyWindow($window);
175 $bearsamppWinbinder->messageBoxError(
178 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
184 $bearsamppWinbinder->destroyWindow($window);