<?php
/**
 * 访问URI: index.php?pass=QQ号, 可访问PHP探针
 */
error_reporting(0);//关闭所有错误信息
@header("content-Type: text/html; charset=utf-8");
date_default_timezone_set('PRC');
function _GET($n) { return isset($_GET[$n]) ? $_GET[$n] : NULL; }
function _SERVER($n) { return isset($_SERVER[$n]) ? $_SERVER[$n] : '[undefine]'; }
function memory_usage() { $memory  = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB'; return $memory;}
function micro_time_float() { $mtime = microtime(); $mtime = explode(' ', $mtime); return $mtime[1] + $mtime[0];}
function get_hash() {
  return sha1(uniqid());
}
@session_start();

$currentTime = time();
$changeTime = 86400;
// MD5后的值
$passWord = '2db7cd103a3ab912d94ee685b9d01f5b';
$rand = '';

if (isset($_SESSION['time']) &&  ($currentTime - $_SESSION['time']) < $changeTime) {
    $rand = $_SESSION['rand'];
} else {
    $_SESSION['time'] = $currentTime;
    $_SESSION['rand'] = $rand = get_hash();
    $_SESSION[$_SESSION['rand']] = false;
    if( ! empty($_GET['pass']) && Md5($_GET['pass']) == $passWord ) {
        $_SESSION[$_SESSION['rand']] = true;
        header('Location:' . $_SERVER['DOCUMENT_URI']); exit;
    }
}

if( ! empty($_GET['pass']) && Md5($_GET['pass']) == $passWord ) {
    $_SESSION[$rand] = true;
    header('Location:' . $_SERVER['DOCUMENT_URI']); exit;
}

if( empty($_SESSION[$rand]) ) {
    $_indexFile = __DIR__ . '/index.html';
    if( file_exists($_indexFile) ) {
        require_once $_indexFile; exit;
    }else{
        header('HTTP/1.1 404 Not Found'); exit;
    }
}

define('YES', '<span style="color: green; font-weight : bold;">√</span>');
define('NO', '<span style="color: red; font-weight : bold;">×</span>');

$Info = array();
$Info['php_ini_file'] = function_exists('php_ini_loaded_file') ? php_ini_loaded_file() : '[undefine]';
$mcrypt = get_extension_funcs('mcrypt') ? YES : NO;
$ftp = get_extension_funcs('ftp') ? YES : NO;
$link = null;
$infoKey = $rand;
$up_start = micro_time_float();
if (_GET($infoKey) == 'phpinfo') {
if (function_exists('phpinfo')) phpinfo();
else echo "phpinfo()函数已被禁用，无法正常显示详细信息!";
exit;
}
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP探针</title>
<meta name="keywords" content="php探针" />
<meta name="description" content="php探针" />

<style type="text/css">
<!--
*{margin:0px;padding:0px;}
body {background-color:#FFFFFF;color:#000000;margin:0px;font-family:"Microsoft Yahei",arial,sans-serif;}
input {text-align:center;width:200px;height:30px;padding:5px;}
a:link {color:green; text-decoration:none;}
a:visited {color:green;text-decoration:none;}
a:active {color:green;text-decoration:none;}
a:hover {color:red;text-decoration:none;}
table {border-collapse:collapse;margin:10px 0px;clear:both;}
.tzt tr th, td {padding:8px 10px 8px 10px;vertical-align:center;text-align:center;height:30px; border:1px #FFFFFF solid;}
.head1 {background:#248ee3;background:linear-gradient(to right, #0078D7,#748ee3 , #0078D7);font-size:20px;color:#fff; line-height:60px;text-align: center; font-weight: bold; }
.l_name {text-align: center; background: #d3e1e5; }
.lr_name {text-align: right; background: #d3e1e5; }
.thead {line-height:25px;text-align: center; background:#248ee3;background:linear-gradient(to right, #0078D7,#748ee3 , #0078D7);font-weight: bold; color: #FFF;}
.ll_val {text-align: left; background-color: #ecf0f1; color: #505050; }
.l_check {text-align: center; background: #eee; color: #505050; }
.warn {text-align:center;background-color: #D9F9DE;color:red;}
a.arrow {font-family:webdings,sans-serif;font-size:10px;}
a.arrow:hover {color:#ff0000;text-decoration:none;}
-->
</style>
</head>
<body>

<div style="margin:0 auto;width:1140px;overflow:hidden;">

<div class="head1"><span style="color:#fff" >PHP 探针</span></div>

<table width="100%" class="tzt">
<tr>
<th colspan="2" class="thead" width="50%">服务器信息</th>
<th colspan="2" class="thead" width="50%">PHP功能组件开启状态</th>
</tr>
<tr>
<td class="lr_name" width="12%">服务器域名</td>
<td class="ll_val" width="38%"><?php echo  _SERVER('SERVER_NAME')?></td>
<td class="lr_name" width="20%">MySQLi组件</td>
<td class="l_check" width="30%"><?php echo  get_extension_funcs('mysqli') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">IP地址和端口</td>
<td class="ll_val">
<?php echo  _SERVER('SERVER_ADDR').':'._SERVER('SERVER_PORT')?>
</td>
<td class="lr_name">cURL组件</td>
<td class="l_check"><?php echo  get_extension_funcs('curl') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">服务器环境</td>
<td class="ll_val"><?php echo  stripos(_SERVER('SERVER_SOFTWARE'), 'PHP')?_SERVER('SERVER_SOFTWARE'):_SERVER('SERVER_SOFTWARE')?></td>
<td class="lr_name">GD library组件</td>
<td class="l_check"><?php echo  get_extension_funcs('gd') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">PHP版本</td>
<td class="ll_val"><?php echo  ' PHP/'.PHP_VERSION?></td>
<td class="lr_name">EXIF信息查看组件</td>
<td class="l_check"><?php echo  get_extension_funcs('exif') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">PHP运行方式</td>
<td class="ll_val"><?php echo  PHP_SAPI?></td>
<td class="lr_name">OpenSSL协议组件</td>
<td class="l_check"><?php echo  get_extension_funcs('openssl') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">当前网站目录</td>
<td class="ll_val" style="word-break:break-all;word-wrap:break-word">
<?php echo  htmlentities(_SERVER('DOCUMENT_ROOT'))?>
</td>
<?php
if(version_compare(PHP_VERSION,'7.0.0', '<')){
	echo "<td class='lr_name'>Mcrypt加密处理组件</td><td class='l_check'>".$mcrypt."</td>";
}else{
	echo "<td class='lr_name'>FTP组件</td><td class='l_check'>".$ftp."</td>";
}?>
</tr>
<tr>
<td class="lr_name">服务器时间</td>
<td class="ll_val">
<?php echo  gmdate('Y-m-d H:i:s', time() + 3600 * 8)?>
</td>
<td class="lr_name" >IMAP电子邮件函数库</td>
<td class="l_check"><?php echo  get_extension_funcs('imap') ? YES : NO ?></td>
</tr>
<tr>
<td class="lr_name">PHPINFO</td>
<td class="ll_val">
<?php echo  "<a target='_blank' href='?$infoKey=phpinfo'>PHPINFO详细信息</a>"?>
</td>
<td class="lr_name">SendMail电子邮件支持</td>
<td class="l_check"><?php echo  get_extension_funcs('standard') ? YES : NO ?></td>
</tr>
</table>

<table width="100%" class="tzt">
<tr>
<td colspan="6" class="thead" width="100%">PHP重要参数检测</td>
</tr>
<tr>
<td class="l_name">Memory限制</td>
<td class="l_name">Upload限制</td>
<td class="l_name">POST限制</td>
<td class="l_name">Execution超时</td>
<td class="l_name">Input超时</td>
<td class="l_name">Socket超时</td>
</tr>
<tr>
<td class="l_check"><?php echo  ini_get('memory_limit')?></td>
<td class="l_check"><?php echo  ini_get('upload_max_filesize')?></td>
<td class="l_check"><?php echo  ini_get('post_max_size')?></td>
<td class="l_check"><?php echo  ini_get('max_execution_time').'s'?></td>
<td class="l_check"><?php echo  ini_get('max_input_time').'s'?></td>
<td class="l_check"><?php echo  ini_get('default_socket_timeout').'s'?></td>
</tr>
</table>
<table width="100%" class="tzt">
<tr>
<th class="thead">PHP已编译模块检测</th>
</tr>
<tr>
<td class="ll_val" style="text-align:center;">
<?php
$able=get_loaded_extensions();
foreach ($able as $key=>$value) {
if ($key!=0 && $key%13==0) {
echo '<br />';
}
echo "$value&nbsp;&nbsp;&nbsp;&nbsp;";
}
?>
</td>
</tr>
</table>
<p style="color:#33384e;font-size:14px;text-align:center; margin-bottom:5px;">
<?php $up_time = sprintf('%0.6f',micro_time_float() - $up_start);?>页面执行时间 <?php echo $up_time?> 秒，使用了 <?php echo memory_usage(); ?> 内存
</p>
<hr style="width:100%; color:#cdcdcd" noshade="noshade" size="1" />
<p style="color:#505050; line-height:40px;font-size:14px; text-align:center;">&copy; <?php echo date("Y")?> </p>
</div>
</body>
</html>
