Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.app.phpmyadmin.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
AppPhpmyadmin
extends
Module
18
{
22
const
ROOT_CFG_VERSION
=
'phpmyadminVersion'
;
23
27
const
LOCAL_CFG_CONF
=
'phpmyadminConf'
;
28
32
private
$conf
;
33
40
public
function
__construct
(
$id
,
$type
)
41
{
42
Log::initClass
($this);
43
$this->
reload
(
$id
,
$type
);
44
}
45
52
public
function
reload
(
$id
=
null
,
$type
=
null
)
53
{
54
global
$bearsamppConfig
,
$bearsamppLang
;
55
Log::reloadClass
($this);
56
57
// This makes name and version the values in bearsampp.conf
58
$this->name =
$bearsamppLang
->getValue(
Lang::PHPMYADMIN
);
59
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
60
parent::reload(
$id
,
$type
);
61
62
if
($this->bearsamppConfRaw !==
false
) {
63
$this->conf = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
64
}
65
66
if
(!$this->enable) {
67
Log::info
($this->name .
' is not enabled!'
);
68
69
return
;
70
}
71
if
(!is_dir($this->currentPath)) {
72
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
73
}
74
if
(!is_dir($this->symlinkPath)) {
75
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
76
77
return
;
78
}
79
if
(!is_file($this->bearsamppConf)) {
80
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
81
}
82
if
(!is_file($this->conf)) {
83
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->conf));
84
}
85
}
86
96
protected
function
updateConfig
(
$version
=
null
, $sub = 0, $showWindow =
false
)
97
{
98
global
$bearsamppRoot
,
$bearsamppBins
;
99
100
if
(!$this->enable) {
101
return
true
;
102
}
103
104
$version
=
$version
==
null
? $this->version :
$version
;
105
Log::debug
(($sub > 0 ? str_repeat(
' '
, 2 * $sub) :
''
) .
'Update '
. $this->name .
' '
.
$version
.
' config'
);
106
107
$alias =
Path::getAliasPath
() .
'/phpmyadmin.conf'
;
108
if
(is_file($alias)) {
109
Util::replaceInFile
($alias, array(
110
'/^Alias\s\/phpmyadmin\s.*/'
=>
'Alias /phpmyadmin "'
.
Path::getModuleSymlinkPath
($this) .
'/"'
,
111
'/^<Directory\s.*/'
=>
'<Directory "'
.
Path::getModuleSymlinkPath
($this) .
'/">'
,
112
));
113
}
else
{
114
Log::error
($this->
getName
() .
' alias not found : '
. $alias);
115
}
116
117
if
(
$bearsamppBins
->getMysql()->isEnable()) {
118
Util::replaceInFile
($this->
getConf
(), array(
119
'/^\$mysqlPort\s=\s(\d+)/'
=>
'$mysqlPort = '
.
$bearsamppBins
->getMysql()->getPort() .
';'
,
120
'/^\$mysqlRootUser\s=\s/'
=>
'$mysqlRootUser = \''
.
$bearsamppBins
->getMysql()->getRootUser() .
'\'
;
',
121
'
/^\$mysqlRootPwd\s=\s/
' => '
$mysqlRootPwd = \
''
.
$bearsamppBins
->getMysql()->getRootPwd() .
'\'
;
'
122
));
123
}
124
if ($bearsamppBins->getMariadb()->isEnable()) {
125
Util::replaceInFile($this->getConf(), array(
126
'
/^\$mariadbPort\s=\s(\d+)/
' => '
$mariadbPort =
' . $bearsamppBins->getMariadb()->getPort() . '
;
',
127
'
/^\$mariadbRootUser\s=\s/
' => '
$mariadbRootUser = \
''
.
$bearsamppBins
->getMariadb()->getRootUser() .
'\'
;
',
128
'
/^\$mariadbRootPwd\s=\s/
' => '
$mariadbRootPwd = \
''
.
$bearsamppBins
->getMariadb()->getRootPwd() .
'\'
;
'
129
));
130
}
131
132
return true;
133
}
134
140
public function setVersion($version)
141
{
142
global $bearsamppConfig;
143
$this->version = $version;
144
$bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
145
$this->reload();
146
}
147
153
public function getConf()
154
{
155
return $this->conf;
156
}
157
}
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
AppPhpmyadmin
Definition
class.app.phpmyadmin.php:18
AppPhpmyadmin\updateConfig
updateConfig($version=null, $sub=0, $showWindow=false)
Definition
class.app.phpmyadmin.php:96
AppPhpmyadmin\LOCAL_CFG_CONF
const LOCAL_CFG_CONF
Definition
class.app.phpmyadmin.php:27
AppPhpmyadmin\getConf
getConf()
Definition
class.app.phpmyadmin.php:153
AppPhpmyadmin\reload
reload($id=null, $type=null)
Definition
class.app.phpmyadmin.php:52
AppPhpmyadmin\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.app.phpmyadmin.php:22
AppPhpmyadmin\__construct
__construct($id, $type)
Definition
class.app.phpmyadmin.php:40
AppPhpmyadmin\$conf
$conf
Definition
class.app.phpmyadmin.php:32
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:154
Lang\PHPMYADMIN
const PHPMYADMIN
Definition
class.lang.php:139
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:156
Log\info
static info($data, $file=null)
Definition
class.log.php:737
Log\debug
static debug($data, $file=null)
Definition
class.log.php:726
Log\reloadClass
static reloadClass($classInstance)
Definition
class.log.php:805
Log\error
static error($data, $file=null)
Definition
class.log.php:760
Log\initClass
static initClass($classInstance)
Definition
class.log.php:784
Module
Definition
class.module.php:15
Module\$version
$version
Definition
class.module.php:29
Module\getName
getName()
Definition
class.module.php:245
Module\$type
$type
Definition
class.module.php:20
Module\$id
$id
Definition
class.module.php:23
Path\getAliasPath
static getAliasPath($aetrayPath=false)
Definition
class.path.php:348
Path\getModuleSymlinkPath
static getModuleSymlinkPath($module)
Definition
class.path.php:57
Util\replaceInFile
static replaceInFile($path, $replaceList)
Definition
class.util.php:300
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:46
sandbox
core
classes
apps
class.app.phpmyadmin.php
Generated by
1.17.0