search
HomeBackend DevelopmentPHP TutorialPHP probe code sharing based on html5

PHP probe code sharing based on html5

Nov 10, 2017 pm 01:38 PM
html5phpprobe

看过我们之前的文章的小伙伴相信对php探针有所了解,但是有人说那都是一些理论写东西,想看一些php探针的代码,借此,今天就给分享一款前台基于HTML5技术的PHP探针,在支持HTML5的浏览器中查看效果最佳。

本代码可检测PHP服务器各个变量信息,比如PHP服务器的操作系统、PHP版本、上传文件的大小限制、当前时间、脚本解释引擎、已编译模块监测、高精度数学运算等,还可检测服务器组件及数据库支持监测、压缩文件支持、IMAP电子邮件系统函数库等,

下面是完整的探针代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>简洁实用PHP探针</title>
<style type="text/css" >
* { padding:0px; margin:0px;}
li { list-style-type:none}
a { color:#333;}
body { background:#f2efe8; font-size:12px; color:#666; padding-top:30px; }
.box { background:#FFF; border:1px solid #e1e1e1; 
-webkit-box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-moz-box-shadow:0 2px 2px rgba(0, 0, 0, 0.3));
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); 
width:90%; margin:0px auto; 
border-radius:10px; 
line-height:30px; padding-bottom:10px; margin-bottom:20px;}
.title { background:#f5f5f5; line-height:40px; padding-left:20px; font-size:14px; 
color:#333; height:40px; border-bottom:1px solid #e5e5e5; border-radius:10px; 
border-bottom-right-radius:0px;border-bottom-left-radius:0px; }
ul li { padding:0px 20px; border-bottom:1px solid #e5e5e5; margin:0px 5px; }
span { margin-left:10px;}
.sudu {padding: 0; background:#5dafd1; }
.suduk { margin:0px; padding:0;}
</style>
<?php
error_reporting(0);
phpversion() >= &#39;5.1.0&#39; && date_default_timezone_set(&#39;UTC&#39;);
@header("content-Type: text/html; charset=utf-8"); 
$stime = date("Y-n-j H:i:s");
function check_os() {
    $uname=php_uname();
    $uname=explode(" ",$uname);
    return $uname[0];
}
function check_extension() {
    $os=get_loaded_extensions();
    for($i=0;$i<count($os);$i++) {
        echo $os[$i];
        if(($i+1)>=15 and ($i+1)%15==0) { echo &#39;<br />&#39;; } else { echo &#39; | &#39;; }
    }
}
function ini($ini) {
    if(preg_match(&#39;/0|off/i&#39;,$x=ini_get($ini))) {
        return &#39;OFF&#39;;
    } elseif($x == null) {
        return &#39;NONE&#39;;
    } else {
        return $x == 1 ? &#39;ON&#39; : $x;
}
}
function isfun($funName = &#39;&#39;) {
    if (!$funName || trim($funName) == &#39;&#39; || preg_match(&#39;~[^a-z0-9\_]+~i&#39;, $funName,
        $tmp))
        return &#39;错误&#39;;
    return (false !== function_exists($funName)) ? &#39;<b>√</b>&#39; : &#39;<em>×</em>&#39;;
}
header("content-type:text/html;charset=UTF-8");
if(isset($_GET[page])) {
    if($_GET[&#39;page&#39;]=="date") {
        echo date("Y-m-d H:i:s");
    } elseif($_GET[&#39;page&#39;]=="phpinfo") {
        phpinfo();
    } elseif($_GET[&#39;page&#39;]=="cpuinfo") {
        check_cpu();
    } elseif($_GET[&#39;page&#39;]=="meminfo") {
        check_mem();
    } elseif($_GET[&#39;page&#39;]=="diskinfo"){
        check_disk();
    } elseif($_GET[&#39;page&#39;]=="uptime") {
        check_uptime();
    } elseif($_GET[&#39;page&#39;]=="download") {
        Header(&#39;Content-Type:application/octet-stream&#39;);
        header(&#39;accept-length:&#39;.filesize($path));
        Header(&#39;Content-Disposition:attachment;filename=check.php&#39;);
        echo file_get_contents(FILE);
    }
    exit();
}
if ($_POST[&#39;act&#39;] == "开始测试") {
?>
	<script language="javascript" type="text/javascript">
		var acd1;
		acd1 = new Date();
		acd1ok=acd1.getTime();
	</script>
<?php
    for ($i = 1; $i <= 100000; $i++) {
        echo "<!--567890#########0#########0#########0#########0#########0#########0#########0#########
        012345-->";
    }
?>
	<script language="javascript" type="text/javascript">
		var acd2;
		acd2 = new Date();
		acd2ok=acd2.getTime();
		window.location = &#39;?speed=&#39; +(acd2ok-acd1ok);
	</script>
<?php
}
//网速测试-结束
if (isset($_POST[&#39;speed&#39;])) {
    $speed = round(100 / ($_POST[&#39;speed&#39;] / 1000), 2);
} elseif ($_GET[&#39;speed&#39;] == "0") {
    $speed = 6666.67;
} elseif (isset($_GET[&#39;speed&#39;]) and $_GET[&#39;speed&#39;] > 0) {
    $speed = round(100 / ($_GET[&#39;speed&#39;] / 1000), 2); //下载速度:$speed kb/s
} else {
    $speed = "<font color=\"red\"> 未探测 </font>";
}
function check_mysql($host,$user,$pass) {
    if(@mysql_connect($host,$user,$pass)) {
        return &#39;<script type="text/javascript">alert("成功连接到MysqL数据库!");</script>&#39;;
    } else {
        return &#39;<script type="text/javascript">alert("无法连接到MysqL数据库!");</script>&#39;;
    }
}
?>
</head>

<body>
<div class="box">
<div class="title">实用探针v1.0</div>
</div>
<div class="box">
<div class="title">服务器参数</div>
<ul>
<li>服务器系统:<?php echo check_os(); ?></li>
<li>PHP版本:<?php echo phpversion(); ?><a href="?page=phpinfo">PHPINFO</a></li>
<li>服务器IP:<?php echo @$_SERVER[&#39;REMOTE_ADDR&#39;];?><span>服务器端口:<?php echo $_SERVER[&#39;SERVER_PORT&#39;];?>
</span></li>
<li>服务器解释引擎:<?php echo $_SERVER[&#39;SERVER_SOFTWARE&#39;];?></li>
<li>服务器当前时间:<?php echo $stime;?></li>
<li>探针真实地址:<?php echo $_SERVER[&#39;DOCUMENT_ROOT&#39;]?str_replace(&#39;\\&#39;,&#39;/&#39;,$_SERVER[&#39;DOCUMENT_ROOT&#39;]):
str_replace(&#39;\\&#39;,&#39;/&#39;,dirname(FILE));?></li>
<li>上传文件的大小限制:<?php echo ini(&#39;upload_max_filesize&#39;); ?></li>
</ul>
</div>
<div class="box">
<form action="<?php echo $_SERVER[PHP_SELF];?>" method="post">
<div class="title">网络速度测试<span><input name="act" type="submit" class="btn" value="开始测试" />
</span></div>
<ul>
<li style="content:">
  <table align="center" width="550" border="0" cellspacing="0" cellpadding="0" >
    <tr >
    <td height="15" width="50">带宽</td>
	<td height="15" width="50">1M</td>
    <td height="15" width="50">2M</td>
    <td height="15" width="50">3M</td>
    <td height="15" width="50">4M</td>
    <td height="15" width="50">5M</td>
    <td height="15" width="50">6M</td>
    <td height="15" width="50">7M</td>
    <td height="15" width="50">8M</td>
    <td height="15" width="50">9M</td>
    <td height="15" width="50">10M</td>
    </tr>
     <tr>
    <td colspan="11" class="suduk" ><table align="center" width="550" border="0" cellspacing="0" 
    cellpadding="0" height="8" class="suduk">
    <tr>
      <td class="sudu"  width="<?php
	if(preg_match("/[^\d-., ]/",$speed))
		{
			echo "0";
		}
	else{
			echo 550*($speed/11000);
		}
		?>"></td>
      <td class="suduk" width="<?php
	if(preg_match("/[^\d-., ]/",$speed))
		{
			echo "550";
		}
	else{
			echo 550-550*($speed/11000);
		}
		?>"></td>
    </tr>
    </table>
   </td>
  </tr>
    </table>
  <?php 
 echo (isset($_GET[&#39;speed&#39;]))?"下载 1000 KB 数据用时 <b>".$_GET[&#39;speed&#39;]."</b> 毫秒,下载速度:
 <b>".$speed." KB/s</b>,需测试多次取平均值,超过10M直接看下载速度": "<em> 未探测 </em>" ?>
</li>
</ul>
</form>
</div>
<!--测速结束-->
<div class="box">
<div class="title">已编译模块监测</div>
<ul>
<li><?php echo check_extension(); ?></li>
</ul>
</div>
<!--模块监测结束-->
<div class="box">
<div class="title">组件及数据库支持监测</div>
<ul>
<li><table width="100%" cellpadding="3" cellspacing="0" align="center">
  <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>GD库支持:</td>
    <td>
    <?php
        if(function_exists(gd_info)) {
            $gd_info = @gd_info();
	        echo $gd_info["GD Version"];
	    }else{echo &#39;<em>×</em>&#39;;}
	?></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>高精度数学运算:</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>
  <tr>
    <td>MCrypt加密处理:</td>
    <td><?php echo isfun("mcrypt_cbc");?></td>
    <td>哈稀计算:</td>
    <td><?php echo isfun("mhash_count");?></td>
  </tr>
  </table>
  </li>
  <li>
  <table width="100%" cellpadding="3" cellspacing="0" align="center">
    <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 ? &#39;  mysql_server 版本:&#39;.$s : &#39;&#39;;
	    $c = &#39;  mysql_client 版本:&#39;.@mysql_get_client_info();
        echo $s ? $s : $c;
    }
    ?>
	</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 echo isfun("sqlite_close"); if(isfun("sqlite_close") == &#39;<b>√</b>&#39;){echo "  版本: 
    ".@sqlite_libversion();}?></td>
    <td>Hyperwave 数据库:</td>
    <td><?php echo isfun("hw_close");?></td>
  </tr>
</table>
</li>
</ul>
</div>
<!--组件支持-->
<div class="box">
<div class="title">数据库连接测试</div>
<ul>
<li><?php if(function_exists(&#39;mysql_connect&#39;)) { ?>
<form action="<?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?>" method="post">
<p>主机:<span><input type="text" name="host" value="127.0.0.1:3306" /></span></p>
<p>用户:<span><input type="text" name="user" /></span></p>
<p>密码:<span><input type="password" name="pass" /></span></p>
<p><input type="submit" value="检测MYSQL" /><?php if(isset($_POST[&#39;host&#39;]) and isset($_POST[&#39;user&#39;]) 
and isset($_POST[&#39;pass&#39;])) { echo &#39;<span style="background-color:#663399">&#39;.check_mysql($_POST[&#39;host&#39;],
$_POST[&#39;user&#39;],$_POST[&#39;pass&#39;]).&#39;</span>&#39;; } ?></p>
</form>
<?php } else { echo &#39;<span style="color:#60def0">未找到Mysql扩展!</span>&#39;; } ?></li>
</ul>
</div>
</body>
</html>

本探针运行截图如下:

PHP probe code sharing based on html5

您可直接保存成phpinfo.php文件,在PHP环境下测试运行。

总结:

本款代码还有一个实用的PHP与MYSQL数据库连接测试模块,HTML5技术的加入,使得本款php探针的界面相当简洁美观,希望对你的工作有所帮助!

相关推荐:

php探针在Linux下的安装过程

php探针检测虚拟主机配置信息的案例

php探针程序的推荐

如何使用php探针环境检测代码的示例

什么是php探针?php探针有什么作用?

The above is the detailed content of PHP probe code sharing based on html5. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

How to make PHP applications fasterHow to make PHP applications fasterMay 12, 2025 am 12:12 AM

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

PHP Performance Optimization Checklist: Improve Speed NowPHP Performance Optimization Checklist: Improve Speed NowMay 12, 2025 am 12:07 AM

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

PHP Dependency Injection: Improve Code TestabilityPHP Dependency Injection: Improve Code TestabilityMay 12, 2025 am 12:03 AM

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

PHP Performance Optimization: Database Query OptimizationPHP Performance Optimization: Database Query OptimizationMay 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.