Bearsampp
2026.9.23
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-2026 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
TplAppMariadb
18
{
19
const
MENU
=
'mariadb'
;
20
const
MENU_VERSIONS
=
'mariadbVersions'
;
21
const
MENU_SERVICE
=
'mariadbService'
;
22
const
MENU_DEBUG
=
'mariadbDebug'
;
23
24
const
ACTION_ENABLE
=
'enableMariadb'
;
25
const
ACTION_SWITCH_VERSION
=
'switchMariadbVersion'
;
26
const
ACTION_CHANGE_PORT
=
'changeMariadbPort'
;
27
const
ACTION_CHANGE_ROOT_PWD
=
'changeMariadbRootPwd'
;
28
const
ACTION_INSTALL_SERVICE
=
'installMariadbService'
;
29
const
ACTION_REMOVE_SERVICE
=
'removeMariadbService'
;
30
42
public
static
function
process
()
43
{
44
global
$bearsamppLang
,
$bearsamppBins
;
45
46
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::MARIADB
), self::MENU, get_called_class(),
$bearsamppBins
->getMariadb()->isEnable());
47
}
48
62
public
static
function
getMenuMariadb
()
63
{
64
global
$bearsamppBins
,
$bearsamppLang
, $bearsamppTools;
65
$resultItems = $resultActions =
''
;
66
67
$isEnabled =
$bearsamppBins
->getMariadb()->isEnable();
68
69
// Download
70
$resultItems .=
TplAestan::getItemLink
(
71
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
72
HttpClient::getWebsiteUrl
(
'module/mariadb'
,
'#releases'
),
73
false
,
74
TplAestan::GLYPH_BROWSER
75
) . PHP_EOL;
76
77
// Enable
78
$tplEnable =
TplApp::getActionMulti
(
79
self::ACTION_ENABLE,
80
array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
81
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
82
false
,
83
get_called_class()
84
);
85
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
86
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
87
88
if
($isEnabled) {
89
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
90
91
// Versions
92
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
93
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
94
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
95
96
// Service
97
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
98
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
99
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
100
101
// Debug
102
$tplDebug =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::DEBUG
), self::MENU_DEBUG, get_called_class());
103
$resultItems .= $tplDebug[
TplApp::SECTION_CALL
] . PHP_EOL;
104
$resultActions .= $tplDebug[
TplApp::SECTION_CONTENT
];
105
106
// Console
107
$resultItems .=
TplAestan::getItemPowerShell
(
108
$bearsamppLang
->getValue(
Lang::CONSOLE
),
109
TplAestan::GLYPH_POWERSHELL
,
110
null
,
111
$bearsamppTools->getPowerShell()->getTabTitleMariadb(),
112
Path::getModuleSymlinkPath
(
$bearsamppBins
->getMariadb()),
113
null
114
) . PHP_EOL;
115
116
// Conf
117
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getMariadb()->getConf()),
$bearsamppBins
->getMariadb()->getConf()) . PHP_EOL;
118
119
// Errors log
120
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getMariadb()->getErrorLog()) . PHP_EOL;
121
}
122
123
return
$resultItems . PHP_EOL . $resultActions;
124
}
125
136
public
static
function
getMenuMariadbVersions
()
137
{
138
global
$bearsamppBins
;
139
$items =
''
;
140
$actions =
''
;
141
142
foreach
(
$bearsamppBins
->getMariadb()->getVersionList() as $version) {
143
$tplSwitchMariadbVersion =
TplApp::getActionMulti
(
144
self::ACTION_SWITCH_VERSION,
145
array($version),
146
array($version, $version ==
$bearsamppBins
->getMariadb()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
147
false
,
148
get_called_class()
149
);
150
151
// Item
152
$items .= $tplSwitchMariadbVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
153
154
// Action
155
$actions .= PHP_EOL . $tplSwitchMariadbVersion[
TplApp::SECTION_CONTENT
];
156
}
157
158
return
$items . $actions;
159
}
160
173
public
static
function
getActionEnableMariadb
($enable)
174
{
175
global
$bearsamppBins
;
176
177
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMariadb()->getName(), $enable)) . PHP_EOL .
178
TplAppReload::getActionReload
();
179
}
180
193
public
static
function
getActionSwitchMariadbVersion
($version)
194
{
195
global
$bearsamppBins
;
196
197
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMariadb()->getName(), $version)) . PHP_EOL .
198
TplAppReload::getActionReload
() . PHP_EOL;
199
}
200
213
public
static
function
getMenuMariadbService
()
214
{
215
global
$bearsamppLang
,
$bearsamppBins
;
216
217
$tplChangePort =
TplApp::getActionMulti
(
218
self::ACTION_CHANGE_PORT,
219
null
,
220
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
221
false
,
222
get_called_class()
223
);
224
225
$isInstalled =
$bearsamppBins
->getMariadb()->getService()->isInstalled();
226
227
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
228
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
229
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMariadb()->getService()->getName()) . PHP_EOL .
230
TplAestan::getItemSeparator
() . PHP_EOL .
231
TplApp::getActionRun
(
232
Action::CHECK_PORT
,
233
array(
$bearsamppBins
->getMariadb()->getName(),
$bearsamppBins
->getMariadb()->getPort()),
234
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMariadb()->getPort()),
TplAestan::GLYPH_LIGHT
)
235
) . PHP_EOL .
236
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL;
237
238
$tplChangeRootPwd =
null
;
239
if
($isInstalled) {
240
$tplChangeRootPwd =
TplApp::getActionMulti
(
241
self::ACTION_CHANGE_ROOT_PWD,
242
null
,
243
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_ROOT_PWD
),
TplAestan::GLYPH_PASSWORD
),
244
!$isInstalled,
245
get_called_class()
246
);
247
248
$result
.= $tplChangeRootPwd[
TplApp::SECTION_CALL
] . PHP_EOL;
249
}
250
251
if
(!$isInstalled) {
252
$tplInstallService =
TplApp::getActionMulti
(
253
self::ACTION_INSTALL_SERVICE,
254
null
,
255
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
256
$isInstalled,
257
get_called_class()
258
);
259
260
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
261
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
262
}
else
{
263
$tplRemoveService =
TplApp::getActionMulti
(
264
self::ACTION_REMOVE_SERVICE,
265
null
,
266
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
267
!$isInstalled,
268
get_called_class()
269
);
270
271
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
272
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
273
}
274
275
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL .
276
($tplChangeRootPwd !=
null
? $tplChangeRootPwd[
TplApp::SECTION_CONTENT
] . PHP_EOL :
''
);
277
278
return
$result
;
279
}
280
291
public
static
function
getMenuMariadbDebug
()
292
{
293
global
$bearsamppLang
;
294
295
return
TplApp::getActionRun
(
296
Action::DEBUG_MARIADB
,
297
array(
BinMariadb::CMD_VERSION
),
298
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_VERSION
),
TplAestan::GLYPH_DEBUG
)
299
) . PHP_EOL .
300
TplApp::getActionRun
(
301
Action::DEBUG_MARIADB
,
302
array(
BinMariadb::CMD_VARIABLES
),
303
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_VARIABLES
),
TplAestan::GLYPH_DEBUG
)
304
) . PHP_EOL .
305
TplApp::getActionRun
(
306
Action::DEBUG_MARIADB
,
307
array(
BinMariadb::CMD_SYNTAX_CHECK
),
308
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MARIADB_SYNTAX_CHECK
),
TplAestan::GLYPH_DEBUG
)
309
) . PHP_EOL;
310
}
311
322
public
static
function
getActionChangeMariadbPort
()
323
{
324
global
$bearsamppBins
;
325
326
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMariadb()->getName())) . PHP_EOL .
327
TplAppReload::getActionReload
();
328
}
329
340
public
static
function
getActionChangeMariadbRootPwd
()
341
{
342
global
$bearsamppBins
;
343
344
return
TplApp::getActionRun
(
Action::CHANGE_DB_ROOT_PWD
, array(
$bearsamppBins
->getMariadb()->getName())) . PHP_EOL .
345
TplAppReload::getActionReload
();
346
}
347
355
public
static
function
getActionInstallMariadbService
()
356
{
357
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMariadb::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
358
TplAppReload::getActionReload
();
359
}
360
368
public
static
function
getActionRemoveMariadbService
()
369
{
370
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMariadb::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
371
TplAppReload::getActionReload
();
372
}
373
}
$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:21
BinMariadb\CMD_SYNTAX_CHECK
const CMD_SYNTAX_CHECK
Definition
class.bin.mariadb.php:72
BinMariadb\CMD_VERSION
const CMD_VERSION
Definition
class.bin.mariadb.php:64
BinMariadb\CMD_VARIABLES
const CMD_VARIABLES
Definition
class.bin.mariadb.php:68
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:131
Lang\MARIADB
const MARIADB
Definition
class.lang.php:132
Lang\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:97
Lang\DEBUG_MARIADB_VARIABLES
const DEBUG_MARIADB_VARIABLES
Definition
class.lang.php:332
Lang\MENU_CHANGE_ROOT_PWD
const MENU_CHANGE_ROOT_PWD
Definition
class.lang.php:90
Lang\SERVICE
const SERVICE
Definition
class.lang.php:66
Lang\DOWNLOAD_MORE
const DOWNLOAD_MORE
Definition
class.lang.php:40
Lang\DEBUG_MARIADB_SYNTAX_CHECK
const DEBUG_MARIADB_SYNTAX_CHECK
Definition
class.lang.php:333
Lang\CONSOLE
const CONSOLE
Definition
class.lang.php:33
Lang\MENU_CHANGE_PORT
const MENU_CHANGE_PORT
Definition
class.lang.php:89
Lang\DEBUG
const DEBUG
Definition
class.lang.php:34
Lang\MENU_ERROR_LOGS
const MENU_ERROR_LOGS
Definition
class.lang.php:98
Lang\MENU_INSTALL_SERVICE
const MENU_INSTALL_SERVICE
Definition
class.lang.php:101
Lang\DEBUG_MARIADB_VERSION
const DEBUG_MARIADB_VERSION
Definition
class.lang.php:331
Lang\MENU_REMOVE_SERVICE
const MENU_REMOVE_SERVICE
Definition
class.lang.php:109
Lang\MENU_CHECK_PORT
const MENU_CHECK_PORT
Definition
class.lang.php:91
Lang\VERSIONS
const VERSIONS
Definition
class.lang.php:79
Path\getModuleSymlinkPath
static getModuleSymlinkPath($module)
Definition
class.path.php:57
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:143
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:346
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:191
TplAestan\getItemNotepad
static getItemNotepad($caption, $path)
Definition
class.tpl.aestan.php:215
TplAestan\getItemActionServiceStart
static getItemActionServiceStart($service)
Definition
class.tpl.aestan.php:322
TplAestan\getItemSeparator
static getItemSeparator()
Definition
class.tpl.aestan.php:126
TplAestan\getItemActionServiceRestart
static getItemActionServiceRestart($service)
Definition
class.tpl.aestan.php:370
TplApp\getActionMulti
static getActionMulti($action, $args=array(), $item=array(), $disabled=false, $class=false)
Definition
class.tpl.app.php:153
TplApp\getMenu
static getMenu($caption, $menu, $class)
Definition
class.tpl.app.php:191
TplApp\getActionRun
static getActionRun($action, $args=array(), $item=array(), $waitUntilTerminated=true)
Definition
class.tpl.app.php:116
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:213
TplAppMariadb
Definition
class.tpl.app.mariadb.php:18
TplAppMariadb\getActionChangeMariadbPort
static getActionChangeMariadbPort()
Definition
class.tpl.app.mariadb.php:322
TplAppMariadb\MENU_DEBUG
const MENU_DEBUG
Definition
class.tpl.app.mariadb.php:22
TplAppMariadb\getActionInstallMariadbService
static getActionInstallMariadbService()
Definition
class.tpl.app.mariadb.php:355
TplAppMariadb\getMenuMariadbDebug
static getMenuMariadbDebug()
Definition
class.tpl.app.mariadb.php:291
TplAppMariadb\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.mariadb.php:24
TplAppMariadb\MENU
const MENU
Definition
class.tpl.app.mariadb.php:19
TplAppMariadb\getActionSwitchMariadbVersion
static getActionSwitchMariadbVersion($version)
Definition
class.tpl.app.mariadb.php:193
TplAppMariadb\process
static process()
Definition
class.tpl.app.mariadb.php:42
TplAppMariadb\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.mariadb.php:25
TplAppMariadb\getActionEnableMariadb
static getActionEnableMariadb($enable)
Definition
class.tpl.app.mariadb.php:173
TplAppMariadb\getActionRemoveMariadbService
static getActionRemoveMariadbService()
Definition
class.tpl.app.mariadb.php:368
TplAppMariadb\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.mariadb.php:20
TplAppMariadb\getActionChangeMariadbRootPwd
static getActionChangeMariadbRootPwd()
Definition
class.tpl.app.mariadb.php:340
TplAppMariadb\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.mariadb.php:21
TplAppMariadb\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.mariadb.php:28
TplAppMariadb\ACTION_CHANGE_ROOT_PWD
const ACTION_CHANGE_ROOT_PWD
Definition
class.tpl.app.mariadb.php:27
TplAppMariadb\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.mariadb.php:29
TplAppMariadb\getMenuMariadb
static getMenuMariadb()
Definition
class.tpl.app.mariadb.php:62
TplAppMariadb\getMenuMariadbVersions
static getMenuMariadbVersions()
Definition
class.tpl.app.mariadb.php:136
TplAppMariadb\getMenuMariadbService
static getMenuMariadbService()
Definition
class.tpl.app.mariadb.php:213
TplAppMariadb\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.mariadb.php:26
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:47
sandbox
core
classes
tpls
app
class.tpl.app.mariadb.php
Generated by
1.17.0