<?php

// This can be displayed in a dmABS sidepage, or asa standalone debugging controsl (eg. in a frame on dmAdmin)

$abs_debugging_standalone = !isset($dmx_debug_settings);

$temp_url = substr($_SERVER['PHP_SELF'], 0, strpos('?', $_SERVER['PHP_SELF']) !== FALSE ? $_SERVER['PHP_SELF'] : 99999);

if ($abs_debugging_standalone)
{
	// 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) != '' ?
							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');
	
	// Abs code starts here
	$abs_root = '';
	@include(DOCROOT . '/abs_version_control.php');
	// include(DOCROOT . $abs_root . '/common/header.php');

	include_once(DOCROOT . $abs_root . '/config/tech_options.php');
	// include_once('abs_lib.php');
	// include_once('abs_run.php');

	?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
			"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Stand-alone debugging controls</title>
		<meta name="generator" content="BBEdit 9.2" />
		
		<script language="javascript" src="<?=$abs_root;?>/js/abs_interface.js" type="text/javascript"></script>
		
		<?php dmx_initialise_trolley(); ?>

		<script language="javascript" type="text/javascript">
		/*<![CDATA[[*/
		var json_debug = Cookie.read('dmx_debug_settings');
		dmx_debug = json_debug ? JSON.decode(json_debug) : new Object;
		window.addEvent('domready', abs_debug_display);
		/*]]>*/
		</script>

	</head>
	<body class="dmb0">

	<?php
}
?>

<!-- DEBUGGING OPTIONS -->
<div id="debugging_controls" class="sidepage sp_gen" onmouseover="sub_menu_hide();">
	<div class="sidepage_box">
		<?php if (!$abs_debugging_standalone) : ?>
			<div id="debugging_controls_handle" class="header_bar">
				<a href="" onclick="abs_layer_store['debugging_controls'].hide(); return false;"><img src="<?=$abs_root;?>/themes/<?=$abs_opt['theme'];?>/gen_images/close_cross.png" alt="" width="15" height="15" style="border: 0px;"></a>
				Debugging Controls
			</div>
		<?php endif; ?>
		<div class="box_content">
		
			<p>
			<span style="float: right; text-align: right; border: 1px #999 dotted; padding: 2px 4px; margin: 0px 0px 10px 10px;">
				<?=$_SERVER['HTTP_HOST'];?><br />
				<?=$_SERVER['SERVER_ADDR'];?>
			</span>
			<?php if (!$abs_debugging_standalone) : ?>
				<b>Control the display of private debugging information,</b> as well as the transmission of data to Google for use by Google Analytics, and to our TST (total sales tracking) servers.
			<?php endif; ?>
			</p>
			
			<form name="debug_options">
			<table>
				<tr>
					<td><input name="abs" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Show dmABS Debugging</td>
					<td></td>
				</tr> 
				<tr>
					<td><input name="pan" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Show dmABS Panel Debugging</td>
					<td></td>
				</tr>
				<tr>
					<td><input name="xcom" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>
						Show XComponent Debugging - Level
						<select name="xcom_lev" onchange="abs_debug_update();">
							<option value="1">1 - Standard</option>
							<option value="2">2 - Intercept Redirects</option>
						</select>
					</td>
					<td></td>
				</tr>
				<tr>
					<td><input name="tst" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Show TST Debugging</td>
					<td></td>
				</tr>
				<tr>
					<td><input name="send_tstd" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Tag TST hits with this debugging code: <input name="tstd" type="text" /> <input type="submit" value="Set" onclick="this.blur(); abs_debug_update(); return false;" /></td>
					<td></td>
				</tr>
				<tr>
					<td><input name="s_goo_ip" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Supress Google Analytics for tester IP ranges (defined in <i>/dmx/dmx_options.php</i>)</td>
					<td></td>
				</tr>
				<tr>
					<td><input name="s_goo_my" type="checkbox" onchange="abs_debug_update();" /></td>
					<td>Supress Google Analytics from this browser <?php if ($abs_debugging_standalone) : ?>and site<?php endif;?></td>
					<td></td>
				</tr>
			</table>
			</form>
			
		</div>
	</div>
</div>
<!-- END DEBUGGING OPTIONS -->

<?php if ($abs_debugging_standalone) : ?>
	</body>
	</html>
<?php endif; ?>
	
