Bearsampp 2025.8.29
Loading...
Searching...
No Matches
AppPhpmyadmin Class Reference
Inheritance diagram for AppPhpmyadmin:

Public Member Functions

 __construct ($id, $type)
 getConf ()
 reload ($id=null, $type=null)
 setVersion ($version)
Public Member Functions inherited from Module
 __toString ()
 getCurrentPath ()
 getId ()
 getName ()
 getRelease ()
 getRootPath ()
 getSymlinkPath ()
 getType ()
 getVersion ()
 getVersionList ()
 isEnable ()
 update ($sub=0, $showWindow=false)

Data Fields

const LOCAL_CFG_CONF = 'phpmyadminConf'
const ROOT_CFG_VERSION = 'phpmyadminVersion'
Data Fields inherited from Module
const BUNDLE_RELEASE = 'bundleRelease'

Protected Member Functions

 updateConfig ($version=null, $sub=0, $showWindow=false)
Protected Member Functions inherited from Module
 __construct ()
 replace ($key, $value)
 replaceAll ($params)

Private Attributes

 $conf

Additional Inherited Members

Protected Attributes inherited from Module
 $bearsamppConf
 $bearsamppConfRaw
 $currentPath
 $enable
 $name
 $release = 'N/A'
 $rootPath
 $symlinkPath
 $version

Detailed Description

Class AppPhpmyadmin

This class represents the phpMyAdmin application module in the Bearsampp application. It extends the Module class and provides functionalities specific to phpMyAdmin, such as configuration management and version handling.

Definition at line 17 of file class.app.phpmyadmin.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $id,
$type )

Constructor for the AppPhpmyadmin class.

Parameters
string$idThe ID of the module.
string$typeThe type of the module.

Definition at line 40 of file class.app.phpmyadmin.php.

40 {
41 Util::logInitClass($this);
42 $this->reload($id, $type);
43 }
reload($id=null, $type=null)
static logInitClass($classInstance)

References Module\$id, Module\$type, Util\logInitClass(), and reload().

Member Function Documentation

◆ getConf()

getConf ( )

Gets the path to the phpMyAdmin configuration file.

Returns
string The path to the configuration file.

Definition at line 146 of file class.app.phpmyadmin.php.

146 {
147 return $this->conf;
148 }

Referenced by updateConfig().

◆ reload()

reload ( $id = null,
$type = null )

Reloads the module configuration based on the provided ID and type.

Parameters
string | null$idThe ID of the module. If null, the current ID is used.
string | null$typeThe type of the module. If null, the current type is used.

Reimplemented from Module.

Definition at line 51 of file class.app.phpmyadmin.php.

51 {
54
55 // This makes name and version the values in bearsampp.conf
56 $this->name = $bearsamppLang->getValue(Lang::PHPMYADMIN);
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 Util::logInfo($this->name . ' is not enabled!');
66 return;
67 }
68 if (!is_dir($this->currentPath)) {
69 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->currentPath));
70 }
71 if (!is_dir($this->symlinkPath)) {
72 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_FILE_NOT_FOUND), $this->name . ' ' . $this->version, $this->symlinkPath));
73 return;
74 }
75 if (!is_file($this->bearsamppConf)) {
76 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->bearsamppConf));
77 }
78 if (!is_file($this->conf)) {
79 Util::logError(sprintf($bearsamppLang->getValue(Lang::ERROR_CONF_NOT_FOUND), $this->name . ' ' . $this->version, $this->conf));
80 }
81 }
global $bearsamppLang
const ERROR_CONF_NOT_FOUND
const PHPMYADMIN
const ERROR_FILE_NOT_FOUND
static logError($data, $file=null)
static logInfo($data, $file=null)
static logReloadClass($classInstance)
global $bearsamppConfig
Definition homepage.php:27

References $bearsamppConfig, $bearsamppLang, Module\$id, Module\$type, Lang\ERROR_CONF_NOT_FOUND, Lang\ERROR_FILE_NOT_FOUND, Util\logError(), Util\logInfo(), Util\logReloadClass(), and Lang\PHPMYADMIN.

Referenced by __construct().

◆ setVersion()

setVersion ( $version)

Sets the version of the phpMyAdmin module.

Parameters
string$versionThe version to set.

Reimplemented from Module.

Definition at line 134 of file class.app.phpmyadmin.php.

134 {
135 global $bearsamppConfig;
136 $this->version = $version;
137 $bearsamppConfig->replace(self::ROOT_CFG_VERSION, $version);
138 $this->reload();
139 }

◆ updateConfig()

updateConfig ( $version = null,
$sub = 0,
$showWindow = false )
protected

Updates the configuration of the phpMyAdmin module.

Parameters
string | null$versionThe version to update to. If null, the current version is used.
int$subThe sub-level for logging indentation.
bool$showWindowWhether to show a window during the update process.
Returns
bool True if the update was successful, false otherwise.

Reimplemented from Module.

Definition at line 91 of file class.app.phpmyadmin.php.

91 {
93
94 if (!$this->enable) {
95 return true;
96 }
97
98 $version = $version == null ? $this->version : $version;
99 Util::logDebug(($sub > 0 ? str_repeat(' ', 2 * $sub) : '') . 'Update ' . $this->name . ' ' . $version . ' config');
100
101 $alias = $bearsamppRoot->getAliasPath() . '/phpmyadmin.conf';
102 if (is_file($alias)) {
103 Util::replaceInFile($alias, array(
104 '/^Alias\s\/phpmyadmin\s.*/' => 'Alias /phpmyadmin "' . $this->getSymlinkPath() . '/"',
105 '/^<Directory\s.*/' => '<Directory "' . $this->getSymlinkPath() . '/">',
106 ));
107 } else {
108 Util::logError($this->getName() . ' alias not found : ' . $alias);
109 }
110
111 if ($bearsamppBins->getMysql()->isEnable()) {
112 Util::replaceInFile($this->getConf(), array(
113 '/^\$mysqlPort\s=\s(\d+)/' => '$mysqlPort = ' . $bearsamppBins->getMysql()->getPort() . ';',
114 '/^\$mysqlRootUser\s=\s/' => '$mysqlRootUser = \'' . $bearsamppBins->getMysql()->getRootUser() . '\';',
115 '/^\$mysqlRootPwd\s=\s/' => '$mysqlRootPwd = \'' . $bearsamppBins->getMysql()->getRootPwd() . '\';'
116 ));
117 }
118 if ($bearsamppBins->getMariadb()->isEnable()) {
119 Util::replaceInFile($this->getConf(), array(
120 '/^\$mariadbPort\s=\s(\d+)/' => '$mariadbPort = ' . $bearsamppBins->getMariadb()->getPort() . ';',
121 '/^\$mariadbRootUser\s=\s/' => '$mariadbRootUser = \'' . $bearsamppBins->getMariadb()->getRootUser() . '\';',
122 '/^\$mariadbRootPwd\s=\s/' => '$mariadbRootPwd = \'' . $bearsamppBins->getMariadb()->getRootPwd() . '\';'
123 ));
124 }
125
126 return true;
127 }
global $bearsamppBins
global $bearsamppRoot
static logDebug($data, $file=null)
static replaceInFile($path, $replaceList)

References $bearsamppBins, $bearsamppRoot, Module\$version, getConf(), Module\getName(), Module\getSymlinkPath(), Util\logDebug(), Util\logError(), and Util\replaceInFile().

Field Documentation

◆ $conf

$conf
private

Definition at line 32 of file class.app.phpmyadmin.php.

◆ LOCAL_CFG_CONF

const LOCAL_CFG_CONF = 'phpmyadminConf'

Constant for the configuration key representing the phpMyAdmin configuration file.

Definition at line 27 of file class.app.phpmyadmin.php.

◆ ROOT_CFG_VERSION

const ROOT_CFG_VERSION = 'phpmyadminVersion'

Constant for the configuration key representing the phpMyAdmin version.

Definition at line 22 of file class.app.phpmyadmin.php.


The documentation for this class was generated from the following file: