Пример #1
0
int total_post_top10(unsigned int gid,char *board,char *title)
{
    struct userec deliveruser;
    unsigned int start,noref,noattach,ret;
    char ut_file[STRLEN];
    char post_title[ARTICLE_TITLE_LEN];
    unsigned char accessed[2] = "\0\0";

    if (init_all()) {
        printf("init data fail\n");
        return -1;
    }

    bzero(&deliveruser, sizeof(struct userec));
    strcpy(deliveruser.userid, "deliver");
    deliveruser.userlevel = -1;
    strcpy(deliveruser.username, "自动发信系统");
    setCurrentUser(&deliveruser);
    strcpy(getSession()->fromhost, "天堂");

    start = gid;
    noref = 0;
    noattach = 0; 
    //accessed[0] |= 0x08;  // m 
    
    ret=get_thread_forward_mail(board, gid, start, noref, noattach, title);
    if (ret > 0) {
        gettmpfilename(ut_file, "ut");
        snprintf(post_title, ARTICLE_TITLE_LEN, "[合集] [%s] %s", board,title);
        post_file_alt(ut_file, NULL, post_title, "ShiDa", NULL, 0x01|0x04, accessed);
        unlink(ut_file);
    }

    return 0;
}
Пример #2
0
Файл: chat.c Проект: wyat/kbs
/*
 2001/5/6  modified by wwj
 聊天室看msg的函数
 */
void chat_show_allmsgs(chatcontext * pthis, const char *arg)
{
    char fname[STRLEN];
    FILE *fp;
    char buf[MAX_MSG_SIZE], showmsg[MAX_MSG_SIZE*2];
    int line, cnt, i, j=0, count;
    struct msghead head;

    line = atoi(arg);
    if (line < screen_lines - 1)
        line = screen_lines - 1;
    if (line > 300)
        line = 300;
    gettmpfilename(fname, "chatmsg");
    //sprintf(fname, "tmp/%s.msg", getCurrentUser()->userid);
    fp = fopen(fname, "w");
    count = get_msgcount(0, getCurrentUser()->userid);
    for (i=0;i<count;i++)
        if (i>=count-line) {
            j++;
            load_msghead(0, getCurrentUser()->userid, i, &head);
            load_msgtext(getCurrentUser()->userid, &head, buf);
            translate_msg(buf, &head, showmsg,getSession());
            fprintf(fp, "%s", showmsg);
        }
    fclose(fp);
    if (count) {
        fp = fopen(fname, "rb");
        sprintf(buf, "【最近 %d 条消息】", j);
        printchatline(pthis, buf);
        while (!feof(fp)) {
            bzero(buf, sizeof(buf));
            fgets(buf, sizeof(buf), fp);
            if (!buf[0])
                break;
            cnt = strlen(buf) - 1;
            buf[cnt] = 0;       /* delete \n */
            printchatline(pthis, buf);
        }
        fclose(fp);
    } else {
        printchatline(pthis, "***** 没有任何的讯息存在!!*****");
    }
    unlink(fname);
}