Example #1
0
static void setup_utmp(int mode) {
    userinfo_t uinfo;
    char buf[80];
    char remotebuf[1024];
    time_t now = time(NULL);
    
    memset(&uinfo, 0, sizeof(uinfo));
    uinfo.pid = currpid = getpid();
    uinfo.uid = usernum;
    uinfo.mode = currstat = mode;
    uinfo.msgcount = 0;
    if(!(cuser.numlogins % 20) &&
       cuser.userlevel & PERM_BM)
	check_BM();	/* Ptt 自動取下離職板主權力 */
    
    uinfo.userlevel = cuser.userlevel;
    uinfo.lastact = time(NULL);
    
    postrecord.times = 0;	/* 計算crosspost數 */
    
    strcpy(uinfo.userid, cuser.userid);
    strcpy(uinfo.realname, cuser.realname);
    strcpy(uinfo.username, cuser.username);
    strncpy(uinfo.from, fromhost, 23);
    
    uinfo.five_win = cuser.five_win;
    uinfo.five_lose = cuser.five_lose;
    uinfo.five_tie = cuser.five_tie;
    
    uinfo.invisible = cuser.invisible % 2;
    uinfo.pager = cuser.pager % 5;
    
    uinfo.brc_id = 0;
#ifdef WHERE
    uinfo.from_alias = where(fromhost);
#else
    uinfo.from_alias = 0;
#endif
    setuserfile(buf, "remoteuser");
    
    strcpy(remotebuf, getenv("RFC931"));
    strcat(remotebuf, ctime(&now));
    remotebuf[strlen(remotebuf)-1] = 0;
    add_distinct(buf, remotebuf);
    
    if(enter_uflag & CLOAK_FLAG)
	uinfo.invisible = YEA;
    getnewutmpent(&uinfo);
#ifndef _BBS_UTIL_C_
    friend_load();
#endif
}
Example #2
0
void 
setup_utmp(int mode)
{
	user_info	uinfo;
	char		buf       [80];

	memset(&uinfo, 0, sizeof(uinfo));
	uinfo.pid = currpid = getpid();
	uinfo.uid = searchuser(cuser.userid);
	uinfo.mode = currstat = mode;
	uinfo.msgcount = 0;
	if (cuser.userlevel & PERM_BM)
		check_BM();	/* Ptt 自動取下離職板主權力 */
	uinfo.userlevel = cuser.userlevel;
	uinfo.lastact = time(NULL);

	strcpy(uinfo.userid, cuser.userid);
	strcpy(uinfo.realname, cuser.realname);
	strcpy(uinfo.username, cuser.username);
	strcpy(uinfo.feeling, cuser.feeling);
	strncpy(uinfo.from, fromhost, 23);
	uinfo.invisible = cuser.invisible % 2;
	uinfo.pager = cuser.pager % 5;
	uinfo.brc_id = 0;
	uinfo.sex = cuser.sex;

	/* Ptt WHERE */

#ifdef WHERE
	uinfo.from_alias = where(fromhost);
#else
	uinfo.from_alias = 0;
#endif
	sethomefile(buf, cuser.userid, "remoteuser");

	if (enter_uflag & CLOAK_FLAG)
		uinfo.invisible = YEA;

	getnewutmpent(&uinfo);
	friend_load();
}
Example #3
0
int login(struct userec *user)
{
    char buf[80];
    int tmp;
    struct user_info *u;
    struct user_info ui;
    int utmpent;

    memset(&ui, 0, sizeof(struct user_info));
    ui.active = true;

    /* Bigman 2000.8.29 智囊团能够隐身 */
    if ((HAS_PERM(user, PERM_CHATCLOAK) || HAS_PERM(user, PERM_CLOAK)) && (user->flags & CLOAK_FLAG))
        ui.invisible = true;
    ui.pager = 0;
    if (DEFINE(user, DEF_FRIENDCALL)) {
        ui.pager |= FRIEND_PAGER;
    }
    if (user->flags & PAGER_FLAG) {
        ui.pager |= ALL_PAGER;
        ui.pager |= FRIEND_PAGER;
    }
    if (DEFINE(user, DEF_FRIENDMSG)) {
        ui.pager |= FRIENDMSG_PAGER;
    }
    if (DEFINE(user, DEF_ALLMSG)) {
        ui.pager |= ALLMSG_PAGER;
        ui.pager |= FRIENDMSG_PAGER;
    }
    ui.uid = searchuser(user->userid);
    strncpy(ui.from, getSession()->fromhost, IPLEN);
    ui.logintime = time(0);     /* for counting user's stay time */
    /* refer to bbsfoot.c for details */
    ui.freshtime = time(0);
    ui.mode = WEBEXPLORE;
    strncpy(ui.userid, user->userid, 20);
    {
        struct userdata ud;

        read_userdata(user->userid, &ud);
        strncpy(ui.realname, ud.realname, 20);
    }
    strncpy(ui.username, user->username, 40);
    utmpent = getnewutmpent(&ui, 1);
    if (utmpent == -1) {
        fprintf(stderr, "抱歉,目前在线用户数已达上限,无法登录。");
        exit(-1);
    }
    /*u = get_user_info(utmpent);*/
    u = &(utmpshm->uinfo[utmpent-1]);
    u->pid = 1;
    tmp = rand() % 100000000;
    u->utmpkey = tmp;
    getfriendstr(user,u, getSession());
    /*setcurruinfo(u);*/
    /*u_info = ui;*/
    /*if (addto_msglist(get_utmpent_num(getcurruinfo()), getcurruserid()) < 0)
        http_fatal("无法添加当前用户到消息列表中");*/
    sprintf(buf, "%d", utmpent);
    printf("UTMPNUM = %s\n", buf);
    sprintf(buf, "%d", tmp);
    printf("UTMPKEY = %s\n", buf);
    printf("UTMPUSERID = %s\n", user->userid);
    return 0;
}