Home Backend Development PHP Tutorial Example of how to use php probe environment to instrument your code

Example of how to use php probe environment to instrument your code

Nov 10, 2017 am 11:33 AM
php Detection environment

In our previous article, we took you to understand what a php probe is and what a php probe does. I believe everyone has a certain understanding of this. So today I use a php probe to detect the implementation of the environment. The code is shared with everyone. This article mainly shares examples of how to use php probe environment to detect code. Friends who need it can refer to it


php probe environment detection code

<?php
/*
 http://phpnow.org
 YinzCN_at_Gmail.com
*/
error_reporting(E_ALL);
define(&#39;TimeZone&#39;, +8.0);
function _GET($n) { return isset($_GET[$n]) ? $_GET[$n] : NULL; }
function _SERVER($n) { return isset($_SERVER[$n]) ? $_SERVER[$n] : &#39;[undefine]&#39;; }

if (_GET(&#39;act&#39;) == &#39;phpinfo&#39;) {
 if (function_exists(&#39;phpinfo&#39;)) phpinfo();
 else echo &#39;phpinfo() has been disabled.&#39;;
 exit;
}
$Info = array();
$Info[&#39;php_ini_file&#39;] = function_exists(&#39;php_ini_loaded_file&#39;) ? php_ini_loaded_file() : &#39;[undefine]&#39;;
if (_GET(&#39;act&#39;) == &#39;getip&#39;) {
 $i = _SERVER(&#39;SERVER_NAME&#39;).&#39;|&#39;._SERVER(&#39;REMOTE_ADDR&#39;).&#39;|&#39;._SERVER(&#39;SERVER_SOFTWARE&#39;).&#39;|&#39;.(function_exists(&#39;mysql_close&#39;)?mysql_get_client_info():&#39;&#39;).&#39;|&#39;._SERVER(&#39;DOCUMENT_ROOT&#39;);
 $c = @file_get_contents(&#39;http://phpnow.org/myip.php?&#39;.base64_encode($i));
 if (preg_match(&#39;/^\d+\.\d+\.\d+\.\d+$/&#39;, $c) == 1) echo $c;
 else echo &#39;false&#39;;
 exit;
}
function colorhost() {
 $c = array(&#39;#87cefa&#39;, &#39;#ffa500&#39;, &#39;#ff6347&#39;, &#39;#9acd32&#39;, &#39;#32cd32&#39;, &#39;#ee82ee&#39;);
 $a = str_split(_SERVER(&#39;SERVER_NAME&#39;));
 $k = $l = 0;
 foreach ($a as &$d) {
  while ($k==$l) $k = array_rand($c);
  $d = &#39;<b style="color: &#39;.$c[$k].&#39;;">&#39;.$d.&#39;</b>&#39;;
  $l = $k;
 }
 return implode(&#39;&#39;, $a);
}

function get_ea_info($name) { $ea_info = eaccelerator_info(); return $ea_info[$name]; }
function get_gd_info($name) { $gd_info = gd_info(); return $gd_info[$name]; }

define(&#39;YES&#39;, &#39;<span style="color: #008000; font-weight : bold;">Yes</span>&#39;);
define(&#39;NO&#39;, &#39;<span style="color: #ff0000; font-weight : bold;">No</span>&#39;);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>PHPnow Works!</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="YinzCN" />
<meta name="reply-to" content="YinzCN@Gmail.com" />
<meta name="copyright" content="YinzCN" />
<style type="text/css">
<!--
body {
font-family : verdana, tahoma;
font-size : 12px;
margin-top : 10px;
}

form {
margin : 0;
}

table {
border-collapse : collapse;
}

.info tr td {
border : 1px solid #000000;
padding : 3px 10px 3px 10px ;
}

.info th {
border : 1px solid #000000;
font-weight : bold;
height : 16px;
padding : 3px 10px 3px 10px;
background-color : #9acd32;
}

input {
border : 1px solid #000000;
background-color : #fafafa;
}

a {
text-decoration : none;
color : #000000;
}

a:hover {
text-decoration : underline;
}

a.arrow {
font-family : webdings, sans-serif;
font-size : 10px;
}

a.arrow:hover {
color : #ff0000;
text-decoration : none;
}

.item {
white-space: nowrap;
text-align: right;
}
-->
</style>
<script type="text/JavaScript">
function $(id) { return document.getElementById(id); }

function get_ip() {
 var XMLHttp, r;
 XMLHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
 XMLHttp.onreadystatechange = function() {
  if (XMLHttp.readyState == 4)
  {
   r = XMLHttp.responseText;
   if (r == &#39;false&#39;) $(&#39;ip_r&#39;).innerHTML = &#39;获取外网 IP 失败!&#39;;
   else $(&#39;ip_r&#39;).innerHTML = &#39;此服务器互联网 IP<br /><a href="http://&#39;+r+&#39;" style="color: #999999;">&#39;+r+&#39;</a>&#39;;
  }
 }
 XMLHttp.open("GET", "?act=getip", true);
 XMLHttp.send();
}
</script>
</head>
<body onload="get_ip();">
<p style="margin: 0 auto; width: 600px;">

<p style="height: 60px;">
 <p style="float: right; margin: 5px; text-align: center;">
  <p><a style="color: #ffa500;" href="http://phpnow.org/go.php?id=1005">为何只能本地访问?</a></p>
  <p id="ip_r" style="color: #999999;">正在获取 IP 地址</p>
 </p>

 <p style="float: left;">
  <p style="font-weight: bold; font-size: 2.2em;"><a href="<?=_SERVER(&#39;PHP_SELF&#39;)?>?" style="text-decoration: none;"><?=colorhost()?></a></p>
  <p style="margin: 5px auto;"># Let&#39;s <b style="color: #777BB4;">PHP</b> <b style="color: #FF4500;">now</b> <b>!</b></p>
 </p>
</p>

<br />

<table width="100%" class="info">
 <tr>
  <th colspan="2">Server Information</th>
 </tr>

 <tr>
  <td class="item">SERVER_NAME</td>
  <td><?=_SERVER(&#39;SERVER_NAME&#39;)?></td>
 </tr>

 <tr>
  <td class="item">SERVER_ADDR:PORT</td>
  <td><?=_SERVER(&#39;SERVER_ADDR&#39;).&#39;:&#39;._SERVER(&#39;SERVER_PORT&#39;)?></td>
 </tr>

 <tr>
  <td class="item">SERVER_SOFTWARE</td>
  <td><?=stripos(_SERVER(&#39;SERVER_SOFTWARE&#39;), &#39;PHP&#39;)?_SERVER(&#39;SERVER_SOFTWARE&#39;):_SERVER(&#39;SERVER_SOFTWARE&#39;).&#39; PHP/&#39;.PHP_VERSION?></td>
 </tr>

 <tr>
  <td class="item">PHP_SAPI</td>
  <td><?=PHP_SAPI?></td>
 </tr>

 <tr>
  <td class="item" style="color: #ff0000;">php.ini</td>
  <td><?=$Info[&#39;php_ini_file&#39;]?></td>
 </tr>

 <tr>
  <td class="item">网站主目录</td>
  <td><?=_SERVER(&#39;DOCUMENT_ROOT&#39;)?></td>
 </tr>

 <tr>
  <td class="item">Server Date / Time</td>
  <td><?=gmdate(&#39;Y-m-d&#39;, time()+TimeZone*3600)?> <?=gmdate(&#39;H:i:s&#39;, time()+TimeZone*3600)?> <span style="color: #999999;">(<?=(TimeZone<0?&#39;-&#39;:&#39;+&#39;).gmdate(&#39;H:i&#39;, abs(TimeZone)*3600)?>)</span></td>
 </tr>

 <tr>
  <td class="item">Other Links</td>
  <td>
  <a href=&#39;<?=_SERVER(&#39;PHP_SELF&#39;)?>?act=phpinfo&#39;>phpinfo()</a>
  | <?=file_exists(&#39;phpMyAdmin&#39;) ? &#39;<a href="/phpMyAdmin">phpMyAdmin</a>&#39; : &#39;<a href="http://phpnow.org">PHPnow.org</a>&#39;?>
  </td>
 </tr>
</table>

<hr />

<table width="100%" class="info">
 <tr>
  <th colspan="2">PHP 组件支持</th>
 </tr>

 <tr>
  <td class="item">Zend Optimizer</td>
  <td><?=defined(&#39;OPTIMIZER_VERSION&#39;) ? YES.&#39; / &#39;.OPTIMIZER_VERSION : NO?></td>
 </tr>

 <tr>
  <td class="item">MySQL 支持</td>
  <td><?=function_exists(&#39;mysql_close&#39;) ? YES.&#39; / client lib version &#39;.mysql_get_client_info() : NO?></td>
 </tr>

 <tr>
  <td class="item">GD library</td>
  <td><?=function_exists(&#39;gd_info&#39;) ? YES.&#39; / &#39;.get_gd_info(&#39;GD Version&#39;) : NO?></td>
 </tr>

 <tr>
  <td class="item">eAccelerator</td>
  <td><?=function_exists(&#39;eaccelerator_info&#39;) ? YES.&#39; / &#39;.get_ea_info(&#39;version&#39;) : NO?></td>
 </tr>
</table>

<hr />

<form method="post" action="<?=_SERVER(&#39;PHP_SELF&#39;)?>">
<table width="100%" class="info">
 <tr>
  <th colspan="4">MySQL 连接测试</th>
 </tr>

 <tr>
  <td>MySQL 服务器</td>
  <td><input type="text" name="mysqlHost" value="localhost" /></td>
  <td>MySQL 数据库名</td>
  <td><input type="text" name="mysqlDb" value="test" /></td>
 </tr>

 <tr>
  <td>MySQL 用户名</td>
  <td><input type="text" name="mysqlUser" value="root" /></td>
  <td>MySQL 用户密码</td>
  <td><input type="text" name="mysqlPassword" /></td>
 </tr>

 <tr>
  <td colspan="4" align="right"><input type="submit" value="连接" name="act" />  </td>
 </tr>
</table>
</form>

<?php if(isset($_POST[&#39;act&#39;])) {?>
<br />

<table width="100%" class="info">
 <tr>
  <th colspan="4">MySQL 测试结果</th>
 </tr>

<?php
$link = @mysql_connect($_POST[&#39;mysqlHost&#39;], $_POST[&#39;mysqlUser&#39;], $_POST[&#39;mysqlPassword&#39;]);
$errno = mysql_errno();
if ($link) $str1 = &#39;<span style="color: #008000; font-weight: bold;">OK</span> (&#39;.mysql_get_server_info($link).&#39;)&#39;;
else $str1 = &#39;<span style="color: #ff0000; font-weight: bold;">Failed</span><br />&#39;.mysql_error();
?>
 <tr>
  <td colspan="2">服务器 <?=$_POST[&#39;mysqlHost&#39;]?></td>
  <td colspan="2"><?=$str1?></td>
 </tr>

 <tr>
  <td colspan="2">数据库 <?=$_POST[&#39;mysqlDb&#39;]?></td>
  <td colspan="2"><?=(@mysql_select_db($_POST[&#39;mysqlDb&#39;],$link))?&#39;<span style="color: #008000; font-weight: bold;">OK</span>&#39;:&#39;<span style="color: #ff0000; font-weight: bold;">Failed</span>&#39;?></td>
 </tr>
</table>
<?}?>
<hr />

<p style="text-align: right; margin: 0;"><a href="http://validator.w3.org/check?uri=referer" style="color: #999999;">Valid XHTML 1.0 Strict</a> / <a href="http://zh.wikipedia.org/wiki/Copyleft" style="color: #008000;"><b>Copyleft</b></a> ! 2007-? by <a href="http://phpnow.org">PHPnow.org</a></p>

</p>
</body>
</html>
Copy after login

##Summary:

The article introducing the code for php probe environment detection ends here. I believe that many friends will have a better understanding of php probes after reading this article. I hope it will be helpful to you. Helped!

Related recommendations:

What is php probe? What does php probe do?


Use PHP probe to detect VPS server performance


php probe Used when the phpinfo() function is disabled

The above is the detailed content of Example of how to use php probe environment to instrument your code. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles