网站推广.NET

网站推广.NET

基于html5的php探针代码分享

来源:互联网

看过我们之前的文章的小伙伴相信对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><?phperror_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><p class="box"><p class="title">实用探针v1.0</p></p><p class="box"><p class="title">服务器参数</p><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></p><p class="box"><form action="<?php echo $_SERVER[PHP_SELF];?>" method="post"><p class="title">网络速度测试<span><input name="act" type="submit" class="btn" value="开始测试" /></span></p><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="<?phpif(preg_match("/[^\d-., ]/",$speed)){echo "0";}else{echo 550*($speed/11000);}?>"></td>      <td class="suduk" width="<?phpif(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></p><!--测速结束--><p class="box"><p class="title">已编译模块监测</p><ul><li><?php echo check_extension(); ?></li></ul></p><!--模块监测结束--><p class="box"><p class="title">组件及数据库支持监测</p><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></p><!--组件支持--><p class="box"><p class="title">数据库连接测试</p><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>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</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></p></body></html>

本探针运行截图如下:

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

总结:

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

相关推荐:

php探针在Linux下的安装过程

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

php探针程序的推荐

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

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

php探针