Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.mariadb.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
10
class
TplAppMariadb
11
{
12
const
MENU
=
'mariadb'
;
13
const
MENU_VERSIONS
=
'mariadbVersions'
;
14
const
MENU_SERVICE
=
'mariadbService'
;
15
const
MENU_DEBUG
=
'mariadbDebug'
;
16
17
const
ACTION_ENABLE
=
'enableMariadb'
;
18
const
ACTION_SWITCH_VERSION
=
'switchMariadbVersion'
;
19
const
ACTION_CHANGE_PORT
=
'changeMariadbPort'
;
20
const
ACTION_CHANGE_ROOT_PWD
=
'changeMariadbRootPwd'
;
21
const
ACTION_INSTALL_SERVICE
=
'installMariadbService'
;
22
const
ACTION_REMOVE_SERVICE
=
'removeMariadbService'
;
23
35
public
static
function
process
()
36
{
37
global
$bearsamppLang
,
$bearsamppBins
;
38
39
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::MARIADB
), self::MENU, get_called_class(),
$bearsamppBins
->getMariadb()->isEnable());
40
}
41
55
public
static
function
getMenuMariadb
()
56
{
57
global
$bearsamppBins
,
$bearsamppLang
, $bearsamppTools;
58
$resultItems = $resultActions =
''
;
59
60
$isEnabled =
$bearsamppBins
->getMariadb()->isEnable();
61
62
// Download
63
$resultItems .=
TplAestan::getItemLink
(
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
64
HttpClient::getWebsiteUrl
(
'module/mariadb'
,
'#releases'
),
65
false
,
66
TplAestan::GLYPH_BROWSER
67
) . PHP_EOL;
68
69
// Enable
70
$tplEnable =
TplApp::getActionMulti
(
71
self::ACTION_ENABLE, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
72
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
73
false
, get_called_class()
74
);
75
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
76
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
77
78
if
($isEnabled) {
79
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
80
81
// Versions
82
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
83
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
84
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
85
86
// Service
87
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
88
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
89
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
90
91
// Debug
92
$tplDebug =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::DEBUG
), self::MENU_DEBUG, get_called_class());
93
$resultItems .= $tplDebug[
TplApp::SECTION_CALL
] . PHP_EOL;
94
$resultActions .= $tplDebug[
TplApp::SECTION_CONTENT
];
95
96
// Console
97
$resultItems .=
TplAestan::getItemPowerShell
(
98
$bearsamppLang
->getValue(
Lang::CONSOLE
),
99
TplAestan::GLYPH_POWERSHELL
,
100
null
, $bearsamppTools->getPowerShell()->getTabTitleMariadb(),
Path::getModuleSymlinkPath
(
$bearsamppBins
->getMariadb()),
null
101
) . PHP_EOL;
102
103
// Conf
104
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getMariadb()->getConf()),
$bearsamppBins
->getMariadb()->getConf()) . PHP_EOL;
105
106
// Errors log
107
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getMariadb()->getErrorLog()) . PHP_EOL;
108
}
109
110
return
$resultItems . PHP_EOL . $resultActions;
111
}
112
123
public
static
function
getMenuMariadbVersions
()
124
{
125
global
$bearsamppBins
;
126
$items =
''
;
127
$actions =
''
;
128
129
foreach
(
$bearsamppBins
->getMariadb()->getVersionList() as $version) {
130
$tplSwitchMariadbVersion =
TplApp::getActionMulti
(
131
self::ACTION_SWITCH_VERSION, array($version),
132
array($version, $version ==
$bearsamppBins
->getMariadb()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
133
false
, get_called_class()
134
);
135
136
// Item
137
$items .= $tplSwitchMariadbVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
138
139
// Action
140
$actions .= PHP_EOL . $tplSwitchMariadbVersion[
TplApp::SECTION_CONTENT
];
141
}
142
143
return
$items . $actions;
144
}
145
158
public
static
function
getActionEnableMariadb
($enable)
159
{
160
global
$bearsamppBins
;
161
162
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMariadb()->getName(), $enable)) . PHP_EOL .
163
TplAppReload::getActionReload
();
164
}
165
178
public
static
function
getActionSwitchMariadbVersion
($version)
179
{
180
global
$bearsamppBins
;
181
182
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMariadb()->getName(), $version)) . PHP_EOL .
183
TplAppReload::getActionReload
() . PHP_EOL;
184
}
185
198
public
static
function
getMenuMariadbService
()
199
{
200
global
$bearsamppLang
,
$bearsamppBins
;
201
202
$tplChangePort =
TplApp::getActionMulti
(
203
self::ACTION_CHANGE_PORT,
null
,
204
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
205
false
, get_called_class()
206
);
207
208
$isInstalled =
$bearsamppBins
->getMariadb()->getService()->isInstalled();
209
210
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
211
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
212
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
213
TplAestan::getItemSeparator
() . PHP_EOL .
214
TplApp::getActionRun
(
215
Action::CHECK_PORT
, array(
$bearsamppBins
->getMariadb()->getName(),
$bearsamppBins
->getMariadb()->getPort()),
216
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMariadb()->getPort()),
TplAestan::GLYPH_LIGHT
)
217
) . PHP_EOL .
218
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL;
219
220
$tplChangeRootPwd =
null
;
221
if
($isInstalled) {
222
$tplChangeRootPwd =
TplApp::getActionMulti
(
223
self::ACTION_CHANGE_ROOT_PWD,
null
,
224
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_ROOT_PWD
),
TplAestan::GLYPH_PASSWORD
),
225
!$isInstalled, get_called_class()
226
);
227
228
$result
.= $tplChangeRootPwd[
TplApp::SECTION_CALL
] . PHP_EOL;
229
}
230
231
if
(!$isInstalled) {
232
$tplInstallService =
TplApp::getActionMulti
(
233
self::ACTION_INSTALL_SERVICE,
null
,
234
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
235
$isInstalled, get_called_class()
236
);
237
238
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
239
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
240
}
else
{
241
$tplRemoveService =
TplApp::getActionMulti
(
242
self::ACTION_REMOVE_SERVICE,
null
,
243
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
244
!$isInstalled, get_called_class()
245
);
246
247
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
248
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
249
}
250
251
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL .
252
($tplChangeRootPwd !=
null
? $tplChangeRootPwd[
TplApp::SECTION_CONTENT
] . PHP_EOL :
''
);
253
254
return
$result
;
255
}
256
267
public
static
function
getMenuMariadbDebug
()
268
{
269
global
$bearsamppLang
;
270
271
return
TplApp::getActionRun
(
272
Action::DEBUG_MARIADB
, array(
BinMariadb::CMD_VERSION
),
273
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_VERSION
),
TplAestan::GLYPH_DEBUG
)
274
) . PHP_EOL .
275
TplApp::getActionRun
(
276
Action::DEBUG_MARIADB
, array(
BinMariadb::CMD_VARIABLES
),
277
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_VARIABLES
),
TplAestan::GLYPH_DEBUG
)
278
) . PHP_EOL .
279
TplApp::getActionRun
(
280
Action::DEBUG_MARIADB
, array(
BinMariadb::CMD_SYNTAX_CHECK
),
281
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_SYNTAX_CHECK
),
TplAestan::GLYPH_DEBUG
)
282
) . PHP_EOL;
283
}
284
295
public
static
function
getActionChangeMariadbPort
()
296
{
297
global
$bearsamppBins
;
298
299
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMariadb()->getName())) . PHP_EOL .
300
TplAppReload::getActionReload
();
301
}
302
313
public
static
function
getActionChangeMariadbRootPwd
()
314
{
315
global
$bearsamppBins
;
316
317
return
TplApp::getActionRun
(
Action::CHANGE_DB_ROOT_PWD
, array(
$bearsamppBins
->getMariadb()->getName())) . PHP_EOL .
318
TplAppReload::getActionReload
();
319
}
320
328
public
static
function
getActionInstallMariadbService
()
329
{
330
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMariadb::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
331
TplAppReload::getActionReload
();
332
}
333
341
public
static
function
getActionRemoveMariadbService
()
342
{
343
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMariadb::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
344
TplAppReload::getActionReload
();
345
}
346
}
$result
$result
Definition
ajax.apache.php:19
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
Action\SWITCH_VERSION
const SWITCH_VERSION
Definition
class.action.php:56
Action\DEBUG_MARIADB
const DEBUG_MARIADB
Definition
class.action.php:26
Action\CHANGE_DB_ROOT_PWD
const CHANGE_DB_ROOT_PWD
Definition
class.action.php:20
Action\SERVICE
const SERVICE
Definition
class.action.php:46
Action\CHANGE_PORT
const CHANGE_PORT
Definition
class.action.php:21
Action\CHECK_PORT
const CHECK_PORT
Definition
class.action.php:22
Action\ENABLE
const ENABLE
Definition
class.action.php:31
ActionService\REMOVE
const REMOVE
Definition
class.action.service.php:22
ActionService\INSTALL
const INSTALL
Definition
class.action.service.php:21
BinMariadb\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.mariadb.php:18
BinMariadb\CMD_SYNTAX_CHECK
const CMD_SYNTAX_CHECK
Definition
class.bin.mariadb.php:33
BinMariadb\CMD_VERSION
const CMD_VERSION
Definition
class.bin.mariadb.php:31
BinMariadb\CMD_VARIABLES
const CMD_VARIABLES
Definition
class.bin.mariadb.php:32
Config\DISABLED
const DISABLED
Definition
class.config.php:36
Config\ENABLED
const ENABLED
Definition
class.config.php:35
HttpClient\getWebsiteUrl
static getWebsiteUrl($path='', $fragment='', $utmSource=true)
Definition
class.httpclient.php:134
Lang\MARIADB
const MARIADB
Definition
class.lang.php:131
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\DEBUG_MARIADB_VARIABLES
const DEBUG_MARIADB_VARIABLES
Definition
class.lang.php:331
Lang\MENU_CHANGE_ROOT_PWD
const MENU_CHANGE_ROOT_PWD
Definition
class.lang.php:91
Lang\SERVICE
const SERVICE
Definition
class.lang.php:67
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:41
Lang\DEBUG_MARIADB_SYNTAX_CHECK
const DEBUG_MARIADB_SYNTAX_CHECK
Definition
class.lang.php:332
Lang\CONSOLE
const CONSOLE
Definition
class.lang.php:34
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:90
Lang\DEBUG
const DEBUG
Definition
class.lang.php:35
Lang\MENU_ERROR_LOGS
const MENU_ERROR_LOGS
Definition
class.lang.php:99
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:102
Lang\DEBUG_MARIADB_VERSION
const DEBUG_MARIADB_VERSION
Definition
class.lang.php:330
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:110
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:92
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:80
Path\getModuleSymlinkPath
static getModuleSymlinkPath($module)
Definition
class.path.php:54
TplAestan\GLYPH_LIGHT
const GLYPH_LIGHT
Definition
class.tpl.aestan.php:71
TplAestan\getItemPowerShell
static getItemPowerShell($caption, $glyph, $id=null, $title=null, $initDir=null, $command=null)
Definition
class.tpl.aestan.php:141
TplAestan\GLYPH_PASSWORD
const GLYPH_PASSWORD
Definition
class.tpl.aestan.php:87
TplAestan\GLYPH_POWERSHELL
const GLYPH_POWERSHELL
Definition
class.tpl.aestan.php:49
TplAestan\GLYPH_CHECK
const GLYPH_CHECK
Definition
class.tpl.aestan.php:61
TplAestan\GLYPH_NETWORK
const GLYPH_NETWORK
Definition
class.tpl.aestan.php:74
TplAestan\GLYPH_SERVICE_REMOVE
const GLYPH_SERVICE_REMOVE
Definition
class.tpl.aestan.php:55
TplAestan\getItemActionServiceStop
static getItemActionServiceStop($service)
Definition
class.tpl.aestan.php:335
TplAestan\GLYPH_DEBUG
const GLYPH_DEBUG
Definition
class.tpl.aestan.php:76
TplAestan\GLYPH_SERVICE_INSTALL
const GLYPH_SERVICE_INSTALL
Definition
class.tpl.aestan.php:56
TplAestan\GLYPH_BROWSER
const GLYPH_BROWSER
Definition
class.tpl.aestan.php:53
TplAestan\getItemLink
static getItemLink($caption, $link, $local=false, $glyph=self::GLYPH_WEB_PAGE)
Definition
class.tpl.aestan.php:188
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:211
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:313
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:125
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:357
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:152
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:190
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:115
TplApp\SECTION_CALL
const SECTION_CALL
Definition
class.tpl.app.php:23
TplApp\SECTION_CONTENT
const SECTION_CONTENT
Definition
class.tpl.app.php:24
TplApp\getMenuEnable
static getMenuEnable($caption, $menu, $class, $enabled=true)
Definition
class.tpl.app.php:212
TplAppMariadb
Definition
class.tpl.app.mariadb.php:11
TplAppMariadb\getActionChangeMariadbPort
static getActionChangeMariadbPort()
Definition
class.tpl.app.mariadb.php:295
TplAppMariadb\MENU_DEBUG
const MENU_DEBUG
Definition
class.tpl.app.mariadb.php:15
TplAppMariadb\getActionInstallMariadbService
static getActionInstallMariadbService()
Definition
class.tpl.app.mariadb.php:328
TplAppMariadb\getMenuMariadbDebug
static getMenuMariadbDebug()
Definition
class.tpl.app.mariadb.php:267
TplAppMariadb\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.mariadb.php:17
TplAppMariadb\MENU
const MENU
Definition
class.tpl.app.mariadb.php:12
TplAppMariadb\getActionSwitchMariadbVersion
static getActionSwitchMariadbVersion($version)
Definition
class.tpl.app.mariadb.php:178
TplAppMariadb\process
static process()
Definition
class.tpl.app.mariadb.php:35
TplAppMariadb\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.mariadb.php:18
TplAppMariadb\getActionEnableMariadb
static getActionEnableMariadb($enable)
Definition
class.tpl.app.mariadb.php:158
TplAppMariadb\getActionRemoveMariadbService
static getActionRemoveMariadbService()
Definition
class.tpl.app.mariadb.php:341
TplAppMariadb\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.mariadb.php:13
TplAppMariadb\getActionChangeMariadbRootPwd
static getActionChangeMariadbRootPwd()
Definition
class.tpl.app.mariadb.php:313
TplAppMariadb\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.mariadb.php:14
TplAppMariadb\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.mariadb.php:21
TplAppMariadb\ACTION_CHANGE_ROOT_PWD
const ACTION_CHANGE_ROOT_PWD
Definition
class.tpl.app.mariadb.php:20
TplAppMariadb\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.mariadb.php:22
TplAppMariadb\getMenuMariadb
static getMenuMariadb()
Definition
class.tpl.app.mariadb.php:55
TplAppMariadb\getMenuMariadbVersions
static getMenuMariadbVersions()
Definition
class.tpl.app.mariadb.php:123
TplAppMariadb\getMenuMariadbService
static getMenuMariadbService()
Definition
class.tpl.app.mariadb.php:198
TplAppMariadb\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.mariadb.php:19
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:44
sandbox
core
classes
tpls
app
class.tpl.app.mariadb.php
Generated by
1.17.0