UIG - User Interface Generator The main PIE cgi script, acts as the interface between the user and the database Input: CGI data Output: HTML to stdout/writes to log file Non-PIE modules used: CGI, DBI, Time::Local PDL - main routine Parse config file (uses ParseXML routine) Set global parameters (from config file) Require shared libraries (error, rdb, shared) - this connects to resource database Parse CGI query Open log file Get current date and time Create log file entry Connect to PIE database Call onerror if response and action both not defined in CGI input - this exits with non-zero status Call present_login if action not defined - this exits Get session information (from userdata table in PIE database) Call onerror unless whether action makes sense (matches existing action module) If action="logon" Call logon action - this produces required output Exit 0 Else if userid not defined Call present_login - this exits Else if timeout set in config file and current time is more than timeout seconds after time of last action Call present_login - this exits Else if lastaction is "exit" Call present_login - this exits Else Call relevant action routine Look for copy of response in user's viewitem table and item table Call onerror unless response defined Get readgroups list for response item/user Unless list empty Call get_html for response Call add_to_item for response Substitute for variables in pseudo-HTML Substitute in locations with itemid (to keep track of which locations belong to which item) Get orderby for item from viewitem table Get list of children in correct order from item/viewitem tables If remaining children Foreach child Look for copy of child in user's viewitem table and item table Update viewitem table Get readgroups list for child/user Unless list empty Call get_html for child Call add_to_item for child Substitute for variables in child pseudo-HTML Substitute for locations with child itemid Insert child HTML in response HTML Put , tags round HTML if they aren't there Update session information in userdata table Put OK diagnostic in log file Close log file Print HTML to stdout Disconnect from PIE database Exit Else Call onerror - this exits ParseXML routine This subroutine parses an XML string until it no longer matches the syntax contents. It is not a full XML parser but makes simplifying assumptions about the DTD. Input: XML text Output: Reference to hash where keys match tag names and contents are arrays with successive tag contents as elements (i.e. the array has multiple elements if the tag is repeated). ReadConfig routine Reads and parses XML configuration file ignoring comment lines (beginning with #). Parsing done via ParseXML routine.