<?php
class netsCache extends netsError {
	private $sysErrorClassID='1206';
	private $sysErrorFuncID=0;
	private $sysErrorID=0;

	public function netsCache(){
		$this->netsError();
	}
	
	public function readCache($pSTR){
		$tmpAR0=array();
		$tmpPATH=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDataCachePath'].$pSTR.'.php';
		if(file_exists($tmpPATH)){
			$tmpSTR='';
			require($tmpPATH);
			$tmpAR0=unserialize($tmpSTR);
			if(!is_array($tmpAR0)){
				$tmpAR0=array();
			}
		}

		return $tmpAR0;
	}
	public function writeCache($pSTR,$pAR){
		$tmpPATH=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDataCachePath'].$pSTR.'.php';
		$tmpSTR='<?php $tmpSTR=\''.serialize($pAR).'\'; ?>';
		$tmpINT=$this->writeFile($tmpPATH,$tmpSTR);
		return 0;
	}
	public function clearCache($pSTR){
		$tmpAR0=array();
		$tmpPATH=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDataCachePath'].$pSTR.'.php';
		$tmpINT=$this->deleteFile($tmpPATH);
		return 0;
	}
	public function clearAllCache($pSTR){
		$tmpAR0=array();
		$tmpPATH=$this->sysFileConfig['PathRoot'].$this->sysFileConfig['sysDataCachePath'].$pSTR;
		$tmpINT=$this->deleteAllFile($tmpPATH);
		return 0;
	}
	protected function ArraySort($pAR,$pIndexName,$pType){
		$this->sysErrorFuncID=$this->sysErrorClassID.'26';
		$retAR=array();
		$tmpAR0=array();
		//
		foreach($pAR as $Cell){
			array_push($tmpAR0,$Cell[$pIndexName]);
		}
		//
		for($index=1;$index<count($tmpAR0);$index++){
			$tmpCont=$tmpAR0[$index];
			$tmpCell=$pAR[$index];
			$tmpPosi=$index-1;
			if($pType==0){
				while($tmpPosi>=0 && $tmpCont>$tmpAR0[$tmpPosi]){
					$tmpAR0[$tmpPosi+1]=$tmpAR0[$tmpPosi];
					$pAR[$tmpPosi+1]=$pAR[$tmpPosi];
					$tmpPosi--;
				}
			}else if ($pType==1){
				while($tmpPosi>=0 && $tmpCont<$tmpAR0[$tmpPosi]){
					$tmpAR0[$tmpPosi+1]=$tmpAR0[$tmpPosi];
					$pAR[$tmpPosi+1]=$pAR[$tmpPosi];
					$tmpPosi--;
				}
			}
			$tmpAR0[$tmpPosi+1]=$tmpCont;
			$pAR[$tmpPosi+1]=$tmpCell;
		}
		
		return $pAR;
	}
	
}
?>