phpnow php探针环境检测代码

 更新时间:2014年11月04日 16:53:41   投稿:mdxy-dxy  
这篇文章主要为大家分享了phpnow php探针环境检测代码,需要的朋友可以参考下
<?php
/*
 http://phpnow.org
 YinzCN_at_Gmail.com
*/

error_reporting(E_ALL);

define('TimeZone', +8.0);

function _GET($n) { return isset($_GET[$n]) ? $_GET[$n] : NULL; }
function _SERVER($n) { return isset($_SERVER[$n]) ? $_SERVER[$n] : '[undefine]'; }

if (_GET('act') == 'phpinfo') {
 if (function_exists('phpinfo')) phpinfo();
 else echo 'phpinfo() has been disabled.';
 exit;
}

$Info = array();
$Info['php_ini_file'] = function_exists('php_ini_loaded_file') ? php_ini_loaded_file() : '[undefine]';

if (_GET('act') == 'getip') {
 $i = _SERVER('SERVER_NAME').'|'._SERVER('REMOTE_ADDR').'|'._SERVER('SERVER_SOFTWARE').'|'.(function_exists('mysql_close')?mysql_get_client_info():'').'|'._SERVER('DOCUMENT_ROOT');
 $c = @file_get_contents('http://phpnow.org/myip.php?'.base64_encode($i));
 if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $c) == 1) echo $c;
 else echo 'false';
 exit;
}

function colorhost() {
 $c = array('#87cefa', '#ffa500', '#ff6347', '#9acd32', '#32cd32', '#ee82ee');
 $a = str_split(_SERVER('SERVER_NAME'));
 $k = $l = 0;
 foreach ($a as &$d) {
  while ($k==$l) $k = array_rand($c);
  $d = '<b style="color: '.$c[$k].';">'.$d.'</b>';
  $l = $k;
 }
 return implode('', $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('YES', '<span style="color: #008000; font-weight : bold;">Yes</span>');
define('NO', '<span style="color: #ff0000; font-weight : bold;">No</span>');
?>
<!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 == 'false') $('ip_r').innerHTML = '获取外网 IP 失败!';
   else $('ip_r').innerHTML = '此服务器互联网 IP<br /><a href="http://'+r+'" style="color: #999999;">'+r+'</a>';
  }
 }
 XMLHttp.open("GET", "?act=getip", true);
 XMLHttp.send();
}
</script>
</head>
<body onload="get_ip();">
<div style="margin: 0 auto; width: 600px;">

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

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

<br />

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

 <tr>
  <td class="item">SERVER_NAME</td>
  <td><?=_SERVER('SERVER_NAME')?></td>
 </tr>

 <tr>
  <td class="item">SERVER_ADDR:PORT</td>
  <td><?=_SERVER('SERVER_ADDR').':'._SERVER('SERVER_PORT')?></td>
 </tr>

 <tr>
  <td class="item">SERVER_SOFTWARE</td>
  <td><?=stripos(_SERVER('SERVER_SOFTWARE'), 'PHP')?_SERVER('SERVER_SOFTWARE'):_SERVER('SERVER_SOFTWARE').' PHP/'.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['php_ini_file']?></td>
 </tr>

 <tr>
  <td class="item">网站主目录</td>
  <td><?=_SERVER('DOCUMENT_ROOT')?></td>
 </tr>

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

 <tr>
  <td class="item">Other Links</td>
  <td>
  <a href='<?=_SERVER('PHP_SELF')?>?act=phpinfo'>phpinfo()</a>
  | <?=file_exists('phpMyAdmin') ? '<a href="/phpMyAdmin">phpMyAdmin</a>' : '<a href="http://phpnow.org">PHPnow.org</a>'?>
  </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('OPTIMIZER_VERSION') ? YES.' / '.OPTIMIZER_VERSION : NO?></td>
 </tr>

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

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

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

<hr />

<form method="post" action="<?=_SERVER('PHP_SELF')?>">
<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" /> &nbsp;</td>
 </tr>
</table>
</form>

<?php if(isset($_POST['act'])) {?>
<br />

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

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

 <tr>
  <td colspan="2">数据库 <?=$_POST['mysqlDb']?></td>
  <td colspan="2"><?=(@mysql_select_db($_POST['mysqlDb'],$link))?'<span style="color: #008000; font-weight: bold;">OK</span>':'<span style="color: #ff0000; font-weight: bold;">Failed</span>'?></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>

</div>
</body>
</html>

相关文章

  • 利用PHP生成静态HTML文档的原理

    利用PHP生成静态HTML文档的原理

    利用PHP,将数据库中的文章数据生成单个的HTML文档。首先,有利于搜索引擎的收录。其次,避免数据库中的字段暴露在地址栏上,更安全
    2012-10-10
  • CodeIgniter框架验证码类库文件与用法示例

    CodeIgniter框架验证码类库文件与用法示例

    这篇文章主要介绍了CodeIgniter框架验证码类库文件与用法,结合实例形式分析了CodeIgniter框架验证码类库文件的定义与具体使用方法,具有一定参考借鉴价值,需要的朋友可以参考下
    2017-03-03
  • 微信支付之JSAPI公众号支付详解

    微信支付之JSAPI公众号支付详解

    这篇文章主要介绍了JSAPI公众号支付的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-05-05
  • 实例讲解PHP设计模式编程中的简单工厂模式

    实例讲解PHP设计模式编程中的简单工厂模式

    这篇文章主要介绍了PHP设计模式编程中的简单工厂模式,举了一个水果销售和一个计算器设计的例子,需要的朋友可以参考下
    2016-02-02
  • PHP实现微信小程序人脸识别刷脸登录功能

    PHP实现微信小程序人脸识别刷脸登录功能

    本文通过实例代码给大家讲解了基于PHP实现微信小程序人脸识别刷脸登录功能,感兴趣的朋友跟随脚本之家小编一起学习吧
    2018-05-05
  • php使用curl模拟登录后采集页面的例子

    php使用curl模拟登录后采集页面的例子

    php使用curl模拟登录后采集页面的例子,附带php curl模块的开启办法。
    2013-11-11
  • php读取msn上的用户信息类

    php读取msn上的用户信息类

    一个可以获取msn上用户信息的代码
    2008-12-12
  • PHP文件读取功能的应用实例

    PHP文件读取功能的应用实例

    这篇文章主要介绍了PHP文件读取功能的应用实例以及常用的文件数据读取的函数的使用方法及区别,非常的详细,有需要的小伙伴可以参考下。
    2015-05-05
  • php伪静态之APACHE篇

    php伪静态之APACHE篇

    mod_rewrite是Apache的一个非常强大的功能,它可以实现伪静态页面。下面我详细说说它的使用方法!对初学者很有用的哦!
    2014-06-06
  • PHP微信支付实例解析

    PHP微信支付实例解析

    这篇文章主要为大家详细介绍了PHP微信支付实例,包括PHP微信支付源码,PHP微信退款源码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-07-07

最新评论