注册 | 登录 |
地方论坛门户及新闻和人才网址大全

DiscuzX3.2开发手机登录流程 禁止转载

时间:2021-07-21人气:-


第一步:修改登录模板找到登陆的模板文件,默认文件为:
  1. /template/default/member/login.htm 登录模板
复制代码引用Discuz模板目录结构对照表:
http://www.dede58.com.cn/dz7top-dztemplate.html

找到如下代码:
  1. <option value="email">{lang email}</option>


在后面加上一句:

  1. <option value="mobile">手机</option>
复制代码

修改后保存:


第二步:修改登录流程

打开sourcefunctionfunction_member.php

搜索代码:
  1. userlogin($username, $password, $questionid,
找到:
  1. if($loginfield == 'uid' && getglobal('setting/uidlogin')) {
  2. $isuid = 1;
  3. } elseif($loginfield == 'email') {
  4. $isuid = 2;
  5. } elseif($loginfield == 'auto') {
  6. $isuid = 3;
  7. } else {
  8. $isuid = 0;
  9. }

修改为:
  1. if($loginfield == 'uid' && getglobal('setting/uidlogin')) {
  2. $isuid = 1;
  3. } elseif($loginfield == 'email') {
  4. $isuid = 2;
  5. } elseif($loginfield == 'auto') {
  6. $isuid = 3;
  7. } elseif($loginfield == 'mobile') {
  8. $isuid = 4;
  9. } else {
  10. $isuid = 0;
  11. }


修改后保存!

第三步:修改UC流程

打开uc_clientcontroluser.php

搜索:
  1. $user = $_ENV['user']->get_user_by_uid($username);
复制代码找到:
  1. if($isuid == 1) {
  2. $user = $_ENV['user']->get_user_by_uid($username);
  3. } elseif($isuid == 2) {
  4. $user = $_ENV['user']->get_user_by_email($username);
  5. } else {
  6. $user = $_ENV['user']->get_user_by_username($username);
  7. }
复制代码修改为:
  1. if($isuid == 1) {
  2. $user = $_ENV['user']->get_user_by_uid($username);
  3. } elseif($isuid == 2) {
  4. $user = $_ENV['user']->get_user_by_email($username);
  5. } elseif($isuid == 4) {
  6. $user = $_ENV['user']->get_user_by_mobile($username);
  7. } else {
  8. $user = $_ENV['user']->get_user_by_username($username);
  9. }
保存

第四步:添加登陆模型

打开uc_clientmodeluser.php

搜索:
  1. function get_user_by_uid($uid)
找到
  1. function get_user_by_uid($uid) {
  2. $arr = $this->db->fetch_first("SELECT * FROM ".UC_DBTABLEPRE."members WHERE uid='$uid'");
  3. return $arr;
  4. }

在他的上面或者下面添加如下代码

  1. function get_user_by_mobile($mobile) {
  2. $arr = $this->db->fetch_first("SELECT * FROM ".UC_DBTABLEPRE."members WHERE mobile='$mobile'");
  3. return $arr;
  4. }


然后保存!




上篇:详细分析 Discuz 中的showmessage()函数 ...

下篇:Discuz-内容页-发帖按钮