Site Configuration
The main configuration of the site is the file CONFIG.INI
. The CONFIG module parses this file into an associative array. This array is accessed by the function
which is passed the name of the variable to read: config()
config('themedir
)' for example. If a variable is not set (does not exist) an empty string is returned. If
is called with no arguments the entire array is returned.config()
During runtime a variable can be set by passing a value in the function call:
config('foobar',"foo");
The value can be any PHP type.
During runtime some settings are set according to the site section being viewed (see SECTIONS). For example, view the section "about" (?arg=about) they are:
setting value section "about" pagedir "pages/about/" importdir "import/about/"
The CONFIG.INI
file is heavily commented.
Directory Names
There are several directories that the code expects to exist which are named in CONFIG.INI
. They all end in dir
. They need exist (and do in the archive of course). (Some of them need to be writeable for full functionality.)
The names do not need a trailing /
but can have one (the code checks for it, adding one if needed).
Three of the directory names are aliased by functions:
function alias htmdir() config('htmdir') imgdir() config('imgdir') themedir() config('themedir')
Sensitive Data
We no longer store any sensitive data — PASSWORDS and SALTS for example — as any variable. Only defined constants are used.
Modifying The Code
For anyone interested in modifying the code, this section explains how to use a new configuration setting. Anything placed into CONFIG.INI
will end up in the configuration array.
Say you are looking at a block of code and want to change it so that it becomes conditional. All you have to do is put the block within a "config test".
Say there is this, and you don't particularly like it:
print "Fooby Looby!";
To conditionalize it, step one is to add the config test to the code:
if (!config('nofoobylooby')) { print "Fooby Looby!"; }
And then add the setting in CONFIG.INI:
nofoobylooby = 1
That is all.
Because config()
returns "" if a config variable is not defined, we chose to use an example with a double negative on purpose — this way the default operation remains the same if you (or someone else) do not define the new setting in the ini file. (You obviously do not have to do things that way if you do not want to.)
Also, let's say you are looking at the code and see something like:
$test = preg_match("/[a-zA-Z0-9]/",$name);
and see that it is used twice in the same block! And you go, "Ya know, it'd be way cool to fix that!"
To do so, step one is to make the code something like:
$namematch = config('namematch'); $test = preg_match($namematch,$name);
and, right! The new ini setting is:
namematch = /[a-zA-Z0-9]/
With the side effect that if your boss had a marketing request to change the code to allow for names with underscores, you can go, "No problemlo. Can do it in just a couple hours!" And then you just change the ini file to:
namematch = /[a-zA-Z0-9_]/
and go on an early lunch!
Notes
1. The file is parsed by the PHP function
.parse_ini_file()