Benpian used tp index carrying module index controller operation ucenter.
note! Benpian all modification or code are operated under tp project, and dz have nothing to do.
Editing Controller
<?php
namespace app\index\controller;
include_once ROOT_PATH.'config/config_ucenter.php';
include_once ROOT_PATH.'uc_client/client.php';
class Index
{
public function register()
{
$result = 'tp的站点注册成功'; // 你本站点注册成功后再注册dz
if ($result == 'tp的站点注册成功') {
$uid = uc_user_register('username', '1', '[email protected]');
var_dump($uid);
// 大于 0:返回用户id,表示用户注册成功
// -1:用户名不合法
// -2:包含不允许注册的词语
// -3:用户名已经存在
// -4:Email 格式有误
// -5:Email 不允许注册
// -6:该 Email 已经被注册
}
}
}
accesshttp://localhost/tp/public/index.php/index/index/register
I represent the membership registration, Table 2 id is
open pre_ucenter_members
table
now, you can go to login. Log in to let you complete activation, activated on login success.
This activation is written in another real membership form pre_common_member
, you do not activate just ucenter registered.
Skip Login activate , tp
modify the configuration file in the root directory
define('DISCUZ_DANAME', 'ultrax'); // dz数据库名
define('DISCUZ_DBRRE', 'pre_'); // dz数据包前缀
tp
Modify the code at the root
Find a add_user
method
to cover
function add_user($username, $password, $email, $uid = 0, $questionid = '', $answer = '', $regip = '') {
$regip = empty($regip) ? $this->base->onlineip : $regip;
$salt = substr(uniqid(rand()), -6);
$password = md5(md5($password).$salt);
$sqladd = $uid ? "uid='".intval($uid)."'," : '';
$sqladd .= $questionid > 0 ? " secques='".$this->quescrypt($questionid, $answer)."'," : " secques='',";
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."members SET $sqladd username='$username', password='$password', email='$email', regip='$regip', regdate='".$this->base->time."', salt='$salt'");
$uid = $this->db->insert_id();
$this->db->query("INSERT INTO ".UC_DBTABLEPRE."memberfields SET uid='$uid'");
$discuz_dbname = DISCUZ_DANAME;
$discuz_table_pre = DISCUZ_DBRRE;
$table_info = $discuz_dbname.'.'.$discuz_table_pre;
$this->db->query("INSERT INTO ".$table_info."common_member SET uid='$uid', username='$username', password='$password', email='$email', adminid='0', groupid='10', regdate='".$this->base->time."', credits='0', timeoffset='9999'");
$this->db->query("INSERT INTO ".$table_info."common_member_status SET uid='$uid', regip='$regip', lastip='$regip', lastvisit='".$this->base->time."', lastactivity='".$this->base->time."', lastpost='0', lastsendmail='0'");
$this->db->query("INSERT INTO ".$table_info."common_member_profile SET uid='$uid'");
$this->db->query("INSERT INTO ".$table_info."common_member_field_forum SET uid='$uid'");
$this->db->query("INSERT INTO ".$table_info."common_member_field_home SET uid='$uid'");
$this->db->query("INSERT INTO ".$table_info."common_member_count SET uid='$uid', extcredits1='0', extcredits2='0', extcredits3='0', extcredits4='0', extcredits5='0', extcredits6='0', extcredits7='0', extcredits8='0'");
return $uid;
}
Modify the method of registration, the user name changed username2, mailbox into [email protected], run again. If the return is not greater than 0, to see the comment, what is the reason.
At this point, the two of you go watch the membership form, have username2, and go username2 log in, log in directly.
If you want to register time without mailbox, go to this comment a few lines of code
to delete the user
added method
public function delUser()
{
$uid = uc_get_user('username');
var_dump($uid);
}
Access http://localhost/tp/public/index.php/index/index/delUser
to the method is querying user information through the user name, we need to get to the user's id, before calling the next method to delete. Index 0 is the id.
public function delUser()
{
$uid = uc_get_user('username4');
var_dump($uid);
$result = uc_user_delete($uid[0]);
var_dump($result);
}
Return value say return 1 is successful, 0 failed. But I return is 4, but really deleted, but also not log on.
pre_ucenter_members
It will be deleted after execution, but pre_common_member
will be deleted when you go to login.
ucenter official website hung up, did not find the manual, but fortunately there is the brother of data, or the devil knows what happened in the end!