标题:
[
Discuz!相关
]
Discuz自动激活UCenter用户
[打印本页]
作者:
shillan
时间:
2013-7-20 12:18
标题:
Discuz自动激活UCenter用户
激活文件:activate.php
<?php
require_once 'config_db.php';
//我这里使用的是GET方式
$uid = empty($_GET['uid'])?0:intval($_GET['uid']);
$username = trim($_GET['username']);
$password = trim($_GET['password']);
$email = trim($_GET['email']);
$regip = trim($_SERVER['REMOTE_ADDR']);
$regdate = time();
//echo $uid." ".$username."<br />";
$existuid = 0;
$existuname = "";
$existuid2 = 0;
$existuname2 = "";
//先从UC会员表dz_uc_members中查找
$sql01 = "select uid,username from dz_uc_members where uid=$uid and username='$username'";
foreach ($dbh->query($sql01) as $row01) {
$existuid = $row01['uid'];
$existuname = $row01['username'];
}
//echo "1. ".$existuid." ".$existuname."<br />";
//如果uc_members中存在,下一步
if ($existuid!="" && $existuid>0) {
//再从discuz会员表dz_members中查找
$sql02 = "select uid,username from dz_members where uid=$uid and username='$username'";
foreach ($dbh->query($sql02) as $row02) {
$existuid2 = $row02['uid'];
$existuname2 = $row02['username'];
}
//echo "2. ".$existuid2." ".$existuname2."<br />";
//如果dz_members中不存在,则激活
if ($existuid2=="" || $existuid2<=0) {
$sqlac="insert into dz_members (uid,username,password,email,adminid,groupid,regip,regdate,lastip,lastvisit,timeoffset) values ('$uid','$username','$password','$email','0','10','$regip','$regdate','$regip','$regdate','9999')";
try {
$dbh->beginTransaction();
$dbh->exec($sqlac);
$dbh->commit();
} catch (Exception $e) {
$dbh->rollBack();
echo "Failed: " . $e->getMessage();
}
$sqlac="insert into dz_memberfields (uid, nickname, site, alipay, icq, qq, yahoo, msn, taobao, location, customstatus, medals, avatar, avatarwidth, avatarheight, bio, sightml, ignorepm, groupterms, authstr, spacename, buyercredit, sellercredit) values ('$uid', '', '', '', '', '', '', '', '', '', '', '', '', '0', '0', '', '', '', '', '', '', '0', '0');";
try {
$dbh->beginTransaction();
$dbh->exec($sqlac);
$dbh->commit();
} catch (Exception $e) {
$dbh->rollBack();
echo "Failed: " . $e->getMessage();
}
//echo "激活成功!";
}
}
$dbh = null;
?>
复制代码
数据库连接:config_db.php
<?php
$dbhost = 'localhost';
$dbuser = 'yutiedun';
$dbpw = '111111';
$dbname = 'discuz';
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpw);
$dbh->query("set names 'gbk'");
?>
复制代码
作者:
wmykt
时间:
2014-7-12 20:14
谢谢!楼主提供!好样的
bjcars.net
作者:
czhal
时间:
2014-7-29 03:44
好人一个啊
bjcars.net
作者:
代民丙lu
时间:
2014-9-20 15:23
呵呵你真厉害,佩服哦
欢迎光临 逐梦论坛 (http://temp2023.zhumeng.org/)
Powered by Discuz! 7.2