discuz直接操作用户--模拟注册和登陆

Discuz版本: Discuz! X3.2

1、模拟注册

<?php
error_reporting(0);

require './source/class/class_core.php';
$discuz = C::app();
$discuz->init();

$res = DB::fetch_first("SELECT max(uid) FROM " . DB::table('common_member'));
$init_arr = explode(',', "0,0,0,0,0,0,0,0,0");
$password = md5(random(10));
$flag =C::t('common_member')->insert($res['max(uid)']+1,$res['max(uid)']+1, $password, "", 'Manual Acting',10, $init_arr, 0);
?>

2、模拟登陆----直接通过ID登陆

<?php
//error_reporting(0);

require './source/class/class_core.php';
$discuz = C::app();
$discuz->init();

$uid=$_GET["uid"];
        $member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid=" .$uid);
        //设置登陆状态
        $_G['uid'] = intval($member['uid']);
        $_G['username'] = $member['username'];
        $_G['adminid'] = $member['adminid'];
        $_G['groupid'] = $member['groupid'];
        $_G['formhash'] = formhash();
        $_G['session']['invisible'] = getuserprofile('invisible');
        $_G['member'] = $member;
        loadcache('usergroup_' . $_G['groupid']);
        C::app()->session->isnew = true;
        C::app()->session->updatesession();

        echo authcode("{$member['password']}\t{$member['uid']}", 'ENCODE')."<br>";

        dsetcookie('auth', authcode("{$member['password']}\t{$member['uid']}", 'ENCODE'), $cookietime, 1, true);
        dsetcookie('loginuser');
        dsetcookie('activationauth');
        dsetcookie('pmnum');

        include_once libfile('function/stat');
        updatestat('login', 1);
?>

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×