<?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\sms\admin\controller;
use \temmoku\db;
use \temmoku\controller;
use plugin\sms\public_class\cache;
class setting extends controller{
	public function set(){
		if('post'===$_POST['step']){
			foreach($_POST['sms'] AS $key=>$name){
				$one=db::select('*')->from(P_jab."setting")->where("u_key LIKE '$key' ")->row();
				if($one){
					db::update(P_jab."setting")->cols(array('u_value'))->where("u_key LIKE '$key'")->bindValue('u_value', "$name")->query();
				}else{
					db::insert(P_jab."setting")->cols(array('u_key'=>"$key",'u_value'=>"$name"))->query();
				}
			}
			cache::setting_cache();
			$this->Success('修改成功');
		}
		
		$settingDB=db::select('*')->from(P_jab."setting")->query();
		foreach($settingDB AS $key=>$row){
			$setting[$row['u_key']]=$row['u_value'];
		}
		$this->assign('setting', $setting);
		$this->display(tpl('set'));
	}
	
}
?>