Exemplo n.º 1
0
//struct file_to_appendix  a;
int main()
{
        FILE *fp;
        char filename[80], dir[80], board[80], title[80], buf[80], *content, vfrom[80];
	char tmpbuf [5], title2 [10];
        char redirfile[80];
        int r, i=0, length=0, sig, mode=0, accessed=0;
        struct fileheader x;
        struct shortfile *brd;
        init_all();
        if(!loginok)
                http_fatal("匆匆过客不能发表文章,请先登录");


        mode=atoi(getparm("mode"));
        if(mode)
                strsncpy(redirfile, getparm("redir"), 20);
        strsncpy(board, getparm("board"), 18);
        strsncpy(vfrom, getparm("vfrom"), 18);
		if (!*vfrom)
		{
			strcpy(vfrom, board);
		}

        if(dashf("NOPOST")&&!HAS_PERM(PERM_OBOARDS)
   		                && insec(1,board) 
          )
                http_fatal("对不起,系统进入只读状态,暂停发表文章.你先四处看看吧");

        /* efan: very faint	*/
        if (dashf ("NOPOST.2") && ! HAS_PERM (PERM_OBOARDS) && (
                                !strcmp (board, "VoiceofNankai") ||
                                !strcmp (board, "Military") ||
                                !strcmp (board, "TaiWan") ||
                                !strcmp (board, "Salon"))
           )
                http_fatal("对不起,本板进入只读状态,暂停发表文章");



        if(!(currentuser.userlevel & PERM_POST)&&strcmp(board, "appeal")&&strcmp(board, "sysop"))
                http_fatal("您尚未通过注册,暂无发表文章权限");

        if(check_post_limit(board)) return 0;

        strsncpy(title, getparm("title"), 50);
	strsncpy (tmpbuf, getparm ("title2"), 5);
	if (tmpbuf [0] != 0)
		sprintf (title2, "【%s】", tmpbuf);
	else
		title2[0] = 0;

	content=getparm("text");
        brd=getbcache(board);
        /* add by wzk for outgo post */
        //out=strlen(getparm("out"));
        //if (!(brd->flag & OUT_FLAG)) out=0;
        /* end */
        if(brd==0)
                http_fatal("错误的讨论区名称");
        strcpy(board, brd->filename);
	//huangxu@070217:no_word_filter flag
	int bd=0; 
        char temp[80];
        if(!(brd->flag2&NOFILTER_FLAG)&&(bad_words(title) || bad_words (tmpbuf) || bad_words(content) )){
                bd=1;		
                printf("您的文章可能包含不便显示的内容,已经提交审核。请返回并进行修改。");
   	        sprintf(temp,"TEMP-%s",board);
                strcpy(board,"TEMP");
        }else
                strcpy(temp,board);

        for(i=0; i<strlen(title); i++)
                if(title[i]<=27 && title[i]>=-1)
                        title[i]=' ';
        sig=atoi(getparm("signature"));

        if(title[0]==0)
                http_fatal("文章必须要有标题");
	if (title2 [0] == 0 && !strcmp (board, "Secondhand"))
		http_fatal ("在Secondhand板请说清楚您的需要!");
	if (tmpbuf [0] != ' ') {
		char tmptmpbuf [80];
		sprintf (tmptmpbuf, "%s%s", title2, title);
		strcpy (title, tmptmpbuf);
	}
        sprintf(dir, "boards/%s/.DIR", board);
        if(bd==0) 
      	  if(!has_post_perm(&currentuser, board))
             	   http_fatal("此讨论区是唯读的, 或是您尚无权限在此发表文章.");
        
	sprintf(filename, "boards/%s/deny_users", board);
        if(file_has_word(filename, currentuser.userid))
                http_fatal("很抱歉, 你被板务人员停止了本板的post权利.");
        if(abs(time(0) - *(int*)(u_info->from+36))<6) {
                *(int*)(u_info->from+36)=time(0);
                http_fatal("两次发文间隔过密, 请休息几秒后再试");
        }
        *(int*)(u_info->from+36)=time(0);
        sprintf(filename, "tmp/%d.%s.tmp", getpid(),currentuser.userid);
        f_append(filename, content);
        accessed=0;
        if(strlen(getparm("noreply"))>0)
                accessed=FILE_NOREPLY;

        int outgo=0;
        if(strlen(getparm("outgo"))>0)     
            outgo=1;

        int attach=atoi(getparm("attach"));
      
        r=0;
        r=post_article2(temp, title, filename, currentuser.userid, currentuser.username, fromhost, sig-1, accessed, attach,outgo);
        if(r<=0)
                http_fatal("内部错误,无法发文");
        char path[STRLEN];
  /*      while( appendix != NULL ) {
                bzero(&a,sizeof(struct appendix));
                strcpy(a.appendixname,appendix);
                a.filename=r;
                a.sign=0;
                strcpy(a.path,board);
                sprintf(path,"%s/file_appendix",UPLOAD_PATH);
                append_record(&a,sizeof(struct appendix),path);
                appendix = strtok( NULL, "," );
        }
*/
        sprintf(buf,"M.%d.A",r);
        brc_init(currentuser.userid, board);
        brc_add_read(buf);
        brc_update(currentuser.userid, board);
        unlink(filename);
        sprintf(buf, "posted WWW '%s' on '%s'", title, board);
        report(buf);
        if(mode==0)
                sprintf(buf, "bbsdoc?board=%s#bottom", vfrom);
        else if(mode==1)
                sprintf(buf, "bbstcon?board=%s&file=%s&vfrom=%s#bottom", board, redirfile, vfrom);
        else if(mode==2)
                sprintf(buf, "bbstdoc?board=%s#bottom", vfrom);
        if(!junkboard(board)) 
	{
                currentuser.numposts++;
                save_user_data(&currentuser);
               // write_posts(currentuser.userid, board, title);
        }
	 if(toptenboard(board))
        {
                 write_posts(currentuser.userid, board, title);
        }

	else if(!strcmp("Blessing",board)) write_posts(currentuser.userid, board, title);
        //  return 0;
        if(bd==0)        redirect(buf);

}
Exemplo n.º 2
0
int bbssnd_main(void)
{
	if (!loginok)
		return BBS_ELGNREQ;
	if (parse_post_data() < 0)
		return BBS_EINVAL;
	int bid = strtol(getparm("bid"), NULL, 10);
	struct boardheader *bp = getbcache2(bid);
	if (bp == NULL || !haspostperm(&currentuser, bp))
		return BBS_ENOBRD;
	if (bp->flag & BOARD_DIR_FLAG)
		return BBS_EINVAL;

	bool isedit = (*(getparm("e")) == '1');
	unsigned int fid;
	struct fileheader fh;
	char *f = getparm("f");
	bool reply = !(*f == '\0');
	if (reply) {
		fid = strtoul(f, NULL, 10);
		if (!bbscon_search(bp, fid, 0, &fh))
			return BBS_ENOFILE;
		if (!isedit && fh.accessed[0] & FILE_NOREPLY)
			return BBS_EPST;
		if (isedit && !chkBM(bp, &currentuser)
				&& strcmp(fh.owner, currentuser.userid))
			return BBS_EACCES;
	}

	char title[sizeof(fh.title)];
	if (!isedit) {
		strlcpy(title, getparm("title"), sizeof(title));
		printable_filter(title);
		if (*title == '\0')
			return BBS_EINVAL;
	}

// TODO: ...
#ifdef SPARC
		if(abs(time(0) - *(int*)(u_info->from+34))<6) { //modified from 36 to 34 for sparc solaris by roly 02.02.28
			*(int*)(u_info->from+34)=time(0); //modified from 36 to 34 for sparc solaris by roly 02.02.28
			return BBS_EPFREQ;
		}
		*(int*)(u_info->from+34)=time(0);//modified from 36 to 34 for sparc solaris by roly 02.02.28
#else
		if(abs(time(0) - *(int*)(u_info->from+36))<6) { //modified from 36 to 34 for sparc solaris by roly 02.02.28
			*(int*)(u_info->from+36)=time(0); //modified from 36 to 34 for sparc solaris by roly 02.02.28
			return BBS_EPFREQ;
		}
		*(int*)(u_info->from+36)=time(0);//modified from 36 to 34 for sparc solaris by roly 02.02.28
#endif

	if (isedit) {
		char file[HOMELEN];
		setbfile(file, bp->filename, fh.filename);
		if (edit_article(file, getparm("text"), mask_host(fromhost)) < 0)
			return BBS_EINTNL;
	} else {
		post_request_t pr = { .autopost = false, .crosspost = false,
			.userid = NULL, .nick = NULL, .user = &currentuser,
			.bp = bp, .title = title, .content = getparm("text"),
			.sig = strtol(getparm("sig"), NULL, 0), .ip = mask_host(fromhost),
			.o_fp = reply ? &fh : NULL, .noreply = false, .mmark = false };
		if (do_post_article(&pr) < 0)
			return BBS_EINTNL;
	}

	if (!isedit && !junkboard(bp)) {
		currentuser.numposts++;
		save_user_data(&currentuser);
	}

	char buf[sizeof(fh.title) + sizeof(bp->filename)];
	snprintf(buf, sizeof(buf), "%sed '%s' on %s", isedit ? "edit" : "post",
			title, bp->filename);
	report(buf, currentuser.userid);

	snprintf(buf, sizeof(buf), "doc?board=%s", bp->filename);
	http_header();
	refreshto(1, buf);
	printf("</head>\n<body>发表成功,1秒钟后自动转到<a href='%s'>版面</a>\n"
			"</body>\n</html>\n", buf);
	return 0;
}
Exemplo n.º 3
0
int boarddetail_act(char * info)
{
	int act;
	char buf[1024];
	char opinfo[256];
	*opinfo = 0;
	strncpy (board, getparm("board"), 79);
	act = atoi(getparm("act"));
	if (loginok)
	{
		wmlmode (u_info, READNEW);
	}
	x = getbcache(board);
	if (x)
	{
		if ((!canenterboard (currentuser.userid, board) || !has_read_perm(&currentuser, board)) && !HAS_PERM(PERM_SYSOP))
		{
			x = NULL;
		}
	}
	if (x)
	{
		switch (act)
		{
			case 1://清除板面未读
				if (loginok)
				{
					brc_init(currentuser.userid, board);
					brc_clear();
					brc_update(currentuser.userid, board);
					strcpy (opinfo, "已标记本板为已读。");
				}
				break;
		}
		printf ("<card title=\"%s/%s\">", x->title + 11, x->filename);
		if (*opinfo)
		{
			printf ("<p>%s</p>", opinfo);
		}
		printf ("<p>板面:<anchor><go href=\"bbsdoc.wml?board=%s\" />%s/%s</anchor></p>", x->filename, x->title + 11, x->filename);
		wmlUseridStr(buf, x->BM);
		printf ("<p>板主:%s %s %s</p>", *buf ? buf : "无", (x->flag & OUT_FLAG) ? "转信" : "", junkboard(board) ? "不计文章数" : "计文章数");
		printf ("<p><anchor><go href=\"bbsdoc.wml?board=%s&amp;mode=0\" />普通</anchor> ", board);
		printf ("<anchor><go href=\"bbsdoc.wml?board=%s&amp;mode=1\" />文摘</anchor> ", board);
		printf ("<anchor><go href=\"bbsdoc.wml?board=%s&amp;mode=8\" />置顶</anchor> ", board);
		if (has_BM_perm(&currentuser, x->filename) || HAS_PERM(PERM_FORCEPAGE))
		{
			printf ("<anchor><go href=\"bbsdoc.wml?board=%s&amp;mode=4\" />回收</anchor>", board);
		}
		printf ("</p>");
		if (HAS_PERM(PERM_POST))
		{
			if (x->flag & VOTE_FLAG)
			{
				printf ("<p><anchor><go href=\"bbsvote.wml?board=%s\" />投票</anchor></p>", x->filename);
			}
			printf ("<p><anchor><go href=\"bbspst.wml?board=%s\" />发文</anchor> <anchor><go href=\"bbspattern.wml?board=%s\" />模板</anchor> <anchor><go href=\"bbs0an.wml?path=%s\" />精华</anchor> <anchor><go href=\"boarddetail.wml?board=%s&amp;act=1\" />清除未读</anchor> </p>", x->filename, x->filename, anno_path_of(x->filename), board);
		}
		printf ("<p><anchor><go href=\"bbscon.wml?board=%s&amp;file=%s\" />封禁名单</anchor> <anchor><go href=\"bbscon.wml?board=%s\" />敏感词</anchor></p>", WML_VB_DENIED, board, WML_VB_HEXIE);
		return 0;
	}
	else
	{
		strcpy (info, "讨论区不存在或您无权进入此讨论区。");
		return -1;
	}
}
Exemplo n.º 4
0
int main()
{
        FILE *fp,*fp2;
        struct shortfile *brd;
        struct fileheader f;
        struct userec *u;
        char buf[80], dir[80], path[80], board[80], file[80], *id;
	char jdir[80];
        int num=0;
        init_all();
        if(!loginok)
                http_fatal("请先登录");
        id=currentuser.userid;
        strsncpy(board, getparm("board"), 60);
        strsncpy(file, getparm("file"), 20);
        brd=getbcache(board);
        if(strncmp(file, "M.", 2) && strncmp(file, "G.", 2))
                http_fatal("错误的参数");
        if(strstr(file, ".."))
                http_fatal("错误的参数");
        if(brd==0)
                http_fatal("板面错误");
        if(!has_post_perm(&currentuser, board))
                http_fatal("错误的讨论区");
        sprintf(dir, "boards/%s/.DIR", board);
        sprintf(path, "boards/%s/%s", board, file);
	sprintf(jdir, "boards/%s/.junk", board);
        fp=fopen(dir, "r");
        if(fp==0)
                http_fatal("错误的参数");
        while(1) {
                if(fread(&f, sizeof(struct fileheader), 1, fp)<=0)
                        break;
                if(!strcmp(f.filename, file)) {//huangxu@060715:web下删除m文章
                        if((strcasecmp(id, f.owner)||(f.accessed[0]&FILE_MARKED)) && !has_BM_perm(&currentuser, board))
                                http_fatal("你无权删除该文");
		fp2=fopen(jdir, "a");
		fwrite(&f, sizeof(struct fileheader), 1, fp2);
		fclose(fp2);
			if(!HAS_PERM(PERM_SYSOP))//huangxu@060406:deleted、junk已经无用
      				if(strstr(board,"syssecurity")||(!strcmp(board,"Punishment")&&!HAS_PERM(PERM_BLEVELS)))
					http_fatal("你无权删除该文");
			del_record(dir, sizeof(struct fileheader), num);
                        sprintf(buf, "\n※ %s 于 %s 删除·Web[FROM: %s]", currentuser.userid, Ctime(time(0))+4, fromhost);
                        f_append(path, buf);
                /*        if(!strcmp(f.owner, currentuser.userid)) {
                                post_article("junk", f.title, path, f.owner, "", fromhost, -1);
                        } else {
                                post_article("deleted", f.title, path, f.owner, "", fromhost, -1);
                        }*/
                        //unlink(path);
                        printf("删除成功.<br><a href='bbsdoc?board=%s'>返回本讨论区</a>", board);
                        u=getuser(f.owner);
                        if(!junkboard(board) && u) {
                                if(u->numposts>0)
                                        u->numposts--;
                                save_user_data(u);
                        }
                        sprintf(buf, "%s %-12s bbsdel %s\n", Ctime(time(0))+4, id, board);
                        f_append("trace", buf);
                        http_quit();
                }
                num++;
        }
        fclose(fp);
        printf("文件不存在, 删除失败.<br>\n");
        printf("<a href='bbsdoc?board=%s'>返回本讨论区</a>", board);
        http_quit();
}