home.php

东方宜
2023-12-01

 home.php

 

<?php

error_reporting(0); //抑制所有错误信息
@header("content-Type: text/html; charset=utf-8"); //语言强制
ob_start();

function valid_email($str) 
{
    return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}

//检测PHP设置参数
function show($varName)
{
    switch($result = get_cfg_var($varName))
    {
        case 0:
            return '<font color="red">×</font>';
        break;
        
        case 1:
            return '<font color="green">√</font>';
        break;
        
        default:
            return $result;
        break;
    }
}


if ($_GET['act'] == "phpinfo") 
{
    phpinfo();
    exit();
} 
elseif($_GET['act'] == "Function")
{
    $arr = get_defined_functions();
    Function php()
    {
    }
    echo "<pre>";
    Echo "这里显示系统所支持的所有函数,和自定义函数\n";
    print_r($arr);
    echo "</pre>";
    exit();
}elseif($_GET['act'] == "disable_functions")
{
    $disFuns=get_cfg_var("disable_functions");
    if(empty($disFuns))
    {
        $arr = '<font color=red>×</font>';
    }
    else
    { 
        $arr = $disFuns;
    }
    Function php()
    {
    }
    echo "<pre>";
    Echo "这里显示系统被禁用的函数\n";
    print_r($arr);
    echo "</pre>";
    exit();
}

//MySQL检测
if ($_POST['act'] == 'MySQL检测')
{
    $host = isset($_POST['host']) ? trim($_POST['host']) : '';
    $port = isset($_POST['port']) ? (int) $_POST['port'] : '';
    $login = isset($_POST['login']) ? trim($_POST['login']) : '';
    $password = isset($_POST['password']) ? trim($_POST['password']) : '';
    $host = preg_match('~[^a-z0-9\-\.]+~i', $host) ? '' : $host;
    $port = intval($port) ? intval($port) : '';
    $login = preg_match('~[^a-z0-9\_\-]+~i', $login) ? '' : htmlspecialchars($login);
    $password = is_string($password) ? htmlspecialchars($password) : '';
}
elseif ($_POST['act'] == '函数检测')
{
    $funRe = "函数".$_POST['funName']."支持状况检测结果:".isfun1($_POST['funName']);
} 
elseif ($_POST['act'] == '邮件检测')
{
    $mailRe = "邮件发送检测结果:发送";
    if($_SERVER['SERVER_PORT']==80){$mailContent = "http://".$_SERVER['SERVER_NAME'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);}
    else{$mailContent = "http://".$_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);}
    $mailRe .= (false !== @mail($_POST["mailAdd"], $mailContent, "This is a test mail!\n\nhttp://lnmp.org")) ? "完成":"失败";
}    
    
// 检测函数支持
function isfun($funName = '')
{
    if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误';
    return (false !== function_exists($funName)) ? '<font color="green">√</font>' : '<font color="red">×</font>';
}
function isfun1($funName = '')
{
    if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误';
    return (false !== function_exists($funName)) ? '√' : '×';
}

?>

<!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>phpStudy 探针 2014 </title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
<!--
* {font-family: Tahoma, "Microsoft Yahei", Arial; }
body{text-align: center; margin: 0 auto; padding: 0; background-color:#FFFFFF;font-size:12px;font-family:Tahoma, Arial}
h1 {font-size: 26px; font-weight: normal; padding: 0; margin: 0; color: #444444;}
h1 small {font-size: 11px; font-family: Tahoma; font-weight: bold; }
a{color: #000000; text-decoration:none;}
a.black{color: #000000; text-decoration:none;}
b{color: #999999;}
table{clear:both;padding: 0; margin: 0 0 10px;border-collapse:collapse; border-spacing: 0;}
th{padding: 3px 6px; font-weight:bold;background:#3066a6;color:#FFFFFF;border:1px solid #3066a6; text-align:left;}
.th_1{padding: 3px 6px; font-weight:bold;background:#666699;color:#FFFFFF;border:1px solid #3066a6; text-align:left;}

tr{padding: 0; background:#F7F7F7;}
td{padding: 3px 6px; border:1px solid #CCCCCC;}
input{padding: 2px; background: #FFFFFF; border-top:1px solid #666666; border-left:1px solid #666666; border-right:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; font-size:12px}
input.btn{font-weight: bold; height: 20px; line-height: 20px; padding: 0 6px; color:#666666; background: #f2f2f2; border:1px solid #999;font-size:12px}
.bar {border:1px solid #999999; background:#FFFFFF; height:5px; font-size:2px; width:89%; margin:2px 0 5px 0;padding:1px;overflow: hidden;}
.bar_1 {border:1px dotted #999999; background:#FFFFFF; height:5px; font-size:2px; width:89%; margin:2px 0 5px 0;padding:1px;overflow: hidden;}
.barli_red{background:#ff6600; height:5px; margin:0px; padding:0;}
.barli_blue{background:#0099FF; height:5px; margin:0px; padding:0;}
.barli_green{background:#36b52a; height:5px; margin:0px; padding:0;}
.barli_1{background:#999999; height:5px; margin:0px; padding:0;}
.barli{background:#36b52a; height:5px; margin:0px; padding:0;}
#page {width: 920px; padding: 0 20px; margin: 0 auto; text-align: left;}
#header{position: relative; padding: 10px;}
#footer {padding: 15px 15px; text-align: left; font-size: 12px; font-family: Tahoma, Verdana;line-height:16px}
#lnmplink {position: absolute; top: 20px; left: 200px; text-align: right; font-weight: bold; color: #06C;}
#lnmplink a {color: #0000FF; text-decoration: underline;}
#lnmplink2 {position: absolute; top: 20px; right: 80px; text-align: right; font-weight: bold; color: #06C;}
#lnmplink2 a {color: #0000FF; text-decoration: underline;}
.w_small{font-family: Courier New;}
.w_number{color: #f800fe;}
.sudu {padding: 0; background:#5dafd1; }
.suduk { margin:0px; padding:0;}
.resNo{color: #FF0000;}
.word{word-break:break-all;}
-->
</style>

</head>
<body>

<div id="page">
    <div id="header">
        <h1>phpStudy 探针</h1>
    </div>

<!--服务器相关参数-->
<table width="100%" cellpadding="3" cellspacing="0">
  <tr><th colspan="4">服务器参数</th></tr>
  <tr>
    <td>服务器域名/IP地址</td>
    <td colspan="3"><?php echo $_SERVER['SERVER_NAME'];?>(<?php if('/'==DIRECTORY_SEPARATOR){echo $_SERVER['SERVER_ADDR'];}else{echo @gethostbyname($_SERVER['SERVER_NAME']);} ?>)</td>
  </tr>
  <tr>
    <td>服务器标识</td>
    <td colspan="3"><?php if($sysInfo['win_n'] != ''){echo $sysInfo['win_n'];}else{echo @php_uname();};?></td>
  </tr>
  <tr>
    <td width="13%">服务器操作系统</td>
    <td width="37%"><?php $os = explode(" ", php_uname()); echo $os[0];?> &nbsp;内核版本:<?php if('/'==DIRECTORY_SEPARATOR){echo $os[2];}else{echo $os[1];} ?></td>
    <td width="13%">服务器解译引擎</td>
    <td width="37%"><?php echo $_SERVER['SERVER_SOFTWARE'];?></td>
  </tr>
  <tr>
    <td>服务器语言</td>
    <td><?php echo getenv("HTTP_ACCEPT_LANGUAGE");?></td>
    <td>服务器端口</td>
    <td><?php echo $_SERVER['SERVER_PORT'];?></td>
  </tr>
  <tr>
      <td>服务器主机名</td>
      <td><?php if('/'==DIRECTORY_SEPARATOR ){echo $os[1];}else{echo $os[2];} ?></td>
      <td>绝对路径</td>
      <td><?php echo $_SERVER['DOCUMENT_ROOT']?str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']):str_replace('\\','/',dirname(__FILE__));?></td>
    </tr>
  <tr>
      <td>管理员邮箱</td>
      <td><?php echo $_SERVER['SERVER_ADMIN'];?></td>
        <td>探针路径</td>
        <td><?php echo str_replace('\\','/',__FILE__)?str_replace('\\','/',__FILE__):$_SERVER['SCRIPT_FILENAME'];?></td>
    </tr>
</table>



<table width="100%" cellpadding="3" cellspacing="0" align="center">
  <tr>
    <th colspan="4">PHP已编译模块检测</th>
  </tr>
  <tr>
    <td colspan="4"><span class="w_small">
<?php
$able=get_loaded_extensions();
foreach ($able as $key=>$value) {
    if ($key!=0 && $key%13==0) {
        echo '<br />';
    }
    echo "$value&nbsp;&nbsp;";
}
?></span>
    </td>
  </tr>
</table>
<table width="100%" cellpadding="3" cellspacing="0" align="center">
  <tr><th colspan="4">PHP相关参数</th></tr>
  <tr>
    <td width="32%">PHP信息(phpinfo):</td>
    <td width="18%">
        <?php
        $phpSelf = $_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME];
        $disFuns=get_cfg_var("disable_functions");
        ?>
    <?php echo (false!==eregi("phpinfo",$disFuns))? '<font color="red">×</font>' :"<a href='$phpSelf?act=phpinfo' target='_blank'>PHPINFO</a>";?>
    </td>
    <td width="32%">PHP版本(php_version):</td>
    <td width="18%"><?php echo PHP_VERSION;?></td>
  </tr>
  <tr>
    <td>PHP运行方式:</td>
    <td><?php echo strtoupper(php_sapi_name());?></td>
    <td>脚本占用最大内存(memory_limit):</td>
    <td><?php echo show("memory_limit");?></td>
  </tr>
  <tr>
    <td>PHP安全模式(safe_mode):</td>
    <td><?php echo show("safe_mode");?></td>
    <td>POST方法提交最大限制(post_max_size):</td>
    <td><?php echo show("post_max_size");?></td>
  </tr>
  <tr>
    <td>上传文件最大限制(upload_max_filesize):</td>
    <td><?php echo show("upload_max_filesize");?></td>
    <td>浮点型数据显示的有效位数(precision):</td>
    <td><?php echo show("precision");?></td>
  </tr>
  <tr>
    <td>脚本超时时间(max_execution_time):</td>
    <td><?php echo show("max_execution_time");?>秒</td>
    <td>socket超时时间(default_socket_timeout):</td>
    <td><?php echo show("default_socket_timeout");?>秒</td>
  </tr>
  <tr>
    <td>PHP页面根目录(doc_root):</td>
    <td><?php echo show("doc_root");?></td>
    <td>用户根目录(user_dir):</td>
    <td><?php echo show("user_dir");?></td>
  </tr>
  <tr>
    <td>dl()函数(enable_dl):</td>
    <td><?php echo show("enable_dl");?></td>
    <td>指定包含文件目录(include_path):</td>
    <td><?php echo show("include_path");?></td>
  </tr>
  <tr>
    <td>显示错误信息(display_errors):</td>
    <td><?php echo show("display_errors");?></td>
    <td>自定义全局变量(register_globals):</td>
    <td><?php echo show("register_globals");?></td>
  </tr>
  <tr>
    <td>数据反斜杠转义(magic_quotes_gpc):</td>
    <td><?php echo show("magic_quotes_gpc");?></td>
    <td>"&lt;?...?&gt;"短标签(short_open_tag):</td>
    <td><?php echo show("short_open_tag");?></td>
  </tr>
  <tr>
    <td>"&lt;% %&gt;"ASP风格标记(asp_tags):</td>
    <td><?php echo show("asp_tags");?></td>
    <td>忽略重复错误信息(ignore_repeated_errors):</td>
    <td><?php echo show("ignore_repeated_errors");?></td>
  </tr>
  <tr>
    <td>忽略重复的错误源(ignore_repeated_source):</td>
    <td><?php echo show("ignore_repeated_source");?></td>
    <td>报告内存泄漏(report_memleaks):</td>
    <td><?php echo show("report_memleaks");?></td>
  </tr>
  <tr>
    <td>自动字符串转义(magic_quotes_gpc):</td>
    <td><?php echo show("magic_quotes_gpc");?></td>
    <td>外部字符串自动转义(magic_quotes_runtime):</td>
    <td><?php echo show("magic_quotes_runtime");?></td>
  </tr>
  <tr>
    <td>打开远程文件(allow_url_fopen):</td>
    <td><?php echo show("allow_url_fopen");?></td>
    <td>声明argv和argc变量(register_argc_argv):</td>
    <td><?php echo show("register_argc_argv");?></td>
  </tr>
  <tr>
    <td>Cookie 支持:</td>
    <td><?php echo isset($_COOKIE)?'<font color="green">√</font>' : '<font color="red">×</font>';?></td>
    <td>拼写检查(ASpell Library):</td>
    <td><?php echo isfun("aspell_check_raw");?></td>
  </tr>
   <tr>
    <td>高精度数学运算(BCMath):</td>
    <td><?php echo isfun("bcadd");?></td>
    <td>PREL相容语法(PCRE):</td>
    <td><?php echo isfun("preg_match");?></td>
   <tr>
    <td>PDF文档支持:</td>
    <td><?php echo isfun("pdf_close");?></td>
    <td>SNMP网络管理协议:</td>
    <td><?php echo isfun("snmpget");?></td>
  </tr> 
   <tr>
    <td>VMailMgr邮件处理:</td>
    <td><?php echo isfun("vm_adduser");?></td>
    <td>Curl支持:</td>
    <td><?php echo isfun("curl_init");?></td>
  </tr> 
   <tr>
    <td>SMTP支持:</td>
    <td><?php echo get_cfg_var("SMTP")?'<font color="green">√</font>' : '<font color="red">×</font>';?></td>
    <td>SMTP地址:</td>
    <td><?php echo get_cfg_var("SMTP")?get_cfg_var("SMTP"):'<font color="red">×</font>';?></td>
  </tr> 
    <tr>
        <td>默认支持函数(enable_functions):</td>
        <td colspan="3"><a href='<?php echo $phpSelf;?>?act=Function' target='_blank' class='static'>请点这里查看详细!</a></td>        
    </tr>
    <tr>
        <td>被禁用的函数(disable_functions):</td>
        <td colspan="3" class="word">
<?php 
$disFuns=get_cfg_var("disable_functions");
if(empty($disFuns))
{
    echo '<font color=red>×</font>';
}
else
{ 
    //echo $disFuns;
    $disFuns_array =  explode(',',$disFuns);
    foreach ($disFuns_array as $key=>$value) 
    {
        if ($key!=0 && $key%5==0) {
            echo '<br />';
    }
    echo "$value&nbsp;&nbsp;";
}    
}

?>
        </td>
    </tr>
</table>
<!--组件信息-->
<table width="100%" cellpadding="3" cellspacing="0" align="center">
  <tr><th colspan="4" >组件支持</th></tr>
  <tr>
    <td width="32%">FTP支持:</td>
    <td width="18%"><?php echo isfun("ftp_login");?></td>
    <td width="32%">XML解析支持:</td>
    <td width="18%"><?php echo isfun("xml_set_object");?></td>
  </tr>
  <tr>
    <td>Session支持:</td>
    <td><?php echo isfun("session_start");?></td>
    <td>Socket支持:</td>
    <td><?php echo isfun("socket_accept");?></td>
  </tr>
  <tr>
    <td>Calendar支持</td>
    <td><?php echo isfun('cal_days_in_month');?>
    </td>
    <td>允许URL打开文件:</td>
    <td><?php echo show("allow_url_fopen");?></td>
  </tr>
  <tr>
    <td>GD库支持:</td>
    <td>
    <?php
        if(function_exists(gd_info)) {
            $gd_info = @gd_info();
            echo $gd_info["GD Version"];
        }else{echo '<font color="red">×</font>';}
    ?></td>
    <td>压缩文件支持(Zlib):</td>
    <td><?php echo isfun("gzclose");?></td>
  </tr>
  <tr>
    <td>IMAP电子邮件系统函数库:</td>
    <td><?php echo isfun("imap_close");?></td>
    <td>历法运算函数库:</td>
    <td><?php echo isfun("JDToGregorian");?></td>
  </tr>
  <tr>
    <td>正则表达式函数库:</td>
    <td><?php echo isfun("preg_match");?></td>
    <td>WDDX支持:</td>
    <td><?php echo isfun("wddx_add_vars");?></td>
  </tr>
  <tr>
    <td>Iconv编码转换:</td>
    <td><?php echo isfun("iconv");?></td>
    <td>mbstring:</td>
    <td><?php echo isfun("mb_eregi");?></td>
  </tr>
  <tr>
    <td>高精度数学运算:</td>
    <td><?php echo isfun("bcadd");?></td>
    <td>LDAP目录协议:</td>
    <td><?php echo isfun("ldap_close");?></td>
  </tr>
  <tr>
    <td>MCrypt加密处理:</td>
    <td><?php echo isfun("mcrypt_cbc");?></td>
    <td>哈稀计算:</td>
    <td><?php echo isfun("mhash_count");?></td>
  </tr>
</table>

<!--第三方组件信息-->
<table width="100%" cellpadding="3" cellspacing="0" align="center">
  <tr><th colspan="4" >第三方组件</th></tr>
  <tr>
    <td width="32%">Zend版本</td>
    <td width="18%"><?php $zend_version = zend_version();if(empty($zend_version)){echo '<font color=red>×</font>';}else{echo $zend_version;}?></td>
    <td width="32%">
<?php
$PHP_VERSION = PHP_VERSION;
$PHP_VERSION = substr($PHP_VERSION,2,1);
if($PHP_VERSION > 2)
{
    echo "ZendGuardLoader[启用]";
}
else
{
    echo "Zend Optimizer";
}
?>
    </td>
    <td width="18%"><?php if($PHP_VERSION > 2){echo (get_cfg_var("zend_loader.enable"))?'<font color=green>√</font>':'<font color=red>×</font>';} else{if(function_exists('zend_optimizer_version')){    echo zend_optimizer_version();}else{    echo (get_cfg_var("zend_optimizer.optimization_level")||get_cfg_var("zend_extension_manager.optimizer_ts")||get_cfg_var("zend.ze1_compatibility_mode")||get_cfg_var("zend_extension_ts"))?'<font color=green>√</font>':'<font color=red>×</font>';}}?></td>
  </tr>
  <tr>
    <td>eAccelerator</td>
    <td><?php if((phpversion('eAccelerator'))!=''){echo phpversion('eAccelerator');}else{ echo "<font color=red>×</font>";} ?></td>
    <td>ioncube</td>
    <td><?php if(extension_loaded('ionCube Loader')){   $ys = ioncube_loader_iversion();   $gm = ".".(int)substr($ys,3,2);   echo ionCube_Loader_version().$gm;}else{echo "<font color=red>×</font>";}?></td>
  </tr>
  <tr>
    <td>XCache</td>
    <td><?php if((phpversion('XCache'))!=''){echo phpversion('XCache');}else{ echo "<font color=red>×</font>";} ?></td>
    <td>APC</td>
    <td><?php if((phpversion('APC'))!=''){echo phpversion('APC');}else{ echo "<font color=red>×</font>";} ?></td>
  </tr>
</table>

<!--数据库支持-->
<table width="100%" cellpadding="3" cellspacing="0" align="center">
  <tr><th colspan="4">数据库支持</th></tr>
  <tr>
    <td width="32%">MySQL 数据库:</td>
    <td width="18%"><?php echo isfun("mysql_close");?>
    <?php
    if(function_exists("mysql_get_server_info")) {
        $s = @mysql_get_server_info();
        $s = $s ? '&nbsp; mysql_server 版本:'.$s : '';
        $c = '&nbsp; mysql_client 版本:'.@mysql_get_client_info();
        echo $s;
    }
    ?>
    </td>
    <td width="32%">ODBC 数据库:</td>
    <td width="18%"><?php echo isfun("odbc_close");?></td>
  </tr>
  <tr>
    <td>Oracle 数据库:</td>
    <td><?php echo isfun("ora_close");?></td>
    <td>SQL Server 数据库:</td>
    <td><?php echo isfun("mssql_close");?></td>
  </tr>
  <tr>
    <td>dBASE 数据库:</td>
    <td><?php echo isfun("dbase_close");?></td>
    <td>mSQL 数据库:</td>
    <td><?php echo isfun("msql_close");?></td>
  </tr>
  <tr>
    <td>SQLite 数据库:</td>
    <td><?php if(extension_loaded('sqlite3')) {$sqliteVer = SQLite3::version();echo '<font color=green>√</font> ';echo "SQLite3 Ver ";echo $sqliteVer[versionString];}else {echo isfun("sqlite_close");if(isfun("sqlite_close") == '<font color="green">√</font>') {echo "&nbsp; 版本: ".@sqlite_libversion();}}?></td>
    <td>Hyperwave 数据库:</td>
    <td><?php echo isfun("hw_close");?></td>
  </tr>
  <tr>
    <td>Postgre SQL 数据库:</td>
    <td><?php echo isfun("pg_close"); ?></td>
    <td>Informix 数据库:</td>
    <td><?php echo isfun("ifx_close");?></td>
  </tr>
  <tr>
    <td>DBA 数据库:</td>
    <td><?php echo isfun("dba_close");?></td>
    <td>DBM 数据库:</td>
    <td><?php echo isfun("dbmclose");?></td>
  </tr>
  <tr>
    <td>FilePro 数据库:</td>
    <td><?php echo isfun("filepro_fieldcount");?></td>
    <td>SyBase 数据库:</td>
    <td><?php echo isfun("sybase_close");?></td>
  </tr> 
</table>

<form action="<?php echo $_SERVER[PHP_SELF]."#bottom";?>" method="post">
<!--MySQL数据库连接检测-->
<table width="100%" cellpadding="3" cellspacing="0" align="center">
    <tr><th colspan="3">MySQL数据库连接检测</th></tr>
  <tr>
    <td width="15%"></td>
    <td width="60%">
      地址:<input type="text" name="host" value="localhost" size="10" />
      端口:<input type="text" name="port" value="3306" size="10" />
      用户名:<input type="text" name="login" size="10" />
      密码:<input type="password" name="password" size="10" />
    </td>
    <td width="25%">
      <input class="btn" type="submit" name="act" value="MySQL检测" />
    </td>
  </tr>
</table>
  <?php
  if ($_POST['act'] == 'MySQL检测') {
      if(function_exists("mysql_close")==1) {
          $link = @mysql_connect($host.":".$port,$login,$password);
          if ($link){
              echo "<script>alert('连接到MySql数据库正常')</script>";
          } else {
              echo "<script>alert('无法连接到MySql数据库!')</script>";
          }
      } else {
          echo "<script>alert('服务器不支持MySQL数据库!')</script>";
      }
  }
    ?>
<!--函数检测-->
<table width="100%" cellpadding="3" cellspacing="0" align="center">
    <tr><th colspan="3">函数检测</th></tr>
  <tr>
    <td width="15%"></td>
    <td width="60%">
      请输入您要检测的函数:
      <input type="text" name="funName" size="50" />
    </td>
    <td width="25%">
      <input class="btn" type="submit" name="act" align="right" value="函数检测" />
    </td>
  </tr>
  <?php
  if ($_POST['act'] == '函数检测') {
      echo "<script>alert('$funRe')</script>";
  }
  ?>
</table>

</form>


<div id="footer">
</div>

</div>
</body>
</html>

 

 

<?php
/* 
 * PHP Lab Script v2.00 (2014-03-20)
 * Brandon Thomas (brandon@uncon.net)
 */

function setHttpResponse() {
    $httpResponseMessage = array(
        // Informational
        100 => '100 Continue',
        101 => '101 Switching Protocols',
        // Successful
        200 => '200 OK',
        201 => '201 Created',
        202 => '202 Accepted',
        203 => '203 Non-Authoritative Information',
        204 => '204 No Content',
        205 => '205 Reset Content',
        206 => '206 Partial Content',
        // Redirection
        300 => '300 Multiple Choices',
        301 => '301 Moved Permanently',
        302 => '302 Found',
        303 => '303 See Other',
        304 => '304 Not Modified',
        305 => '305 Use Proxy',
        306 => '306 (Unused)',
        307 => '307 Temporary Redirect',
        // Client Error
        400 => '400 Bad Request',
        401 => '401 Unauthorized',
        402 => '402 Payment Required',
        403 => '403 Forbidden',
        404 => '404 Not Found',
        405 => '405 Method Not Allowed',
        406 => '406 Not Acceptable',
        407 => '407 Proxy Authentication Required',
        408 => '408 Request Timeout',
        409 => '409 Conflict',
        410 => '410 Gone',
        411 => '411 Length Required',
        412 => '412 Precondition Failed',
        413 => '413 Request Entity Too Large',
        414 => '414 Request-URI Too Long',
        415 => '415 Unsupported Media Type',
        416 => '416 Requested Range Not Satisfiable',
        417 => '417 Expectation Failed',
        // Server Error
        500 => '500 Internal Server Error',
        501 => '501 Not Implemented',
        502 => '502 Bad Gateway',
        503 => '503 Service Unavailable',
        504 => '504 Gateway Timeout',
        505 => '505 HTTP Version Not Supported'
    );

    if(! @$httpResp = (int)rawurldecode($_GET['resp'])) $httpResp = 200;
    if($httpResp >= 100 && $httpResp < 600) {
        $httpHeader = 'HTTP/1.1 ' . $httpResponseMessage[$httpResp];
        header($httpHeader);
    }
    return $httpHeader;
}

function doSleep() {
    if(! @$sleep = (int)rawurldecode($_GET['sleep'])) $sleep = 0;
    if($sleep > 0) {
        $slept['start time'] = date('h:i:s');
        sleep($sleep);
        $slept['end time'] = date('h:i:s');
    }
    if(!empty($slept)) return $slept;
}

function doPad() {
        if(! @$pad = (int)rawurldecode($_GET['pad'])) $pad = 0;
        if($pad > 8) {
                $realPad = $pad - 4;
                $padding = str_pad("<!-- ", $realPad, "#") . " -->";
                $padded['padded'] = $pad . " bytes" . $padding;
        }
        if(!empty($padded)) return $padded;
}

function setHttpLocation() {
    if(! @$locationHeader = rawurldecode($_GET['loc'])) $locationHeader = "";
    if(! $locationHeader == "") {
        header("Location: " . $locationHeader);
    }
}

function getHttpParams() { 
    $param = array();
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 5) == 'HTTP_') { 
            $param[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
        }
    }
    return $param;
}

function getRequestParams() { 
    $param = array();
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 8) == 'REQUEST_') { 
            $param[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 8)))))] = $value;
        }
    }
    return $param;
}

function getDocumentParams() { 
    $param = array();
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 9) == 'DOCUMENT_') { 
            $param[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 9)))))] = $value;
        }
    }
    return $param;
}

function getServerParams() { 
    $param = array();
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 7) == 'SERVER_') { 
            $param[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 7)))))] = $value;
        }
    }
    return $param;
}

function getRemoteParams() { 
    $param = array();
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 7) == 'REMOTE_') { 
            $param[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 7)))))] = $value;
        }
    }
    return $param;
}

function buildTable($params) {
    $table = "";
    if (!empty($params)) {
        $table = "<table>\n\t<tbody>\n";
        foreach ($params as $Header => $Value) {
            $table .= "\t\t<tr>\n";
            $table .= "\t\t\t<th>$Header</th>";
            $table .= "<td>$Value</td>\n";
            $table .= "\t\t</tr>\n";
        }
        $table .= "\t</tbody>\n</table>\n";
    }
    return $table;
}

function buildFilesTable($params) {
    $table = "";
    if (!empty($params)) {
        $table = "<table>\n\t<tbody>\n";
        foreach ($params as $File => $Value) {
            $table .= "\t\t<tr>\n";
            $table .= "\t\t\t<th>$File</th>";
            $table .= "<td>$Value[name]</td>";
            $table .= "<td>$Value[type]</td>";
            $table .= "<td>$Value[size] bytes</td>\n";
            $table .= "\t\t</tr>\n";
        }
        $table .= "\t</tbody>\n</table>\n";
    }
    return $table;
}

function getColor() {
    switch (substr($_SERVER['SERVER_ADDR'], -1)) {
    case 0:
        $pageColor = "Black";
        break;
    case 1:
        $pageColor = "Blue";
        break;
    case 2:
        $pageColor = "Red";
        break;
    case 3:
        $pageColor = "Green";
        break;
    case 4:
        $pageColor = "Maroon";
        break;
    case 5:
        $pageColor = "Navy";
        break;
    case 6:
        $pageColor = "Olive";
        break;
    case 7:
        $pageColor = "Purple";
        break;
    case 8:
        $pageColor = "Gray";
        break;
    case 9:
        $pageColor = "Teal";
        break;
    default:
        $pageColor = "Black";
    }
    return $pageColor;
}

function setHttpCookie() {
    if (!empty($_POST["NewCookie"])) setcookie("CookieTest" . time(), $_POST["NewCookie"], time()+300, "/");
}

$slept = doSleep();
$pad = doPad();
$httpHeader = setHttpResponse();
setHttpLocation();
setHttpCookie();
$serverName = php_uname("n");
$pageColor = getColor();
$pageTitle = strtolower("$serverName $pageColor");

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<title><?php echo $pageTitle; ?></title>
<style>
body {
    font-family: Helvetica, Arial, sans-serif;
    color: White;
    background-color: <?php echo $pageColor ?>;
    font-size: 11pt;
}
a, a:link, a:visited, a:hover, a:active {
    color: DarkGray;
    text-decoration: none ;
}
table {
    margin-left: 12px;
    border: 1px solid White;
}
th {
    text-align: left;
    padding: 4px;
    background: rgb(128, 128, 128);
    background: rgba(0, 0, 0, .25);
}
td {
    text-align: left;
    padding: 4px;
    background: rgb(64, 64, 64);
    background: rgba(0, 0, 0, .125);
}
</style>
</head>
<body>

<h1><?php echo $pageTitle; ?></h1>

<?php if(!empty($slept)) {
    echo "<h2>slept</h2>\n";
    echo buildTable($slept);
} ?>

<?php if(!empty($pad)) {
        echo "<h2>pad</h2>\n";
        echo buildTable($pad);
} ?>

<!--
<div class="content">
    <pre>
Using Note: Need Edit `/usr/local/etc/nginx/sites/default.conf`.

        server {
            expires max;

            listen 80;
            listen 443 ssl;
            include conf.d/ssl;

            location / {
                fastcgi_pass unix:/var/run/php-fpm.sock;
                fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx/index.php;
                include fastcgi_params;
            }
        }
    </pre>
</div>
-->

<h2>request</h2>
<?php echo buildTable(getRequestParams()); ?>

<h2>http (headers)</h2>
<?php echo buildTable(getHttpParams()); ?>

<?php if(!empty($_COOKIE)) {
    echo "<h2>cookies</h2>\n";
    echo buildTable($_COOKIE);
} ?>

<?php if(!empty($_POST) || !empty($_FILES)) {
    echo "<h2>post</h2>\n";
    echo buildTable($_POST);
    echo buildFilesTable($_FILES);
} ?>

<h2>document</h2>
<?php echo buildTable(getDocumentParams()); ?>

<h2>remote</h2>
<?php echo buildTable(getRemoteParams()); ?>

<h2>server</h2>
<?php echo buildTable(getServerParams()); ?>

<h2>links</h2>
<table>
    <tbody>
        <tr>
            <td><a href="<?php echo $_SERVER['REQUEST_URI']; ?>">myself</a></td>
        </tr><tr>
            <td><a href="/">root</a></td>
        </tr><tr>
            <td><a href="http://google.com">Google</a></td>
        </tr>
    </tbody>
</table>

<h2>create cookie</h2>
<table>
    <tbody>
        <tr>
            <th>add a cookie</th>
        </tr>
        <tr>
            <td>
                <form action=" <?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
                    <input maxlength=2048 name="NewCookie" size=55>
                    <input type="submit" value="create" />
                </form>
            </td>
        </tr>
        <tr>
            <td>(this cookie will expire 5 minutes after creation)</td>
        </tr>
    </tbody>
</table>

<h2>create post</h2>
<table>
    <tbody>
        <tr>
            <th>post text</th>
        </tr>
        <tr>
            <td>
                <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
                    <input maxlength=2048 name="PostText" size=55 />
                    <input type="submit" value="post">
                </form>
            </td>
        </tr>
    </tbody>
</table>
<br />
<table>
    <tbody>
        <tr>
            <th>post a file</th>
        </tr>
        <tr>
            <td>
                <form enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
                    <input name="PostFile" type=file />
                    <input type="submit" value="post">
                </form>
            </td>
        </tr>
    </tbody>
</table>

<h2>options</h2>
<table>
    <tbody>
        <tr>
            <th>?sleep=X</th><td>sleep X seconds during response</td>
        </tr><tr>
                        <th>?pad=X</th><td>pad response with X bytes (must be &gt; 8)</td>
                </tr><tr>
            <th>?resp=X</th><td>set response code to X</td>
        </tr><tr>
            <th>?loc=X</th><td>set location header to X</td>
        </tr>
    </tbody>
</table>

</body>
</html>

<!-- <?php echo $pageTitle; ?> -->

 

 类似资料:

相关阅读

相关文章

相关问答