Location: PHPKode > scripts > olDelete > oldelete/class.oldelete.php
<?php
include_once("class.navigator.php");
/*
*	Old Delete: Simple class to delete files in a path that are X minutes OLD:
	Usage: $oldie = new olDelete($full_path_to_file,$minutes);
*			Delete ----->    $oldie->delete();
*
*	Class Navigator is NEEDED.
*
*
*
*/

	class oldelete {
		// Class creation:
		public $path;
		public $minutes;
		public $error;
		
		public function __construct($path,$minutes){
			// Check Parameters:
			if(empty($path)){
				$this->error[0]="Path not present in parameters";
			}
			else{
				$this->path=$path;
			}
			if (empty($minutes)){
				$this->error[1]="Time not present in parameters";
			}
			else{
				$this->minutes=$minutes;
			}	
		}
		
		public function deleteFile(){
			$naviGatorClass = new Navigator($this->path);
			if (! $naviGatorClass){
				$error[2]="Error delete";
				exit;
			}

			//Mientras tratemos un fichero....
			while($naviGatorClass->NextFile()){
				$nombreFich=$naviGatorClass->FieldName;
				// Convert dates:
				$fechaModif=strtotime($naviGatorClass->FieldDate);
				$fechaComp=time()-($this->minutes*60);
				// Compare dates:
				if ($fechaComp > $fechaModif){
					$naviGatorClass->Remove($nombreFich);
				}
			}
		}
		
		public function deleteFolder(){
			$naviGatorClass = new Navigator($this->path);
			if (! $naviGatorClass){
				$error[2]="Error delete";
				exit;
			}

			//Mientras tratemos un fichero....
			while($naviGatorClass->NextDir()){
				$nombreDir=$naviGatorClass->FieldName;
				// Convert dates:
				$fechaModif=strtotime($naviGatorClass->FieldDate);
				$fechaComp=time()-($this->minutes*60);
				// Compare dates:
				if ($fechaComp > $fechaModif){
					$naviGatorClass->RemoveDir($nombreDir);
				}
			}
		}
		
		
	}

?>
Return current item: olDelete