43 if (isset($args[0]) && !empty($args[0])) {
44 $filePath =
$bearsamppRoot->getVhostsPath() .
'/' . $args[0] .
'.conf';
45 $fileContent = file_get_contents($filePath);
46 if (preg_match(
'/ServerName\s+(.*)/', $fileContent, $matchServerName) && preg_match(
'/DocumentRoot\s+"(.*)"/', $fileContent, $matchDocumentRoot)) {
47 $this->initServerName = trim($matchServerName[1]);
50 $bearsamppWinbinder->reset();
51 $this->wbWindow = $bearsamppWinbinder->createAppWindow(sprintf(
$bearsamppLang->getValue(
Lang::EDIT_VHOST_TITLE), $this->initServerName), 490, 200, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
54 $this->wbInputServerName = $bearsamppWinbinder->createInputText($this->wbWindow, $this->initServerName, 105, 13, 150,
null);
57 $this->wbInputDocRoot = $bearsamppWinbinder->createInputText($this->wbWindow, $initDocumentRoot, 105, 43, 190,
null,
null, WBC_READONLY);
60 $this->wbLabelExp = $bearsamppWinbinder->createLabel($this->wbWindow, sprintf(
$bearsamppLang->getValue(
Lang::VHOST_EXP_LABEL), $this->initServerName, $initDocumentRoot), 15, 80, 470, 50);
62 $this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE + 1, 15, 137, 190);
67 $bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processWindow');
68 $bearsamppWinbinder->mainLoop();
69 $bearsamppWinbinder->reset();
92 $bearsamppWinbinder->setText(
96 $bearsamppWinbinder->setEnabled($this->wbBtnSave[
WinBinder::CTRL_OBJ], empty($serverName) ?
false :
true);
100 if ($documentRoot && is_dir($documentRoot)) {
101 $bearsamppWinbinder->setText($this->wbInputDocRoot[
WinBinder::CTRL_OBJ], $documentRoot .
'\\');
102 $bearsamppWinbinder->setText(
111 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
112 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
115 $bearsamppWinbinder->messageBoxError(
118 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
122 if ($serverName != $this->initServerName && is_file(
$bearsamppRoot->getVhostsPath() .
'/' . $serverName .
'.conf')) {
123 $bearsamppWinbinder->messageBoxError(
126 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
131 $bearsamppOpenSsl->removeCrt($this->initServerName);
132 @unlink(
$bearsamppRoot->getVhostsPath() .
'/' . $this->initServerName .
'.conf');
134 if ($bearsamppOpenSsl->createCrt($serverName) && file_put_contents(
$bearsamppRoot->getVhostsPath() .
'/' . $serverName .
'.conf',
$bearsamppBins->getApache()->getVhostContent($serverName, $documentRoot)) !==
false) {
135 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
138 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
140 $bearsamppWinbinder->messageBoxInfo(
143 $bearsamppWinbinder->destroyWindow($window);
145 $bearsamppWinbinder->messageBoxError(
148 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
155 $bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_DELETE + 1);
158 $confirm = $bearsamppWinbinder->messageBoxYesNo(
162 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
165 if ($bearsamppOpenSsl->removeCrt($this->initServerName) && @unlink(
$bearsamppRoot->getVhostsPath() .
'/' . $this->initServerName .
'.conf')) {
166 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
169 $bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
171 $bearsamppWinbinder->messageBoxInfo(
174 $bearsamppWinbinder->destroyWindow($window);
176 $bearsamppWinbinder->messageBoxError(
179 $bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
185 $bearsamppWinbinder->destroyWindow($window);