<?php
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST, ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace plugin\advertisement\admin\controller;
use \temmoku\db;
use \temmoku\controller;
use plugin\advertisement\public_class\cache;
use \plugin\advertisement\init;
class setting extends controller{
	public function set(){
		if('post'===$_POST['step']){
			foreach($_POST['web'] AS $key=>$name){
				$one=db::select('*')->from(init::$table."set")->where("u_key LIKE '$key' ")->row();
				if($one){
					db::update(init::$table."set")->cols(array('u_value'))->where("u_key LIKE '$key'")->bindValue('u_value', "$name")->query();
				}else{
					db::insert(init::$table."set")->cols(array('u_key'=>"$key",'u_value'=>"$name"))->query();
				}
			}
			cache::setting_cache();
			$this->Success('修改成功');
		}
		
		$settingDB=db::select('*')->from(init::$table."set")->query();
		foreach($settingDB AS $key=>$row){
			$setting[$row['u_key']]=$row['u_value'];
		}
		$this->assign('setting', $setting);
		$this->display(tpl('set'));
	}
	
}
?>