<?php

// debug.php
// -----------------------------------------------------------------------------
// Display results of translationg a single URL (in debugging mode) or
// the results of translation a web log file (in any mode)
//
// Release    > 1.00
// Project    > dmClubURLTranslation-Sep06:S01_C03
// Copyright  > (C) Digital Mail Limited (2006)
// Author     > Richard Knight (RAK) for DML
// -----------------------------------------------------------------------------

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>URL Translation Engine - Debug Mode</title>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<meta name="Copyright" content="Digital Mail Limited 2005-2010">

	<link href="/dmx/core/b0/css/core_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/over_dmclub.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/core.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/over.css" rel="stylesheet" type="text/css" media="All">
	<link href="/dmx/core/b0/css/print.css" rel="stylesheet" type="text/css" media="Print">
	<!--[if lt IE 7]>
		<link href="/dmx/core/b0/css/ie6.css" rel="stylesheet" type="text/css" media="All" />
	<![endif]-->
	
	<script language="javascript" src="/dmx/core/js/mootools-1.2.3-core-yc.js" type="text/javascript"></script>
	<script language="javascript" src="/dmx/core/js/mootools-1.2.3.1-more.js" type="text/javascript"></script>
	<script language="javascript" src="/dmx/core/b0/js/b0_interface.js" type="text/javascript"></script>

	<script language="javascript">
	
	// Set up page initialisation event handler
	if (window.addEventListener)
	{
		window.addEventListener('load', b0_interface_init, true); // W3C
	}
	else if (window.attachEvent)
	{
		window.attachEvent('onload', b0_interface_init); // IE  - Quirks Mode
	}
	else
	{
		window.onload = b0_interface_init;
	}

	</script>

	<!-- Override normal B0 width limitation -->
	<style type="text/css">
	<!--
	.dmb0 .limit_width_700
	{
	max-width: 100% !important;
	width: expression(document.body.clientWidth > 700? "100%": "auto" ) !important;
	}
	-->
	</style>

</head>

<body>
<div class="dmb0">

<a name="top"></a>

<!-- ************** -->
<!-- HEADER SECTION -->
<!-- ************** -->

<!-- MAIN HEADER BAR AND BRANDING -->
<div id="header_bar">
	<div class="content" align="center">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="limit_width_700">
			<tr>
				<td style="width: 99%; vertical-align: middle;" class="title">URL Translation Engine</td>
				<td><img src="/dmx/core_resources/b0/images/dmclub_header/dmclub_better_biz.gif" alt="better business through  innovative telecoms" width="164" height="71" border="0"></td>
				<td><img src="/dmx/core_resources/b0/images/dmclub_header/dmclub_logo.gif" alt="dmClub logo" width="63" height="71" border="0"></td>
			</tr>
			<tr>
				<td></td>
				<td colspan="2"><img src="/dmx/core_resources/b0/images/dmclub_header/dmclub_highlight.gif" alt="" width="227" height="8" border="0"></td>
			</tr>
		</table>
	</div>
</div>
<!-- END MAIN HEADER BAR AND BRANDING -->

<!-- NAV BAR -->
<div id="nav_bar">
	<div class="content" align="center">
		<div class="limit_width_700">
		 	<div style="float: right">
		 		<!-- RHS NAV BAR CONTENT -->
		 		<a href="/test/index.php" class="infotext nu">back<span class="tipcontents">Return to<br />testbed homepage</span></a>				
		 		<!-- END RHS NAV BAR CONTENT -->
		 	</div>
		 	<!-- LHS NAV BAR CONTENT -->
		 	<!-- END LHS NAV BAR CONTENT -->
		 	&nbsp;
		</div>
	</div>
</div>
<!-- END NAV BAR -->

<!-- ERROR MESSAGE BAR -->
<div id="err_msg_bar" style="display: none;">
	<div class="content" align="center">
		<div class="limit_width_700">
		 	<script language="javascript" type="text/javascript">document.write(errMsg)</script>
		</div>
	</div>
</div>
<!-- END ERROR MESSAGE BAR -->

<!-- ****************** -->
<!-- END HEADER SECTION -->
<!-- ****************** -->


<!-- ******************* -->
<!-- PAGE BODY CONTAINER -->
<!-- ******************* -->

<div class="content" align="center">
<div class="limit_width_700">

<!-- BODY CONTENT STARTS HERE -->

<h1>URL processed by translation engine</h1>

<?php if (isset($_POST['logfile'])) : ?>
<p>
<strong>Scanned <?=$stats['count'];?> lines</strong><br>
( <?=$stats['blank'];?> blank lines / <?=$stats['badly_formed'];?> badly formed lines discarded )<br>
<?=$stats['ref_empty'];?> requests with no HTTP referrer in total<br><br>
<strong>Parsed <?=$stats['parsed'];?> lines</strong> (trying <?=$desc;?>)<br>
<b><?=$stats['matched'];?> URLs matched</b> (<?=$stats['matched_ref_empty'];?> of these had no HTTP referrer)
<?php if (isset($_POST['sortby_match'])) : ?>(Results have been sorted by regex matched)<?php endif; ?>
<br>
<?=$stats['parsed_ref_empty'];?> requests with no HTTP referrer in subset
</p>
<?php endif; ?>

<?php if (isset($_POST['matches_only'])) : ?>
<p>
Displaying matched results only...
</p>
<?php endif; ?>

<table width="100%">
	<tr><td colspan="2" class="divider"><img src="/dmx/core_resources/b0/images/clear.gif" width="1" height="1" alt=""></td></tr>
	<?php for ($i=0; $i<count($trans_res); $i++) : ?>
	<?php if (isset($_POST['matches_only']) && !$trans_res[$i]['match']) continue; ?>
	<tr>
		<td class="cell1f">URL</td>
		<td class="cell2f"><?=$trans_res[$i]['url'];?></td>
	</tr>
	<tr>
		<td class="cell1f">Referrer</td>
		<td class="cell2f"><a href="<?=$trans_res[$i]['ref'];?>"><?=$trans_res[$i]['ref'];?></a></td>
	</tr>
	<tr>
		<td class="cell1f">Dealer</td>
		<td class="cell2f"><?=$trans_res[$i]['dealer'];?></td>
	</tr>
	<tr>
		<td class="cell1f">Destination</td>
		<td class="cell2f">
			<?php if ($trans_res[$i]['dest'] != 'TERMINATE') : ?>
				<a href="<?=$trans_res[$i]['dest'];?>"><?=$trans_res[$i]['dest'];?><a/>
			<?php else: ?>
				TERMINATE
			<?php endif; ?>
		</td>
	</tr>
	<tr><td colspan="2" class="divider"><img src="/dmx/core_resources/b0/images/clear.gif" width="1" height="1" alt=""></td></tr>
	<?php endfor; ?>
</table>

<?php if ($debug_level > 1) : ?>
<h2>Deatailed debugging</h2>
<?=$debug_msg;?>
<?php endif; ?>

<!-- END BODY CONTENT -->

</div>
</div>

<!-- *********************** -->
<!-- END PAGE BODY CONTAINER -->
<!-- *********************** -->

<!-- ********** -->
<!-- FOOTER BAR -->
<!-- ********** -->

<br style="clear: both;">
<div id="footer_bar">
	<div class="content" align="center">
		<div class="limit_width_700">
		 	<div style="float: right">
		 		<!-- RHS FOOTER CONTENT -->
		 		<!-- Standard back to top link -->
		 		&nbsp;&nbsp;&nbsp;<a href="#top">back to top</a>
		 		<!-- END RHS FOOTER CONTENT -->
		 	</div>
		 	<!-- LHS FOOTER CONTENT -->
			trans_engine:debug.php:S01_C03
		 	<!-- END LHS FOOTER CONTENT -->
		</div>
	</div>
</div>

<!-- ************** -->
<!-- END FOOTER BAR -->
<!-- ************** -->

</div>

</body>
</html>