class.config.php 864 Bytes
<?php

class config{
	private $data = array();
	private $file = '';
	public function __construct($file){
		$this -> file = $file;
	}
	public function set_array($name,$value){
		if ( sizeof($value)==0 ){
		$this -> data[$name] = 'array()';	
		}else{
			$this -> data[$name] = var_export($value,true);
		}
	}
	public function set_str($name,$value){
		$this -> data[$name] = "'".addslashes($value)."'";
	}
	public function set_bin($name,$value){
		$this -> data[$name] = !empty($value) ? 1 : 0;
	}
	public function set_int($name,$value){
	    $value = intval($value);
		$value = !empty($value) ? $value : 0;
		$this -> data[$name] = $value;
	}
	
	public function save(){
		$txt = '<?php'."\n\r";
		foreach( $this -> data AS $k=>$v ){
			$txt .='cms::set_config(\''.$k."',$v);\n\r";
		}
		$txt .= "\n\r".'?>';
		return sys_write_file($this -> file,$txt);
	}
	
	
}

?>