<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 完整代碼 >注:注釋的部分,可根據實際情況進行去掉! ``` <?php namespace app\agent\controller; use think\Controller; class PublicController extends Controller { /** * 后臺登陸界面 */ public function login() { // $loginAllowed = session("__LOGIN_BY_CMF_ADMIN_PW__"); // if (empty($loginAllowed)) { // $this->error('非法登錄!', cmf_get_root() . '/'); // } $agent_id = session('AGENT_ID'); if (!empty($agent_id)) {//已經登錄 redirect(url("agent/Index/index")); } else { // $site_admin_url_password = config("cmf_SITE_ADMIN_URL_PASSWORD"); // $upw = session("__CMF_UPW__"); // if (!empty($site_admin_url_password) && $upw != $site_admin_url_password) { // redirect(ROOT_PATH . "/"); // } else { // session("__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__", true); // $result = hook_one('admin_login'); // if (!empty($result)) { // return $result; // } return $this->fetch(":login"); // } } } } ``` ## `session`說明 | session名字 | 作用 | | --- | --- | | `__LOGIN_BY_CMF_ADMIN_PW__` | 設置后臺登錄加密碼,如果設置后值為1 | | `AGENT_ID` | 登錄ID | | `cmf_SITE_ADMIN_URL_PASSWORD` | 這個不清楚 | | `__CMF_UPW__` | 這個不清楚 | | `__SP_ADMIN_LOGIN_PAGE_SHOWED_SUCCESS__` | 這個不清楚 | ## 解析 ### 簡單登錄 >本身登錄應該是簡簡單單的 ``` <?php namespace app\agent\controller; use think\Controller; class PublicController extends Controller { /** * 后臺登陸界面 */ public function login() { $agent_id = session('AGENT_ID'); if (!empty($agent_id)) {//已經登錄 redirect(url("agent/Index/index")); } else { return $this->fetch(); } } } ``` ### 驗證登錄 >但是為了更安全一些,后臺設置了 `后臺加密碼` ``` <?php namespace app\agent\controller; use think\Controller; class PublicController extends Controller { /** * 后臺登陸界面 */ public function login() { $loginAllowed = session("__LOGIN_BY_CMF_ADMIN_PW__"); if (empty($loginAllowed)) { $this->error('非法登錄!', cmf_get_root() . '/'); } $admin_id = session('AGENT_ID'); if (!empty($admin_id)) {//已經登錄 redirect(url("agent/Index/index")); } else { return $this->fetch(); } } } ``` ### 后臺加密碼前端相關 #### 后臺加密碼代碼 ``` <div class="form-group"> <label for="input-admin_url_password" class="col-sm-2 control-label">后臺加密碼</label> <div class="col-md-6 col-sm-10"> <input type="text" class="form-control" id="input-admin_url_password" name="admin_settings[admin_password]" value="{$admin_settings.admin_password|default=''}" id="js-site-admin-url-password"> <p class="help-block">英文字母數字,不能為純數字</p> <if condition="!empty($admin_settings.admin_password)"> <p class="help-block" style="color: red;">設置加密碼后必須通過以下地址訪問后臺,請勞記此地址,為了安全,您也可以定期更換此加密碼!</p> <php> $site_admin_url_password =config("SP_SITE_ADMIN_URL_PASSWORD"); $root=cmf_get_root(); $root=empty($root)?'':'/'.$root; $site_domain = cmf_get_domain().$root; </php> <p class="help-block">后臺登錄地址:<span id="js-site-admin-url">{:$site_domain}/{$admin_settings.admin_password}</span></p> </if> </div> </div> ``` #### 后臺加密碼圖片 ![mark](http://qiniu.newthink.cc/blog/20171024-105807310.png) 非法登錄 ![mark](http://qiniu.newthink.cc/blog/20171024-121551192.png) #### 后臺加密碼路由 點擊保存后,會在 `data/route.php` 生成一個路由設置 ``` <?php return array ( 'test$' => 'admin/Index/index', ); ``` 如圖所示: ![mark](http://qiniu.newthink.cc/blog/20171024-110016098.png) 這時我們訪問 `http://thinkcmf/admin` 或者 `http://thinkcmf/test` 就者可以訪問了! ![mark](http://qiniu.newthink.cc/blog/20171024-111303217.png) 這個值是在這里進行設置的!! 后臺登錄地址也很明顯可以訪問 ![mark](http://qiniu.newthink.cc/blog/20171024-114648136.png) ### 備注二 ``` $site_admin_url_password = config("cmf_SITE_ADMIN_URL_PASSWORD"); $upw = session("__CMF_UPW__"); ``` 這個應該是沒有用的! ### 備注三:hook ``` $result = hook_one('admin_login'); if (!empty($result)) { return $result; } ``` 如果想要在登錄時加載一個 `hook`鉤子插件,可以在這里加載一個這樣的代碼 ![mark](http://qiniu.newthink.cc/blog/20171024-112015279.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看