コード例 #1
0
ファイル: bbsdenyadd.c プロジェクト: lytsing/ytht
static int
inform(char *board, char *user, char *exp, int dt)
{
	FILE *fp;
	char path[80], title[80], buf[512];
	struct tm *tmtime;
	time_t daytime = now_t + (dt + 1) * 86400;
	tmtime = gmtime(&daytime);
	sprintf(title, "%s 被 %s 取消在%s的POST权", user, currentuser->userid, board);
	sprintf(path, "bbstmpfs/tmp/%d.tmp", thispid);
	fp = fopen(path, "w");
	fprintf(fp, "【此篇文章是由自动发信系统所张贴】\n\n");
	snprintf(buf, sizeof (buf),
		"被封原因: %s\n"
		"被封天数: %d\n"
		"解封日期: %d月%d日\n"
		"管理人员: %s\n"
		"解封办法: 联系版主提前解封或由系统自动解封\n"
		"如有异议,可向管理人员提出,或到Arbitration版投诉\n\n\n",
		 exp, dt, tmtime->tm_mon + 1, tmtime->tm_mday,
		currentuser->userid);
	fputs(buf, fp);
	fclose(fp);
	securityreport(title, buf);
	post_article(board, title, path, "deliver", "自动发信系统",
		     "自动发信系统", -1, 0, 0, "deliver", -1);
	if (!hideboard(board))
		post_article("Penalty", title, path, "deliver", "自动发信系统",
			     "自动发信系统", -1, 0, 0, "deliver", -1);
	mail_file(path, user, title, "deliver");
	unlink(path);
	printf("系统已经发信通知了%s.<br>\n", user);
	return 0;
}
コード例 #2
0
ファイル: receive_article.c プロジェクト: wyat/kbs
int receive_control()
{
    char *boardhome, *fname;
    char firstpath[MAXPATHLEN], *firstpathbase;
    char **splitptr, *ngptr;
    newsfeeds_t *nf;

    innbbsdlog("control post %s\n", HEADER[CONTROL_H]);
    boardhome = (char *) fileglue("%s/boards/control", BBSHOME);
    testandmkdir(boardhome);
    *firstpath = '\0';
    if (isdir(boardhome)) {
        fname = (char *) post_article(boardhome, FROM, "control", bbspost_write_control, NULL, firstpath);
        if (fname != NULL) {
            if (firstpath[0] == '\0')
                sprintf(firstpath, "%s/boards/control/%s", BBSHOME, fname);
            if (storeDB(HEADER[MID_H], (char *) fileglue("control/%s", fname)) < 0) {
            }
            bbsfeedslog(fileglue("control/%s", fname), 'C');
            firstpathbase = firstpath + strlen(BBSHOME) + strlen("/boards/");
            splitptr = (char **) BNGsplit(GROUPS);
            for (ngptr = *splitptr; ngptr != NULL; ngptr = *(++splitptr)) {
                if (*ngptr == '\0')
                    continue;
                nf = (newsfeeds_t *) search_group(ngptr);
                if (nf == NULL)
                    continue;
                if (nf->board == NULL)
                    continue;
                if (nf->path == NULL)
                    continue;
                feedfplog(nf, firstpathbase, 'C');
            }
        }
    }
    return 0;
}
コード例 #3
0
ファイル: receive_article.c プロジェクト: wyat/kbs
/* process cancel write */
int receive_article()
{
    char *user, *userptr;
    char *ngptr, *pathptr;
    char **splitptr;
    static char userid[32];
    static char xdate[32];
    static char xpath[180];
    time_t datevalue;
    newsfeeds_t *nf;
    char *boardhome;
    char hispaths[4096];
    char firstpath[MAXPATHLEN], *firstpathbase;
    char *lesssym, *nameptrleft, *nameptrright;
    static char sitebuf[80];

    if (FROM == NULL) {
        innbbsdlog(":Err: article without usrid %s\n", MSGID);
        return 0;
    }
    if (strchr(FROM, '<') && (FROM[strlen(FROM) - 1] == '>'))
        user = (char *) strrchr(FROM, '@');
    else
        user = (char *) strchr(FROM, '@');
    lesssym = (char *) strchr(FROM, '<');
    nameptrleft = NULL, nameptrright = NULL;
    if (lesssym == NULL || lesssym >= user) {
        lesssym = FROM;
        nameptrleft = strchr(FROM, '(');
        if (nameptrleft != NULL)
            nameptrleft++;
        nameptrright = strrchr(FROM, ')');
    } else {
        nameptrleft = FROM;
        nameptrright = strrchr(FROM, '<');
        lesssym++;
    }
    if (user != NULL) {
        *user = '******';
        userptr = (char *) strchr(FROM, '.');
        if (userptr != NULL) {
            *userptr = '\0';
            strncpy(userid, lesssym, sizeof userid);
            *userptr = '.';
        } else {
            strncpy(userid, lesssym, sizeof userid);
        }
        *user = '******';
    } else {
        strncpy(userid, lesssym, sizeof userid);
    }
    if (!isalnum(userid[0]))
        strcpy(userid, "Unknown");
    strcat(userid, ".");
    datevalue = parsedate(DATE, NULL);

    if (datevalue > 0) {
        char *p;

        strncpy(xdate, ctime(&datevalue), sizeof(xdate));
        p = (char *) strchr(xdate, '\n');
        if (p != NULL)
            *p = '\0';
        DATE = xdate;
    }
    if (SITE && strcasecmp("Computer Science & Information Engineering NCTU", SITE) == 0) {
        SITE = NCTUCSIETxt;
    } else if (SITE && strcasecmp("Dep. Computer Sci. & Information Eng., Chiao Tung Univ., Taiwan, R.O.C", SITE) == 0) {
        SITE = NCTUCSIETxt;
    } else if (SITE == NULL || *SITE == '\0') {
        if (nameptrleft != NULL && nameptrright != NULL) {
            char savech = *nameptrright;

            *nameptrright = '\0';
            strncpy(sitebuf, nameptrleft, sizeof sitebuf);
            *nameptrright = savech;
            SITE = sitebuf;
        } else
            /*
             * SITE = "(Unknown)"; 
             */
            SITE = "";
    }
    if (strlen(MYBBSID) > 70) {
        innbbsdlog(" :Err: your bbsid %s too long\n", MYBBSID);
        return 0;
    }
    sprintf(xpath, "%s!%.*s", MYBBSID, (int)(sizeof(xpath) - strlen(MYBBSID) - 2), PATH);
    PATH = xpath;
    for (pathptr = PATH; pathptr != NULL && (pathptr = strstr(pathptr, ".edu.tw")) != NULL;) {
        if (pathptr != NULL) {
            strcpy(pathptr, pathptr + 7);
        }
    }
    xpath[71] = '\0';

    echomaillog();
    *hispaths = '\0';
    splitptr = (char **) BNGsplit(GROUPS);
    firstpath[0] = '\0';
    firstpathbase = firstpath;
    /*
     * try to split newsgroups into separate group and check if any
     * duplicated
     */

    /*
     * try to use hardlink 
     */
    /*
     * for ( ngptr = GROUPS, nngptr = (char*) strchr(ngptr,','); ngptr !=
     * NULL && *ngptr != '\0'; nngptr = (char*)strchr(ngptr,',')) {
     */
    for (ngptr = *splitptr; ngptr != NULL; ngptr = *(++splitptr)) {
        char *boardptr, *nboardptr;

        /*
         * if (nngptr != NULL) { nngptr = '\0'; }
         */
        if (*ngptr == '\0')
            continue;
        nf = (newsfeeds_t *) search_group(ngptr);
        /*
         * printf("board %s\n",nf->board); 
         */
        if (nf == NULL) {
            innbbsdlog("unwanted \'%s\'\n", ngptr);
            /*
             * if( strstr( ngptr, "tw.bbs" ) != NULL ) { }
             */
            continue;
        }
        if (nf->board == NULL || !*nf->board)
            continue;
        if (nf->path == NULL || !*nf->path)
            continue;
        for (boardptr = nf->board, nboardptr = (char *) strchr(boardptr, ','); boardptr != NULL && *boardptr != '\0'; nboardptr = (char *) strchr(boardptr, ',')) {
            if (nboardptr != NULL) {
                *nboardptr = '\0';
            }
            if (*boardptr == '\t') {
                goto boardcont;
            }
            boardhome = (char *) fileglue("%s/boards/%s", BBSHOME, boardptr);
            if (!isdir(boardhome)) {
                innbbsdlog(":Err: unable to write %s\n", boardhome);
            } else {
                char *fname;

                /*
                 * if ( !isdir( boardhome )) { innbbsdlog( ":Err:
                 * unable to write %s\n",boardhome);
                 * testandmkdir(boardhome); }
                 */
                fname = (char *) post_article(boardhome, userid, boardptr, bbspost_write_post, NULL, firstpath);
                if (fname != NULL) {
                    fname = (char *) fileglue("%s/%s", boardptr, fname);
                    if (firstpath[0] == '\0') {
                        sprintf(firstpath, "%s/boards/%s", BBSHOME, fname);
                        firstpathbase = firstpath + strlen(BBSHOME) + strlen("/boards/");
                    }
                    if (strlen(fname) + strlen(hispaths) + 1 < sizeof(hispaths)) {
                        strcat(hispaths, fname);
                        strcat(hispaths, " ");
                    }
                } else {
                    innbbsdlog("fname is null %s\n", boardhome);
                    return -1;
                }
            }

          boardcont:
            if (nboardptr != NULL) {
                *nboardptr = ',';
                boardptr = nboardptr + 1;
            } else
                break;

        }                       /* for board1,board2,... */
        /*
         * if (nngptr != NULL) ngptr = nngptr + 1; else break;
         */
        if (*firstpathbase)
            feedfplog(nf, firstpathbase, 'P');
    }
    if (*hispaths)
        bbsfeedslog(hispaths, 'P');

    if (Junkhistory || *hispaths) {
        if (storeDB(HEADER[MID_H], hispaths) < 0) {
            innbbsdlog("store DB fail\n");
            /*
             * I suspect here will introduce duplicated articles 
             */
            /*
             * return -1; 
             */
        }
    }
    return 0;
}