Example #1
0
static int
readuserallbrc(char *userid, char *userhost)
{
	char buf[STRLEN];
	int oldbrcexpired = brcexpired;
	if (!userid)
		return 0;
	brcexpired = 0;
	if (!*userid || !strcmp(userid, "guest")) {
		snprintf(buf, sizeof (buf), "guest.%s", userhost);
		if (!oldbrcexpired
		    && !strncmp(allbrcuser, buf, sizeof (allbrcuser))) return 0;
		strsncpy(allbrcuser, buf, sizeof (allbrcuser));
		brc_init(&allbrc, allbrcuser, NULL);

	} else {
		if (!oldbrcexpired
		    && !strncmp(allbrcuser, userid, sizeof (allbrcuser)))
			    return 0;
		sethomefile(buf, userid, "brc");
		strsncpy(allbrcuser, userid, sizeof (allbrcuser));
		brc_init(&allbrc, userid, buf);
	}
	return 0;
}
Example #2
0
int show_file(char *board, struct fileheader *x)
{
    char title[STRLEN];
    char *ptr=x->title;
    if(!strncmp(ptr, "Re:", 3))
        ptr+=4;
    strsncpy(title, ptr, 60);

    brc_init(currentuser.userid, board);
    brc_add_read(x->filename);
    brc_update(currentuser.userid, board);
    //printf("ok");return 0;
    FILE *fp;
    char path[80], buf[512];
    if(loginok)
        brc_add_read(x->filename);
    sprintf(path, "boards/%s/%s", board, x->filename);
    fp=fopen(path, "r");
    if(fp==0)
    {
        http_fatal("文章内容已被删除<br>\n");
        return;
    }
    printf("<p>");

    if(fgets(buf, 256, fp)==0)
    {
        printf("读取文件出错!");
        fclose(fp);
        return 0;
    }
    char *id,*s;

    int w=80;
    if(ads) {
        w=100;
    }
    int con=1,qmd=0,cite=0;
    printf("<table><tr><td id=\"c\" bgcolor=\"black\" style=\"font-size:16px;line-height:1\"></td></tr></table>");
    printf("<script language=\"javascript\">\n\r	init();\n\r");
    printf("document.getElementById('c').innerHTML=previewthis('");
    fseek (fp,0,0);
    while(1)
    {
        if(fgets(buf, 500, fp)==0)
            break;
        jsprint(buf);
    }
    printf("');\n\r</script>");
    fclose(fp);
    if(ads) googleads();
    return 1;
}
Example #3
0
int tui_check_notice(const char *board_name)
{
	screen_move_clear(-1);
	prints("\033[m\xb2\xe9\xbf\xb4:");

	int replies, mentions;
	notice_count(&replies, &mentions);

	print_option("\xc8\xa1\xcf\xfb", NULL, 0, 0);
	print_option("\xbb\xd8\xb8\xb4", "\xc6\xaa", replies, 1);
	print_option("\xcc\xe1\xbc\xb0", "\xc6\xaa", mentions, 2);

	int choice = 0;
	if (replies)
		choice = 1;
	else if (mentions)
		choice = 2;
	prints(" [%d]: ", choice);

	char ans[2];
	int x, y;
	screen_coordinates(&x, &y);
	getdata(x, y, "", ans, sizeof(ans), true, true);

	if (*ans == '\0')
		*ans = '0' + choice;
	if (*ans == '1') {
		post_list_reply();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	if (*ans == '2') {
		post_list_mention();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	return MINIUPDATE;
}
Example #4
0
File: tui.c Project: fbbs/fbbs
int tui_check_notice(const char *board_name)
{
	int replies, mentions;
	notice_count(&replies, &mentions);

	int choice = 0;
	char buf[64], reply_string[16], mention_string[16];
	reply_string[0] = mention_string[0] = '\0';
	if (mentions > 0) {
		snprintf(mention_string, sizeof(mention_string), "%d篇", mentions);
		choice = 2;
	}
	if (replies) {
		snprintf(reply_string, sizeof(reply_string), "%d篇", replies);
		choice = 1;
	}
	snprintf(buf, sizeof(buf), "查看: 0) 取消 1) %s回复 2) %s提及 [%d]: ",
			reply_string, mention_string, choice);

	char ans[2];
	tui_input(-1, buf, ans, sizeof(ans));

	if (*ans == '\0')
		*ans = '0' + choice;
	if (*ans == '1') {
		post_list_reply();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	if (*ans == '2') {
		post_list_mention();
		brc_init(currentuser.userid, board_name);
		return FULLUPDATE;
	}
	return MINIUPDATE;
}
Example #5
0
static char *boardmargin(void)
{
	static char buf[STRLEN];

	if (currbp->id)
		//% snprintf(buf, sizeof(buf), "讨论区 [%s]", currboard);
		snprintf(buf, sizeof(buf), "\xcc\xd6\xc2\xdb\xc7\xf8 [%s]", currboard);
	else {
		brc_init(currentuser.userid, DEFAULTBOARD);

		board_t board;
		get_board(DEFAULTBOARD, &board);
		change_board(&board);

		//% sprintf(buf, "讨论区 [%s]", currboard);
		sprintf(buf, "\xcc\xd6\xc2\xdb\xc7\xf8 [%s]", currboard);
	}
	return buf;
}
Example #6
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);

}
Example #7
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;
	}
}
Example #8
0
int web_sector(void)
{
	int sid = 0;
	board_t parent = { .id = 0 };
	db_res_t *res = NULL;

	const char *sname = web_get_param("s");
	if (*sname) {
		res = db_query("SELECT id, descr"
				" FROM board_sectors WHERE name = %s", sname);
		if (!res || db_res_rows(res) < 1) {
			db_clear(res);
			return BBS_EINVAL;
		}
	} else {
		const char *pname = web_get_param("board");
		if (*pname)
			get_board(pname, &parent);
		else
			get_board_by_bid(strtol(web_get_param("bid"), NULL, 10), &parent);
		if (!parent.id || !(parent.flag & BOARD_FLAG_DIR)
				|| !has_read_perm(&parent))
			return BBS_ENOBRD;
	}

	xml_header(NULL);
	printf("<bbsboa link='%sdoc' ", get_post_list_type_string());

	if (*sname) {
		char path[HOMELEN];
		sprintf(path, "%s/info/egroup%d/icon.jpg", BBSHOME,
				(int) strtol(sname, NULL, 16));
		if (dashf(path))
			printf(" icon='%s'", path);
		
		const char *utf8_sector = db_get_value(res, 0, 1);
		if (web_request_type(UTF8)) {
			printf(" title='%s'>", utf8_sector);
		} else {
			GBK_BUFFER(sector, BOARD_SECTOR_NAME_CCHARS);
			convert_u2g(utf8_sector, gbk_sector);
			printf(" title='%s'>", gbk_sector);
		}
		sid = db_get_integer(res, 0, 0);
		db_clear(res);
	} else {
		if (web_request_type(UTF8)) {
			printf(" dir= '1' title='%s'>", parent.descr);
		} else {
			GBK_BUFFER(descr, BOARD_DESCR_CCHARS);
			convert_u2g(parent.descr, gbk_descr);
			printf(" dir= '1' title='%s'>", gbk_descr);
		}
	}

	if (sid)
		res = db_query(BOARD_SELECT_QUERY_BASE "WHERE b.sector = %d", sid);
	else
		res = db_query(BOARD_SELECT_QUERY_BASE "WHERE b.parent = %d", parent.id);

	if (res && db_res_rows(res) > 0)
		show_board(res);
	db_clear(res);

	print_session();
	printf("</bbsboa>");
	return 0;
}

int bbsclear_main(void)
{
	if (!session_id())
		return BBS_ELGNREQ;

	board_t board;
	if (!get_board(web_get_param("board"), &board)
			|| !has_read_perm(&board))
		return BBS_ENOBRD;
	session_set_board(board.id);

	const char *start = web_get_param("start");
	brc_init(currentuser.userid, board.name);
	brc_clear_all();
	brc_sync(currentuser.userid);
	char buf[STRLEN];
	snprintf(buf, sizeof(buf), "doc?board=%s&start=%s", board.name, start);
	http_header();
	refreshto(0, buf);
	printf("</head></html>");
	return 0;
}

int bbsnot_main(void)
{
	board_t board;
	if (!get_board(web_get_param("board"), &board)
			|| !has_read_perm(&board))
		return BBS_ENOBRD;

	if (board.flag & BOARD_FLAG_DIR)
		return BBS_EINVAL;
	session_set_board(board.id);

	char fname[HOMELEN];
	snprintf(fname, sizeof(fname), "vote/%s/notes", board.name);
	mmap_t m;
	m.oflag = O_RDONLY;
	if (mmap_open(fname, &m) < 0)
		return BBS_ENOFILE;
	xml_header(NULL);
	printf("<bbsnot brd='%s'>", board.name);
	xml_fputs2((char *) m.ptr, m.size);
	mmap_close(&m);
	print_session();
	printf("</bbsnot>");
	return 0;
}
Example #9
0
int main()
{
    FILE *fp;
    char userid[80], buf[512], board[80], dir[80], file[512], filename[80];
    char ch, tmp[80], *ptr;
    struct fileheader x;
    int i, found=0;
    init_all();
    strsncpy(board, getparm("board"), 32);
    strsncpy(file, getparm("file"), 32);
    //printf("<head>我爱南开站-Telnet样式</head>");
    printf("<script language='javascript' src='/js/telnetview.js'></script>");//Js支持
    printf("<body bgproperties=fixed>",mytheme.bgpath);
    if (*file!='/') //帖子
    {
        modify_mode(u_info,READING);	//bluetent
        start=atoi(getparm("num"));
        if(!has_read_perm(&currentuser, board) && !HAS_PERM(PERM_SYSOP))
            http_fatal("错误的讨论区");
        if (!canenterboard (currentuser.userid, board) && !HAS_PERM(PERM_SYSOP))
            http_fatal ("您已经被取消进入本板的权限");
        strcpy(board, getbcache(board)->filename);
        if(loginok)
            brc_init(currentuser.userid, board);
        sprintf(dir, "boards/%s/.DIR", board);
        total=file_size(dir)/sizeof(struct fileheader);
        if(start>=total)
            start=total-1;
        if(start<0)
            start=0;
        fp=fopen(dir, "r+");
        if(fp==0)
            http_fatal("目录错误");
        if(start==0) {
            while(1) {
                if(fread(&x, sizeof(x), 1, fp)<=0) {
                    printf("文章不存在!");
                    break;
                }
                if(!strcmp(x.filename, file)) {
                    show_file(board,&x);
                    break;
                }
            }
            fcloseall();
            return 0;
        }

        fseek(fp,sizeof(struct fileheader)*start,SEEK_SET);
        if(fread(&x, sizeof(x), 1, fp)<=0)
            http_fatal("读取错误.");
        show_file(board,&x);
        fcloseall();
        return 0;
    }//帖子结束
    else {//精华区
        FILE *fp;
        modify_mode(u_info,DIGEST+20000);	//bluetent
        strsncpy(file, getparm("file"), 511);
        if(strstr(file, ".Search") || strstr(file, ".Names")|| strstr(file, "..")|| strstr(file, "SYSHome"))
            http_fatal("错误的文件名");
        sprintf(buf, "0Announce%s", file);
        fp=fopen(buf, "r");
        if(fp==0)
            http_fatal("错误的文件名");
        printf("<table><tr><td id=\"c\" bgcolor=\"black\" style=\"font-size:16px;line-height:1\"></td></tr></table>");
        printf("<script language=\"javascript\">\n\r	init();\n\r");
        printf("document.getElementById('c').innerHTML=previewthis('");

        while(1) {
            if(fgets(buf, 256, fp)==0)
                break;
            jsprint(void1(buf));
        }
        printf("');\n\r</script>");
        fclose(fp);
        //check_msg();//bluetent 2002.10.31
    }

    http_quit();
}