Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.tpl.app.mysql.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
TplAppMysql
18
{
19
// Constants for menu and action identifiers
20
const
MENU
=
'mysql'
;
21
const
MENU_VERSIONS
=
'mysqlVersions'
;
22
const
MENU_SERVICE
=
'mysqlService'
;
23
const
MENU_DEBUG
=
'mysqlDebug'
;
24
25
const
ACTION_ENABLE
=
'enableMysql'
;
26
const
ACTION_SWITCH_VERSION
=
'switchMysqlVersion'
;
27
const
ACTION_CHANGE_PORT
=
'changeMysqlPort'
;
28
const
ACTION_CHANGE_ROOT_PWD
=
'changeMysqlRootPwd'
;
29
const
ACTION_INSTALL_SERVICE
=
'installMysqlService'
;
30
const
ACTION_REMOVE_SERVICE
=
'removeMysqlService'
;
31
42
public
static
function
process
()
43
{
44
global
$bearsamppLang
,
$bearsamppBins
;
45
46
return
TplApp::getMenuEnable
(
$bearsamppLang
->getValue(
Lang::MYSQL
), self::MENU, get_called_class(),
$bearsamppBins
->getMysql()->isEnable());
47
}
48
61
public
static
function
getMenuMysql
()
62
{
63
global
$bearsamppBins
,
$bearsamppLang
, $bearsamppTools;
64
$resultItems = $resultActions =
''
;
65
66
$isEnabled =
$bearsamppBins
->getMysql()->isEnable();
67
68
// Download
69
$resultItems .=
TplAestan::getItemLink
(
70
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
71
HttpClient::getWebsiteUrl
(
'module/mysql'
,
'#releases'
),
72
false
,
73
TplAestan::GLYPH_BROWSER
74
) . PHP_EOL;
75
76
// Enable
77
$tplEnable =
TplApp::getActionMulti
(
78
self::ACTION_ENABLE,
79
array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
80
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
81
false
,
82
get_called_class()
83
);
84
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
85
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
86
87
if
($isEnabled) {
88
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
89
90
// Versions
91
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
92
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
93
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
94
95
// Service
96
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
97
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
98
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
99
100
// Debug
101
$tplDebug =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::DEBUG
), self::MENU_DEBUG, get_called_class());
102
$resultItems .= $tplDebug[
TplApp::SECTION_CALL
] . PHP_EOL;
103
$resultActions .= $tplDebug[
TplApp::SECTION_CONTENT
];
104
105
// Console
106
$resultItems .=
TplAestan::getItemPowerShell
(
107
$bearsamppLang
->getValue(
Lang::CONSOLE
),
108
TplAestan::GLYPH_POWERSHELL
,
109
null
,
110
$bearsamppTools->getPowerShell()->getTabTitleMysql(),
111
Path::getModuleSymlinkPath
(
$bearsamppBins
->getMysql()),
112
null
113
) . PHP_EOL;
114
115
// Conf
116
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getMysql()->getConf()),
$bearsamppBins
->getMysql()->getConf()) . PHP_EOL;
117
118
// Errors log
119
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getMysql()->getErrorLog()) . PHP_EOL;
120
}
121
122
return
$resultItems . PHP_EOL . $resultActions;
123
}
124
134
public
static
function
getMenuMysqlVersions
()
135
{
136
global
$bearsamppBins
;
137
$items =
''
;
138
$actions =
''
;
139
140
foreach
(
$bearsamppBins
->getMysql()->getVersionList() as $version) {
141
$tplSwitchMysqlVersion =
TplApp::getActionMulti
(
142
self::ACTION_SWITCH_VERSION,
143
array($version),
144
array($version, $version ==
$bearsamppBins
->getMysql()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
145
false
,
146
get_called_class()
147
);
148
149
// Item
150
$items .= $tplSwitchMysqlVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
151
152
// Action
153
$actions .= PHP_EOL . $tplSwitchMysqlVersion[
TplApp::SECTION_CONTENT
];
154
}
155
156
return
$items . $actions;
157
}
158
170
public
static
function
getActionEnableMysql
($enable)
171
{
172
global
$bearsamppBins
;
173
174
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMysql()->getName(), $enable)) . PHP_EOL .
175
TplAppReload::getActionReload
();
176
}
177
189
public
static
function
getActionSwitchMysqlVersion
($version)
190
{
191
global
$bearsamppBins
;
192
193
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMysql()->getName(), $version)) . PHP_EOL .
194
TplAppReload::getActionReload
() . PHP_EOL;
195
}
196
208
public
static
function
getMenuMysqlService
()
209
{
210
global
$bearsamppLang
,
$bearsamppBins
;
211
212
$tplChangePort =
TplApp::getActionMulti
(
213
self::ACTION_CHANGE_PORT,
214
null
,
215
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
216
false
,
217
get_called_class()
218
);
219
220
$isInstalled =
$bearsamppBins
->getMysql()->getService()->isInstalled();
221
222
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
223
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
224
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
225
TplAestan::getItemSeparator
() . PHP_EOL .
226
TplApp::getActionRun
(
227
Action::CHECK_PORT
,
228
array(
$bearsamppBins
->getMysql()->getName(),
$bearsamppBins
->getMysql()->getPort()),
229
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMysql()->getPort()),
TplAestan::GLYPH_LIGHT
)
230
) . PHP_EOL .
231
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL;
232
233
$tplChangeRootPwd =
null
;
234
if
($isInstalled) {
235
$tplChangeRootPwd =
TplApp::getActionMulti
(
236
self::ACTION_CHANGE_ROOT_PWD,
237
null
,
238
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_ROOT_PWD
),
TplAestan::GLYPH_PASSWORD
),
239
!$isInstalled,
240
get_called_class()
241
);
242
243
$result
.= $tplChangeRootPwd[
TplApp::SECTION_CALL
] . PHP_EOL;
244
}
245
246
if
(!$isInstalled) {
247
$tplInstallService =
TplApp::getActionMulti
(
248
self::ACTION_INSTALL_SERVICE,
249
null
,
250
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
251
$isInstalled,
252
get_called_class()
253
);
254
255
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
256
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
257
}
else
{
258
$tplRemoveService =
TplApp::getActionMulti
(
259
self::ACTION_REMOVE_SERVICE,
260
null
,
261
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
262
!$isInstalled,
263
get_called_class()
264
);
265
266
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
267
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
268
}
269
270
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL .
271
($tplChangeRootPwd !=
null
? $tplChangeRootPwd[
TplApp::SECTION_CONTENT
] . PHP_EOL :
''
);
272
273
return
$result
;
274
}
275
286
public
static
function
getMenuMysqlDebug
()
287
{
288
global
$bearsamppLang
;
289
290
return
TplApp::getActionRun
(
291
Action::DEBUG_MYSQL
,
292
array(
BinMysql::CMD_VERSION
),
293
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_VERSION
),
TplAestan::GLYPH_DEBUG
)
294
) . PHP_EOL .
295
TplApp::getActionRun
(
296
Action::DEBUG_MYSQL
,
297
array(
BinMysql::CMD_VARIABLES
),
298
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_VARIABLES
),
TplAestan::GLYPH_DEBUG
)
299
) . PHP_EOL .
300
TplApp::getActionRun
(
301
Action::DEBUG_MYSQL
,
302
array(
BinMysql::CMD_SYNTAX_CHECK
),
303
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_SYNTAX_CHECK
),
TplAestan::GLYPH_DEBUG
)
304
) . PHP_EOL;
305
}
306
316
public
static
function
getActionChangeMysqlPort
()
317
{
318
global
$bearsamppBins
;
319
320
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMysql()->getName())) . PHP_EOL .
321
TplAppReload::getActionReload
();
322
}
323
333
public
static
function
getActionChangeMysqlRootPwd
()
334
{
335
global
$bearsamppBins
;
336
337
return
TplApp::getActionRun
(
Action::CHANGE_DB_ROOT_PWD
, array(
$bearsamppBins
->getMysql()->getName())) . PHP_EOL .
338
TplAppReload::getActionReload
();
339
}
340
348
public
static
function
getActionInstallMysqlService
()
349
{
350
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMysql::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
351
TplAppReload::getActionReload
();
352
}
353
361
public
static
function
getActionRemoveMysqlService
()
362
{
363
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMysql::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
364
TplAppReload::getActionReload
();
365
}
366
}
$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\CHANGE_DB_ROOT_PWD
const CHANGE_DB_ROOT_PWD
Definition
class.action.php:20
Action\DEBUG_MYSQL
const DEBUG_MYSQL
Definition
class.action.php:27
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
BinMysql\SERVICE_NAME
const SERVICE_NAME
Definition
class.bin.mysql.php:21
BinMysql\CMD_SYNTAX_CHECK
const CMD_SYNTAX_CHECK
Definition
class.bin.mysql.php:72
BinMysql\CMD_VERSION
const CMD_VERSION
Definition
class.bin.mysql.php:64
BinMysql\CMD_VARIABLES
const CMD_VARIABLES
Definition
class.bin.mysql.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\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:97
Lang\DEBUG_MYSQL_SYNTAX_CHECK
const DEBUG_MYSQL_SYNTAX_CHECK
Definition
class.lang.php:328
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\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_MYSQL_VERSION
const DEBUG_MYSQL_VERSION
Definition
class.lang.php:326
Lang\MYSQL
const MYSQL
Definition
class.lang.php:133
Lang\DEBUG_MYSQL_VARIABLES
const DEBUG_MYSQL_VARIABLES
Definition
class.lang.php:327
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
TplAppMysql
Definition
class.tpl.app.mysql.php:18
TplAppMysql\MENU_DEBUG
const MENU_DEBUG
Definition
class.tpl.app.mysql.php:23
TplAppMysql\getActionRemoveMysqlService
static getActionRemoveMysqlService()
Definition
class.tpl.app.mysql.php:361
TplAppMysql\getMenuMysql
static getMenuMysql()
Definition
class.tpl.app.mysql.php:61
TplAppMysql\getMenuMysqlService
static getMenuMysqlService()
Definition
class.tpl.app.mysql.php:208
TplAppMysql\ACTION_ENABLE
const ACTION_ENABLE
Definition
class.tpl.app.mysql.php:25
TplAppMysql\MENU
const MENU
Definition
class.tpl.app.mysql.php:20
TplAppMysql\process
static process()
Definition
class.tpl.app.mysql.php:42
TplAppMysql\ACTION_SWITCH_VERSION
const ACTION_SWITCH_VERSION
Definition
class.tpl.app.mysql.php:26
TplAppMysql\getActionChangeMysqlRootPwd
static getActionChangeMysqlRootPwd()
Definition
class.tpl.app.mysql.php:333
TplAppMysql\getMenuMysqlDebug
static getMenuMysqlDebug()
Definition
class.tpl.app.mysql.php:286
TplAppMysql\getActionEnableMysql
static getActionEnableMysql($enable)
Definition
class.tpl.app.mysql.php:170
TplAppMysql\getActionChangeMysqlPort
static getActionChangeMysqlPort()
Definition
class.tpl.app.mysql.php:316
TplAppMysql\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.mysql.php:21
TplAppMysql\getMenuMysqlVersions
static getMenuMysqlVersions()
Definition
class.tpl.app.mysql.php:134
TplAppMysql\MENU_SERVICE
const MENU_SERVICE
Definition
class.tpl.app.mysql.php:22
TplAppMysql\ACTION_INSTALL_SERVICE
const ACTION_INSTALL_SERVICE
Definition
class.tpl.app.mysql.php:29
TplAppMysql\getActionSwitchMysqlVersion
static getActionSwitchMysqlVersion($version)
Definition
class.tpl.app.mysql.php:189
TplAppMysql\ACTION_CHANGE_ROOT_PWD
const ACTION_CHANGE_ROOT_PWD
Definition
class.tpl.app.mysql.php:28
TplAppMysql\ACTION_REMOVE_SERVICE
const ACTION_REMOVE_SERVICE
Definition
class.tpl.app.mysql.php:30
TplAppMysql\getActionInstallMysqlService
static getActionInstallMysqlService()
Definition
class.tpl.app.mysql.php:348
TplAppMysql\ACTION_CHANGE_PORT
const ACTION_CHANGE_PORT
Definition
class.tpl.app.mysql.php:27
TplAppReload\getActionReload
static getActionReload()
Definition
class.tpl.app.reload.php:47
sandbox
core
classes
tpls
app
class.tpl.app.mysql.php
Generated by
1.17.0