<?
// We use output buffers
ob_start();

$Debug_Messages = true;
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
// Default Paths ... These are extremely important
// Each one MUST end in a trailing forward-slash
$doc_dir = realpath($_SERVER['DOCUMENT_ROOT']) . '/';
$server_root = realpath($doc_dir . '..') . '/';
$inc_dir = $server_root . 'includes/';
$temp_dir = '/var/tmp/';
$pages_dir = $server_root . 'pages/';
$int_pages_dir = $server_root . 'pages_int/';
$images_dir = $doc_dir . 'images/';

// Clean up input. This is critical as all of the other pages
// expect this to be done.
foreach ($_GET as $key=>$value)
	if (is_string($value))
		$_GET[$key] = trim($value);
foreach ($_POST as $key=>$value)
	if (is_string($value))
		$_POST[$key] = trim($value);

// Functions to display inputs in forms. This helps keep elements
// consistent throughout the whole site.
require_once($inc_dir . 'inputbox.inc');

// This function displays a node container on the page
require_once($inc_dir . 'node.inc');

// This function displays a tab bar (should be used inside a node)
require_once($inc_dir . 'tabbar.inc');

// This one contains our function to display a fatal error.
// We source this first because any unrecoverable errors will call
// this function.
require_once($inc_dir . 'nice_death.inc');

// This function is used to help verify that dependencies are present
require_once($inc_dir . 'require_function.inc');

// This file contains our function to perform a forced redirect.
require_once($inc_dir . 'redirect.inc');

// Read in our global configuration file
// This file contains information on how to connect to the database
// and any other global configuration information, because I don't
// like using MySQL for tables which will only hold one row.
require_once($inc_dir . 'config_file.inc');

// Include our database functions and create the container object.
// This uses $Config for connection
// details and database owner credentials.
require_once($inc_dir . 'database.inc');

// Some of our pages don't use a session, and we dont like failures
if (!$noSession){
	// We prefer to use MySQL for our sessions instead of files in /tmp
	// for (somewhat obvious) security reasons. Our functions to handle this
	// are in here.
	require_once($inc_dir . 'session.inc');

	// Let's see if the user is trying to log in. We do this here because
	// the login form is displayed on all pages until the user logs in.
	// This file is also responsible for destroying the session if the user
	// is not logged in.
	require_once($inc_dir . 'login.inc');
}

// Useful for any page which displays file sizes.
require_once($inc_dir . 'human_readable.inc');

// These are useful for verification that users typed in something
// at least reasonable in the input forms
require_once($inc_dir . 'valid_username.inc');

// Fix object names so they are valid for files/DOM IDs
require_once($inc_dir . 'objname.inc');

// Parse a query string into its individual keywords to query MySQL
require_once($inc_dir . 'parse_keywords.inc');
?>
