PHP Classes
elePHPant
Icontem

Mrasnika's configuration system: Store and retrieve settings from XML files

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2004-01-06 (11 years ago) RSS 2.0 feedStarStarStarStar 66%Total: 2,200 All time: 1,684 This week: 1,155Up
Version License Categories  
mrasnika_cnfgrsystm 1.0Free for non-comm...XML, Configuration
Description Author  

This class uses an XML file to store a data structure for keeping different kind of settings.

The XML file has different element of several data types, which are validated when the settings are stored or retrieved.

The settings from the configuration file are split in different groups, depending on the purpose for which they are used in the application.

These settings can be modified using the class, and then again saved to XML format.

Picture of Kaloyan Kirilov
Name: Kaloyan Kirilov <contact>
Classes: 4 packages by
Country: Bulgaria Bulgaria
Age: 37
All time rank: 4183 in Bulgaria Bulgaria
Week rank: 1587 Down13 in Bulgaria Bulgaria Down

Details provided by the author  
This class uses an XML file to build a data structure for keeping different kind of
settings. The XML file has different element for various data types, which are
validated when read or set. The settings from the configuration file are separated
into different groups, depending on the purpose they are used in the application.
These settings can be modified using the class, and then again saved to XML format.





Here's a brief description of the XML file elements:
	- The root element CONFIG has 3 attributes:
		- "saveDate" is the date on which the
		config was was altered for the last time;
 
		- "authorAdmin" is the administrator
		account, that was the last to alter the
		configuration file. This is either the
		master-administrator account from
		<administrationSettings>, or any
		of the application administrators;

		- "authorIP" is the IP address, from
		which the configuration file was
		altered for the last time.

	- There are 9 setting-group elements, used for seaprating different data.
		- "administrationSettings" is for
		built-in administrator accounts, and
		administration specific data;

		- "applicationSettings" is for settings
		and restrictions applied to the information,
		used by the application;
		
		- "phpSettings" is used to modify the
		PHP settigs for the application to run
		correctly;
		
		- "sessionSettings" is the place where
		session declaration and all related data
		are stored;

		- "fileSettings" is the declaration for all the
		directories and files that the
		applicataion(web-site) uses, along with their
		file permissions;
		
		- "debugSettings" is for storing debug settings;
		
		- "miscellaneousSettings" is for all the settings,
		that can not fit in any other setting-group :)
		
		- "customSettings" is for your own custom
		settings;
		
		- "databaseSettings" is for database accounts,
		and related database settings.

	- You can make your own setting-groups in the "big" setting-groups, using
	the GROUP element, which has only one attribute - the name of the group.
	
	- There are a couple of settings, used as groups, and they are:
		- "administrator" - for storing administrator
		accounts in the configuration file instead in
		account database (or whatever you use);
		
		- "session" element is for grouping the
		declarations for session used by the
		application - name and timeout in general,
		but you can add whatever you want.
	
	- The basic elements of the configiration XML file are validated, depending
	on their type. The types and the validation are:
		- "alias" is a string, which has some restrictions -
		it has to start with a letter, and then the rest of
		the characters must be letters, digits, or
		underscore("_");
		
		- "password" is a valid MD5 hash - 32 symbols,
		using all the digits and the letters from A to F(
		these are all the symbols used for representing
		hexdecinal numbers);
		
		- "email" has to a be a valid email address;
		
		- "string" has no restrictions - it's just a string :)
		
		- "url" has to be a valid URL address. I made
		a state of the art validation regular expression,
		which even checks the TLD(top-level-domain)
		of the URL (.com, .cc, .net, etc, but all existing).
		
		- "boolean" has to be a valid boolean value.
		The only allowed values are:
			- 1, TRUE or ON for True;
			- 0, FALSE or OFF for False.
		The values are case-insensitive, and when set,
		all values will be converted to ON/OFF;
		
		- "int" - valid integer value (negative too);
		
		- "float" - valid floating point number (real,
		double);
		
		- "file" - path to a file. The path will not be
		checked, because it may not be absolute, but
		relative to some different base directory (the
		root directory for the application, or something
		else). The validation made are only for the
		absence of illeagal characters, and for the
		file permissions, which are set using the
		"permissions" attribute;
		
		- "directory" - the same as "file", but for
		directories. It has to end with a slash (trailing
		slash).
	
	- Each setting or group (without the root element) has a description property,
	declared using DESCRIPTION element within the described elements.
  Files folder image Files  
File Role Description
Plain text file config.inc.php Class The class itself
Accessible without login Plain text file config.xml Data Data Source
Accessible without login Plain text file readme.txt Doc. Some details on the script
Accessible without login Plain text file test.php Example An example

 Version Control Unique User Downloads Download Rankings  
 0%Total:2,200All time:1,684
 This week:0This week:1,155Up
 User Ratings  
 
 All time
Utility:87%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:70%StarStarStarStar
Examples:70%StarStarStarStar
Tests:-
Videos:-
Overall:66%StarStarStarStar
Rank:447