Example #1
0
static int choose_board_read(choose_t *cp)
{
	choose_board_t *cbrd = cp->data;
	board_data_t *ptr = cbrd->brds + cp->cur;
	if (ptr->flag & BOARD_DIR_FLAG) {
		int parent = cbrd->parent;
		const char *prefix = cbrd->prefix;
		bool recursive = cbrd->recursive;
		bool goodbrd = cbrd->goodbrd;
		int cur = cp->cur;

		cbrd->parent = ptr->pos;
		cbrd->prefix = NULL;
		cbrd->recursive = true;
		cbrd->goodbrd = (ptr->flag & BOARD_CUSTOM_FLAG) ? true : false;

		choose_board(cbrd);

		cbrd->parent = parent;
		cbrd->prefix = prefix;
		cbrd->recursive = recursive;
		cbrd->goodbrd = goodbrd;
		cp->cur = cur;
	} else {
		brc_initial(currentuser.userid, ptr->name);
		changeboard(&currbp, currboard, ptr->name);
		memcpy(currBM, ptr->BM, BM_LEN - 1);

		char buf[STRLEN];
		if (DEFINE(DEF_FIRSTNEW)) {
			setbdir(buf, currboard);
			int tmp = unread_position(buf, ptr);
			int page = tmp - t_lines / 2;
			getkeep(buf, page > 1 ? page : 1, tmp + 1);
		}
		board_read();
		brc_zapbuf(cbrd->zapbuf + ptr->pos);
		ptr->total = -1;
		currBM[0] = '\0';
	}
	return FULLUPDATE;
}
Example #2
0
int main()
{
	wml_init();
	wml_head();
	int i, tmp, max, min;
	int z;
	char board[80];
	char buf[256], buf2[256], title[256];
	FILE * fp;
	struct rmd r;
	if (loginok)
	{
		wmlmode(u_info, SELECT);
	}
	z = atoi(getparm("zone"));
	if (!*(getparm("zone")) || z < -1 || z >= SECNUM)
	{
		z = -3;//list mode
	}
	strncpy(board, getparm("board"), 79);
	if (*board)//zone模式
	{
		z = -2;
	}
	if (z == -3)
	{
		printf ("<card title=\"选择讨论区 -- %s\" >", BBSNAME);
		printf ("<p>");
		min = 0;
		if (loginok)
		{
			min -= 2;
		}
		for (i = min; i < SECNUM; i++)
		{
			if (i == -2)
			{
				printf ("&#32;&#32;<anchor><go href=\"bbsboa.wml?zone=-1\" />我的收藏</anchor>");
			}
			else if ( i == -1)
			{
				printf ("&#32;&#32;<anchor><go href=\"bbsdoc.wml?board=%s\" />查看邮箱</anchor>", WML_VB_MAIL);
			}
			else
			{
				printf ("&#32;&#32;<anchor><go href=\"bbsboa.wml?zone=%d\" />%s</anchor>", i, secname[i][0]);
			}
			if ((i & 1) && (i < SECNUM - 1))
			{
				printf ("<br />");
			}
		}
		printf ("</p>");
		fp = fopen(PATHRMD, "rb");
		if (fp)
		{
			printf ("<p><em>精彩推荐</em><br />");
			while (fread (&r, sizeof(struct rmd), 1, fp))
			{
				w_hsprintf(buf, "%s", r.cn);
				printf ("<anchor><go href=\"bbscon.wml?board=%s&amp;file=%s\" />%s</anchor> <anchor><go href=\"bbsqry.wml?userid=%s\" />%s</anchor>@<anchor><go href=\"bbsdoc.wml?board=%s\" />%s</anchor><br />", r.board, r.en, buf, r.owner, r.owner, r.board, r.board);
			}
			printf ("</p>");
			fclose (fp);
		}
		fp = fopen("etc/posts/day", "rt");
		if (fp)
		{
			printf ("<p><em>十大热门话题</em><br />");
			fgets(buf, 255, fp);
			fgets(buf, 255, fp);//跳过两行开头
			for(i = 1; i <= 10; i++) 
			{
				if (!fgets(buf, 255, fp))
				{
					break;
				}
				sscanf (buf + 45, "%s", board);
				if (!fgets(buf, 255, fp))//话说,显示ID没有用啊,反正也老出错
				{
					break;
				}
				strsncpy (title, buf + 27, 60);
				rtrims(title);
				printf ("<anchor><go href=\"bbstopic.wml?board=%s&amp;topic=%s\" />", board, urlencode2(title));
				w_hsprintf(buf2, "%s", title);
				printf ("%s</anchor> <anchor><go href=\"bbsdoc.wml?board=%s\" />%s板</anchor> <br />", buf2, board, board);
			}
			fclose (fp);
			printf ("</p>");
		}
		printf ("<p><input name=\"inp_goto\" /><anchor><go href=\"bbssel.wml\" method=\"post\"><postfield name=\"goto\" value=\"$(inp_goto)\" /></go>带我去</anchor></p>");
		wml_bar(0);
		printf ("</card>");
	}
	else//板面
	{
		struct shortfile data[MAXBOARD], *x;
		int total, br;
		printf ("<card title=\"%s -- %s\">", (z >= 0 ? secname[z][0] : (z == -1 ? "我的收藏" : board)), BBSNAME);
		if (z == -1)
		{
			char mybrd[GOOD_BRC_NUM][80];
			int mybrdnum = 0;
			mybrdnum = LoadMyBrdsFromGoodBrd(currentuser.userid, mybrd);
			for(i=0; i<mybrdnum; i++) 
			{
				if(!(x=getbcache(mybrd[i])))
				{
					continue;
				}
				if(x->filename[0] <= 32 || x->filename[0] > 'z')
				{
					continue;
				}
				if(!has_read_perm(&currentuser, x->filename))
				{
					continue;
				}
				if(x->flag & ZONE_FLAG)
				{
					continue;
				}
				data[total++] = *x;
			}
		}
		else
		{
			for(i = 0; i < MAXBOARD; i++) 
			{
				x = &(shm_bcache->bcache[i]);
				if(x->filename[0] <= 32 || x->filename[0] > 'z')
				{
					continue;
				}
				if(!has_read_perm(&currentuser, x->filename))
				{
					continue;
				}
				if(z >= 0 && !strchr(seccode[z], x->title[0]))
				{
					continue;
				}
				if (z == -2)
					//这是某个子分区
				{
					if(!(x->flag & CHILDBOARD_FLAG) && strcasecmp(x->owner, board))
					{
						continue;
					}
				}
				else
					//这是某个分区
				{
					if(x->flag & CHILDBOARD_FLAG)
					{
						continue;
					}
				}
				if((x->flag & ZONE_FLAG) && !count_zone(BOARDS, x->filename))
				{
					continue;
				}
				//节约资源?
				memcpy(&data[total], x, sizeof(struct shortfile));
				total++;
			}
			qsort(data, total, sizeof(struct shortfile), cmpboard);
			//printf ("<p><anchor><go href=\"userindex.wml?zone=%d\" />本区导读</anchor></p>", z);
		}
		for (i = 0; i < total; i++)
		{
			printf ("<p>");
			br = board_read(data[i].filename);
			printf ("<anchor><go href=\"%s.wml?board=%s\" />", (data[i].flag & ZONE_FLAG) ? "bbsboa" : "bbsdoc", data[i].filename);
			if (!br)
			{
				printf ("<em>&#42;");
			}
			w_hprintf ("%s/%s", data[i].title + 10, data[i].filename);
			if (!br)
			{
				printf ("</em>");
			}
			printf ("</anchor></p>");
		}
		wml_bar(0);
		printf ("</card>");
	}
	wml_tail();
	return 0;
}
Example #3
0
int
bbssbs_main()
{	
	int result[MAXBOARD], i, total=0;
	char keyword[80], *ptr, buf[128], bmbuf[(IDLEN + 1) * 4];
	struct boardmem *bp;
	
	html_header(1);
	check_msg();
	changemode(READING);
	strsncpy(keyword, getparm("keyword"), 32);
	printf("<body><center>");
	printf("<div class=rhead>%s -- 超级版面选择</div><hr>\n", BBSNAME);
	
	if (strlen(strtrim(keyword))) { 
		for (i = 0; i < shm_bcache->number && total < MAXBOARD ; i++){
			if (shm_bcache->bcache[i].header.filename[0] == '\0')
				continue;
			if (has_read_perm_x(&currentuser, &(shm_bcache->bcache[i].header))) {
				if (strcasestr(shm_bcache->bcache[i].header.filename, keyword) 
				 || strcasestr(shm_bcache->bcache[i].header.keyword, keyword) 
				 || strcasestr(shm_bcache->bcache[i].header.title, keyword) ){
					result[total] = i;
					total++;
				}
			}
		}
		if (total == 0){
			printf("Sorry,我真的帮你找了,没找到符合条件的讨论区啊!");
			printf("<p><a href=javascript:history.go(-1)>快速返回</a>");
			http_quit();
/*			
		}else if (total == 1){
			sprintf(buf, "%s?board=%s", "bbshome", shm_bcache->bcache[result[0]].header.filename);
			redirect(buf);
*/
		}else {
			printf("<table width=\"100%\" border=0 cellpadding=0 cellspacing=0><tr>\n"
				"<td width=40>&nbsp;</td>\n"
				"<td colspan=2 class=\"level1\"><TABLE width=\"90%\" border=0 cellPadding=2 cellSpacing=0>\n"
				"<TBODY>\n");
			printf("<TR>\n"
				"<TD class=tdtitle>未</TD>\n"
				"<TD class=tduser>讨论区名称</TD>\n"
				"<TD class=tdtitle>V</TD>\n"
				"<TD class=tdtitle>类别</TD>\n"
				"<TD class=tdtitle>中文描述</TD>\n"
				"<TD class=tdtitle>版主</TD>\n"
				"<TD class=tdtitle>文章数</TD>\n"
				"<TD class=tdtitle>人气</TD>\n"
				"<TD class=tdtitle>在线</TD>\n"
				"</TR>\n");
			//brc_initial(currentuser.userid, NULL);
			printf("<tr>\n");
			for (i = 0; i < total; i++){
				bp=&(shm_bcache->bcache[result[i]]);
				printf("<td class=tdborder>%s</td>\n", 
					board_read(bp->header.filename, bp->lastpost) ? "◇" : "◆");
				printf("<td class=tduser><a href=%s?B=%s >%s</a></td>\n",
					"bbsdoc", bp->header.filename, bp->header.filename);
				printf("<td class=tdborder>");
				if (bp->header.flag & VOTE_FLAG)
					printf("<a href=vote?B=%s>V</a>", bp->header.filename);
				else
					printf("&nbsp;");
				printf("</td>\n");
				printf("<td class=tdborder>[%4.4s]</td>\n", bp->header.type);
				printf("<td class=tdborder><a href=%s?B=%s>%s</a></td>\n",
					"bbshome",bp->header.filename, bp->header.title);
				ptr = userid_str(bm2str(bmbuf, &(bp->header)));
				if (strlen(ptr) == 0)
					printf("<td class=tdborder>诚征版主中</td>\n");
				else
					printf("<td class=tdborder>%s</td>\n", ptr);
				printf("<td class=tdborder>%d</td>\n"
					"<td class=tdborder>%d</td>\n"
					"<td class=tdborder>%d</td>\n</tr>\n",
					bp->total, bp->score, bp->inboard);
				setbfile(buf, bp->header.filename, "introduction");
				if (file_exist(buf)) { 
					printf("<tr><td>&nbsp;&nbsp;</td>\n"
						"<td class=tduser>版面简介: </td>\n"
						"<td class=tdborder colspan=7>"
						"<div title=\"本版关键字: %s\">\n", 
						bp->header.keyword[0] ? bp->header.keyword: "(暂无)");
					fshowcon(stdout, buf, 2);
					printf("</div></td></tr>\n");
				}
				printlastmark(bp->header.filename);
			}
			printf("</TR></TBODY></TABLE></td></tr></table>\n");
		}
	}
	printf("<br><form action=bbssbs>\n");
	printf
	    ("<div title=\"支持中英文版名/版面关键字定位至版面。例如,输入“铁路”可定位至traffic版。\">"
	    "<input name=keyword maxlength=20 size=20>\n");
	printf("<input type=submit value=开始搜索></div>\n");
	printf("</form><hr>\n");
	http_quit();
	return 0;	
}