Discuz自动激活UCenter用户
激活文件:activate.php[code]<?phprequire_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;
?>[/code]数据库连接:config_db.php[code]<?php
$dbhost = 'localhost';
$dbuser = 'yutiedun';
$dbpw = '111111';
$dbname = 'discuz';
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpw);
$dbh->query("set names 'gbk'");
?>[/code] 谢谢!楼主提供!好样的
bjcars.net 好人一个啊
bjcars.net 呵呵你真厉害,佩服哦
页:
[1]