예제 #1
0
파일: refriend.c 프로젝트: xingskycn/kbs
int refriend(struct userec* user,char* arg)
{
   char buf[256],buf2[256];
   char cmd[1024];
   sethomefile(buf,user->userid,"friends");
   sethomefile(buf2,user->userid,"friends.sav");
   f_cp(buf,buf2,O_TRUNC);
   sethomefile(buf2,user->userid,"newfriends");
   newfd=open(buf2,O_WRONLY|O_TRUNC|O_CREAT,0644);
   apply_record(buf,(APPLY_FUNC_ARG)conver,sizeof(struct oldfriend),NULL,0,false);
   close(newfd);
   f_rm(buf);
   f_mv(buf2,buf);
}
예제 #2
0
파일: bbsfall.c 프로젝트: phoenixgao/fdubbs
int bbsfall_main(void)
{
	if (!loginok)
		return BBS_ELGNREQ;
	xml_header("bbs");
	printf("<bbsfall ");
	print_session();
	printf(">");
	char file[HOMELEN];
	sethomefile(file, currentuser.userid, "friends");
	apply_record(file, print_override, sizeof(override_t), NULL, false,
			false, true);
	printf("</bbsfall>");
	return 0;
}
예제 #3
0
파일: read.c 프로젝트: bencrox/hkday-pttbbs
int
TagPruner(int bid)
{
    boardheader_t  *bp=NULL;
    char direct[PATHLEN];

    assert(bid >= 0);   /* bid == 0 means in mailbox */
    if (bid && currstat != RMAIL) {
        bp = getbcache(bid);
        if (is_readonly_board(bp->brdname))
            return DONOTHING;
        setbdir(direct, bp->brdname);
    } else if(currstat == RMAIL) {
        sethomedir(direct, cuser.userid);
    } else {
        vmsg("抱歉,程式異常 - 請至 " BN_BUGREPORT " 報告您剛的詳細步驟。");
        return FULLUPDATE;
    }

    if (IsEmptyTagList() || (currstat == READING && !(currmode & MODE_BOARD)))
        return DONOTHING;
    if (vans("刪除所有標記[N]?") != 'y')
        return READ_REDRAW;

    // ready to start.
    outmsg("處理中,請稍後...");
    refresh();

    // first, delete and backup all files
    apply_record(direct, _iter_delete_tagged, sizeof(fileheader_t), direct);

    // now, delete the header
#ifdef SAFE_ARTICLE_DELETE
    if(bp && !(currmode & MODE_DIGEST) &&
            bp->nuser >= SAFE_ARTICLE_DELETE_NUSER)
        safe_delete_range(currdirect, 0, 0);
    else
#endif
        delete_range(currdirect, 0, 0);

    TagNum = 0;
    if (bid)
        setbtotal(bid);
    else if(currstat == RMAIL)
        setupmailusage();

    return NEWDIRECT;
}
예제 #4
0
파일: bbsinfo.c 프로젝트: phoenixgao/fdubbs
int bbsidle_main(void)
{
	if (!loginok)
		return BBS_ELGNREQ;
	printf("Content-type: text/xml; charset="CHARSET"\n\n"
			"<?xml version=\"1.0\" encoding=\""CHARSET"\"?>\n<bbsidle");
	char file[HOMELEN];
	setmdir(file, currentuser.userid);
	mail_count_t c;
	c.limit = time(NULL) - 24 * 60 * 60 * NEWMAIL_EXPIRE;
	c.count = 0;
	apply_record(file, count_new_mail, sizeof(struct fileheader), &c, false,
			true, true);
	printf(" mail='%d'></bbsidle>", c.count);
	return 0;
}
예제 #5
0
int cleanmail(struct userec* urec)
{
    struct stat statb;
    if (urec->userid[0] == '\0' || !strcmp(urec->userid, "new"))
        return 0;
    sprintf(genbuf, "mail/%c/%s/%s", toupper(urec->userid[0]), urec->userid, DOT_DIR);
    fprintf(cleanlog, "%s: ", urec->userid);
    if (stat(genbuf, &statb) == -1)
        fprintf(cleanlog, "no mail\n");
    else if (statb.st_size == 0)
        fprintf(cleanlog, "no mail\n");
    else
    {
        strcpy(curruser, urec->userid);
        delcnt = 0;
        apply_record(genbuf, domailclean, sizeof(struct fileheader));
        domailclean(NULL);
    }
    return 0;
}
예제 #6
0
파일: announce.c 프로젝트: Fdhvdu/pttbbs
static int
a_pastetagpost(menu_t * pm, int mode)
{
    boardheader_t  *bh = NULL;
    char            dirname[PATHLEN];
    _iter_paste_tag_param param = {0};
    param.pm = pm;
    param.mode = mode;

    if (TagBoard == 0){
	sethomedir(dirname, cuser.userid);
    }
    else{
	bh = getbcache(TagBoard);
	setbdir(dirname, bh->brdname);
        param.bh = bh;
    }

    // prevent if anything wrong
    if (TagNum > MAXTAGS || TagNum < 0)
    {
	vmsg("內部錯誤。請把你剛剛進行的完整步驟貼到 "
		BN_BUGREPORT " 板。");
	return 0;
    }

    if (IsEmptyTagList())
	return 0;

    /* since we use different tag features,
     * copyqueue is not required/used. */
    copyqueue_reset();
    apply_record(dirname, _iter_paste_tag, sizeof(fileheader_t),  &param);

    TagNum = 0;
    return param.copied;
}
예제 #7
0
void resolve_ucache()
{
    struct stat st;
    int     ftime;
    if (uidshm == NULL)
    {
        uidshm = attach_shm("UCACHE_SHMKEY", 3696, sizeof(*uidshm));
    }
    if (stat(FLUSH, &st) < 0)
    {
        ftime = time(0) - 86400;
    }
    else
        ftime = st.st_mtime;
    if (uidshm->uptime < ftime||forceresolve)
    {
        log_usies("CACHE", "reload ucache");
        /* uidshm->uptime = ftime; */
        usernumber = 0;
        apply_record(PASSFILE, fillucache, sizeof(struct userec));
        uidshm->number = usernumber;
        uidshm->uptime = ftime;
    }
}
예제 #8
0
void resolve_boards()
{
    struct stat st;
    time_t  now;
    if (brdshm == NULL)
    {
        brdshm = attach_shm("BCACHE_SHMKEY", 3693, sizeof(*brdshm));
    }
    numboards = brdshm->number;
    bcache = brdshm->bcache;
    now = time(0);
    if (stat(BOARDS, &st) < 0)
    {
        st.st_mtime = now - 3600;
    }
    if (brdshm->uptime < st.st_mtime || brdshm->uptime < now - 3600)
    {
        log_usies("CACHE", "reload bcache");
        numboards = 0;
        apply_record(BOARDS, fillbcache, sizeof(struct boardheader));
        brdshm->number = numboards;
        brdshm->uptime = now;
    }
}
예제 #9
0
파일: post_brdlog.c 프로젝트: wyat/kbs
int fillboard()
{
    bzero(x, MAXBOARD * sizeof(struct _brdlog));
    return apply_record(BOARDS, fillbcache, sizeof(struct boardheader), NULL, 0,false);
}
예제 #10
0
int fillboard()
{
        apply_record(BBSBOARDS,fillbcache,sizeof(struct boardheader));
}
예제 #11
0
int fillboard(void){
    return apply_record(BOARDS, (APPLY_FUNC_ARG)fillbcache, sizeof(struct boardheader), NULL, 0,false);
}
예제 #12
0
파일: read.c 프로젝트: bencrox/hkday-pttbbs
static int
TagThread(const char *direct)
{
    apply_record(direct, _iter_tag_match_title, sizeof(fileheader_t), currtitle);
    return FULLUPDATE;
}