Bearsampp
2026.9.23
Toggle main menu visibility
Loading...
Searching...
No Matches
class.app.phppgadmin.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
16
class
AppPhppgadmin
extends
Module
17
{
21
const
ROOT_CFG_VERSION
=
'phppgadminVersion'
;
22
26
const
LOCAL_CFG_CONF
=
'phppgadminConf'
;
27
31
private
$conf
;
32
39
public
function
__construct
(
$id
,
$type
)
40
{
41
Log::initClass
($this);
42
$this->
reload
(
$id
,
$type
);
43
}
44
51
public
function
reload
(
$id
=
null
,
$type
=
null
)
52
{
53
global
$bearsamppConfig
,
$bearsamppLang
;
54
Log::reloadClass
($this);
55
56
$this->name =
$bearsamppLang
->getValue(
Lang::PHPPGADMIN
);
57
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
58
parent::reload(
$id
,
$type
);
59
60
if
($this->bearsamppConfRaw !==
false
) {
61
$this->conf = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
62
}
63
64
if
(!$this->enable) {
65
Log::info
($this->name .
' is not enabled!'
);
66
67
return
;
68
}
69
if
(!is_dir($this->currentPath)) {
70
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
71
}
72
if
(!is_dir($this->symlinkPath)) {
73
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
74
75
return
;
76
}
77
if
(!is_file($this->bearsamppConf)) {
78
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
79
}
80
if
(!is_file($this->conf)) {
81
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->conf));
82
}
83
}
84
94
protected
function
updateConfig
(
$version
=
null
, $sub = 0, $showWindow =
false
)
95
{
96
global
$bearsamppRoot
,
$bearsamppBins
;
97
98
if
(!$this->enable) {
99
return
true
;
100
}
101
102
$version
=
$version
==
null
? $this->version :
$version
;
103
Log::debug
(($sub > 0 ? str_repeat(
' '
, 2 * $sub) :
''
) .
'Update '
. $this->name .
' '
.
$version
.
' config'
);
104
105
$alias =
Path::getAliasPath
() .
'/phppgadmin.conf'
;
106
if
(is_file($alias)) {
107
Util::replaceInFile
($alias, array(
108
'/^Alias\s\/phppgadmin\s.*/'
=>
'Alias /phppgadmin "'
.
Path::getModuleSymlinkPath
($this) .
'/"'
,
109
'/^<Directory\s.*/'
=>
'<Directory "'
.
Path::getModuleSymlinkPath
($this) .
'/">'
,
110
));
111
}
else
{
112
Log::error
($this->
getName
() .
' alias not found : '
. $alias);
113
}
114
115
if
(
$bearsamppBins
->getPostgresql()->isEnable()) {
116
Util::replaceInFile
($this->
getConf
(), array(
117
'/^\$postgresqlPort\s=\s(\d+)/'
=>
'$postgresqlPort = '
.
$bearsamppBins
->getPostgresql()->getPort() .
';'
,
118
'/^\$postgresqlRootUser\s=\s/'
=>
'$postgresqlRootUser = \''
.
$bearsamppBins
->getPostgresql()->getRootUser() .
'\'
;
',
119
'
/^\$postgresqlRootPwd\s=\s/
' => '
$postgresqlRootPwd = \
''
.
$bearsamppBins
->getPostgresql()->getRootPwd() .
'\'
;
',
120
'
/^\$postgresqlDumpExe\s=\s/
' => '
$postgresqlDumpExe = \
''
.
$bearsamppBins
->getPostgresql()->getDumpExe() .
'\'
;
',
121
'
/^\$postgresqlDumpAllExe\s=\s/
' => '
$postgresqlDumpAllExe = \
''
.
$bearsamppBins
->getPostgresql()->getDumpAllExe() .
'\'
;
',
122
));
123
}
124
125
return true;
126
}
127
133
public function setVersion($version)
134
{
135
global $bearsamppConfig;
136
$this->version = $version;
137
$bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
138
$this->reload();
139
}
140
146
public function getConf()
147
{
148
return $this->conf;
149
}
150
}
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
$bearsamppRoot
global $bearsamppRoot
Definition
ajax.apache.php:16
AppPhppgadmin
Definition
class.app.phppgadmin.php:17
AppPhppgadmin\updateConfig
updateConfig($version=null, $sub=0, $showWindow=false)
Definition
class.app.phppgadmin.php:94
AppPhppgadmin\LOCAL_CFG_CONF
const LOCAL_CFG_CONF
Definition
class.app.phppgadmin.php:26
AppPhppgadmin\getConf
getConf()
Definition
class.app.phppgadmin.php:146
AppPhppgadmin\reload
reload($id=null, $type=null)
Definition
class.app.phppgadmin.php:51
AppPhppgadmin\ROOT_CFG_VERSION
const ROOT_CFG_VERSION
Definition
class.app.phppgadmin.php:21
AppPhppgadmin\__construct
__construct($id, $type)
Definition
class.app.phppgadmin.php:39
AppPhppgadmin\$conf
$conf
Definition
class.app.phppgadmin.php:31
Lang\ERROR_CONF_NOT_FOUND
const ERROR_CONF_NOT_FOUND
Definition
class.lang.php:154
Lang\PHPPGADMIN
const PHPPGADMIN
Definition
class.lang.php:140
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.phppgadmin.php
Generated by
1.17.0