<?php
class UpdateAction extends IniAction{
	public function index(){
		$pre = C('DB_PREFIX');
		is_file('update.php') && include 'update.php';
		if(empty($sql_field) && empty($sql_setting)){
			exit("no update");
		}
		
		foreach($sql_setting as $key=>$val){
			if(!array_key_exists($val[0], $this->setting)){
				mysql_query("INSERT INTO `{$pre}setting` (setting_key,setting_val) values ('{$val[0]}','{$val[1]}')");
			}				
		}
		
		foreach($sql_field as $key=>$val){
			mysql_query($val);
		}
		M('setting')->where("setting_key='version'")->save(array('setting_val'=>$version));
		/*
		$f = fopen('update.php','w');
		fwrite($f,'');
		fclose($f);
		*/
		exit('finish');
	}
}