<?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 news\admin\controller;
use \temmoku\db;
use \temmoku\controller;
use news\public_class\cache;
class setting extends Controller{
	public function index(){
		$settingDB=db::select('*')->from(M_jab."setting")->query();
		foreach($settingDB AS $key=>$rs){
			$setting[$rs['s_key']]=$rs['s_name'];
		}
		
		if('post'===$_POST['step']){
			foreach($_POST['set'] AS $key=>$name){
				if($key=='m_jab') continue;
				if($key=='special_category_cache_time' || $key=='special_content_cache_time' ){
					$name=round($name,2);
				}
				$one=db::select('*')->from(M_jab."setting")->where("s_key LIKE '$key' ")->row();
				if($one){
					db::update(M_jab."setting")->cols(array('s_name'))->where("s_key LIKE '$key'")->bindValue('s_name', "$name")->query();
				}else{
					db::insert(M_jab."setting")->cols(array('s_key'=>"$key",'s_name'=>"$name"))->query();
				}
			}
			cache::setting();
			$this->success('修改成功');
		}
		$this->assign('setting', $setting);
		$this->display(tpl('setting/index'));
	}
	
}
?>
