Location: PHPKode > projects > PHPMyServer > server/modules/hardware/index.php4.php
<?PHP
//
// PHPMyServer - A PHP System Information Script - Old project name was PHPMyStats
// http://www.phpmyserver.com/
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// $Id: index.php/index.php4.php/index.php5.php/etc ,v 2.6 13-08-2005 16:30 precision Exp $
//
// Date in $Id is as DD-MM-YY

//PHPMyServer - XML Server v2.6
//Build version:
//  split version at the DOT, before the DOT is the CORE version, AFTER the DOT is de RELEASE
//Every new release will get an higher number, so when i released version 2 of the script for the 126523st time, its version v2.126523

//Copyright 2004-2005 by KingOfDos Intra/Extra/Internet WebServices
//http://www.phpmyserver.com
//http://www.kingofdos.com
//http://www.kingofdos.com

class pmsmod_hardware {

	var $module;

	function GetHardware($class='usb') {
		$val = array();

		//if (function_exists('pmsFuncStatic'))
		//	$func =& pmsFuncStatic();
		
		if (isset($this->func)) {
			if ($this->func->OSIsWindows()) {
				// windows results here
				$class=addslashes($class);
			
				if ($data = $this->func->shell_mexec('.\\hardware\\devcon.exe listclass '.$class)) { //devcon.exe resources *
					$expl_data = explode("\n",$data);
					$ret_data = array();
					$i=1;
					foreach($expl_data as $this_key => $this_data) {
						$this_data_expl = explode(': ',$this_data);
						
					if (ereg('\\\\',$this_data_expl[0]))
							$ret_data[] = trim($this_data_expl[1]);
					}
					$val = $ret_data;
				} else
					$val = false;
			} else {
				$val = false;
			}
		} else {
			$val = false;
		}
		return $val;
	}
	
	function GetCPUExec() {
		//if (function_exists('pmsFuncStatic'))
		//	$func =& pmsFuncStatic();
		
		if ($cpu_exec_data = $this->func->shell_mexec(".\\hardware\\cpu.exe /v")) {
			$cpu_data_arr = explode("\n", $cpu_exec_data); //execute cpu.exe and explodes it on "new rule"
			foreach($cpu_data_arr as $tmp_key => $tmp_val){
				if (eregi("CPU-ID Name string", $tmp_val)){
					$tmp_model = explode(": ", $tmp_val);
					$cpu_model = $tmp_model[1];
				}
				if (eregi("Internal CPU speed", $tmp_val)){
					$tmp_speed = explode(": ", $tmp_val);
					$tmp_speed = $tmp_speed[1];
					$cpu_speed = str_replace("  (using internal Time Stamp Counter)", "", $tmp_speed);
				}
				if (eregi("Size of L1 cache", $tmp_val)){
					$tmp_l1 = explode(": ", $tmp_val);
					$cpu_l1 = $tmp_l1[1];
				}
				if (eregi("CPU Vendor and Model", $tmp_val)){
					$tmp_vendor = explode(": ", $tmp_val);
					$tmp_vendor = explode(" ", $tmp_vendor[1]);
					if (!isset($cpu_model))
						$cpu_model = $tmp_vendor[0] . " " . $tmp_vendor[1];
					$cpu_vendor = $tmp_vendor;
				}
			}
			
			if ((isset($cpu_model)) && (isset($cpu_speed)))
				return $cpu_model . " @ " . $cpu_speed;
			else
				return false;
		} else
			return false;
	}
	
	
	function eregi_in_array($string,$array) {
		foreach($array as $key => $val) {
			if (eregi($val,$string))
				return true;
		}
		return false;
	}
	




	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	


	//Constructor
	function pmsmod_hardware() {
		if (function_exists('pmsFuncStatic'))
			$this->func=& pmsFuncStatic();

		$this->module = array();

		//Compatible versions of PHPMyServer for this module
		$this->module['compatible_version'] = array(
		'03d21b594c8a1b5831a7101c10df7b83',
		'02f1051414bda3eb39439ce2c998abca'
		);

		//Information
		include 'info_data.php';
		$this->module['information'] = $val;
		$this->module['return_data'] = array();
		
		//-------------------------- Function Remover
		$no_allow_data = array('miniport','parallel','minipoort');
		
		//Init
		$i = 1;
		
		//-------------------------- Network Devices
		if ($networkdevices = $this->GetHardware('net') AND is_array($networkdevices)) {
			foreach($networkdevices as $this_key => $this_val) {
				if (!$this->eregi_in_array($this_val,$no_allow_data)) {
							$this->module['return_data']['device'][] = array(
								'pms_id'=>$i,
								'type'=>'network',
								'name'=>$this_val
							);
					$i++;
				}
			} 
		}
		
		//-------------------------- Processor Devices
		if ($processordevices = $this->GetHardware('processor') AND is_array($processordevices)) {
			foreach($processordevices as $this_key => $this_val) {
				if (!$this->eregi_in_array($this_val,$no_allow_data)) {
							$this->module['return_data']['device'][] = array(
								'pms_id'=>$i,
								'type'=>'processor',
								'name'=>$this_val
							);
					$i++;
				}
			} 
		}
		
		//-------------------------- SCSI / SATA Adapter Devices
		if ($scsiadapterdevices = $this->GetHardware('scsiadapter') AND is_array($scsiadapterdevices)) {
			foreach($scsiadapterdevices as $this_key => $this_val) {
				if (!$this->eregi_in_array($this_val,$no_allow_data)) {
							$this->module['return_data']['device'][] = array(
								'pms_id'=>$i,
								'type'=>'scsiadapter',
								'name'=>$this_val
							);
					$i++;
				}
			} 
		}
		
		//-------------------------- IDE (HDC) Devices
		if ($hdcdevices = $this->GetHardware('hdc') AND is_array($hdcdevices)) {
			foreach($hdcdevices as $this_key => $this_val) {
				if (!$this->eregi_in_array($this_val,$no_allow_data)) {
							$this->module['return_data']['device'][] = array(
								'pms_id'=>$i,
								'type'=>'hdc',
								'name'=>$this_val
							);
					$i++;
				}
			} 
		}

	}

	//Returner
	function pmsmod_return() {
		return $this->module;
	}
}

?>
Return current item: PHPMyServer