PHP probe code sharing based on html5
看过我们之前的文章的小伙伴相信对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() >= '5.1.0' && date_default_timezone_set('UTC'); @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 '<br />'; } else { echo ' | '; } } } function ini($ini) { if(preg_match('/0|off/i',$x=ini_get($ini))) { return 'OFF'; } elseif($x == null) { return 'NONE'; } else { return $x == 1 ? 'ON' : $x; } } function isfun($funName = '') { if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误'; return (false !== function_exists($funName)) ? '<b>√</b>' : '<em>×</em>'; } header("content-type:text/html;charset=UTF-8"); if(isset($_GET[page])) { if($_GET['page']=="date") { echo date("Y-m-d H:i:s"); } elseif($_GET['page']=="phpinfo") { phpinfo(); } elseif($_GET['page']=="cpuinfo") { check_cpu(); } elseif($_GET['page']=="meminfo") { check_mem(); } elseif($_GET['page']=="diskinfo"){ check_disk(); } elseif($_GET['page']=="uptime") { check_uptime(); } elseif($_GET['page']=="download") { Header('Content-Type:application/octet-stream'); header('accept-length:'.filesize($path)); Header('Content-Disposition:attachment;filename=check.php'); echo file_get_contents(FILE); } exit(); } if ($_POST['act'] == "开始测试") { ?> <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 = '?speed=' +(acd2ok-acd1ok); </script> <?php } //网速测试-结束 if (isset($_POST['speed'])) { $speed = round(100 / ($_POST['speed'] / 1000), 2); } elseif ($_GET['speed'] == "0") { $speed = 6666.67; } elseif (isset($_GET['speed']) and $_GET['speed'] > 0) { $speed = round(100 / ($_GET['speed'] / 1000), 2); //下载速度:$speed kb/s } else { $speed = "<font color=\"red\"> 未探测 </font>"; } function check_mysql($host,$user,$pass) { if(@mysql_connect($host,$user,$pass)) { return '<script type="text/javascript">alert("成功连接到MysqL数据库!");</script>'; } else { return '<script type="text/javascript">alert("无法连接到MysqL数据库!");</script>'; } } ?> </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['REMOTE_ADDR'];?><span>服务器端口:<?php echo $_SERVER['SERVER_PORT'];?> </span></li> <li>服务器解释引擎:<?php echo $_SERVER['SERVER_SOFTWARE'];?></li> <li>服务器当前时间:<?php echo $stime;?></li> <li>探针真实地址:<?php echo $_SERVER['DOCUMENT_ROOT']?str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']): str_replace('\\','/',dirname(FILE));?></li> <li>上传文件的大小限制:<?php echo ini('upload_max_filesize'); ?></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['speed']))?"下载 1000 KB 数据用时 <b>".$_GET['speed']."</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 '<em>×</em>';} ?></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 ? ' mysql_server 版本:'.$s : ''; $c = ' mysql_client 版本:'.@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") == '<b>√</b>'){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('mysql_connect')) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" 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['host']) and isset($_POST['user']) and isset($_POST['pass'])) { echo '<span style="background-color:#663399">'.check_mysql($_POST['host'], $_POST['user'],$_POST['pass']).'</span>'; } ?></p> </form> <?php } else { echo '<span style="color:#60def0">未找到Mysql扩展!</span>'; } ?></li> </ul> </div> </body> </html>
本探针运行截图如下:
您可直接保存成phpinfo.php文件,在PHP环境下测试运行。
总结:
本款代码还有一个实用的PHP与MYSQL数据库连接测试模块,HTML5技术的加入,使得本款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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.
