Пример #1
0
$query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('member') . " WHERE username='******'");
$value = $_SGLOBAL['db']->fetch_array($query);
if (empty($value)) {
    showmessage('login_failure_please_re_login', 'do.php?ac=' . $_SCONFIG['login_action']);
}
$password = $value[2];
//同步获取用户源
if (!($passport = getpassport($username, $password))) {
    showmessage('login_failure_please_re_login', 'do.php?ac=' . $_SCONFIG['login_action']);
}
$setarr = array('uid' => $passport['uid'], 'username' => addslashes($passport['username']), 'password' => md5("{$passport['uid']}|{$_SGLOBAL['timestamp']}"));
include_once S_ROOT . './source/function_space.php';
//开通空间
$query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$setarr['uid']}'");
if (!($space = $_SGLOBAL['db']->fetch_array($query))) {
    $space = space_open($setarr['uid'], $setarr['username'], 0, $passport['email']);
}
$_SGLOBAL['member'] = $space;
//实名
realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']);
//检索当前用户
$query = $_SGLOBAL['db']->query("SELECT password FROM " . tname('member') . " WHERE uid='{$setarr['uid']}'");
if ($value = $_SGLOBAL['db']->fetch_array($query)) {
    $setarr['password'] = addslashes($value['password']);
} else {
    //更新本地用户库
    inserttable('member', $setarr, 0, true);
}
//清理在线session
insertsession($setarr);
//同步登录
Пример #2
0
function getspace($key, $indextype = 'uid', $auto_open = 0)
{
    global $_SGLOBAL, $_SCONFIG, $_SN;
    $var = "space_{$key}_{$indextype}";
    if (empty($_SGLOBAL[$var])) {
        $space = array();
        $query = $_SGLOBAL['db']->query("SELECT sf.*, s.* FROM " . tname('space') . " s LEFT JOIN " . tname('spacefield') . " sf ON sf.uid=s.uid WHERE s.{$indextype}='{$key}'");
        if (!($space = $_SGLOBAL['db']->fetch_array($query))) {
            $space = array();
            if ($indextype == 'uid' && $auto_open) {
                //自动开通空间
                include_once S_ROOT . './uc_client/client.php';
                if ($user = uc_get_user($key, 1)) {
                    include_once S_ROOT . './source/function_space.php';
                    $space = space_open($user[0], addslashes($user[1]), 0, addslashes($user[2]));
                }
            }
        }
        if ($space) {
            $_SN[$space['uid']] = $_SCONFIG['realname'] && $space['name'] && $space['namestatus'] ? $space['name'] : $space['username'];
            $space['self'] = $space['uid'] == $_SGLOBAL['supe_uid'] ? 1 : 0;
            //好友缓存
            $space['friends'] = array();
            if (empty($space['friend'])) {
                if ($space['friendnum'] > 0) {
                    $fstr = $fmod = '';
                    $query = $_SGLOBAL['db']->query("SELECT fuid FROM " . tname('friend') . " WHERE uid='{$space['uid']}' AND status='1'");
                    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                        $space['friends'][] = $value['fuid'];
                        $fstr .= $fmod . $value['fuid'];
                        $fmod = ',';
                    }
                    $space['friend'] = $fstr;
                }
            } else {
                $space['friends'] = explode(',', $space['friend']);
            }
            $space['username'] = addslashes($space['username']);
            $space['name'] = addslashes($space['name']);
            $space['privacy'] = empty($space['privacy']) ? empty($_SCONFIG['privacy']) ? array() : $_SCONFIG['privacy'] : unserialize($space['privacy']);
            //通知数
            $space['allnotenum'] = 0;
            foreach (array('notenum', 'pokenum', 'addfriendnum', 'mtaginvitenum', 'eventinvitenum', 'myinvitenum') as $value) {
                $space['allnotenum'] = $space['allnotenum'] + $space[$value];
            }
            if ($space['self']) {
                $_SGLOBAL['member'] = $space;
            }
        }
        $_SGLOBAL[$var] = $space;
    }
    return $_SGLOBAL[$var];
}
Пример #3
0
     } elseif ($newuid == -5) {
         showmessage('email_not_registered');
     } elseif ($newuid == -6) {
         showmessage('email_has_been_registered');
     } else {
         showmessage('register_error');
     }
 } else {
     $setarr = array('uid' => $newuid, 'username' => $username, 'password' => md5($password));
     //更新本地用户库
     inserttable('member', $setarr, 0, true);
     //add action log
     inserttable('actionlog', array('uid' => "{$newuid}", 'dateline' => "{$_SGLOBAL['timestamp']}", 'action' => 'register', 'value' => 'mobile'));
     //开通空间
     include_once S_ROOT . './source/function_space.php';
     $space = space_open($newuid, $username, 0, $email);
     //默认好友
     $flog = $inserts = $fuids = $pokes = array();
     if (!empty($bp['inviter'])) {
         $query = $_SGLOBAL['db']->query("SELECT username FROM " . tname('member') . " WHERE uid='{$bp['inviter']}' limit 1");
         $inviterusername = $_SGLOBAL['db']->result($query);
         $invitee[] = "('{$newuid}','{$bp['inviter']}','{$inviterusername}','1','{$_SGLOBAL['timestamp']}')";
         $inviter[] = "('{$bp['inviter']}','{$newuid}','{$username}','1','{$_SGLOBAL['timestamp']}')";
         $_SGLOBAL['db']->query("REPLACE INTO " . tname('friend') . " (uid,fuid,fusername,status,dateline) VALUES " . implode(',', $invitee));
         $_SGLOBAL['db']->query("REPLACE INTO " . tname('friend') . " (uid,fuid,fusername,status,dateline) VALUES " . implode(',', $inviter));
         $flog[] = "('{$bp['inviter']}','{$newuid}','add','{$_SGLOBAL['timestamp']}')";
         $_SGLOBAL['db']->query("REPLACE INTO " . tname('friendlog') . " (uid,fuid,action,dateline) VALUES " . implode(',', $flog));
     }
     if (!empty($_SCONFIG['defaultfusername'])) {
         $query = $_SGLOBAL['db']->query("SELECT uid,username FROM " . tname('space') . " WHERE\tusername IN (" . simplode(explode(',', $_SCONFIG['defaultfusername'])) . ")");
         while ($value = $_SGLOBAL['db']->fetch_array($query)) {
Пример #4
0
	} elseif($uid > 0) {
		$setarr = array(
			'uid' => $uid,
			'username' => $_POST['username']
		);
	} else {
		show_msg('输入的用户名无法注册,请重新确认');
	}
	$setarr['password'] = md5("$setarr[uid]|$_SGLOBAL[timestamp]");//本地密码随机生成

	//更新本地用户库
	inserttable('member', $setarr, 0, true);

	//开通空间
	include_once(S_ROOT.'./source/function_space.php');
	$space = space_open($setarr['uid'], $_POST['username'], 1);

	//反馈受保护
	$result = uc_user_addprotected($_POST['username'], $_POST['username']);
	$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET flag=1 WHERE username='******'");

	//清理在线session
	insertsession($setarr);

	//设置cookie
	ssetcookie('auth', authcode("$setarr[password]\t$setarr[uid]", 'ENCODE'), 2592000);

	//写log
	if(@$fp = fopen($lockfile, 'w')) {
		fwrite($fp, 'UCenter Home');
		fclose($fp);
Пример #5
0
function DB_Set_Logined($uid)
{
    global $db, $_SGLOBAL, $_SN;
    // echo var_dump($_SN)."--_SN0<br>";
    $setarr = array('uid' => $uid, 'username' => '', 'password' => '');
    $query = $db->query("SELECT username,password FROM " . tname('member') . " WHERE uid='{$setarr['uid']}'");
    if ($value = $db->fetch_array($query)) {
        $setarr['username'] = addslashes($value['username']);
        $setarr['password'] = addslashes($value['password']);
    }
    $invitearr = $_SESSION['invitearr'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $url_plus = $_SESSION['url_plus'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $app = $_SESSION['app'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $_SN = $_SESSION['SN'];
    //从会话里取出后边要用的这个变量
    // echo var_dump($invitearr)."--invitearr<br>";
    // echo var_dump($url_plus)."--url_plus<br>";
    // echo var_dump($app)."--app<br>";
    // echo var_dump($_SN)."--_SN1<br>";
    include_once S_ROOT . './source/function_space.php';
    //开通空间
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$setarr['uid']}'");
    if (!($space = $_SGLOBAL['db']->fetch_array($query))) {
        $space = space_open($setarr['uid'], $setarr['username'], 0, $passport['email']);
    }
    $_SGLOBAL['member'] = $space;
    //实名
    realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']);
    //这里$_SN再次被赋值
    // echo var_dump($_SN)."--_SN2<br>";
    //设置cookie
    ssetcookie('auth', authcode("{$setarr['password']}\t{$setarr['uid']}", 'ENCODE'), $cookietime);
    ssetcookie('loginuser', $passport['username'], 31536000);
    ssetcookie('_refer', '');
    //同步登录
    include_once S_ROOT . './uc_client/client.php';
    $ucsynlogin = uc_user_synlogin($setarr['uid']);
    // echo var_dump($ucsynlogin)."--ucsynlogin<br>";
    //好友邀请
    if ($invitearr) {
        // echo $_SGLOBAL."--_SGLOBAL1<br>";
        // echo var_dump($_SN)."--_SN1<br>";
        // echo var_dump($invitearr['id'])."--invitearr['id']<br>";
        // echo var_dump($setarr['uid'])."--setarr['uid']<br>";
        // echo var_dump($setarr['username'])."--setarr['username']<br>";
        // echo var_dump($invitearr['uid'])."--invitearr['uid']<br>";
        // echo var_dump($invitearr['username'])."--invitearr['username']<br>";
        //成为好友
        invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app);
    }
    // echo var_dump($_SGLOBAL['supe_uid'])."--_SGLOBAL['supe_uid']<br>";
    // echo var_dump($space['uid'])."--space['uid']<br>";
    //判断用户是否设置了头像
    $_SGLOBAL['supe_uid'] = $space['uid'];
    $reward = $setarr = array();
    $experience = $credit = 0;
    $avatar_exists = ckavatar($space['uid']);
    if ($avatar_exists) {
        if (!$space['avatar']) {
            //奖励积分
            $reward = getreward('setavatar', 0);
            $credit = $reward['credit'];
            $experience = $reward['experience'];
            if ($credit) {
                $setarr['credit'] = "credit=credit+{$credit}";
            }
            if ($experience) {
                $setarr['experience'] = "experience=experience+{$experience}";
            }
            $setarr['avatar'] = 'avatar=1';
            $setarr['updatetime'] = "updatetime={$_SGLOBAL['timestamp']}";
        }
    } else {
        if ($space['avatar']) {
            $setarr['avatar'] = 'avatar=0';
        }
    }
    if (empty($_POST['refer'])) {
        $_POST['refer'] = 'space.php?do=home';
    }
    realname_get();
    showmessage('login_success', $app ? "userapp.php?id={$app}" : $_POST['refer'], 1, array($ucsynlogin));
}
Пример #6
0
function regiter_user_to_uchome()
{
    global $_SCONFIG, $_SGLOBAL, $_SN, $openid_identifier, $setarr, $email, $username, $newuid;
    // echo var_dump($_SCONFIG)."--_SCONFIG<br/>";
    // echo var_dump($_SGLOBAL)."--_SGLOBAL<br/>";
    // echo var_dump($setarr)."--setarr<br/>";
    $invitearr = $_SESSION['invitearr'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $url_plus = $_SESSION['url_plus'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $app = $_SESSION['app'];
    //从会话里将已有帐户登录时的邀请信息取出,不用从通行证返回信息里取
    $_SN = $_SESSION['SN'];
    //从会话里取出后边要用的这个变量
    // echo var_dump($invitearr)."--invitearr<br>";
    // echo var_dump($url_plus)."--url_plus<br>";
    // echo var_dump($app)."--app<br>";
    // echo var_dump($_SN)."--_SN1<br>";
    // echo var_dump($_SESSION['jumpurl'])."--_SESSION['jumpurl']<br/>";
    //开通空间
    // echo var_dump($_SGLOBAL['db'])."--_SGLOBAL['db']<br/>";
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$setarr['uid']}'");
    // echo var_dump($query)."--query<br/>";
    include S_ROOT . './source/function_space.php';
    if (!($space = $_SGLOBAL['db']->fetch_array($query))) {
        $space = space_open($setarr['uid'], $setarr['username'], 0, $email);
    }
    // echo var_dump($space)."--space<br/>";
    // breakpoint();
    $_SGLOBAL['member'] = $space;
    // echo var_dump($_SGLOBAL['member'])."--_SGLOBAL['member']<br/>";
    //实名
    realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']);
    //这里$_SN再次被赋值
    // echo var_dump($_SN)."--_SNn2<br>";
    //检索当前用户
    $query = $_SGLOBAL['db']->query("SELECT password FROM " . tname('member') . " WHERE uid='{$setarr['uid']}'");
    if ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $setarr['password'] = addslashes($value['password']);
    } else {
        //更新本地用户库
        inserttable('member', $setarr, 0, true);
    }
    // 关联uid和openid
    //$db->query("INSERT INTO {$tablepre}user_openids VALUES (null,$newuid,'$openid_identifier')");//openid自带的db链接
    $openids = array('uid' => $setarr['uid'], 'url' => $openid_identifier);
    inserttable('user_openids', $openids, 0, true);
    //uchome的db链接
    // showmessage($openidlang['msg_bind_ok'],$plugin_url);//绑定成功
    //默认好友
    $flog = $inserts = $fuids = $pokes = array();
    echo var_dump($_SCONFIG['defaultfusername']) . "--_SCONFIG['defaultfusername']<br/>";
    if (!empty($_SCONFIG['defaultfusername'])) {
        $query = $_SGLOBAL['db']->query("SELECT uid,username FROM " . tname('space') . " WHERE username IN (" . simplode(explode(',', $_SCONFIG['defaultfusername'])) . ")");
        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
            $value = saddslashes($value);
            $fuids[] = $value['uid'];
            $inserts[] = "('{$newuid}','{$value['uid']}','{$value['username']}','1','{$_SGLOBAL['timestamp']}')";
            //$inserts[] = "('$value[uid]','$newuid','$username','1','$_SGLOBAL[timestamp]')";
            $inserts[] = "('{$value['uid']}','{$newuid}','{$setarr['username']}','1','{$_SGLOBAL['timestamp']}')";
            $pokes[] = "('{$newuid}','{$value['uid']}','{$value['username']}','" . addslashes($_SCONFIG['defaultpoke']) . "','{$_SGLOBAL['timestamp']}')";
            //添加好友变更记录
            $flog[] = "('{$value['uid']}','{$newuid}','add','{$_SGLOBAL['timestamp']}')";
        }
        /////////
        if ($inserts) {
            $_SGLOBAL['db']->query("REPLACE INTO " . tname('friend') . " (uid,fuid,fusername,status,dateline) VALUES " . implode(',', $inserts));
            $_SGLOBAL['db']->query("REPLACE INTO " . tname('poke') . " (uid,fromuid,fromusername,note,dateline) VALUES " . implode(',', $pokes));
            $_SGLOBAL['db']->query("REPLACE INTO " . tname('friendlog') . " (uid,fuid,action,dateline) VALUES " . implode(',', $flog));
            //添加到附加表
            $friendstr = empty($fuids) ? '' : implode(',', $fuids);
            updatetable('space', array('friendnum' => count($fuids), 'pokenum' => count($pokes)), array('uid' => $newuid));
            updatetable('spacefield', array('friend' => $friendstr, 'feedfriend' => $friendstr), array('uid' => $newuid));
            //更新默认用户好友缓存
            include_once S_ROOT . './source/function_cp.php';
            foreach ($fuids as $fuid) {
                friend_cache($fuid);
            }
        }
    }
    //清理在线session
    insertsession($setarr);
    //设置cookie
    ssetcookie('auth', authcode("{$setarr['password']}\t{$setarr['uid']}", 'ENCODE'), 2592000);
    ssetcookie('loginuser', $username, 31536000);
    ssetcookie('_refer', '');
    // echo var_dump($invitearr)."--invitearr<br/>";
    //好友邀请
    if ($invitearr) {
        //成为好友
        invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app);
        //统计更新
        include_once S_ROOT . './source/function_cp.php';
        if ($app) {
            updatestat('appinvite');
        } else {
            updatestat('invite');
        }
    }
    $_SGLOBAL['supe_uid'] = $space['uid'];
    //判断用户是否设置了头像
    $reward = $setarr = array();
    $experience = $credit = 0;
    $avatar_exists = ckavatar($space['uid']);
    if ($avatar_exists) {
        if (!$space['avatar']) {
            //奖励积分
            $reward = getreward('setavatar', 0);
            $credit = $reward['credit'];
            $experience = $reward['experience'];
            if ($credit) {
                $setarr['credit'] = "credit=credit+{$credit}";
            }
            if ($experience) {
                $setarr['experience'] = "experience=experience+{$experience}";
            }
            $setarr['avatar'] = 'avatar=1';
            $setarr['updatetime'] = "updatetime={$_SGLOBAL['timestamp']}";
        }
    } else {
        if ($space['avatar']) {
            $setarr['avatar'] = 'avatar=0';
        }
    }
    //变更记录
    if ($_SCONFIG['my_status']) {
        inserttable('userlog', array('uid' => $newuid, 'action' => 'add', 'dateline' => $_SGLOBAL['timestamp']), 0, true);
    }
    // echo var_dump($_SESSION['jumpurl'])."--_SESSION['jumpurl']<br/>";
    // breakpoint();
    showmessage('login_success', $_SESSION['jumpurl']);
}
Пример #7
0
function quickregister_interface($quickcollegeid, $quickpassword)
{
    //先是验证是否已经激活
    $collegeid = trim($quickcollegeid);
    $collegepw = $quickpassword;
    $verifyname = verifycollegeid($collegeid, $collegepw);
    $res_json = array();
    if ($verifyname == -1) {
        $res_json = array('status' => "error", "reason" => 'collegeid_is_null');
    } elseif ($verifyname == -2) {
        $res_json = array('status' => 'error', 'reason' => 'collegepassword_is_null');
    }
    if (empty($verifyname->out->string)) {
        $res_json = array('status' => 'error', 'reason' => 'verify_fail');
    }
    $username = $collegeid;
    $password = $collegepw;
    $query = $_SGLOBAL['db']->query("SELECT identifier,identifier_not_use, realname,birthday, sex, defaultemail, isactive, emaildateline FROM " . tname('baseprofile') . " WHERE collegeid='{$collegeid}'  and (usertype like binary '教师' or (usertype between 1 and 5) or usertype like binary '学生') limit 1");
    $one = $_SGLOBAL['db']->fetch_array($query);
    $id = $one['identifier_not_use'];
    $realname = $one['realname'];
    $birthday_exist = $one['birthday'];
    if (strlen($id) == 18) {
        $birthday_id = substr($id, 6, 8);
    } elseif (strlen($id) == 16) {
        $birthday_id = '19' . substr($id, 6, 6);
    }
    if ($one) {
        $wheresql = "0";
        if ($id) {
            $wheresql .= " or identifier_not_use='" . $id . "'";
        }
        if (strlen($birthday_exist) == 8) {
            $wheresql .= " or (realname='" . $realname . "' and birthday='" . $birthday_exist . "')";
        }
        if ($birthday_id) {
            $wheresql .= " or (realname='" . $realname . "' and birthday='" . $birthday_id . "')";
        }
        $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('baseprofile') . " WHERE {$wheresql}");
        $flagnotactive = 0;
        $flagactive = 0;
        $userlines = $recordids = array();
        $c_uid = 0;
        while ($row = $_SGLOBAL['db']->fetch_array($query)) {
            $userlines[] = $row;
            if ($row['isactive'] == '1') {
                $flagactive = 1;
            } else {
                $flagnotactive = 1;
                $recordids[] = $row['userid'];
            }
            if ($row['uid']) {
                if (!$c_uid) {
                    $c_uid = $row['uid'];
                } elseif ($c_uid != $row['uid']) {
                    $act_err = 1;
                }
            }
        }
        //如果一个人激活了多个ihome账号时,系统将向ihome邮箱发送检查邮件
        if ($act_err) {
            $title = cplang('active_different_uids_title');
            $content = $collegeid . " " . $realname . " " . cplang('active_different_uids_content');
            $cid = inserttable('mailcron', array('email' => '*****@*****.**'), 1);
            $setarr = array('cid' => $cid, 'subject' => addslashes(stripslashes($title)), 'message' => addslashes(stripslashes($content)), 'dateline' => $_GLOBAL['timestamp']);
            inserttable('mailqueue', $setarr);
        }
        //如果既有激活的 也有没激活的 更新没激活的信息
        if ($flagactive == 1 && $flagnotactive == 1) {
            $useridlist = implode(',', $recordids);
            $_SGLOBAL['db']->query("UPDATE " . tname('baseprofile') . " SET isactive=1, uid={$c_uid} WHERE userid in ({$useridlist})");
            foreach ($userlines as $value) {
                if ($value['isactive'] != '1') {
                    if ($value['academy']) {
                        if ($value['usertype'] == '教师' || $value['usertype'] == 5 || $value['usertype'] == 4) {
                            $workinfo = array('uid' => $c_uid, 'type' => 'work', 'title' => '北京航空航天大学', 'subtitle' => $value['academy'], 'startyear' => $value['startyear'], 'city' => '北京');
                            inserttable('spaceinfo', $workinfo, 1);
                        }
                        if (strlen($value['collegeid']) != 5 && strlen($value['collegeid']) != 6) {
                            if (!in_array($value['collegeid'], $collegeids)) {
                                $collegeids[] = $value['collegeid'];
                                $eduinfo = array('uid' => $c_uid, 'type' => 'edu', 'title' => '北京航空航天大学', 'subtitle' => $value['academy'], 'startyear' => $value['startyear']);
                                inserttable('spaceinfo', $eduinfo, 1);
                            }
                        }
                    }
                }
            }
            $res_json = array("status" => "error", "indentifier is active");
        } elseif ($flagactive == 1) {
            $res_json = array("status" => "error", "indentifier is active");
        }
    } else {
        $res_json = array('status' => "error", "reason" => "Please use correct register method!");
    }
    if ($_SCONFIG['seccode_register']) {
        include_once S_ROOT . '../source/function_cp.php';
        if (!ckseccode($_POST['quickseccode'])) {
            $res_json = array("status" => "error", "reason" => 'incorrect_code');
        }
    }
    if (!@(include_once S_ROOT . '../uc_client/client.php')) {
        $res_json = array("status" => "error", "reason" => 'system_error');
    }
    $email = isemail(trim($_POST['quickemail'])) ? trim($_POST['quickemail']) : '';
    if (empty($email)) {
        $res_json = array('status' => 'error', 'reason' => 'email_format_is_wrong');
    }
    if ($count = getcount('space', array('username' => $username))) {
        $res_json = array('status' => 'error', 'reason' => 'user_name_already_exists');
    }
    if ($count = getcount('spacefield', array('email' => $email))) {
        $res_json = array('status' => 'error', 'reason' => 'email_has_been_registered');
    }
    $onlineip = getonlineip();
    if ($_SCONFIG['regipdate']) {
        $query = $_SGLOBAL['db']->query("SELECT dateline FROM " . tname('space') . " WHERE regip='{$onlineip}' ORDER BY dateline DESC LIMIT 1");
        if ($value = $_SGLOBAL['db']->fetch_array($query)) {
            if ($_SGLOBAL['timestamp'] - $value['dateline'] < $_SCONFIG['regipdate'] * 3600) {
                $res_json = array('status' => 'regip_has_been_registered');
            }
        }
    }
    //验证完成
    //创建新用户.开始
    $newuid = uc_user_register($username, $password, $email);
    if ($newuid <= 0) {
        if ($newuid == -1) {
            $res_json = array('status' => 'error', 'reason' => 'user_name_is_not_legitimate');
        } elseif ($newuid == -2) {
            $res_json = array('status' => 'error', 'reason' => 'include_not_registered_words');
        } elseif ($newuid == -3) {
            $res_json = array('status' => 'error', 'reason' => 'user_name_already_exists');
        } elseif ($newuid == -4) {
            $res_json = array('status' => 'error', 'reason' => 'email_format_is_wrong');
        } elseif ($newuid == -5) {
            $res_json = array('status' => 'error', 'reason' => 'email_not_registered');
        } elseif ($newuid == -6) {
            $res_json = array('status' => 'error', 'reason' => 'email_has_been_registered');
        } else {
            $res_json = array('status' => 'error', 'reason' => 'register_error');
        }
    } else {
        //检查uid是否在ucenter里面,如果不在,就采取野蛮方式插入新纪录
        $q = $_SGLOBAL['db']->query("SELECT uid FROM ihomeuser_members WHERE uid='{$newuid}'");
        $members_match = $_SGLOBAL['db']->fetch_array($q);
        $members_match = $members_match['uid'];
        $q = $_SGLOBAL['db']->query("SELECT uid FROM ihomeuser_memberfields WHERE uid='{$newuid}'");
        $memberfields_match = $_SGLOBAL['db']->fetch_array($q);
        $memberfields_match = $memberfields_match['uid'];
        if (!$members_match && !$memberfields_match) {
            $salt = substr(uniqid(rand()), -6);
            $hhpassword = md5(md5($password) . $salt);
            $sqladd = "uid='" . intval($newuid) . "',";
            $sqladd .= " secques='',";
            $_SGLOBAL['db']->query("INSERT INTO ihomeuser_members SET {$sqladd} username='******', password='******', email='{$email}', regip='" . $_SERVER["HTTP_X_FORWARDED_FOR"] . "', regdate='" . time() . "', salt='{$salt}'");
            $_SGLOBAL['db']->query("INSERT INTO ihomeuser_memberfields SET uid='{$newuid}'");
        }
        $setarr = array('uid' => $newuid, 'username' => $username, 'password' => md5($password));
        inserttable('member', $setarr, 0, true);
        //add action log
        inserttable('actionlog', array('uid' => "{$newuid}", 'dateline' => "{$_SGLOBAL['timestamp']}", 'action' => 'register', 'value' => 'quick'));
        include_once S_ROOT . './source/function_space.php';
        $space = space_open($newuid, $username, 0, $email);
        //默认好友
        $flog = $inserts = $fuids = $pokes = array();
        if (!empty($_SCONFIG['defaultfusername'])) {
            $query = $_SGLOBAL['db']->query("SELECT uid,username FROM " . tname('space') . " WHERE\tusername IN (" . simplode(explode(',', $_SCONFIG['defaultfusername'])) . ")");
            while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                $value = saddslashes($value);
                $fuids[] = $value['uid'];
                $inserts[] = "('{$newuid}','{$value['uid']}','{$value['username']}','1','{$_SGLOBAL['timestamp']}')";
                $inserts[] = "('{$value['uid']}','{$newuid}','{$username}','1','{$_SGLOBAL['timestamp']}')";
                $pokes[] = "('{$newuid}','{$value['uid']}','{$value['username']}','" . addslashes($_SCONFIG['defaultpoke']) . "','{$_SGLOBAL['timestamp']}')";
                $flog[] = "('{$value['uid']}','{$newuid}','add','{$_SGLOBAL['timestamp']}')";
            }
            if ($inserts) {
                $_SGLOBAL['db']->query("REPLACE INTO " . tname('friend') . " (uid,fuid,fusername,status,dateline) VALUES " . implode(',', $inserts));
                $_SGLOBAL['db']->query("REPLACE INTO " . tname('poke') . " (uid,fromuid,fromusername,note,dateline) VALUES " . implode(',', $pokes));
                $_SGLOBAL['db']->query("REPLACE INTO " . tname('friendlog') . " (uid,fuid,action,dateline) VALUES " . implode(',', $flog));
                //添加到附加表
                $friendstr = empty($fuids) ? '' : implode(',', $fuids);
                updatetable('space', array('friendnum' => count($fuids), 'pokenum' => count($pokes)), array('uid' => $newuid));
                updatetable('spacefield', array('friend' => $friendstr, 'feedfriend' => $friendstr), array('uid' => $newuid));
                //更新默认用户好友缓存
                include_once S_ROOT . '../source/function_cp.php';
                foreach ($fuids as $fuid) {
                    friend_cache($fuid);
                }
            }
        }
        //好友邀请
        if ($invitearr) {
            include_once S_ROOT . '../source/function_cp.php';
            invite_update($invitearr['id'], $setarr['uid'], $setarr['username'], $invitearr['uid'], $invitearr['username'], $app);
            //如果提交的邮箱地址与邀请相符的则直接通过邮箱验证
            if ($invitearr['email'] == $email) {
                updatetable('spacefield', array('emailcheck' => 1), array('uid' => $newuid));
            }
            //统计更新
            include_once S_ROOT . '../source/function_cp.php';
            if ($app) {
                updatestat('appinvite');
            } else {
                updatestat('invite');
            }
        }
        //标记为已激活,并反写uid
        if ($recordids) {
            $useridlist = implode(',', $recordids);
            $_SGLOBAL['db']->query("UPDATE " . tname('baseprofile') . " SET isactive=1, uid={$newuid} WHERE userid in ({$useridlist})");
        }
        $insertinfo = array('identifier' => $one['identifier'], 'realname' => $realname, 'defaultemail' => $one['defaultemail']);
        //获得用户生日数据
        //$decid = M_decode($value['identifier'], aeskeyA);
        $UserBirthday = '';
        if ($birthday_id) {
            $UserBirthday = $birthday_id;
        } elseif ($birthday_exist) {
            $UserBirthday = $birthday_exist;
        }
        if ($UserBirthday) {
            $insertinfo['birthyear'] = intval(substr($UserBirthday, 0, 4));
            $insertinfo['birthmonth'] = intval(substr($UserBirthday, 4, 2));
            $insertinfo['birthday'] = intval(substr($UserBirthday, 6, 2));
        }
        if ($one['sex'] == '男') {
            $sexc = 1;
        } else {
            if ($one['sex'] == '女') {
                $sexc = 2;
            } else {
                $sexc = 0;
            }
        }
        $insertinfo['sex'] = $sexc;
        //print_r($insertinfo);exit();
        //更新spacefield
        updatetable('spacefield', $insertinfo, array('uid' => $newuid));
        if ($insertinfo['birthyear'] && $insertinfo['birthmonth'] && $insertinfo['birthday']) {
            $_SGLOBAL['db']->query("INSERT INTO " . tname('spaceinfo') . " (type,subtype,uid,friend) VALUES ('base','birth'," . $newuid . ",3)");
        }
        //更新space
        $space = array('uid' => $newuid, 'name' => $realname, 'namestatus' => 1);
        //print_r($space);
        //exit();
        updatetable('space', $space, array('uid' => $newuid));
        foreach ($userlines as $value) {
            if ($value['isactive'] != '1') {
                if ($value['academy']) {
                    if ($value['usertype'] == '教师' || $value['usertype'] == 5 || $value['usertype'] == 4) {
                        $workinfo = array('uid' => $newuid, 'type' => 'work', 'title' => '北京航空航天大学', 'subtitle' => $value['academy'], 'startyear' => $value['startyear'], 'city' => '北京');
                        inserttable('spaceinfo', $workinfo, 1);
                    }
                    if (strlen($value['collegeid']) != 5 && strlen($value['collegeid']) != 6) {
                        if (!empty($value['class']) && !empty($value['startyear'])) {
                            $eduinfo = array('uid' => $newuid, 'type' => 'edu', 'title' => '北京航空航天大学', 'subtitle' => $value['academy'] . $value['startyear'] . '级' . $value['class'] . '班', 'startyear' => $value['startyear']);
                            $tagname = $value['startyear'] . '年' . $value['class'] . '班';
                            auto_join($newuid, $tagname, $_SGLOBAL['db']);
                            inserttable('spaceinfo', $eduinfo, 1);
                        }
                    }
                }
            }
        }
        //毕业校友的就业信息
        $query1 = $_SGLOBAL['db']->query("SELECT * FROM " . tname('stuemp') . " WHERE collegeid='{$value['collegeid']}'");
        if ($value1 = $_SGLOBAL['db']->fetch_array($query1)) {
            $setarr1 = array('uid' => $newuid, 'type' => 'work', 'title' => $value['unit'], 'province' => $value['province'], 'city' => $value['city']);
            inserttable('spaceinfo', $setarr1, 1);
        }
        //变更记录
        if ($_SCONFIG['my_status']) {
            inserttable('userlog', array('uid' => $newuid, 'action' => 'add', 'dateline' => $_SGLOBAL['timestamp']), 0, true);
        }
        //创建新用户结束
        $res_json = array('status' => 'correct', 'uid' => $newuid, 'username' => $username, 'password' => $password, 'email' => $email);
    }
    //自动为用户添加好友
    if ($userlines) {
        autobefriends($userlines, $newuid, $_POST['username']);
    }
    echo json_encode($res_json);
    return json_encode($res_json);
}
Пример #8
0
 }
 if ($_SCONFIG['seccode_login']) {
     include_once S_ROOT . './source/function_cp.php';
     if (!ckseccode($_POST['seccode'])) {
         $_SGLOBAL['input_seccode'] = 1;
         include template('do_login');
         exit;
     }
 }
 $setarr = array('uid' => $userid, 'username' => addslashes($username), 'password' => md5("{$userid}|{$_SGLOBAL['timestamp']}"));
 include_once S_ROOT . './source/function_space.php';
 //开通空间
 $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('space') . " WHERE uid='{$setarr['uid']}'");
 if (!($space = $_SGLOBAL['db']->fetch_array($query))) {
     //$space = space_open($setarr['uid'], $setarr['username'], 0, $passport['email']);
     $space = space_open($setarr['uid'], $setarr['username'], 0);
 }
 $_SGLOBAL['member'] = $space;
 //实名
 realname_set($space['uid'], $space['username'], $space['name'], $space['namestatus']);
 //检索当前用户
 $query = $_SGLOBAL['db']->query("SELECT password FROM " . tname('member') . " WHERE uid='{$setarr['uid']}'");
 if ($value = $_SGLOBAL['db']->fetch_array($query)) {
     $setarr['password'] = addslashes($value['password']);
 } else {
     //更新本地用户库
     inserttable('member', $setarr, 0, true);
 }
 //清理在线session
 //insertsession($setarr);
 //设置cookie