ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 基本设置 ## 修改个人信息 /admin/index/userInfo ~~~ // 用户信息 public function userInfo(){ $Admin = new AdminModel(); $adminInfo = $Admin->getInfo($this->admin_id); // 修改用户信息 if(request()->isAjax()){ $param = input('post.'); $param['data']['id'] = $this->admin_id; $flag = $Admin->add($param['data']); $description = '修改信息:昵称='.$param['data']['nickname'].',昵称='.$param['data']['phone'] .',昵称='.$param['data']['email'].''; writelog_admin('admin','editUserInfo',$description); return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]); } $this->assign('info',$adminInfo); return $this->fetch(); } ~~~ ## 修改个人密码 /admin/index/password 修改密码需要添加原密码,修改成功后会自动退出 ~~~ public function password(){ $Admin = new AdminModel(); if(request()->isAjax()){ $post = Request::instance()->param(); $password = $post['data']['password']; $rpassword = $post['data']['rpassword']; $old_password = $post['data']['old_password']; if($password!=$rpassword){ return json(['code' => 1, 'msg' => '两次密码不一致']); } $map = []; $map['id'] = $this->admin_id; $map['password'] = password($old_password); $adminInfo = Db::name('admin')->where( $map )->find(); if(empty($adminInfo)){ return json(['code' => 1, 'msg' => '原密码不正确']); } Db::name('admin')->where( 'id',$this->admin_id )->update(['password'=>password($password)]); session(null); writelog_admin('admin','changePassword','密码修改成功'); return json(['code' => 0, 'msg' => '密码修改成功']); } $adminInfo = $Admin->getInfo($this->admin_id); $this->assign('info',$adminInfo); return $this->fetch(); } ~~~ ## 清理缓存 /admin/index/clearCache ~~~ /** * 清除缓存 */ public function clearCache() { $act = input('act'); if($act=='clear_all'){ Cache::clear(); array_map( 'unlink', glob( TEMP_PATH.'*.php' ) ); $path = glob( LOG_PATH.'*' ); foreach ($path as $item) { array_map( 'unlink', glob( $item.DS.'*.*' ) ); rmdir( $item ); } return json(['code' => '0', 'data' => '', 'msg' => '操作成功!']); } //清除缓存文件 if($act=='clear_cache'){ Cache::clear(); return json(['code' => '0', 'data' => '', 'msg' => '操作成功!']); } // 删除日志目录及文件 if($act=='clear_log'){ $path = glob( LOG_PATH.'*' ); foreach ($path as $item) { array_map( 'unlink', glob( $item.DS.'*.*' ) ); rmdir( $item ); } return json(['code' => '0', 'data' => '', 'msg' => '操作成功!']); } // 清空临时文件 if($act=='clear_temp'){ array_map( 'unlink', glob( TEMP_PATH.'*.php' ) ); return json(['code' => '0', 'data' => '', 'msg' => '操作成功!']); } $cacheFileNum = scanfiles('../runtime/cache/'); $this->assign('cacheFileNum',count($cacheFileNum)); $tempFileNum = scanfiles('../runtime/temp/'); $this->assign('tempFileNum',count($tempFileNum)); $logFileNum = scanfiles('../runtime/log/'); $this->assign('logFileNum',count($logFileNum)); return $this->fetch(); } ~~~