123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- // +—————————————————————————————————————————————————————————————————————
- // | Created by Yunbao
- // +—————————————————————————————————————————————————————————————————————
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
- // +—————————————————————————————————————————————————————————————————————
- // | Author: https://gitee.com/yunbaokeji
- // +—————————————————————————————————————————————————————————————————————
- // | Date: 2022-02-17
- // +—————————————————————————————————————————————————————————————————————
- namespace app\user\controller;
- use cmf\controller\HomeBaseController;
- use app\user\model\UserModel;
- use think\Validate;
- class PublicController extends HomeBaseController
- {
- // 用户头像api
- public function avatar()
- {
- $id = $this->request->param("id", 0, "intval");
- $user = UserModel::get($id);
- $avatar = '';
- if (!empty($user)) {
- $avatar = cmf_get_user_avatar_url($user['avatar']);
- if (strpos($avatar, "/") === 0) {
- $avatar = $this->request->domain() . $avatar;
- }
- }
- if (empty($avatar)) {
- $cdnSettings = cmf_get_option('cdn_settings');
- if (empty($cdnSettings['cdn_static_root'])) {
- $avatar = $this->request->domain() . "/static/images/headicon.png";
- } else {
- $cdnStaticRoot = rtrim($cdnSettings['cdn_static_root'], '/');
- $avatar = $cdnStaticRoot . "/static/images/headicon.png";
- }
- }
- return redirect($avatar);
- }
- }
|