您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php windows系统探测程序_PHP教程

2024/3/30 23:28:15发布14次查看
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;
}
//windows系统探测
function sys_windows() {
 $objlocator = new com(wbemscripting.swbemlocator);
 $wmi = $objlocator->connectserver();
 $prop = $wmi->get(win32_pnpentity);
 //cpu
 $cpuinfo = getwmi($wmi,win32_processor, array(name,l2cachesize,numberofcores));
 $res['cpu']['num'] = $cpuinfo[0]['numberofcores'];
 if (null == $res['cpu']['num']) {
  $res['cpu']['num'] = 1;
 }
 for ($i=0;$i  $res['cpu']['model'] .= $cpuinfo[0]['name'].
;
  $res['cpu']['cache'] .= $cpuinfo[0]['l2cachesize'].
;
 }
 // sysinfo
 $sysinfo = getwmi($wmi,win32_operatingsystem, array('lastbootuptime','totalvisiblememorysize','freephysicalmemory','caption','csdversion','serialnumber','installdate'));
 $res['win_n'] = $sysinfo[0]['caption']. .$sysinfo[0]['csdversion']. 序列号:{$sysinfo[0]['serialnumber']} 于.date('y年m月d日h:i:s',strtotime(substr($sysinfo[0]['installdate'],0,14))).安装;
 //uptime
 $res['uptime'] = $sysinfo[0]['lastbootuptime'];
$sys_ticks = 3600*8 + time() - strtotime(substr($res['uptime'],0,14));
 $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
 $res['memtotal'] = $sysinfo[0]['totalvisiblememorysize'];
 $res['memfree'] = $sysinfo[0]['freephysicalmemory'];
 $res['memused'] = $res['memtotal'] - $res['memfree'];
 $res['mempercent'] = round($res['memused'] / $res['memtotal']*100,2);
 $swapinfo = getwmi($wmi,win32_pagefileusage, array('allocatedbasesize','currentusage'));
 // todo swp区获取
 $res['swaptotal'] = $swapinfo[0][allocatedbasesize];
 $res['swapused'] = $swapinfo[0][currentusage];
 $res['swapfree'] = $res['swaptotal'] - $res['swapused'];
 $res['swappercent'] = (floatval($res['swaptotal'])!=0)?round($res['swapused']/$res['swaptotal']*100,2):0;
 // loadpercentage
 $loadinfo = getwmi($wmi,win32_processor, array(loadpercentage));
 $res['loadavg'] = $loadinfo[0]['loadpercentage'];
 return $res;
}
function getwmi($wmi,$strclass, $strvalue = array()) {
 $arrdata = array();
 $objwebm = $wmi->get($strclass);
 $arrprop = $objwebm->properties_;
 $arrwebmcol = $objwebm->instances_();
 foreach($arrwebmcol as $objitem) {
  @reset($arrprop);
  $arrinstance = array();
  foreach($arrprop as $propitem) {
   eval($value = $objitem-> . $propitem->name . ;);
   if (empty($strvalue)) {
    $arrinstance[$propitem->name] = trim($value);
   } else {
    if (in_array($propitem->name, $strvalue)) {
     $arrinstance[$propitem->name] = trim($value);
    }
   }
  }
  $arrdata[] = $arrinstance;
 }
 return $arrdata;
}
http://www.bkjia.com/phpjc/632007.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/632007.htmltecharticlefunction do_command($commandname, $args) { $buffer = ; if (false === ($command = find_command($commandname))) return false; if ($fp = @popen($command $args, 'r')) { while (!@feof($...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product