//系统配置
function config(){
if (!$this->request->isPost()){
$info = db("config")->find(1);
// dump($info);
$this->view->assign('info',checkData($info,false));
// $this->view->assign('themesList',CatagoryService::tplList(''));
return view('base/config');
}else{
$data = $this->request->post();
// dump($data);exit;
$where['c_name']=$data['c_name'];
$where['c_webname'] = $data['c_webname'];
$where['c_weburl'] = $data['c_weburl'];
$where['c_indextemp'] =$data['c_indextemp'];
$where['c_webtemp']= $data['c_webtemp'];
$where['c_mobiletemp']= $data['c_mobiletemp'];
$where['c_indexkeyword']= $data['c_indexkeyword'];
$where['c_indexdescription']= $data['c_indexkeyword'];
$where['c_webcopyright']= $data['c_webcopyright'];
$where['c_icpnum']= $data['c_icpnum'];
$result=db('config')->where(['c_id'=>1])->save($where);
if($result){
// return json(['status'=>'00','msg'=>'修改成功']);
$this->success('修改成功',url('Base/config'));
}else{
$this->error('无修改,正在返回',url('Base/config'));
}
}
}
继承admin.php
<?php
/**
* ============================================================================
* * COPYRIGHT 2016-2019 xhadmin.com , and all rights reserved.
* * WEBSITE: http://www.xhadmin.com;
* ----------------------------------------------------------------------------
* This is not a free software!You have not used for commercial purposes in the
* premise of the program code to modify and use; and publication does not allow
* any form of code for any purpose.
* ============================================================================
* Author: QQ:2228293408
*/
namespace app\admin\controller;
use think\exception\FuncNotFoundException;
use think\exception\ValidateException;
use app\BaseController;
class Admin extends BaseController
{
public function initialize(){
$controller = $this->request->controller();
$action = $this->request->action();
$app = app('http')->getName();
$admin = session('admin');
$userid = session('admin_sign') == data_auth_sign($admin) ? $admin['a_id'] : 0;
if( !$userid && ( $app <> 'admin' || $controller <> 'Login' )){
echo '<script type="text/javascript">window.parent.frames.location.href="'.url('admin/Login/index').'";</script>';exit();
}
$url = "{$app}/{$controller}/{$action}";
// if(session('admin.role_id') <> 1 && !in_array($url,config('my.nocheck')) && $action !== 'getExtends' && $controller <> 'FormData'){
// if(!in_array($url,session('admin.nodes'))){
// throw new ValidateException ('你没操作权限');
// }
// }
event('DoLog');
$list = db("config")->cache(true,60)->find(1);
config($list,'xhadmin');
}
public function __call($method, $args){
throw new FuncNotFoundException('方法不存在',$method);
}
}