PHP代码:--------------------------------------------------------------------------------
<?phpclass OS_Guess
{
var $sysname;
var $nodename;
var $cpu;
var $release;
var $extra; function OS_Guess($uname = null)
{
list($this->sysname,
$this->release,
$this->cpu,
$this->extra,
$this->nodename) = $this->parseSignature($uname);
} function parseSignature($uname = null)
{
static $sysmap = array(
'HP-UX' => 'hpux',
'IRIX64' => 'irix',
// Darwin?
);
static $cpumap = array(
'i586' => 'i386',
'i686' => 'i386',
);
if ($uname === null) {
$uname = php_uname();
}
$parts = split('[[:space:]]+', trim($uname));
$n = count($parts); $release = $machine = $cpu = '';
$sysname = $parts[0];
$nodename = $parts[1];
$cpu = $parts[$n-1];
$extra = '';
if ($cpu == 'unknown') {
$cpu = $parts[$n-2];
} switch ($sysname) {
case 'AIX':
$release = "$parts[3].$parts[2]";
break;
case 'Windows':
switch ($parts[1]) {
case '95/98':
$release = '9x';
break;
default:
$release = $parts[1];
break;
}
$cpu = 'i386';
break;
case 'Linux':
$extra = $this->_detectGlibcVersion();
// use only the first two digits from the kernel version
$release = ereg_replace('^([[:digit:]]+.[[:digit:]]+).*', '1', $parts[2]);
break;
default:
$release = ereg_replace('-.*', '', $parts[2]);
break;
}
if (isset($sysmap[$sysname])) {
$sysname = $sysmap[$sysname];
} else {
$sysname = strtolower($sysname);
}
if (isset($cpumap[$cpu])) {
$cpu = $cpumap[$cpu];
}
return array($sysname, $release, $cpu, $extra, $nodename);
} function _detectGlibcVersion()
{
// Use glibc's <features.h> header file to
// get major and minor version number:
include_once "System.php";
$tmpfile = System::mktemp("glibctest");
$fp = fopen($tmpfile, "w");
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
fclose($fp);
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
$major = $minor = 0;
while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#') {
continue;
}
if (list($major, $minor) = explode(' ', trim($line))) {
break;
}
}
pclose($cpp);
unlink($tmpfile);
if (!($major && $minor) && file_exists('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (ereg('^libc-([.*]).so$', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches);
}
}
if (!($major && $minor)) {
return '';
}
return "glibc{$major}.{$minor}";
} function getSignature()
{
if (empty($this->extra)) {
return "{$this->sysname}-{$this->release}-{$this->cpu}";
}
return "{$this->sysname}-{$this->release}-{$this->cpu}-{$this->extra}";
} function getSysname()
{
return $this->sysname;
} function getNodename()
{
return $this->nodename;
} function getCpu()
{
return $this->cpu;
} function getRelease()
{
return $this->release;
} function getExtra()
{
return $this->extra;
} function matchSignature($match)
{
if (is_array($match)) {
$fragments = $match;
} else {
$fragments = explode('-', $match);
}
$n = count($fragments);
$matches = 0;
if ($n > 0) {
$matches += $this->_matchFragment($fragments[0], $this->sysname);
}
if ($n > 1) {
$matches += $this->_matchFragment($fragments[1], $this->release);
}
if ($n > 2) {
$matches += $this->_matchFragment($fragments[2], $this->cpu);
}
if ($n > 3) {
$matches += $this->_matchFragment($fragments[3], $this->extra);
}
return ($matches == $n);
} function _matchFragment($fragment, $value)
{
if (strcspn($fragment, '*?') < strlen($fragment)) {
$reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\/'), $fragment) . '$';
return eregi($reg, $value);
}
return ($fragment == '*' || !strcasecmp($fragment, $value));
}}/*
* Local Variables:
* indent-tabs-mode: nil
* c-basic-offset: 4
* End:
*/
?>
<?phpclass OS_Guess
{
var $sysname;
var $nodename;
var $cpu;
var $release;
var $extra; function OS_Guess($uname = null)
{
list($this->sysname,
$this->release,
$this->cpu,
$this->extra,
$this->nodename) = $this->parseSignature($uname);
} function parseSignature($uname = null)
{
static $sysmap = array(
'HP-UX' => 'hpux',
'IRIX64' => 'irix',
// Darwin?
);
static $cpumap = array(
'i586' => 'i386',
'i686' => 'i386',
);
if ($uname === null) {
$uname = php_uname();
}
$parts = split('[[:space:]]+', trim($uname));
$n = count($parts); $release = $machine = $cpu = '';
$sysname = $parts[0];
$nodename = $parts[1];
$cpu = $parts[$n-1];
$extra = '';
if ($cpu == 'unknown') {
$cpu = $parts[$n-2];
} switch ($sysname) {
case 'AIX':
$release = "$parts[3].$parts[2]";
break;
case 'Windows':
switch ($parts[1]) {
case '95/98':
$release = '9x';
break;
default:
$release = $parts[1];
break;
}
$cpu = 'i386';
break;
case 'Linux':
$extra = $this->_detectGlibcVersion();
// use only the first two digits from the kernel version
$release = ereg_replace('^([[:digit:]]+.[[:digit:]]+).*', '1', $parts[2]);
break;
default:
$release = ereg_replace('-.*', '', $parts[2]);
break;
}
if (isset($sysmap[$sysname])) {
$sysname = $sysmap[$sysname];
} else {
$sysname = strtolower($sysname);
}
if (isset($cpumap[$cpu])) {
$cpu = $cpumap[$cpu];
}
return array($sysname, $release, $cpu, $extra, $nodename);
} function _detectGlibcVersion()
{
// Use glibc's <features.h> header file to
// get major and minor version number:
include_once "System.php";
$tmpfile = System::mktemp("glibctest");
$fp = fopen($tmpfile, "w");
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
fclose($fp);
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
$major = $minor = 0;
while ($line = fgets($cpp, 1024)) {
if ($line{0} == '#') {
continue;
}
if (list($major, $minor) = explode(' ', trim($line))) {
break;
}
}
pclose($cpp);
unlink($tmpfile);
if (!($major && $minor) && file_exists('/lib/libc.so.6')) {
// Let's try reading the libc.so.6 symlink
if (ereg('^libc-([.*]).so$', basename(readlink('/lib/libc.so.6')), $matches)) {
list($major, $minor) = explode('.', $matches);
}
}
if (!($major && $minor)) {
return '';
}
return "glibc{$major}.{$minor}";
} function getSignature()
{
if (empty($this->extra)) {
return "{$this->sysname}-{$this->release}-{$this->cpu}";
}
return "{$this->sysname}-{$this->release}-{$this->cpu}-{$this->extra}";
} function getSysname()
{
return $this->sysname;
} function getNodename()
{
return $this->nodename;
} function getCpu()
{
return $this->cpu;
} function getRelease()
{
return $this->release;
} function getExtra()
{
return $this->extra;
} function matchSignature($match)
{
if (is_array($match)) {
$fragments = $match;
} else {
$fragments = explode('-', $match);
}
$n = count($fragments);
$matches = 0;
if ($n > 0) {
$matches += $this->_matchFragment($fragments[0], $this->sysname);
}
if ($n > 1) {
$matches += $this->_matchFragment($fragments[1], $this->release);
}
if ($n > 2) {
$matches += $this->_matchFragment($fragments[2], $this->cpu);
}
if ($n > 3) {
$matches += $this->_matchFragment($fragments[3], $this->extra);
}
return ($matches == $n);
} function _matchFragment($fragment, $value)
{
if (strcspn($fragment, '*?') < strlen($fragment)) {
$reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\/'), $fragment) . '$';
return eregi($reg, $value);
}
return ($fragment == '*' || !strcasecmp($fragment, $value));
}}/*
* Local Variables:
* indent-tabs-mode: nil
* c-basic-offset: 4
* End:
*/
?>
解决方案 »
- php实现本地下载的问题
- 出现 503 错误
- 添加一条空白记录的函数是?
- 不用javascript 如何用图片实现流量统计
- 如何根据类名得到类, 再根据方法名得到方法
- 正则问题
- 关于php发邮件的问题
- 网页本身和页面编码都是utf-8的,通过form提交文字。如何换行和显示控白。代码如下。
- 求助~~~~急~~~~~问题: $data =addslashes(fread(fopen($ufile, "r"), filesize($ufile)));
- 关于数据查询返回结果的问题!!!高分相送!!
- 急求:PHP 中文免费书 最好是pdf格式的
- PHP网站发布的配置问题,希望大家给予帮助,小弟感激不尽!(急!!!!!)
<?php
@exec("ipconfig /all",$array);
for($Tmpa;$Tmpa<count($array);$Tmpa++){
if(eregi("Physical",$array[$Tmpa])){
$getstr=explode(":",$array[$Tmpa]);
echo $getstr[1];
}
}
?>
现在客户端一般都是用路由上网,用ARP的方法也没用除非你让客户端强制安装一个ActiveX插件
但是除了IE谁都不支持
UP,我也想知道
这样以后程序安全得多