|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/simes/unused/fCMSBackend/includes/configdb/ |
Upload File : |
<?php
require_once "./includes/xpath/xpath.php";
function factory_configdb () {
return new FCMSConfig ();
}
class FCMSConfig {
var $xp;
var $loginRequired;
function FCMSConfig () {
$path = "./config/config.xml";
$this->xp = new FCMSXPath ();
$this->xp->parse ($path);
$this->loginRequired = $this->checkLoginRequired ();
}
function getError ($key) {
$xpath = '/config/global/errors/e[@key="' . $key . '"]';
return $this->xp->getNodeValue ($xpath);
}
function getGroupProperties ($group) {
$ret = array ();
$xp =& $this->xp;
$imgroot = $this->getGlobalProperty ('root');
$root_xpath = '/config/group[@name="' . $group . '"]';
$keys = $xp->matchNames ($root_xpath . '/*');
foreach ($keys as $key) {
$ret [$key] = array ();
$key_xpath = $root_xpath . '/' . $key;
$values = $xp->matchNames ($key_xpath . '/*');
foreach ($values as $value) {
$value_xpath = $key_xpath . '/' . $value;
$v = $xp->getNodeValue ($value_xpath);
// For the filebrowser root, we need to append
// global root.
if (($key == 'filebrowser') and ($value == 'root')) {
$v = $imgroot . $v;
$v = str_replace ('//', '/', $v);
}
$ret [$key] [$value] = $v;
}
}
return $ret;
}
function getGroupProperty ($group, $v1, $v2) {
$d = $this->getGroupProperties ($group);
$d1 = $d [$v1];
if (! $d1) return "";
$v = $d1 [$v2];
if (! $v) return "";
return $v;
}
function getGlobalProperty ($pname) {
$xpath = '/config/global/' . $pname;
return $this->xp->getNodeValue ($xpath);
}
# ----- Internal utility methods
function checkLoginRequired () {
$gxpath = "/config/global";
$n = $this->xp->matchNode ($gxpath);
$attr = $this->xp->getAttribute ($n, 'requireLogin');
return ($attr != 'false');
}
}
?>