<!-- MDPHP DEBUG -->
<style>
	#md_debug{
		font: 12px "Microsoft YaHei", Helvetica, Arial, Lucida Grande, Tahoma, sans-serif;
		background: #F7F7F7;
		position: fixed;
		left: 0px;
		right: 0px;
		bottom: 0px;
		height: 240px;
		display: none;
	}
	#md_debug .menu{
		overflow: hidden;
		border-top: 1px solid #AAAAAA;
		border-bottom: 1px solid #AAAAAA;
	}
	#md_debug .menu ul{
		list-style: none;
		margin: 0;
		padding: 0;
		display: inline;
	}
	#md_debug .menu li{
		color: #333333;
		float: left;
		background: #F7F7F7;
		cursor: pointer;
		padding: 5px 12px;
		border-right: 1px solid #AAAAAA;
	}
	#md_debug .menu li.active{
		color: white;
		background: #4C9ED9;
		border-right: 1px solid #4C9ED9;
	}
	#md_debug .content div.active{
		display: block;
	}
	#md_debug .menu a.official{
		color: red;
		text-decoration: none;
		margin: 5px;
		float: right;
	}
	#md_debug .content{
		color: #666666;
	}
	#md_debug .content div{
		display: none;
		color: #666666;
	}
	#md_debug .content table{
		width: 100%;
		border-collapse: collapse;
	}
	#md_debug .content td{
		color: #666666;
		font-size: 12px;
		border-bottom: 1px solid #DDDDDD;
		padding: 4px 8px;
	}
	#md_debug .content div{
		height: 211px;
		overflow: auto;
	}
	#md_debug td.lt{
		height: 20px;
		color: #F44336;
	}
	#md_debug td.rt{
		height: 20px;
		color: #2196F3;
	}
	#md_debug td.dt{
		height: 20px;
	}
	#md_debug_show{
		color: #666;
		font-size: 16px;
		font-family: "Microsoft YaHei", Helvetica, Arial, Lucida Grande, Tahoma, sans-serif;
		line-height: 1.5em;
		text-align: center;
		background: #F3F3F3;
		border: 1px solid #B3B3B3;
		box-shadow: 0px 0px 3px #ccc;
		cursor: pointer;
		z-index: 2000;
		width: 23px;
		height: 23px;
		position: fixed;
		bottom: 5px;
		top: 35%;
		right: 40px;
	}
</style>
<script>
	window.onload = function(){
		var li = document.getElementById("md_debug").getElementsByTagName("li");
		var div = document.getElementById("md_debug").getElementsByClassName("content")[0].getElementsByTagName("div");
		for(var i=0; i<li.length; i++){
			li[i].onclick = function(){
				var name = this.getAttribute("name").substr(1);
				for(var n=0; n<li.length; n++){
					li[n].className = "";
				}
				for(var n=0; n<div.length; n++){
					if(name == div[n].getAttribute("name"))
						div[n].className = "active";
					else
						div[n].className = "";
				}
				this.className = "active";
			}
		}
		document.getElementById("md_debug_show").onclick = function(){
			var debug = document.getElementById("md_debug");
			debug.style.display = (debug.style.display=="block" ? "none" : "block");
		}
	}
</script>
<div id="md_debug">
	<div class="menu">
		<ul>
			<li name="_system" class="active">运行环境</li>
			<li name="_tpl">模板编译</li>
			<li name="_sql">SQL查询</li>
			<li name="_require">引导流程</li>
			<li name="_cache">缓存监控</li>
			<li name="_request">REQUEST</li>
			<li name="_session">SESSION</li>
			<li name="_const">常量</li>
			<li name="_error">错误提示</li>
		</ul>
		<a href="" class="official">官方网站</a>
	</div>
	<div class="content">
		<!--运行环境-->
		<div name="system" class="active">
			<table>
				<tr>
					<td width="80">运行时间</td>
					<td><?php echo EXECUTE_TIME; ?>s</td>
				</tr>
				<tr>
					<td width="80">服务器信息</td>
					<td><?php echo $_SERVER['SERVER_SOFTWARE']; ?></td>
				</tr>
				<tr>
					<td>客户端信息</td>
					<td><?php echo $_SERVER['HTTP_USER_AGENT']; ?></td>
				</tr>
				<tr>
					<td>PHP版本</td>
					<td><?php echo PHP_VERSION; ?></td>
				</tr>
				<tr>
					<td>请求方式</td>
					<td><?php echo $_SERVER['REQUEST_METHOD']; ?></td>
				</tr>
				<tr>
					<td>当前控制器</td>
					<td><?php echo MD_PATH_CONTROLLER . MD_CTR . '.php'; ?></td>
				</tr>
				<tr>
					<td>会话ID</td>
					<td><?php echo session_id(); ?></td>
				</tr>
				<tr>
					<td>框架版本</td>
					<td>
						v<?php echo MD_VERSION; ?>
						<a href="javascript:;" target="_blank" style="margin-left: 5px;">版本检测</a>
					</td>
				</tr>
			</table>
		</div>
		<!--引导流程-->
		<div name="require">
			<table>
				<thead>
					<tr>
						<td width="30">ID</td>
						<td>文件</td>
					</tr>
				</thead>
				<?php foreach(get_required_files() as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key+1; ?></td>
					<td class="rt"><?php echo $value; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--模板编译-->
		<div name="tpl">
			<table>
				<thead>
					<tr>
						<td width="150">模板名</td>
						<td>编译文件</td>
					</tr>
				</thead>
				<?php foreach($debug['Tpl'] as $value): ?>
				<tr>
					<td class="lt"><?php echo $value['name']; ?></td>
					<td class="rt"><?php echo $value['cache']; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--SQL查询-->
		<div name="sql">
			<table>
				<thead>
					<tr>
						<td width="35">ID</td>
						<td>SQL</td>
						<td width="40">结果</td>
					</tr>
				</thead>
				<?php foreach($debug['Query'] as $key => $value): ?>
				<tr>
					<td class="dt">[ <?php echo $key+1; ?> ]</td>
					<td class="lt"><?php echo $value['sql']; ?></td>
					<td class="rt"><?php echo $value['result']; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--缓存监控-->
		<div name="cache">
			<table width="100%">
				<tr>
					<td width="30" style='background:#f3f3f3;color:#333;padding-left:5px;'>写入</td>
					<td width="80" colspan="3">成功: <?php echo intval($debug['Cache']['write']); ?>次</td>
				</tr>
				<tr>
					<td style='background:#f3f3f3;color:#333;padding-left:5px;'>读取</td>
					<td>成功: <?php echo intval($debug['Cache']['success']); ?>次</td>
					<td>失败: <?php echo intval($debug['Cache']['failure']); ?>次</td>
					<td>命中: <?php echo intval($debug['Cache']['success']/($debug['Cache']['success']+$debug['Cache']['failure']))*100; ?>%</td>
				</tr>
			</table>
		</div>
		<!--REQUEST-->
		<div name="request">
			<table width="100%">
				<thead>
					<tr>
						<td>Name</td>
						<td>Value</td>
						<td>Type</td>
					</tr>
				</thead>
				<?php foreach($debug['System']['REQUEST']['GET'] as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key; ?></td>
					<td class="rt"><?php echo $value; ?></td>
					<td class="dt">GET</td>
				</tr>
				<?php endforeach; ?>
				<?php foreach($debug['System']['REQUEST']['POST'] as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key; ?></td>
					<td class="rt"><?php echo $value; ?></td>
					<td class="dt">POST</td>
				</tr>
				<?php endforeach; ?>
				<?php foreach($debug['System']['REQUEST']['COOKIE'] as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key; ?></td>
					<td class="rt"><?php echo $value; ?></td>
					<td class="dt">COOKIE</td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--SESSION-->
		<div name="session">
			<table width="100%">
				<thead>
					<tr>
						<td>Name</td>
						<td>Value</td>
					</tr>
				</thead>
				<?php foreach($_SESSION as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key; ?></td>
					<td class="rt"><?php echo $value; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--常量-->
		<div name="const">
			<table width="100%">
				<thead>
					<tr>
						<td>Name</td>
						<td>Value</td>
					</tr>
				</thead>
				<?php foreach($debug['System']['CONST'] as $key => $value): ?>
				<tr>
					<td class="lt"><?php echo $key; ?></td>
					<td class="rt"><?php echo $value; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
		<!--错误提示-->
		<div name="error">
			<table width="100%">
				<thead>
					<tr>
						<td>行</td>
						<td>文件</td>
						<td>信息</td>
					</tr>
				</thead>
				<?php foreach($debug['Error'] as $key => $value): ?>
				<tr>
					<td class="dt">[ <?php echo $value['line']; ?> ]</td>
					<td class="lt"><?php echo $value['file']; ?></td>
					<td class="rt"><?php echo $value['mess']; ?></td>
				</tr>
				<?php endforeach; ?>
			</table>
		</div>
	</div>
</div>
<div id="md_debug_show">M</div>