Location: PHPKode > projects > vStats > data.php
<?
/******************************************************************************
 *	Data container for vStats 
 *	(c) by Christian Goesswein - hide@address.com
 *
 *	$Revision: 30 $
 *	$Date: 2006-04-23 15:11:39 +0200 (So, 23 Apr 2006) $
 *	$Author: dc_d00de $
 *	$Id: data.php 30 2006-04-23 13:11:39Z dc_d00de $
 *
 ******************************************************************************/

class Data{
	
	// The variable where everything is stored.
	var $items;

	function Data(){
		// Add the default language.
		$this->add_item("LANGUAGE","english");
	}

	function add_item($item, $data){ 
		// Add data to a given item in the array.
		$this->items[$item]=$data; 
	}

	function get_data($stuff){
		// If the mysql-time is wanted, calculate and return it.
		if($stuff=="DEBUG_TIME" && !isset($this->items["DEBUG_TIME"])){
			$mtime = microtime();
			$mtime = explode(' ',$mtime);
			$mtime = $mtime[1] + $mtime[0];
			$endtime = $mtime;
			$totaltime = round(($endtime - $this->items["debug_starttime"]),5);
			return $totaltime;
		}
		// If the percentage of sql queries during the processing time is wanted,
		// calculate and return it.
		else if($stuff=="DEBUG_SQL_PERCENT" && !isset($this->items["DEBUG_SQL_PERCENT"])){
			$percent=0;
			$totaltime=$this->get_data("DEBUG_TIME");
			$percent=round($this->get_data("DEBUG_QUERYTIME")/($totaltime/100),2);
			return $percent;
		}
		// Return the wanted value of it exists.
		else{
			if(isset($this->items[$stuff])){
				return $this->items[$stuff];
			}
			else{
				return false;
			}
		}
	}
}
?>
Return current item: vStats