phpinfo被禁用,可用php探针

UPDATE 2018-04-17 16:24

不说废话,直接上代码。

<?php
header("content-Type: text/html; charset=utf-8");
header("Cache-Control: no-cache, must-revalidate");  
header("Pragma: no-cache");
error_reporting(0);
ob_end_flush();
?>

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>PHP 探针 v1.0</title>
  <style>
    body{text-align:center;margin:20px 0;font-size:14px;}
    #overview{width:934px;margin:0 auto;}
    a{text-decoration:none;color:#992700;}
    a:hover{text-decoration:underline;}
    h1{font-size: 150%;}
    table{border-collapse:collapse;border-spacing:none;width:934px;}
    td{border:1px solid #666;padding:4px 5px;text-align:left;}
    .e{
      background:#ccf;
      font-weight:bold;
      width:200px;
    }
    .v{
      border:1px solid #666;
      padding:4px 5px;
      text-align:left;
      background:#ddd;
    }
  </style>
</head>

<body>
  <div id="overview">
    <div style="text-align:left;">
      <a href="?type=baseinfo">[基本信息]</a>
      <a href="?type=superinfo">[高级信息]</a>
      <?php
        if (function_exists("phpinfo")){
          echo'<a href="?type=phpinfo">[phpinfo]</a>';
        }
      ?>
      <br />
      php探针v1.0 by MKDuse(blueidea-id)
      <br /><br />
    </div>

    <?php
      if (empty($_GET['type'])) {
        baseinfo();
      } else {
        switch ($_GET['type']) {
          case 'phpinfo':
            phpinfoview();
            break;
          case 'superinfo':
            superinfo();
            break;
          case 'baseinfo':
            baseinfo();
            break;
          default:
            baseinfo();
        }
      }

      function getime() {
        $t = gettimeofday();
        return (float)($t['sec'] + $t['usec']/1000000);
      }

      function baseinfo() {
        echo '<h1>基本信息</h1>';

        $arr[] = array("Current PHP version:", phpversion());
        $arr[] = array("Zend engine version:", zend_version());
        $arr[] = array("服务器版本", $_SERVER['SERVER_SOFTWARE']);
        $arr[] = array("ip地址", $_SERVER['REMOTE_HOST']);//ip
        $arr[] = array("域名", $_SERVER['HTTP_HOST']);
        $arr[] = array("协议端口", $_SERVER['SERVER_PROTOCOL'] . ', ' . $_SERVER['SERVER_PORT']);
        $arr[] = array("站点根目录", $_SERVER['PATH_TRANSLATED']);
        $arr[] = array("服务器时间", date('Y年m月d日,H:i:s,D'));
        $arr[] = array("当前用户", get_current_user());
        $arr[] = array("操作系统", php_uname('s') . php_uname('r') . php_uname('v'));
        $arr[] = array("include_path", ini_get('include_path'));
        $arr[] = array("Server API", php_sapi_name());
        $arr[] = array("error_reporting level", ini_get("display_errors"));
        $arr[] = array("POST提交限制", ini_get('post_max_size'));
        $arr[] = array("upload_max_filesize", ini_get('upload_max_filesize'));
        $arr[] = array("脚本超时时间", ini_get('max_execution_time') . '秒');

        if (ini_get("safe_mode")==0) {
          $arr[]=array("PHP安全模式(Safe_mode)",'off');
        } else {
          $arr[]=array("PHP安全模式(Safe_mode)",'on');
        }

        if (function_exists('memory_get_usage')) {
          $arr[]=array("memory_get_usage",ini_get('memory_get_usage'));
        }

        //$arr[]=array("可用空间",intval(diskfreespace('/')/(1024 * 1024))."M");

        echo '<table>';
        for ($i = 0; $i < count($arr); $i++) {
          $overview = '<tr><td class="e">'.$arr[$i][0].'</td><td class="v">'.$arr[$i][1].'</td></tr>';
          echo $overview;
        }
        echo'</table>';

        echo '<h2>服务器性能测试</h2>';
        echo'<table><tr><td class="e">整数运算<br />50万次加法(1+1)</td>';

        $time_start=getime();
        for ($i = 0; $i <= 500000; $i++) {
          $count = 1 + 1;
        }
        $timea=round((getime()-$time_start)*1000,2);
        echo '<td class="v">'.$timea.'ms</td></tr><tr><td class="e">浮点运算<br />50万次平方根(3.14开方)</td>';
        $time_start=getime();
        for ($i = 0; $i <= 500000; $i++) {
          sqrt(3.14);
        }

        $timea = round((getime()-$time_start)*1000, 2);
        echo '<td class="v">' . $timea . 'ms</td></tr></table>';
        echo '<h2>带宽测试</h2>';

          ?>
            <script>
              function gettime () {  
                var time
                time = new Date()
                return time.getTime()
              }
              start_time = gettime()
            </script>
          <?php

        for ($i=0;$i<100;$i++){
          print "<!--1234567890#########0#########0#########0#########0#########0#########0#########0#########012345-->";
        }

          ?>
            <p id="dk" class="v"></p>
            <script>
              var timea
              var netspeed
              timea = gettime() - start_time
              netspeed = Math.round(10 / timea * 1000);
              document.getElementById("dk").innerHTML = "向客户端发送10KB数据,耗时" + timea + "ms<br />您与此服务器的连接速度为" + netspeed + "kb/s"
            </script>
          <?php

        echo '<h2>已加载的扩展库(enable)</h2><div class="v">';
        $arr = get_loaded_extensions();
        foreach ($arr as $value) {
          echo $value . ', ';
        }
        echo'</div><h2>禁用的函数</h2><p class="v">';
        $disfun = ini_get('disable_functions');
        if (empty($disfun)) {
          echo'没有禁用</p>';
        } else {
          echo ini_get('disable_functions').'</p>';
        }
      }

      function superinfo(){
        echo '<h1>高级信息</h1><p style="text-align:left;">PHP_INI_USER 1 配置选项可用在用户的 PHP 脚本或Windows 注册表中<br> PHP_INI_PERDIR 2 配置选项可在 php.ini, .htaccess 或 httpd.conf 中设置 <br>PHP_INI_SYSTEM 4 配置选项可在 php.ini or httpd.conf 中设置 <br>PHP_INI_ALL 7 配置选项可在各处设置</p><div class="v">';
        $arr1 = ini_get_all();
        for ($i = 0; $i < count($arr1); $i++) {
          $arr2 = array_slice($arr1,$i,1);
          print_r($arr2);
          echo '<br />';
        }
        echo '</div>';
      }

      function phpinfoview(){
        phpinfo();
      }
    ?>
  </div>
</body>
</html>

您的赞助将会支持作者创作及本站运维

发表评论


TOP