<?php
/*
##################   GraFX Press   #################
############################################################
GraFX Press			    Version 1.0
Writed by               GraFX (webmaster@grafxsoftware.com)
Created 04/04/04        Last Modified $Date: 2006/10/18 11:53:33 $
Scripts Home:           http://www.grafxsoftware.com
############################################################
File name               cls_configwrapper.php
File purpose            CLASS Config Wrapper
File created by         GraFX (webmaster@grafxsoftware.com)
############################################################
*/
/*
$cw=new ConfigWrapper();

$cw->getId();
$cw->getDescription();
$cw->getName();
$cw->getValue();
$cw->getComment();
$cw->getType();
$cw->setId();
$cw->setDescription();
$cw->setName();
$cw->setValue();
$cw->setComment();
$cw->setType();
$cw->save();
*/
class ConfigWrapper
{
 var  $id;
 var  $description;
 var  $name;
 var  $value;
 var  $comment;
 var  $type;
function ConfigWrapper($id)
	{


	
	}//end constructor ConfigWrapper

function generateConfig($path,$carray){
// checking the file rights
	if (!file_exists($path))
	    return 0;
	 else {
			
        	$buffer="";
			 foreach($carray as $row){

				if(!empty($row['comment']))
				$buffer.="// ".str_replace("\n","// ",$row['comment'])."\n";
				$buffer.="define(\"".str_replace("\n","",$row['name'])."\",\"". addslashes(str_replace("\n","",$row['value']))."\");\n";
		   }
		   
		   if($buffer<>"")
		   {
				$handle = @fopen($path, "w");
			$buffer="<?php \n".$buffer."\n\n // if Error Reporting Disable, then set to not report any errors on screen\n if (ERROR_DEBUG==0)\n\n error_reporting(E_ALL & ~E_NOTICE);\n\n// Disable magic_quotes_runtime\n\nset_magic_quotes_runtime(0);\nheader(\"Content-Type: text/html; charset=\".CONF_CHARSET);\n\n?>";
				if (@fwrite($handle, $buffer) === FALSE) {
					return 0;
		   		}
    		fclose($handle);
			return 1;
		}
   }
 }
} // end class ConfigWrapper
?>