Bearsampp
2026.7.11
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-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
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
Log::initClass
($this);
41
$this->
reload
(
$id
,
$type
);
42
}
43
50
public
function
reload
(
$id
=
null
,
$type
=
null
) {
51
global
$bearsamppConfig
,
$bearsamppLang
;
52
Log::reloadClass
($this);
53
54
$this->name =
$bearsamppLang
->getValue(
Lang::PHPPGADMIN
);
55
$this->version =
$bearsamppConfig
->getRaw(self::ROOT_CFG_VERSION);
56
parent::reload(
$id
,
$type
);
57
58
if
($this->bearsamppConfRaw !==
false
) {
59
$this->conf = $this->symlinkPath .
'/'
. $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
60
}
61
62
if
(!$this->enable) {
63
Log::info
($this->name .
' is not enabled!'
);
64
return
;
65
}
66
if
(!is_dir($this->currentPath)) {
67
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->currentPath));
68
}
69
if
(!is_dir($this->symlinkPath)) {
70
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_FILE_NOT_FOUND
), $this->name .
' '
. $this->version, $this->symlinkPath));
71
return
;
72
}
73
if
(!is_file($this->bearsamppConf)) {
74
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->bearsamppConf));
75
}
76
if
(!is_file($this->conf)) {
77
Log::error
(sprintf(
$bearsamppLang
->getValue(
Lang::ERROR_CONF_NOT_FOUND
), $this->name .
' '
. $this->version, $this->conf));
78
}
79
}
80
89
protected
function
updateConfig
(
$version
=
null
, $sub = 0, $showWindow =
false
) {
90
global
$bearsamppRoot
,
$bearsamppBins
;
91
92
if
(!$this->enable) {
93
return
true
;
94
}
95
96
$version
=
$version
==
null
? $this->version :
$version
;
97
Log::debug
(($sub > 0 ? str_repeat(
' '
, 2 * $sub) :
''
) .
'Update '
. $this->name .
' '
.
$version
.
' config'
);
98
99
$alias =
Path::getAliasPath
() .
'/phppgadmin.conf'
;
100
if
(is_file($alias)) {
101
Util::replaceInFile
($alias, array(
102
'/^Alias\s\/phppgadmin\s.*/'
=>
'Alias /phppgadmin "'
.
Path::getModuleSymlinkPath
($this) .
'/"'
,
103
'/^<Directory\s.*/'
=>
'<Directory "'
.
Path::getModuleSymlinkPath
($this) .
'/">'
,
104
));
105
}
else
{
106
Log::error
($this->
getName
() .
' alias not found : '
. $alias);
107
}
108
109
if
(
$bearsamppBins
->getPostgresql()->isEnable()) {
110
Util::replaceInFile
($this->
getConf
(), array(
111
'/^\$postgresqlPort\s=\s(\d+)/'
=>
'$postgresqlPort = '
.
$bearsamppBins
->getPostgresql()->getPort() .
';'
,
112
'/^\$postgresqlRootUser\s=\s/'
=>
'$postgresqlRootUser = \''
.
$bearsamppBins
->getPostgresql()->getRootUser() .
'\'
;
',
113
'
/^\$postgresqlRootPwd\s=\s/
' => '
$postgresqlRootPwd = \
''
.
$bearsamppBins
->getPostgresql()->getRootPwd() .
'\'
;
',
114
'
/^\$postgresqlDumpExe\s=\s/
' => '
$postgresqlDumpExe = \
''
.
$bearsamppBins
->getPostgresql()->getDumpExe() .
'\'
;
',
115
'
/^\$postgresqlDumpAllExe\s=\s/
' => '
$postgresqlDumpAllExe = \
''
.
$bearsamppBins
->getPostgresql()->getDumpAllExe() .
'\'
;
',
116
));
117
}
118
119
return true;
120
}
121
127
public function setVersion($version) {
128
global $bearsamppConfig;
129
$this->version = $version;
130
$bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
131
$this->reload();
132
}
133
139
public function getConf() {
140
return $this->conf;
141
}
142
}
$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:89
AppPhppgadmin\LOCAL_CFG_CONF
const LOCAL_CFG_CONF
Definition
class.app.phppgadmin.php:26
AppPhppgadmin\getConf
getConf()
Definition
class.app.phppgadmin.php:139
AppPhppgadmin\reload
reload($id=null, $type=null)
Definition
class.app.phppgadmin.php:50
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:153
Lang\PHPPGADMIN
const PHPPGADMIN
Definition
class.lang.php:139
Lang\ERROR_FILE_NOT_FOUND
const ERROR_FILE_NOT_FOUND
Definition
class.lang.php:155
Log\info
static info($data, $file=null)
Definition
class.log.php:627
Log\debug
static debug($data, $file=null)
Definition
class.log.php:616
Log\reloadClass
static reloadClass($classInstance)
Definition
class.log.php:670
Log\error
static error($data, $file=null)
Definition
class.log.php:650
Log\initClass
static initClass($classInstance)
Definition
class.log.php:660
Module
Definition
class.module.php:15
Module\$version
$version
Definition
class.module.php:24
Module\getName
getName()
Definition
class.module.php:201
Module\$type
$type
Definition
class.module.php:20
Module\$id
$id
Definition
class.module.php:21
Path\getAliasPath
static getAliasPath($aetrayPath=false)
Definition
class.path.php:331
Path\getModuleSymlinkPath
static getModuleSymlinkPath($module)
Definition
class.path.php:54
Util\replaceInFile
static replaceInFile($path, $replaceList)
Definition
class.util.php:292
$bearsamppConfig
global $bearsamppConfig
Definition
homepage.php:41
sandbox
core
classes
apps
class.app.phppgadmin.php
Generated by
1.17.0