Bearsampp
2026.7.11
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-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
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
(
$bearsamppLang
->getValue(
Lang::DOWNLOAD_MORE
),
70
HttpClient::getWebsiteUrl
(
'module/mysql'
,
'#releases'
),
71
false
,
72
TplAestan::GLYPH_BROWSER
73
) . PHP_EOL;
74
75
// Enable
76
$tplEnable =
TplApp::getActionMulti
(
77
self::ACTION_ENABLE, array($isEnabled ?
Config::DISABLED
:
Config::ENABLED
),
78
array(
$bearsamppLang
->getValue(
Lang::MENU_ENABLE
), $isEnabled ?
TplAestan::GLYPH_CHECK
:
''
),
79
false
, get_called_class()
80
);
81
$resultItems .= $tplEnable[
TplApp::SECTION_CALL
] . PHP_EOL;
82
$resultActions .= $tplEnable[
TplApp::SECTION_CONTENT
] . PHP_EOL;
83
84
if
($isEnabled) {
85
$resultItems .=
TplAestan::getItemSeparator
() . PHP_EOL;
86
87
// Versions
88
$tplVersions =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::VERSIONS
), self::MENU_VERSIONS, get_called_class());
89
$resultItems .= $tplVersions[
TplApp::SECTION_CALL
] . PHP_EOL;
90
$resultActions .= $tplVersions[
TplApp::SECTION_CONTENT
] . PHP_EOL;
91
92
// Service
93
$tplService =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::SERVICE
), self::MENU_SERVICE, get_called_class());
94
$resultItems .= $tplService[
TplApp::SECTION_CALL
] . PHP_EOL;
95
$resultActions .= $tplService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
96
97
// Debug
98
$tplDebug =
TplApp::getMenu
(
$bearsamppLang
->getValue(
Lang::DEBUG
), self::MENU_DEBUG, get_called_class());
99
$resultItems .= $tplDebug[
TplApp::SECTION_CALL
] . PHP_EOL;
100
$resultActions .= $tplDebug[
TplApp::SECTION_CONTENT
];
101
102
// Console
103
$resultItems .=
TplAestan::getItemPowerShell
(
104
$bearsamppLang
->getValue(
Lang::CONSOLE
),
105
TplAestan::GLYPH_POWERSHELL
,
106
null
,
107
$bearsamppTools->getPowerShell()->getTabTitleMysql(),
108
Path::getModuleSymlinkPath
(
$bearsamppBins
->getMysql()),
109
null
110
) . PHP_EOL;
111
112
// Conf
113
$resultItems .=
TplAestan::getItemNotepad
(basename(
$bearsamppBins
->getMysql()->getConf()),
$bearsamppBins
->getMysql()->getConf()) . PHP_EOL;
114
115
// Errors log
116
$resultItems .=
TplAestan::getItemNotepad
(
$bearsamppLang
->getValue(
Lang::MENU_ERROR_LOGS
),
$bearsamppBins
->getMysql()->getErrorLog()) . PHP_EOL;
117
}
118
119
return
$resultItems . PHP_EOL . $resultActions;
120
}
121
131
public
static
function
getMenuMysqlVersions
()
132
{
133
global
$bearsamppBins
;
134
$items =
''
;
135
$actions =
''
;
136
137
foreach
(
$bearsamppBins
->getMysql()->getVersionList() as $version) {
138
$tplSwitchMysqlVersion =
TplApp::getActionMulti
(
139
self::ACTION_SWITCH_VERSION, array($version),
140
array($version, $version ==
$bearsamppBins
->getMysql()->getVersion() ?
TplAestan::GLYPH_CHECK
:
''
),
141
false
, get_called_class()
142
);
143
144
// Item
145
$items .= $tplSwitchMysqlVersion[
TplApp::SECTION_CALL
] . PHP_EOL;
146
147
// Action
148
$actions .= PHP_EOL . $tplSwitchMysqlVersion[
TplApp::SECTION_CONTENT
];
149
}
150
151
return
$items . $actions;
152
}
153
164
public
static
function
getActionEnableMysql
($enable)
165
{
166
global
$bearsamppBins
;
167
168
return
TplApp::getActionRun
(
Action::ENABLE
, array(
$bearsamppBins
->getMysql()->getName(), $enable)) . PHP_EOL .
169
TplAppReload::getActionReload
();
170
}
171
182
public
static
function
getActionSwitchMysqlVersion
($version)
183
{
184
global
$bearsamppBins
;
185
186
return
TplApp::getActionRun
(
Action::SWITCH_VERSION
, array(
$bearsamppBins
->getMysql()->getName(), $version)) . PHP_EOL .
187
TplAppReload::getActionReload
() . PHP_EOL;
188
}
189
201
public
static
function
getMenuMysqlService
()
202
{
203
global
$bearsamppLang
,
$bearsamppBins
;
204
205
$tplChangePort =
TplApp::getActionMulti
(
206
self::ACTION_CHANGE_PORT,
null
,
207
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_PORT
),
TplAestan::GLYPH_NETWORK
),
208
false
, get_called_class()
209
);
210
211
$isInstalled =
$bearsamppBins
->getMysql()->getService()->isInstalled();
212
213
$result
=
TplAestan::getItemActionServiceStart
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
214
TplAestan::getItemActionServiceStop
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
215
TplAestan::getItemActionServiceRestart
(
$bearsamppBins
->getMysql()->getService()->getName()) . PHP_EOL .
216
TplAestan::getItemSeparator
() . PHP_EOL .
217
TplApp::getActionRun
(
218
Action::CHECK_PORT
, array(
$bearsamppBins
->getMysql()->getName(),
$bearsamppBins
->getMysql()->getPort()),
219
array(sprintf(
$bearsamppLang
->getValue(
Lang::MENU_CHECK_PORT
),
$bearsamppBins
->getMysql()->getPort()),
TplAestan::GLYPH_LIGHT
)
220
) . PHP_EOL .
221
$tplChangePort[
TplApp::SECTION_CALL
] . PHP_EOL;
222
223
$tplChangeRootPwd =
null
;
224
if
($isInstalled) {
225
$tplChangeRootPwd =
TplApp::getActionMulti
(
226
self::ACTION_CHANGE_ROOT_PWD,
null
,
227
array(
$bearsamppLang
->getValue(
Lang::MENU_CHANGE_ROOT_PWD
),
TplAestan::GLYPH_PASSWORD
),
228
!$isInstalled, get_called_class()
229
);
230
231
$result
.= $tplChangeRootPwd[
TplApp::SECTION_CALL
] . PHP_EOL;
232
}
233
234
if
(!$isInstalled) {
235
$tplInstallService =
TplApp::getActionMulti
(
236
self::ACTION_INSTALL_SERVICE,
null
,
237
array(
$bearsamppLang
->getValue(
Lang::MENU_INSTALL_SERVICE
),
TplAestan::GLYPH_SERVICE_INSTALL
),
238
$isInstalled, get_called_class()
239
);
240
241
$result
.= $tplInstallService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
242
$tplInstallService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
243
}
else
{
244
$tplRemoveService =
TplApp::getActionMulti
(
245
self::ACTION_REMOVE_SERVICE,
null
,
246
array(
$bearsamppLang
->getValue(
Lang::MENU_REMOVE_SERVICE
),
TplAestan::GLYPH_SERVICE_REMOVE
),
247
!$isInstalled, get_called_class()
248
);
249
250
$result
.= $tplRemoveService[
TplApp::SECTION_CALL
] . PHP_EOL . PHP_EOL .
251
$tplRemoveService[
TplApp::SECTION_CONTENT
] . PHP_EOL;
252
}
253
254
$result
.= $tplChangePort[
TplApp::SECTION_CONTENT
] . PHP_EOL .
255
($tplChangeRootPwd !=
null
? $tplChangeRootPwd[
TplApp::SECTION_CONTENT
] . PHP_EOL :
''
);
256
257
return
$result
;
258
}
259
270
public
static
function
getMenuMysqlDebug
()
271
{
272
global
$bearsamppLang
;
273
274
return
TplApp::getActionRun
(
275
Action::DEBUG_MYSQL
, array(
BinMysql::CMD_VERSION
),
276
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_VERSION
),
TplAestan::GLYPH_DEBUG
)
277
) . PHP_EOL .
278
TplApp::getActionRun
(
279
Action::DEBUG_MYSQL
, array(
BinMysql::CMD_VARIABLES
),
280
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_VARIABLES
),
TplAestan::GLYPH_DEBUG
)
281
) . PHP_EOL .
282
TplApp::getActionRun
(
283
Action::DEBUG_MYSQL
, array(
BinMysql::CMD_SYNTAX_CHECK
),
284
array(
$bearsamppLang
->getValue(
Lang::DEBUG_MYSQL_SYNTAX_CHECK
),
TplAestan::GLYPH_DEBUG
)
285
) . PHP_EOL;
286
}
287
297
public
static
function
getActionChangeMysqlPort
()
298
{
299
global
$bearsamppBins
;
300
301
return
TplApp::getActionRun
(
Action::CHANGE_PORT
, array(
$bearsamppBins
->getMysql()->getName())) . PHP_EOL .
302
TplAppReload::getActionReload
();
303
}
304
314
public
static
function
getActionChangeMysqlRootPwd
()
315
{
316
global
$bearsamppBins
;
317
318
return
TplApp::getActionRun
(
Action::CHANGE_DB_ROOT_PWD
, array(
$bearsamppBins
->getMysql()->getName())) . PHP_EOL .
319
TplAppReload::getActionReload
();
320
}
321
329
public
static
function
getActionInstallMysqlService
()
330
{
331
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMysql::SERVICE_NAME
,
ActionService::INSTALL
)) . PHP_EOL .
332
TplAppReload::getActionReload
();
333
}
334
342
public
static
function
getActionRemoveMysqlService
()
343
{
344
return
TplApp::getActionRun
(
Action::SERVICE
, array(
BinMysql::SERVICE_NAME
,
ActionService::REMOVE
)) . PHP_EOL .
345
TplAppReload::getActionReload
();
346
}
347
}
$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:18
BinMysql\CMD_SYNTAX_CHECK
const CMD_SYNTAX_CHECK
Definition
class.bin.mysql.php:33
BinMysql\CMD_VERSION
const CMD_VERSION
Definition
class.bin.mysql.php:31
BinMysql\CMD_VARIABLES
const CMD_VARIABLES
Definition
class.bin.mysql.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\MENU_ENABLE
const MENU_ENABLE
Definition
class.lang.php:98
Lang\DEBUG_MYSQL_SYNTAX_CHECK
const DEBUG_MYSQL_SYNTAX_CHECK
Definition
class.lang.php:327
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\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_MYSQL_VERSION
const DEBUG_MYSQL_VERSION
Definition
class.lang.php:325
Lang\MYSQL
const MYSQL
Definition
class.lang.php:132
Lang\DEBUG_MYSQL_VARIABLES
const DEBUG_MYSQL_VARIABLES
Definition
class.lang.php:326
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
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:342
TplAppMysql\getMenuMysql
static getMenuMysql()
Definition
class.tpl.app.mysql.php:61
TplAppMysql\getMenuMysqlService
static getMenuMysqlService()
Definition
class.tpl.app.mysql.php:201
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:314
TplAppMysql\getMenuMysqlDebug
static getMenuMysqlDebug()
Definition
class.tpl.app.mysql.php:270
TplAppMysql\getActionEnableMysql
static getActionEnableMysql($enable)
Definition
class.tpl.app.mysql.php:164
TplAppMysql\getActionChangeMysqlPort
static getActionChangeMysqlPort()
Definition
class.tpl.app.mysql.php:297
TplAppMysql\MENU_VERSIONS
const MENU_VERSIONS
Definition
class.tpl.app.mysql.php:21
TplAppMysql\getMenuMysqlVersions
static getMenuMysqlVersions()
Definition
class.tpl.app.mysql.php:131
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:182
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:329
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:44
sandbox
core
classes
tpls
app
class.tpl.app.mysql.php
Generated by
1.17.0