/***************************************************************************
* LIBRARY INSERTION FOR XCOMPONENTS
*
* Using a text-editor with batch-processing and PCRE support, this
* find-and-replace adds the XComponents library includes into the
* top of the page
*
* Author: Richard Knight (RAK)
* © Digital Mail Limited 2005
***************************************************************************/

COPY AND PASTE THE FOLLOWING INTO THE find AND replace FIELDS OF YOUR
TEXT EDITOR, AND BATCH-PROCESS THE FILES THAT MAKE UP YOUR WEBSITE

DO NOT INCLUDE TRAILING LINEBREAKS WHEN COPY-AND-PASTING!

Find:
-----
(?-m)^(?!<\?php\s// Call in the XComponents)


Replace with:
-------------
<?php
// Call in the XComponents engine and options file
define('MOD_PHP', substr(PHP_SAPI, 0, 3) != 'cgi'); // Are we running as mod_php?
define('DOCROOT', 
	MOD_PHP && isset($_SERVER['DOCUMENT_ROOT']) ? 
		$_SERVER['DOCUMENT_ROOT'] : 
			(
				MOD_PHP && isset($_SERVER['SCRIPT_FILENAME']) ? 
					substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF'])) : 
					substr(str_repeat('../', count(explode('/', preg_replace('_/+_', '/', $_SERVER['PHP_SELF'])))-2), 0, -1) . '.'
			)
	);
include(DOCROOT . '/dmx/dmx_options.php');
include(DOCROOT . '/dmx/core/php/dmx_shop_handler.php');
include(DOCROOT . '/dmx/core/php/dmx_shop_components.php');
?>
