<?
require("./config.inc.php");
// The only parameter the
// constructor needs, is the path
// to the configuration XML file.
// You cann't assign ot later -
// only on initiliazation.
//
$CONFIG = new Config("./config.xml");
// You can get the data from the
// configuration file using the
// Get() method. Its parameters
// are the configuration file
// elements (levels) to the
// element you desire to access.
//
$session_id = $CONFIG->Get(
"sessionSettings",
"SESSION_USER",
"SESSION_ID"
);
printf("The <b>session id</b> for the <i>user sessions</i> is [%s] <br><br>", $session_id);
// The Get() mehod is case
// insensitive, and you shouldn't
// bother matching the cases.
//
$MQ_gpc = $CONFIG->Get(
"PHPSETTINGS",
"magic_quotes_gpc"
);
printf("The <b>Magic_quotes_GPC</b> is %s <br><br>", $MQ_gpc);
// An example of accessing
// super-administrator accounts.
//
printf("The <b>Built-In Super-Administrator</b> <i>Alias</i> is [%s] <br><br>",
$CONFIG->Get(
"administrationSettings",
"built-in",
"admin_alias"));
// An example fo accessing
// option-list settings, which will
// be returned as an array.
//
$NOTIFICATIONS = $CONFIG->Get( "administrationSettings", "ADMIN_NOTIFICATION_OPTIONS" );
echo "Administrators <b>notification options</b> are:<br>";
while (list($key, $value) = each($NOTIFICATIONS)) {
echo " - <i>$key</i> = $value<br>";
}
echo "<br>";
// You can access them
// individially by their name.
//
printf("The <b>notification option</b> <i>if error occurs</i> is %s <br><br>",
$CONFIG->Get(
"administrationSettings",
"ADMIN_NOTIFICATION_OPTIONS",
"error-occurs"
));
// The Set() method is for
// modifing the elements of
// the configuration. The first
// paramter passed is the value
// itself, and the rest parameters
// are the path to the element (
// just like for the Get() method).
//
// If element's not found, the
// method returns false.
//
$CONFIG->Set("iso-8859-1",
"applicationSettings",
"SITE_CHARSET");
$CONFIG->Set( "1",
//1 is for ON or TRUE, and
//0 is for OFF or FALSE
"administrationSettings",
"ADMIN_NOTIFICATION_OPTIONS",
"error-occurs"
);
// You can use the @-operatior to
// silence the errors from the config
// class.
@$CONFIG->Get(
"applicationSettings",
"THERE_ISNT_SUCH_AN_ELEMENT");
// You can get all of the element
// properties by using the Details()
// method. It uses the same paramters
// as the Get() method.
$debug_log = $CONFIG->Details(
"debugSettings",
"debug_log"
);
echo "<b>Debug-Log</b> properties are:<br>";
while (list($key, $value) = each($debug_log)) {
echo " - <i>$key</i> = $value<br>";
}
// You can save the modifications you
// made using the Save() method. It
// will creates a backup copy with your
// old settings, and then save the new
// one.
//
// The first save you ever make will be
// named "your_config_name.xml~ORIGINAL",
// the ones you make afterwards will be
// "your_config_name.xml~BACKUP-current_date"
//
// The only paramter provided is an
// alias for the "account", that saves
// the new configuration
//
$CONFIG->Save("super-administrator");
?>
|