PHP needle control (view server details)_PHP tutorial
php tutorial needle control (view server details)
/
* 1. This program is based on the div+css tutorial new architecture php probe , free and open source free software, with powerful functions, clear structure and easy to use.
1. Support windows, linux, unix, freebsd, sun solar system
2. Support ie6, ie7, firefox, google chrome and other browsers.
2. Main uses and applicable objects:
1. Amateurs and professional developers who are familiar with PHP programming.
2. The computer room manager configures the linux (windows) + php + mysql tutorial + zend system environment and checks whether the system is configured successfully.
3. For users who purchase virtual hosts, it is used to test server performance.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
////////////////////The following two variables can be modified and configured
//If you are using this probe for verification, you can Enter relevant information in the variables below (will be displayed at the bottom of the page
header("content-type: text/html; charset=utf-8");
error_reporting(e_error | e_warning | e_parse);
ob_start ();
$valint = (false == empty($_post['pint']))?$_post['pint']:"Not tested";
$valfloat = (false = = empty($_post['pfloat']))?$_post['pfloat']:"Not tested";
$valio = (false == empty($_post['pio']))?$_post ['pio']:"Not tested";
$mysqlreshow = "none";
$mailreshow = "none";
$funreshow = "none";
$opreshow = "none" ;
$sysreshow = "none";
//============ Define constants to replace template output variables ============== =========
//define("yes", "yes");
//define("no", "no");
define("yes", "√");
define("no", "×");//================================================ ====================
break;
define("icon", "2 ");
$phps tutorial elf = $_server[php_self] ? $_server[php_self] : $_server[script_name];
define("phpself", preg_replace("/(.{0,}?/+)/ ", "", $phpself));
if ($_get['act'] == "phpinfo")
{
phpinfo();
exit();
}
elseif($_post['act'] == "integer test")
{
$valint = test_int();
}
elseif($_post[' act'] == "Floating point test")
{
$valfloat = test_float();
}
elseif($_post['act'] == "io test")
{
$valio = test_io(); > $ Mysqlre = "MySQL connection test results:";
$ mysqlre. = (False! == @mysql_connect ($ _ post ['mysqlhost'], $ _post ['mysqluser'], $ _post ['mysqlpas sword '] ; ;
$mysqlre .= (false != @mysql_select_db($_post['mysqldb']))?"Connection OK": "Connection failed";
}
elseif($_post['act' ] == "sendmail")
$mailreshow = mail($_post["mailreceiver"], "uenuprobe mail server test.", "this email is sent by uenuprobe.rnrnrnrnrncopyright uenucomrnhttp://www.uenu.com"))?"Complete":"Failed";
}
elseif($_post['act'] == "function_check")
{
$funreshow = "show";
$funre = "function".$_post ['funname']." Support status detection results: ".isfun($_post['funname']);
}
elseif($_post['act'] == "configuration_check ")
{
$opreshow = "show";
$opre = "Configuration parameters".$_post['opname']." Detection result: ". getcon($_post['opname']);
}
//=========================== =============================================
//================================================ =========================
switch (php_os)
{
case "linux":
$sysreshow = (false != ($sysinfo = sys_linux()))?"show":"none";
break;
case "freebsd":
$sysreshow = (false != ($sysinfo = sys_freebsd ()))?"show":"none";case "windows":
//$sysreshow = (false != ($sysinfo = sys_windows()))?"show ":"none";
$sysinfo['uptime'] ="Sorry, windows system does not support";
break;
default:
break;
}
//================================================ ========================?>
服务器信息
服务器信息
switch($_get['action']){
case '':
?>服务器处理器cpu个数:服务器处理器cpu个数:内存使用状况
m, 已使用
m, 空闲
m, 使用率
%swap区
共m, 已使用
m, 空闲
m, 使用率
%系统平均负载
break;
case 'phpinfo':
?>
break;
case 'otherinfo':
?>
php component support status
Spell check aspell library
High Precision mathematical operations bcmath
< tr>
Calendar operation calendar
< td>Graphics processing gd library
Class/Object Support
String type detection support
< /tr>
iconv encoding support
< ;/td>
mcrypt encryption processing support
Hash calculation mhash
openssl support
prel compatible syntax pcre
正则扩展(兼容perl)支持
socket支持
流媒体支持
tokenizer支持
url支持
wddx支持(web distributed data exchange)
压缩文件支持(zlib)
xml解析
ftp
目录存取协议(ldap)支持
yellow page系统支持
php和java综合支持
imap电子邮件系统支持
snmp网络管理协议支持
vmailmgr邮件处理支持
pdf文档支持
fdf表单资料格式支持
break;
case 'dbinfo':
?>
数据库支持状况
mysql数据库支持
mysql数据库持续连接
mysql最大连接数
odbc数据库连接
sql server数据库支持
msql数据库支持
postgre sql数据库支持
oracle数据库支持
oracle 8 数据库支持
dbase数据库支持
sybase数据库支持
dba数据库支持
dbm数据库支持
dbx数据库支持
db++数据库支持
frontbase数据库支持
filepro数据库支持
informix数据库支持
lotus notes数据库支持
interbase数据库支持
ingres数据库支持
hyperwave数据库支持
ovrimos sql数据库连接支持
sesam数据库连接支持
sqlite数据库连接支持
adabas d数据库连接支持
break;
case 'testinfo':
?>
$ismysql = (false !== function_exists("mysql_query"))?"":" disabled";
$ismail = (false !== function_exists("mail"))?"":" disabled";
?>
break;
}?>/*==================== ===========================================
Function library
================================================== ============*//*------------------------------------------------ -------------------------------------------------- -------------
';
Detection function support
-------------------------- -------------------------------------------------- ----------------------------------*/
function isfun($funname)
{
Return (false !== function_exists($funname))?yes:no;
}
/*------------------------ -------------------------------------------------- ------------------------------------
Detect php setting parameters
---- -------------------------------------------------- -------------------------------------------------- ------*/
function getcon($varname)
{
switch($res = get_cfg_var($varname))
{
case 0:
return no ;
break;
case 1:
return yes;
break;
default:
return $res;
break;
}
/*-------------------------------------------------- -------------------------------------------------- ---------------
Integer arithmetic ability test
------------------------- -------------------------------------------------- ----------------------------------*/
function test_int()
{
$timestart = gettimeofday(); $timeend = gettimeofday();
$time = ($timeend["usec"]-$timestart["usec"])/1000000+$timeend["sec"]-$timestart["sec"];
$time = round($time, 6)."seconds"; -------------------------------------------------- ------------------------------------------
Floating point computing ability test
-------------------------------------------------- -------------------------------------------------- -------------*/
function test_float()
{
$t = pi();
$timestart = gettimeofday();
for ($i = 0; $i < 3000000; $i++);
sqrt($t);
}
$timeend = gettimeofday(); $timeend["usec"]-$timestart["usec"])/1000000+$timeend["sec"]-$timestart["sec"];
$time = round($time, 6)." Seconds";
return $time;
}
/*---------------------------------- -------------------------------------------------- ----------------------------
Data io ability test
--------------------- -------------------------------------------------- ----------------------------------------*/
function test_io()
{
$fp = @fopen(phpself, "r");
$timestart = gettimeofday();
for($i = 0; $i < ; 10000; $i++)
since}
$timeend = gettimeofday();
@fclose($fp);
$time = ($timeend["usec"]-$timestart["usec"])/1000000+$timeend[ "sec"]-$timestart["sec"];
$time = round($time, 6)."seconds";
-------------------------------------------------- -------------------------------------------------- --------
Proportional bar
---------------------------------- -------------------------------------------------- --------------------------*/
function bar($percent)
{
echo '
}
/*--------------------------------- -------------------------------------------------- --------------------------
Obtain cpu related information according to different systems
-------- -------------------------------------------------- -------------------------------------------------- --*/
switch(php_os) {
case "linux":
$sysreshow = (false !== ($sysinfo = sys_linux()))?"show":"none";
break;
case "freebsd":
$sysreshow = (false !== ($sysinfo = sys_freebsd()))?"show":"none";
break;
case "winnt":
$sysreshow = (false !== ($sysinfo = sys_windows()))?"show":"none";
break;
default:
break;
}
/*-------------------------------------------------------------------------------------------------------------
-------------------- -------------------------------------------------- ----------------------------------------*/
系统参数探测 linux
--------------------------------------------------------------------------------------------------------------*/
function sys_linux()
{
// cpu
if (false === ($str = @file("/proc/cpuinfo"))) return false;
$str = implode("", $str);
@preg_match_all("/models+names{0,}:+s{0,}([ws)(.]+)[rn]+/", $str, $model);
//@preg_match_all("/cpus+mhzs{0,}:+s{0,}([d.]+)[rn]+/", $str, $mhz);
@preg_match_all("/caches+sizes{0,}:+s{0,}([d.]+s{0,}[a-z]+[rn]+)/", $str, $cache);
if (false !== is_array($model[1]))
{
$res['cpu']['num'] = sizeof($model[1]);
for($i = 0; $i < $res['cpu']['num']; $i++)
{
$res['cpu']['detail'][] = "类型:".$model[1][$i]." 缓存:".$cache[1][$i];
}
if (false !== is_array($res['cpu']['detail'])) $res['cpu']['detail'] = implode("
", $res['cpu']['detail']);
}
// uptime
if (false === ($str = @file("/proc/uptime"))) return false;
$str = explode(" ", implode("", $str));
$str = trim($str[0]);
$min = $str / 60;
$hours = $min / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$min = floor($min - ($days * 60 * 24) - ($hours * 60));
if ($days != 0) {$res['uptime'] = $days."天";}
if ($hours != 0) {$res['uptime'] .= $hours."小时";}
$res['uptime'] .= $min."分钟";
// memory
if (false === ($str = @file("/proc/meminfo"))) return false;
$str = implode("", $str);
preg_match_all("/memtotals{0,}:+s{0,}([d.]+).+?memfrees{0,}:+s{0,}([d.]+).+?swaptotals{0,}:+s{0,}([d.]+).+?swapfrees{0,}:+s{0,}([d.]+)/s", $str, $buf);
$res['memtotal'] = round($buf[1][0]/1024, 2);
$res['memfree'] = round($buf[2][0]/1024, 2);
$res['memused'] = ($res['memtotal']-$res['memfree']);
$res['mempercent'] = (floatval($res['memtotal'])!=0)?round($res['memused']/$res['memtotal']*100,2):0;
$res['swaptotal'] = round($buf[3][0]/1024, 2);
$res['swapfree'] = round($buf[4][0]/1024, 2);
$res['swapused'] = ($res['swaptotal']-$res['swapfree']);
$res['swappercent'] = (floatval($res['swaptotal'])!=0)?round($res['swapused']/$res['swaptotal']*100,2):0;
// load avg
if (false === ($str = @file("/proc/loadavg"))) return false;
$str = explode(" ", implode("", $str));
$str = array_chunk($str, 3);
$res['loadavg'] = implode(" ", $str[0]);
return $res;
}
/*-------------------------------------------------------------------------------------------------------------
系统参数探测 freebsd
--------------------------------------------------------------------------------------------------------------*/
function sys_freebsd()
{
//cpu
if (false === ($res['cpu']['num'] = get_key("hw.ncpu"))) return false;
$res['cpu']['detail'] = get_key("hw.model");
//load avg
if (false === ($res['loadavg'] = get_key("vm.loadavg"))) return false;
$res['loadavg'] = str_replace("{", "", $res['loadavg']);
$res['loadavg'] = str_replace("}", "", $res['loadavg']);
//uptime
if (false === ($buf = get_key("kern.boottime"))) return false;
$buf = explode(' ', $buf);
$sys_ticks = time() - intval($buf[3]);
$min = $sys_ticks / 60;
$hours = $min / 60;
$days = floor($hours / 24);
$hours = floor($hours - ($days * 24));
$min = floor($min - ($days * 60 * 24) - ($hours * 60));
if ($days != 0) $res['uptime'] = $days."天";
if ($hours != 0) $res['uptime'] .= $hours."小时";
$res['uptime'] .= $min."分钟";
//memory
if (false === ($buf = get_key("hw.physmem"))) return false;
$res['memtotal'] = round($buf/1024/1024, 2);
$buf = explode("n", do_command("vmstat", ""));
$buf = explode(" ", trim($buf[2]));
$res['memfree'] = round($buf[5]/1024, 2);
$res['memused'] = ($res['memtotal']-$res['memfree']);
$res['mempercent'] = (floatval($res['memtotal'])!=0)?round($res['memused']/$res['memtotal']*100,2):0;
$buf = explode("n", do_command("swapinfo", "-k"));
$buf = $buf[1];
preg_match_all("/([0-9]+)s+([0-9]+)s+([0-9]+)/", $buf, $bufarr);
$res['swaptotal'] = round($bufarr[1][0]/1024, 2);
$res['swapused'] = round($bufarr[2][0]/1024, 2);
$res['swapfree'] = round($bufarr[3][0]/1024, 2);
$res['swappercent'] = (floatval($res['swaptotal'])!=0)?round($res['swapused']/$res['swaptotal']*100,2):0;
return $res;
}
/*-------------------------------------------------------------------------------------------------------------
取得参数值 freebsd
--------------------------------------------------------------------------------------------------------------*/
function get_key($keyname)
{
return do_command('sysctl', "-n $keyname");
}
/*--------------------------- -------------------------------------------------- ------------------------------------
Determine the location of the executable file freebsd
--- -------------------------------------------------- -------------------------------------------------- -------*/
function find_command($commandname)
{
$path = array('/bin', '/sbin', '/usr/bin', '/usr /sbin', '/usr/local/bin', '/usr/local/sbin');
foreach($path as $p)
{
if (@is_executable("$p/ $commandname")) return "$p/$commandname";
}
return false; -------------------------------------------------- ---------------------------------------------
Execution system Command freebsd
------------------------------------------------ -------------------------------------------------- ---------------*/
function do_command($commandname, $args)
{
$buffer = "";
if (false == = ($command = find_command($commandname))) return false;
if ($fp = @popen("$command $args", 'r'))
{
while (!@feof ($fp))
{
$buffer .= @fgets($fp, 4096);
}
return trim($buffer);
}
return false;
}
/*------------------------------------------ -------------------------------------------------- --------------------
System parameter detection windowsfunction sys_windows()
{
//$phpos=php_os;
$sysinfo['uptime'] ="Sorry, windows system does not support";
}
?>
http://www.bkjia.com/PHPjc/444855.html

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

AI Hentai Generator
Generate AI Hentai for free.

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 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

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

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

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

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,

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

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 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.
