<?php
/*
######################      CWB\     #######################
############################################################
CWB PRO			$Name: release_version1_0_03112006 $
Revision		$Revision: 1.2 $
Author			$Author: zelteto $
Created 03/01/03        $Date: 2006/10/30 15:28:21 $
Writed by               GraFX (webmaster@grafxsoftware.com)
Scripts Home:           http://www.grafxsoftware.com
############################################################
*/

class MiniFile
{
	
	var $data_array;
	var $file;
	var $backup_data_array;
	
	function MiniFile($file)
	{					
		
		if(file_exists(REPOSITORY_PATH.$file))
		{
		 
		  $content_array=file(REPOSITORY_PATH.$file);


		  $content_array=array_slice($content_array, 2, -1);
		  
		  $this->backup_data_array=$content_array[0];
		  $this->data_array=unserialize($content_array[0]);
		  $this->file=$file;
		}
		else
		  $this->data_array=array();
		
    }
	
	function getArray(){
	
	return $this->data_array;
	
	}
	function setArray($new){
	
	$this->data_array=$new;
	
	}	
	
	function save($path=""){
	
	$backup_time=date("YmdHsj");
	
	$backup_path=(empty($path)?REPOSITORY_PATH."b_".$backup_time."_".$this->file:$path);
	
	$handle = @fopen($backup_path, 'w+');
    @fwrite($handle, "<?php\n/*\n".$this->backup_data_array."\n*/\n?>");
    @fclose($handle);
	
	
	
	$new_path=(empty($path)?REPOSITORY_PATH.$this->file:$path);
	
	
	if(is_writable($new_path)) {
	$handle = fopen($new_path, 'w+');
    fwrite($handle, "<?php\n/*\n".serialize($this->data_array)."\n*/\n?>");
    fclose($handle);
	return 1;
	}
	else
	 return 0;

	}
	
}
?> 