Location: PHPKode > projects > PHPMyServer > server/modules/harddisk/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_harddisk {

	var $module;

	function GetDrives() {
		$onlyhdd='';//To scan ONLY harddrives (instead of "all available" drives) add ' hdd'. Like $onlyhdd=' hdd';
		include 'mod_getdrives.php';
		return $val;	
	}
	
	function ReadDrive($driveletter) {
		$val = array();

		if (function_exists('pmsFuncStatic'))
			$func =& pmsFuncStatic();
	
		if (isset($func) AND disk_total_space($driveletter)) {
			$val['free_byte'] = disk_free_space($driveletter);
			$val['total_byte'] = disk_total_space($driveletter);
			$val['used_byte'] = $val['total_byte'] - $val['free_byte'];
			$val['free_mb'] = round($val['free_byte'] / 1048576, 2);
			$val['total_mb'] = round($val['total_byte'] / 1048576, 2);
			$val['used_mb'] = round($val['total_mb'] - $val['free_mb'],2);
			$val['free_gb'] = round($val['free_byte'] / (1048576 * 1024),2);
			$val['total_gb'] = round($val['total_byte'] / (1048576 * 1024),2);
			$val['used_gb'] = round(($val['total_mb'] - $val['free_mb']) / 1024,2);
			$val['percent_used'] = round(($val['used_byte'] / $val['total_byte']) * 100, 2);
			$val['percent_free'] = round(($val['free_byte'] / $val['total_byte']) * 100, 2);

			if ($func->OSIsWindows()) {
				//drvlbl.exe made by Jasper Bekkers aka PrisonerOfPain
				$CurDriveLabel = explode("\n",$func->shell_mexec(".\\harddisk\\drvlbl.exe ".strtolower($driveletter)."\\"));
				if (!$val['label'] = str_replace("'","",$CurDriveLabel[3]))
					$val['label'] = 'NO_LABEL';
		
			} else {
				$val['label'] = 'NO-LINUX'; //Linux has no system scripted yet that reads the drivelabel
			}
		} else
			return false;
		return $val;
	}






	//Constructor
	function pmsmod_harddisk() {
		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();
		
		if ($drives = $this->GetDrives()) {
			$i = 1;
			
			$this->module['return_data']['drive'] = array();
			
			foreach($drives as $drive_nr => $drive_str) {
				if (isset($drive_str) AND strlen($drive_str)>=1 AND $driveinfo = $this->ReadDrive($drive_str)) {
					//$this->module['return_data']['drive_'.$i] = array(
					$this->module['return_data']['drive'][] = array(
						'pms_id'		=> $i,
						'volume'		=> $drive_str,
						'byte_free'	=> $driveinfo['free_byte'],
						'byte_total'	=> $driveinfo['total_byte'],
						'byte_used'	=> $driveinfo['used_byte'],
						'mb_free'		=> $driveinfo['free_mb'],
						'mb_total'	=> $driveinfo['total_mb'],
						'mb_used'		=> $driveinfo['used_mb'],
						'gb_free'		=> $driveinfo['free_gb'],
						'gb_total'		=> $driveinfo['total_gb'],
						'gb_used'		=> $driveinfo['used_gb'],
						'percent_free' => $driveinfo['percent_free'],
						'percent_used' => $driveinfo['percent_used'],
						'label'			=> $driveinfo['label']
					);
					$i++;
				}
			}
		}
	}

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

?>
Return current item: PHPMyServer