Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.action.genSslCertificate.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
17
class
ActionGenSslCertificate
18
{
19
private
$wbWindow
;
20
private
$wbLabelName
;
21
private
$wbInputName
;
22
private
$wbLabelDest
;
23
private
$wbInputDest
;
24
private
$wbBtnDest
;
25
private
$wbProgressBar
;
26
private
$wbBtnSave
;
27
private
$wbBtnCancel
;
28
29
const
GAUGE_SAVE
= 2;
30
38
public
function
__construct
($args)
39
{
40
global
$bearsamppRoot
,
$bearsamppLang
, $bearsamppWinbinder;
41
42
$initServerName =
'test.local'
;
43
$initDocumentRoot =
Path::formatWindowsPath
(
Path::getSslPath
());
44
45
$bearsamppWinbinder->reset();
46
$this->wbWindow = $bearsamppWinbinder->createAppWindow(
$bearsamppLang
->getValue(
Lang::GENSSL_TITLE
), 490, 160, WBC_NOTIFY, WBC_KEYDOWN | WBC_KEYUP);
47
48
$this->wbLabelName = $bearsamppWinbinder->createLabel($this->wbWindow,
$bearsamppLang
->getValue(
Lang::NAME
) .
' :'
, 15, 15, 85,
null
, WBC_RIGHT);
49
$this->wbInputName = $bearsamppWinbinder->createInputText($this->wbWindow, $initServerName, 105, 13, 150,
null
);
50
51
$this->wbLabelDest = $bearsamppWinbinder->createLabel($this->wbWindow,
$bearsamppLang
->getValue(
Lang::TARGET
) .
' :'
, 15, 45, 85,
null
, WBC_RIGHT);
52
$this->wbInputDest = $bearsamppWinbinder->createInputText($this->wbWindow, $initDocumentRoot, 105, 43, 190,
null
,
null
, WBC_READONLY);
53
$this->wbBtnDest = $bearsamppWinbinder->createButton($this->wbWindow,
$bearsamppLang
->getValue(
Lang::BUTTON_BROWSE
), 300, 43, 110);
54
55
$this->wbProgressBar = $bearsamppWinbinder->createProgressBar($this->wbWindow, self::GAUGE_SAVE + 1, 15, 97, 275);
56
$this->wbBtnSave = $bearsamppWinbinder->createButton($this->wbWindow,
$bearsamppLang
->getValue(
Lang::BUTTON_SAVE
), 300, 92);
57
$this->wbBtnCancel = $bearsamppWinbinder->createButton($this->wbWindow,
$bearsamppLang
->getValue(
Lang::BUTTON_CANCEL
), 387, 92);
58
59
$bearsamppWinbinder->setHandler($this->wbWindow, $this,
'processWindow'
);
60
$bearsamppWinbinder->mainLoop();
61
$bearsamppWinbinder->reset();
62
}
63
76
public
function
processWindow
($window, $id, $ctrl, $param1, $param2)
77
{
78
global
$bearsamppLang
, $bearsamppOpenSsl, $bearsamppWinbinder;
79
80
$name = $bearsamppWinbinder->getText($this->wbInputName[
WinBinder::CTRL_OBJ
]);
81
$target = $bearsamppWinbinder->getText($this->wbInputDest[
WinBinder::CTRL_OBJ
]);
82
83
switch
($id) {
84
case
$this->wbBtnDest[
WinBinder::CTRL_ID
]:
85
$target = $bearsamppWinbinder->sysDlgPath($window,
$bearsamppLang
->getValue(
Lang::GENSSL_PATH
), $target);
86
if
($target && is_dir($target)) {
87
$bearsamppWinbinder->setText($this->wbInputDest[
WinBinder::CTRL_OBJ
], $target .
'\\'
);
88
}
89
break
;
90
case
$this->wbBtnSave[
WinBinder::CTRL_ID
]:
91
$bearsamppWinbinder->setProgressBarMax($this->wbProgressBar, self::GAUGE_SAVE + 1);
92
$bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
93
94
$target =
Path::formatUnixPath
($target);
95
if
($bearsamppOpenSsl->createCrt($name, $target)) {
96
$bearsamppWinbinder->incrProgressBar($this->wbProgressBar);
97
$bearsamppWinbinder->messageBoxInfo(
98
sprintf(
$bearsamppLang
->getValue(
Lang::GENSSL_CREATED
), $name),
99
$bearsamppLang
->getValue(
Lang::GENSSL_TITLE
));
100
$bearsamppWinbinder->destroyWindow($window);
101
}
else
{
102
$bearsamppWinbinder->messageBoxError(
$bearsamppLang
->getValue(
Lang::GENSSL_CREATED_ERROR
),
$bearsamppLang
->getValue(
Lang::GENSSL_TITLE
));
103
$bearsamppWinbinder->resetProgressBar($this->wbProgressBar);
104
}
105
break
;
106
case
IDCLOSE:
107
case
$this->wbBtnCancel[
WinBinder::CTRL_ID
]:
108
$bearsamppWinbinder->destroyWindow($window);
109
break
;
110
}
111
}
112
}
113
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
ActionGenSslCertificate
Definition
class.action.genSslCertificate.php:18
ActionGenSslCertificate\$wbInputDest
$wbInputDest
Definition
class.action.genSslCertificate.php:23
ActionGenSslCertificate\$wbLabelName
$wbLabelName
Definition
class.action.genSslCertificate.php:20
ActionGenSslCertificate\$wbWindow
$wbWindow
Definition
class.action.genSslCertificate.php:19
ActionGenSslCertificate\$wbBtnDest
$wbBtnDest
Definition
class.action.genSslCertificate.php:24
ActionGenSslCertificate\__construct
__construct($args)
Definition
class.action.genSslCertificate.php:38
ActionGenSslCertificate\$wbLabelDest
$wbLabelDest
Definition
class.action.genSslCertificate.php:22
ActionGenSslCertificate\$wbInputName
$wbInputName
Definition
class.action.genSslCertificate.php:21
ActionGenSslCertificate\$wbBtnCancel
$wbBtnCancel
Definition
class.action.genSslCertificate.php:27
ActionGenSslCertificate\$wbBtnSave
$wbBtnSave
Definition
class.action.genSslCertificate.php:26
ActionGenSslCertificate\GAUGE_SAVE
const GAUGE_SAVE
Definition
class.action.genSslCertificate.php:29
ActionGenSslCertificate\processWindow
processWindow($window, $id, $ctrl, $param1, $param2)
Definition
class.action.genSslCertificate.php:76
ActionGenSslCertificate\$wbProgressBar
$wbProgressBar
Definition
class.action.genSslCertificate.php:25
Lang\GENSSL_TITLE
const GENSSL_TITLE
Definition
class.lang.php:347
Lang\GENSSL_CREATED
const GENSSL_CREATED
Definition
class.lang.php:349
Lang\NAME
const NAME
Definition
class.lang.php:58
Lang\BUTTON_BROWSE
const BUTTON_BROWSE
Definition
class.lang.php:373
Lang\BUTTON_CANCEL
const BUTTON_CANCEL
Definition
class.lang.php:370
Lang\GENSSL_PATH
const GENSSL_PATH
Definition
class.lang.php:348
Lang\BUTTON_SAVE
const BUTTON_SAVE
Definition
class.lang.php:368
Lang\GENSSL_CREATED_ERROR
const GENSSL_CREATED_ERROR
Definition
class.lang.php:350
Lang\TARGET
const TARGET
Definition
class.lang.php:73
Path\getSslPath
static getSslPath($aetrayPath=false)
Definition
class.path.php:918
Path\formatWindowsPath
static formatWindowsPath($path)
Definition
class.path.php:118
Path\formatUnixPath
static formatUnixPath($path)
Definition
class.path.php:156
WinBinder\CTRL_ID
const CTRL_ID
Definition
class.winbinder.php:21
WinBinder\CTRL_OBJ
const CTRL_OBJ
Definition
class.winbinder.php:22
sandbox
core
classes
actions
class.action.genSslCertificate.php
Generated by
1.17.0