usercode.php - index







































































<?php

/* USERCODE.PHP - manage "user" added code

NOTE this code is actually not used anywhere in this version -- we use it 
on our website, but nothing in this code takes advantage of it; more later...

This is a short but complicated module. There is not much to it, what, 120 
lines so far? But it provides a great deal of processing, um, power (hate that 
word though). You will probably not understand how it works by just looking at 
it. Trust me. Yet it does work.

Quickly, what it does is to allow the "adding" of PHP code, and therefore 
application functionality, remotely -- i.e. you can use the administration 
code to edit the PHP code. It's a nifty thing and can be done silently and 
easily. (You can't change everything or anything, mind you, just how the 
application processes posts; but it is useful.)
*/

setmodule();

// this module handles it's internal data differently than the others

// "user code" is code attached to a record and is 'eval'ed during the 
// record display process

$user_code _readusercode(themedir('usercode.ini'));

// include local code (like a "Plug-In")
$file html('themedir')."functions.php";
if (
file_exists($file)) {
    
debug("'$file'");
    include 
$file;
}


/* usercode - get user code code string */

function usercode($codeid) {
    global 
$user_code;

    if (!isset(
$user_code[$codeid]))
        return 
FALSE;

    return 
$user_code[$codeid];
}


/* dumpusercode - display user code */

function dumpusercode() {
    global 
$user_code;

    print 
'usercode ';
    
print_r($user_code);
}


/* _readusercode - read theme's usercode.ini file into usercode data array */

// this is just to have the debug statement

function _readusercode($file) {

    
debug("'$file'");
    return 
datafile($file);
}

?>