Ejemplo n.º 1
0
static void post_add(FILE *fp, const struct userec *user, fb_time_t now)
{
    fprintf(fp, "\033[1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 "
            "\033[1;32m%d\033[m 次 [\033[1;3%dm%s\033[m]\n",
            user->userid, user->username, user->numlogins,
            (user->gender == 'F') ? 5 : 6,
            horoscope(user->birthmonth, user->birthday));
    fprintf(fp, "上 次 在:[\033[1;32m%s\033[m] 从 [\033[1;32m%s\033[m] "
            "到本站一游。\n", getdatestring(user->lastlogin, DATE_ZH),
            (user->lasthost[0] == '\0' ? "(不详)" : user->lasthost));
    fprintf(fp, "离站时间:[\033[1;32m%s\033[m] ",
            getdatestring(user->lastlogout, DATE_ZH));

    int exp = countexp(user);
    int perf = countperf(user);
#ifdef SHOW_PERF
    fprintf(fp, "表现值:%d(\033[1;33m%s\033[m)\n", perf, cperf(perf));
#else
    fprintf(fp, "表现值:[\033[1;33m%s\033[m]\n", cperf(perf));
#endif

#ifdef ALLOWGAME
    fprintf(fp, "银行存款: [\033[1;32m%d元\033[m] "
            "目前贷款: [\033[1;32m%d元\033[m](\033[1;33m%s\033[m) "
            "经验值:[\033[1;32m%d\033[m](\033[1;33m%s\033[m)。\n",
            user->money, user->bet, cmoney(user->money - user->bet),
            exp, cexpstr(exp));
    fprintf(fp, "文 章 数: [\033[1;32m%d\033[m] "
            "奖章数: [\033[1;32m%d\033[m](\033[1;33m%s\033[m) 生命力:"
            "[\033[1;32m%d\033[m] 网龄[\033[1;32m%"PRIdFBT"天\033[m]\n\n",
            user->numposts, user->nummedals, cnummedals(user->nummedals),
            compute_user_value(user), (now - user->firstlogin) / 86400);
#else
    fprintf(fp, "文 章 数:[\033[1;32m%d\033[m] 经 验 值:"
#ifdef SHOWEXP
            "%d(\033[1;33m%-10s\033[m)"
#else
            "[\033[1;33m%-10s\033[m]"
#endif
            " 生命力:[\033[1;32m%d\033[m] 网龄[\033[1;32m%d天\033[m]\n\n",
            user->numposts,
#ifdef SHOWEXP
            exp,
#endif
            cexpstr(exp), compute_user_value(user),
            (now - user->firstlogin) / 86400);
#endif
}
Ejemplo n.º 2
0
Archivo: miscd.c Proyecto: wyat/kbs
int killauser(struct userec *theuser, void *data)
{
    int a;
    struct userec *ft,copyuser;

    if (!theuser || theuser->userid[0] == 0)
        return 0;
    memcpy(&copyuser,theuser,sizeof(copyuser));

    if (id_invalid(copyuser.userid))
        return 0;

    a = compute_user_value(&copyuser);

    if ((a <= 0)&&strcmp(copyuser.userid,"guest")) {
        newbbslog(BBSLOG_USIES, "kill user %s", copyuser.userid);
        kick_user_utmp(getuser(copyuser.userid, NULL), NULL, SIGKILL);
        a = getuser(copyuser.userid, &ft);
        setmailpath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sethomepath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sprintf(genbuf1, "/bin/rm -fr tmp/email/%s", copyuser.userid);
        system(genbuf1);
        setuserid2(a, "");
        theuser->userlevel = 0;
        /*strcpy(theuser->address, "");*/
        strcpy(theuser->username, "");
        /*strcpy(theuser->realname, "");*/
    }

    return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv)
{
    bool pretend = (argc != 2) || (strcasecmp(argv[1], "-f") != 0);

    int fd;
    FILE *log, *data, *post;

    if (!pretend) {
        int fd = open(BBSHOME"/tmp/killuser", O_RDWR | O_CREAT | O_EXCL, 0600);
        if (fd < 0)
            return EXIT_FAILURE;
        unlink(BBSHOME"/tmp/killuser");

        log = fopen(BBSHOME"/tomb/log", "w+");
        if (!log)
            return EXIT_FAILURE;

        data = fopen(BBSHOME"/tomb/PASSWDS", "w+");
        if (!data)
            return EXIT_FAILURE;

        post = fopen(BBSHOME"/tomb/post", "w+");
        if (!post)
            return EXIT_FAILURE;

        log_usies("CLEAN", "dated users.", NULL);
    }

    fb_time_t now = time(NULL);

    struct userec user, zero;
    memset(&zero, 0, sizeof(zero));
    char file[HOMELEN], buf[HOMELEN];

    for (int i = 0; i < MAXUSERS; ++i) {
        getuserbyuid(&user, i + 1);

        int val = compute_user_value(&user);

        if (user.userid[0] != '\0' && val < 0) {
            user.userid[sizeof(user.userid) - 1] = '\0';

            if (pretend) {
                puts(user.userid);
                continue;
            }

            post_add(post, &user, now);
            fwrite(&user, sizeof(user), 1, data);
            fprintf(log, "%s\n", user.userid);

            snprintf(file, sizeof(file), "mail/%c/%s",
                     toupper(user.userid[0]), user.userid);
            snprintf(buf, sizeof(buf), "%s~", file);
            rename(file, buf);

            snprintf(file, sizeof(file), "home/%c/%s",
                     toupper(user.userid[0]), user.userid);
            snprintf(buf, sizeof(buf), "%s~", file);
            rename(file, buf);

            substitut_record(PASSFILE, &zero, sizeof(zero), i + 1);
            del_uidshm(i + 1, user.userid);
        }
    }

    if (!pretend) {
        fclose(post);
        fclose(data);
        fclose(log);
        close(fd);
    }
    return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
Archivo: chat.c Proyecto: wyat/kbs
static void query_user(chatcontext * pthis, const char *userid)
{
    int tuid = 0;
    char qry_mail_dir[STRLEN], inbuf[STRLEN * 2];
    char *newline;
    time_t exit_time, temp;
    struct userec *lookupuser;

    if (!(tuid = getuser(userid, &lookupuser))) {
        printchatline(pthis, "\033[32m这个ID不存在!\033[m");
        return;
    }
    setmailfile(qry_mail_dir, lookupuser->userid, DOT_DIR);
    /*--- modified by period 2000-11-02 hide posts/logins ---*/

    sprintf(genbuf, "%s (%s):      %s", lookupuser->userid,
            lookupuser->username,
            (check_query_mail(qry_mail_dir, NULL)) ? "有新信" : "    ");
    printchatline(pthis, genbuf);
    sprintf(genbuf, "共上站 %d 次,发表过 %d 篇文章,生命力[%d]%s",
            lookupuser->numlogins, lookupuser->numposts,
            compute_user_value(lookupuser),
            (lookupuser->userlevel & PERM_SUICIDE) ? " (自杀中)" : " ");
    printchatline(pthis, genbuf);

    strcpy(inbuf, ctime(&(lookupuser->lastlogin)));
    if ((newline = strchr(genbuf, '\n')) != NULL)
        *newline = '\0';
    strcpy(genbuf, "当前状态:");
    if (apply_utmpuid((APPLY_UTMP_FUNC) chat_status, tuid, (char *) pthis)) {
        char buf[1024];

        lookupuser->lasthost[IPLEN-1] = '\0';
        sprintf(buf, "目前正在线上: 来自 %s 上线时间 %s" /*\n" */ ,
                (lookupuser->lasthost[0] == '\0' /* || DEFINE(getCurrentUser(),DEF_HIDEIP) */ ? "(不详)" : SHOW_USERIP(lookupuser, lookupuser->lasthost)), inbuf);    /*Haohmaru.99.12.18 */
        printchatline(pthis, buf);
        printchatline(pthis, genbuf);
    } else {
        lookupuser->lasthost[IPLEN-1] = '\0';
        sprintf(genbuf, "上次上线来自  %s 时间为 %s " /*\n" */ ,
                (lookupuser->lasthost[0] == '\0' /* || DEFINE(getCurrentUser(),DEF_HIDEIP) */ ? "(不详)" : SHOW_USERIP(lookupuser, lookupuser->lasthost)), inbuf);    /* Haohmaru.99.12.18 */
        printchatline(pthis, genbuf);
        /* 获得离线时间 Luzi 1998/10/23 */
        exit_time = get_exit_time(lookupuser, genbuf);
        if ((newline = strchr(genbuf, '\n')) != NULL)
            *newline = '\0';
        if (exit_time > lookupuser->lastlogin)
            strcpy(inbuf, genbuf);
        /*Haohmaru.98.12.04.和菜单查询结果一致 */
        if (exit_time <= lookupuser->lastlogin)
            /*
               || (uin.active && uin.pid
               && (!uin.invisible || (uin.invisible && HAS_PERM(getCurrentUser(),PERM_SEECLOAK)))))
             */
            strcpy(inbuf, "因在线上或非常断线不详");
        if (exit_time <= lookupuser->lastlogin) {       /* && (uin.invisible&& !HAS_PERM(getCurrentUser(),PERM_SEECLOAK))) */
            temp = lookupuser->lastlogin + (lookupuser->numlogins % 7) + 5;
            strcpy(inbuf, ctime(&temp));        /*Haohmaru.98.12.04.让隐身用户看上去离线时间比上线时间晚5秒钟 */
            if ((newline = strchr(inbuf, '\n')) != NULL)
                *newline = '\0';
        }
        /*       else strcpy(inbuf,"[因非常断线不详]"); */
        sprintf(genbuf, "离线时间为 %s " /*\n" */ , inbuf);
        printchatline(pthis, genbuf);
    }
#ifdef DEBUG
    if (HAS_PERM(getCurrentUser(), PERM_SYSOP)) {
        sprintf(genbuf, "%d", tuid);
        printchatline(pthis, genbuf);
    }
#endif                          /* 
    */
}
Ejemplo n.º 5
0
Archivo: talk.c Proyecto: icewwn/fbbs-1
int tui_query_result(const char *userid)
{
	struct userec user;
	int unum = getuserec(userid, &user);
	if (!unum)
		return -1;

	screen_move(0, 0);
	screen_clrtobot();

	int color = 2;
	if (HAS_DEFINE(user.userdefine, DEF_COLOREDSEX))
		color = (user.gender == 'F') ? 5 : 6;
	char horo[32] = "";
	if (HAS_DEFINE(user.userdefine, DEF_S_HOROSCOPE)
			&& strcasecmp(user.userid, "guest") != 0) {
		snprintf(horo, sizeof(horo), "[\033[1;3%dm%s\033[m] ",
				color, horoscope(user.birthmonth, user.birthday));
	}
	//% prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 \033[1;32m%d\033[m "
	prints("\033[0;1;37m%s \033[m(\033[1;33m%s\033[m) \xb9\xb2\xc9\xcf\xd5\xbe \033[1;32m%d\033[m "
			//% "次  %s\n", user.userid, user.username, user.numlogins, horo);
			"\xb4\xce  %s\n", user.userid, user.username, user.numlogins, horo);

	bool self = !strcmp(currentuser.userid, user.userid);
	const char *host;
	if (user.lasthost[0] == '\0') {
		//% host = "(不详)";
		host = "(\xb2\xbb\xcf\xea)";
	} else {
		if (self || HAS_PERM2(PERM_OCHAT, &currentuser))
			host = user.lasthost;
		else 
			host = mask_host(user.lasthost);
	}
	//% prints("进站 [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n",
	prints("\xbd\xf8\xd5\xbe [\033[1;32m%s\033[m] %s[\033[1;32m%s\033[m]\n",
			format_time(user.lastlogin, TIME_FORMAT_ZH),
			//% strlen(host) > IPADDR_OMIT_THRES ? "" : "来自 ", host);
			strlen(host) > IPADDR_OMIT_THRES ? "" : "\xc0\xb4\xd7\xd4 ", host);

	user_id_t uid = get_user_id(userid);
	session_basic_info_t *res = get_sessions(uid);

	bool any_session_visible = false;
	for (int i = 0; i < (res ? session_basic_info_count(res) : 0); ++i) {
		if (HAS_PERM(PERM_SEECLOAK) || session_basic_info_visible(res, i)) {
			any_session_visible = true;
			break;
		}
	}

	if (any_session_visible) {
		//% prints("在线 [\033[1;32m讯息器:(\033[36m%s\033[32m)\033[m] ",
		prints("\xd4\xda\xcf\xdf [\033[1;32m\xd1\xb6\xcf\xa2\xc6\xf7:(\033[36m%s\033[32m)\033[m] ",
				//% "打开");
				"\xb4\xf2\xbf\xaa");
	} else {
		fb_time_t t = user.lastlogout;
		if (user.lastlogout < user.lastlogin)
			t = ((fb_time() - user.lastlogin) / 120) % 47 + 1 + user.lastlogin;
		//% prints("离站 [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH));
		prints("\xc0\xeb\xd5\xbe [\033[1;32m%s\033[m] ", format_time(t, TIME_FORMAT_ZH));
	}

	char path[HOMELEN];
	snprintf(path, sizeof(path), "mail/%c/%s/%s",
			toupper(user.userid[0]), user.userid, DOT_DIR);
	int perf = countperf(&user);
	//% prints("表现值 "
	prints("\xb1\xed\xcf\xd6\xd6\xb5 "
#ifdef SHOW_PERF
			"%d(\033[1;33m%s\033[m)"
#else
			"[\033[1;33m%s\033[m]"
#endif
			//% " 信箱 [\033[1;5;32m%2s\033[m]\n"
			" \xd0\xc5\xcf\xe4 [\033[1;5;32m%2s\033[m]\n"
#ifdef SHOW_PERF
			, perf
#endif
			//% , cperf(perf), (check_query_mail(path) == 1) ? "信" : "  ");
			, cperf(perf), (check_query_mail(path) == 1) ? "\xd0\xc5" : "  ");

	int exp = countexp(&user);

	uinfo_t u;
	uinfo_load(user.userid, &u);

#ifdef ENABLE_BANK
	//% prints("贡献 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib));
	prints("\xb9\xb1\xcf\xd7 [\033[1;32m%d\033[m", TO_YUAN_INT(u.contrib));
	if (self || HAS_PERM2(PERM_OCHAT, &currentuser)) {
		prints("/\033[1;33m%d\033[m", TO_YUAN_INT(u.money));
	}
	{
		char rank_buf[8];
		snprintf(rank_buf, sizeof(rank_buf), "%.1f%%", PERCENT_RANK(u.rank));
		prints("](%s) ", rank_buf);
	}

#endif

#ifdef ALLOWGAME
	//% prints("存贷款 [\033[1;32m%d\033[m/\033[1;32m%d\033[m]"
	prints("\xb4\xe6\xb4\xfb\xbf\xee [\033[1;32m%d\033[m/\033[1;32m%d\033[m]"
			//% "(\033[1;33m%s\033[m) 经验值 [\033[1;32m%d\033[m]\n",
			"(\033[1;33m%s\033[m) \xbe\xad\xd1\xe9\xd6\xb5 [\033[1;32m%d\033[m]\n",
			user.money, user.bet, cmoney(user.money - user.bet), exp);
	//% prints("发文 [\033[1;32m%d\033[m] 奖章 [\033[1;32m%d\033[m]"
	prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] \xbd\xb1\xd5\xc2 [\033[1;32m%d\033[m]"
			//% "(\033[1;33m%s\033[m) 生命力 [\033[1;32m%d\033[m]\n",
			"(\033[1;33m%s\033[m) \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n",
			user.numposts, user.nummedals, cnummedals(user.nummedals),
			compute_user_value(&user));
#else
	//% prints("发文 [\033[1;32m%d\033[m] ", user.numposts);
	prints("\xb7\xa2\xce\xc4 [\033[1;32m%d\033[m] ", user.numposts);
	//% prints("经验值 [\033[1;33m%-10s\033[m]", cexpstr(exp));
	prints("\xbe\xad\xd1\xe9\xd6\xb5 [\033[1;33m%-10s\033[m]", cexpstr(exp));
#ifdef SHOWEXP
	prints("(%d)", exp);
#endif
	//% prints(" 生命力 [\033[1;32m%d\033[m]\n", compute_user_value(&user));
	prints(" \xc9\xfa\xc3\xfc\xc1\xa6 [\033[1;32m%d\033[m]\n", compute_user_value(&user));
#endif

	char buf[160];
	show_position(&user, buf, sizeof(buf), u.title);
	//% prints("身份 %s\n", buf);
	prints("\xc9\xed\xb7\xdd %s\n", buf);
	
	uinfo_free(&u);

	if (any_session_visible)
		show_statuses(res);
	session_basic_info_clear(res);

	show_user_plan(userid);
	return 0;
}