偶尔疯癫 發表於 2023-11-14 00:00:00

织梦dedecmsv5.x自动登录的方法

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>实现步骤如下:</span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>取消DEDE未登陆时出现的登陆提示 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>自动登陆DEDE </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>修改一处DEDE的代码,为DEDE程序管理员目录的config.php,默认路径为dede/config.php,代码如下:</span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        //检验用户登录状态<br>
        $cuserLogin = new userLogin(); <br>
        if($cuserLogin-&gt;getUserID()==-1) <br>
        { header("location:login.php?gotopage=".urlencode($dedeNowurl)); <br>
        exit(); <br>
        } </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这段代码的作用是如果未检测到用户的登陆信息,就引导用户进入登陆过程,修改如下:</span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        //检验用户登录状态<br>
        $cuserLogin = new userLogin(); <br>
        if($cuserLogin-&gt;getUserID()==-1) <br>
        { <br>
        if($my_u != ''){ <br>
        $res = $cuserLogin-&gt;checkUser($my_u, $my_p); <br>
        if($res==1) $cuserLogin-&gt;keepUser(); <br>
        } <br>
        if($cuserLogin-&gt;getUserID()==-1) <br>
        { <br>
        header("location:login.php?gotopage=".urlencode($dedeNowurl)); <br>
        exit(); <br>
        } <br>
        } </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这段代码的作用是在检测到用户未登陆时,尝试使用页面传递过来的参数进行登陆,如果登陆成功,则保存用户的信息并进行其它操作;如果登陆失败,就引导用户进入登陆页面。</span></p>
頁: [1]
查看完整版本: 织梦dedecmsv5.x自动登录的方法