Ejemplo n.º 1
0
int main()
{
        struct shortfile data[MAXBOARD], *x;
        int i, total=0;
        int all=0;//所有品味文章的用户数
        init_all();
        getdatestring(time(0), NA);
        printf("<body background=/bg_1.gif bgproperties=fixed>");
        printf("<center>%s -- 当前板面在线人数排行 (%s)\n<hr>\n", BBSNAME, datestring);
        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;
                memcpy(&data[total], x, sizeof(struct shortfile));
                total++;
                all+=*((int*)(x->filename+72));
        }
        qsort(data, total, sizeof(struct shortfile), cmpboard);
        printf("<table><tr><td>排名<td>板面名称<td>中文名称<td>在线人数<td>百分比");
        for(i=0; i<total; i++) {
                printf("<tr><td>%3d", i+1);
                printf("<td>%s", data[i].filename);
                printf("<td>%s", data[i].title+8);
                printf("<td align=right>%d", *((int*)(data[i].filename+72)));
                printf("<td align=right>%5.2f%%", (*((int*)(data[i].filename+72)))*100.0/all);
        }

        return 1;
}
Ejemplo n.º 2
0
int web_sel(void)
{
	xml_header("bbssel");
	printf("<bbssel>");
	print_session();

	const char *brd = web_get_param("brd");
	if (*brd != '\0') {
		char name[BOARD_NAME_LEN + 3];
		snprintf(name, sizeof(name), "%%%s%%", brd);

		db_res_t *res = db_query(BOARD_SELECT_QUERY_BASE
				"WHERE lower(b.name) LIKE %s", name);
		if (res && db_res_rows(res) > 0) {
			board_t board;
			for (int i = 0; i < db_res_rows(res); ++i) {
				res_to_board(res, i, &board);
				if (has_read_perm(&board)) {
					board_to_gbk(&board);
					printf("<brd dir='%d' title='%s' desc='%s' />",
							is_board_dir(&board), board.name, board.descr);
				}
			}
		} else {
			printf("<notfound/>");
		}
		db_clear(res);
	}
	printf("</bbssel>");
	return 0;
}
Ejemplo n.º 3
0
int main()
{
        int i;
        int shift=1;	//wzk
        char board[80];
        init_all();
        if(!loginok)
                http_fatal("您尚未登录, 请先登录");
        strsncpy(board, getparm("board"), 30);
        if(!has_read_perm(&currentuser, board))
                http_fatal("错误的讨论区");
        if(!has_BM_perm(&currentuser, board))
                http_fatal("你无权进行本操作");
        loaddenyuser(board);
        printf("<center>\n");
        printf("%s -- 被封用户名单 [讨论区: %s]<hr color=green><br>\n", BBSNAME, board);
        printf("本板共有 %d 人被封<br>", denynum);
        printf("<table border=0><tr class=title><td>序号<td>用户帐号<td>被封原因<td>原定解封日期<td>管理\n");
        for(i=0; i<denynum; i++) {
                printf("<tr><td>%d", i+1);
                printf("<td><a href=bbsqry?userid=%s>%s</a>", denyuser[i].id, denyuser[i].id);
                printf("<td>%s\n", nohtml(denyuser[i].exp));
                printf("<td>%s\n", denyuser[i].free_time);
                printf("<td>[<a onclick='return confirm(\"确实解封吗?\")' href=bbsdenydel?board=%s&userid=%s>解封</a>]",
                       board, denyuser[i].id);
        }
        printf("</table><hr color=green>\n");
        printf("[<a href=bbsdenyadd?board=%s>设定新的不可POST用户</a>]</center>\n", board);
        http_quit();
}
Ejemplo n.º 4
0
int main()
{
        struct fileheader *x;
        char board[80], file[80], target[80];
        init_all();
        strsncpy(board, getparm("board"), 30);
        strsncpy(file, getparm("file"), 30);
        strsncpy(target, getparm("target"), 30);
        if(!loginok)
                http_fatal("匆匆过客不能进行本项操作");
        if(!has_read_perm(&currentuser, board))
                http_fatal("错误的讨论区");
        x=get_file_ent(board, file);
        if(x==0)
                http_fatal("错误的文件名");
        printf("<center>%s -- 转寄/推荐给好友 [使用者: %s]<hr color=green>\n", BBSNAME, currentuser.userid);
        if(target[0]) {
                if(!strstr(target, "@")) {
                        if(!getuser(target))
                                http_fatal("错误的使用者帐号");
                        strcpy(target, getuser(target)->userid);
                }
                return do_fwd(x, board, target);
        }
        printf("<table><tr><td>\n");
        printf("文章标题: %s<br>\n", nohtml(x->title));
        printf("文章作者: %s<br>\n", x->owner);
        printf("原讨论区: %s<br>\n", board);
        printf("<form action=bbsfwd method=post>\n");
        printf("<input type=hidden name=board value=%s>", board);
        printf("<input type=hidden name=file value=%s>", file);
        printf("把文章转寄给 <input name=target size=30 maxlength=30 value=%s> (请输入对方的id或email地址). <br>\n",
               currentuser.email);
        printf("<input type=submit value=确定转寄></form>");
}
Ejemplo n.º 5
0
int main()
{
        FILE *fp;
        char board[80], dir[80], *ptr, flag[80];
        struct shortfile *x1;
        struct fileheader x;
        int i, start, total, my_t_lines=0, chart=0, showhead=0;
        init_all();
        strsncpy(board, getparm("board"), 32);
        my_t_lines=atoi(getparm("my_t_lines"));
        if(my_t_lines<10 || my_t_lines>40)
                my_t_lines=20;
        x1=getbcache(board);
        if(x1==0)
                http_fatal("错误的讨论区");
        strcpy(board, x1->filename);
        board_ban_ip(board);
        if (!canenterboard (currentuser.userid, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal ("您已经被取消进入本板的权限");
        if(!has_read_perm(&currentuser, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal("错误的讨论区");
        if(!has_BM_perm(&currentuser, board))
                http_fatal("您没有权限访问本页");

        modify_mode(u_info,READING);	//bluetent
        sprintf(dir, "boards/%s/.DIR", board);
        fp=fopen(dir, "r");
        if(fp==0)
                http_fatal("错误的讨论区目录");
        total=file_size(dir)/sizeof(struct fileheader);
        start=atoi(getparm("start"));
        if(strlen(getparm("start"))==0 || start>total-my_t_lines)
                start=total-my_t_lines;
        if(start<0)
                start=0;
        printf("<nobr><center>\n");
        strcpy(u_info->board, board);
        /*	printf("%s -- [讨论区: %s] 板主[%s] 文章数[%d]<hr color=green>\n",
        		BBSNAME, board, userid_str(x1->BM), total);
        	if(total<=0) http_fatal("本讨论区目前没有文章");
        	printf("<form name=form1 method=post action=bbsman>\n");
              	printf("<table width=613>\n");
              	printf("<tr><td>序号<td>管理<td>状态<td>作者<td>日期<td>标题\n");
        	fseek(fp, start*sizeof(struct fileheader), SEEK_SET);*/
        printf("<script language=JavaScript>\
               \
               function MM_jumpMenu(selObj){\
               eval(\"window.location='\"+selObj.options[selObj.selectedIndex].value+\"'\");\
       }\
               function SubmitFlag(flagmode){\
               document.form1.mode.value=flagmode;\
               document.form1.submit();\
       }\
       function selrange(x)\
       {if(event.shiftKey){var min=x;var max=document.getElementById('lastsel').value;if(min>max){var tmp=min;min=max;max=tmp;}var stt=document.getElementById('chk'+x).checked;for(var i=min;i<=max;i++)document.getElementById('chk'+i).checked=stt;}document.getElementById('lastsel').value=x;}\
               </script>\
Ejemplo n.º 6
0
int
bbssel_main()
{
    char *board, buf[80], *board1, *title;
    int i, total = 0;
    html_header(1);
    check_msg();
    changemode(SELECT);
    board = nohtml(getparm("board"));
    if (board[0] == 0) {
        printf("%s -- 选择讨论区<hr>\n", BBSNAME);
        printf("<form action=bbssel>\n");
        printf("讨论区名称: <input type=text name=board>");
        printf(" <input type=submit value=确定>");
        printf("</form>\n");
        http_quit();
    } else {
        struct boardmem *x;
        x = getboard(board);
        if (x) {
            sprintf(buf, "%s%s", showByDefMode(), x->header.filename);
            redirect(buf);
            http_quit();
        }
        printf("%s -- 选择讨论区<hr>\n", BBSNAME);
        printf("找不到这个讨论区, ", board);
        printf("标题中含有'%s'的讨论区有: <br><br>\n", board);
        printf("<table>");
        for (i = 0; i < MAXBOARD && i < shm_bcache->number; i++) {
            board1 = shm_bcache->bcache[i].header.filename;
            title = shm_bcache->bcache[i].header.title;
            if (!has_read_perm(&currentuser, board1))
                continue;
            if (strcasestr(board1, board)
                    || strcasestr(title, board)) {
                total++;
                printf("<tr><td>%d", total);
                printf
                ("<td><a href=%s%s>%s</a><td>%s<br>\n",
                 showByDefMode(), board1, board1, title + 7);
            }
        }
        printf("</table><br>\n");
        printf("共找到%d个符合条件的讨论区.\n", total);
    }
}
Ejemplo n.º 7
0
int bbsbrdchg_act(char * info)
{
	int i, num;
	int add;
	char board[80];
	strcpy (board, getparm("board"));
	if (!loginok)
	{
		strcpy (info, "匆匆过客无法使用收藏夹");
		return -1;
	}
	if (!has_read_perm(&currentuser, board))
	{
		strcpy (info, "不正确的板面。");
		return -2;
	}
	add = 1;
	num = LoadMyBrdsFromGoodBrd(currentuser.userid, mybrd);
	for (i = 0; i < num; i++)
	{
		if (!strcasecmp(board, mybrd[i]))
		{
			memmove (mybrd[i], mybrd[i + 1], 80 * (num - i - 1));
			printf ("<card title=\"取消订阅 -- %s\">", BBSNAME);
			printf ("<p>板面“%s”取消成功。</p>", board);
			num --;
			add = 0;
			break;
		}
	}
	if (add)
	{
		if (num + 1 > GOOD_BRC_NUM)
		{
			sprintf (info, "收藏夹上限为%d。不能继续收藏板面。", GOOD_BRC_NUM);
			return -3;
		}
		strcpy (mybrd[num], board);
		printf ("<card title=\"订阅板面 -- %s\">", BBSNAME);
		printf ("<p>板面“%s”订阅成功。</p>", board);
		num++;
	}
	SaveMyBrdsToGoodBrd(currentuser.userid, mybrd, num);
	return 0;
}
Ejemplo n.º 8
0
int web_all_boards(void)
{
	xml_header(NULL);
	printf("<bbsall>");
	print_session();

	db_res_t *res = db_query(BOARD_SELECT_QUERY_BASE);
	if (!res)
		return BBS_EINTNL;
	for (int i = 0; i < db_res_rows(res); ++i) {
		board_t board;
		res_to_board(res, i, &board);
		if (!has_read_perm(&board))
			continue;
		board_to_gbk(&board);
		printf("<brd dir='%d' title='%s' cate='%s' desc='%s' bm='%s' />",
				(board.flag & BOARD_FLAG_DIR) ? 1 : 0, board.name, board.categ,
				board.descr, board.bms);
	}
	db_clear(res);

	printf("</bbsall>");
	return 0;
}
Ejemplo n.º 9
0
int api_board_all(void)
{
	db_res_t *res = db_query(BOARD_SELECT_QUERY_BASE);
	if (!res)
		return WEB_ERROR_INTERNAL;

	xml_node_t *root = set_response_root("bbs-board-all",
			XML_NODE_ANONYMOUS_JSON, XML_ENCODING_UTF8);
	xml_node_t *boards = xml_new_node("boards", XML_NODE_CHILD_ARRAY);
	xml_add_child(root, boards);

	for (int i = db_res_rows(res) - 1; i >= 0; --i) {
		board_t board;
		res_to_board(res, i, &board);
		if (!has_read_perm(&board))
			continue;

		xml_node_t *node = xml_new_node("board", XML_NODE_ANONYMOUS_JSON);
		board_to_node(&board, node);
		xml_add_child(boards, node);
	}
	db_clear(res);
	return WEB_OK;
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
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;
	}
}
Ejemplo n.º 12
0
int bbs0an_main(void)
{
	char path[512];
	board_t board;
	int bid = strtol(web_get_param("bid"), NULL, 10);
	if (bid <= 0) {
		strlcpy(path, web_get_param("path"), sizeof(path));
		if (strstr(path, "..") || strstr(path, "SYSHome"))
			return BBS_EINVAL;
		char *bname = getbfroma(path);
		if (*bname != '\0') {
			if (!get_board(bname, &board) || !has_read_perm(&board))
				return BBS_ENODIR;
		}
	} else {
		if (!get_board_by_bid(bid, &board) || !has_read_perm(&board))
			return BBS_ENOBRD;
		if (board.flag & BOARD_FLAG_DIR)
			return BBS_EINVAL;

		path[0] = '\0';
		FILE *fp = fopen("0Announce/.Search", "r");
		if (fp == NULL)
			return BBS_EINTNL;
		char tmp[256];
		int len = strlen(board.name);
		while (fgets(tmp, sizeof(tmp), fp) != NULL) {
			if (!strncmp(tmp, board.name, len) && tmp[len] == ':'
					&& tmp[len + 1] == ' ') {
				tmp[len + 1] = '/';
				strlcpy(path, tmp + len + 1, sizeof(path));
				path[strlen(path) - 1] = '\0';
				break;
			}
		}
		fclose(fp);
		if (path[0] == '\0')
			return BBS_ENODIR;
	}
	char names[512];
	snprintf(names, sizeof(names), "0Announce%s/.Names", path);
	FILE *fp = fopen(names, "r");
	if (fp == NULL)
		return BBS_ENODIR; // not indicating hidden directories.
	char buf[512], *title;
	// check directory permission.
	while (true) {
		if (fgets(buf, sizeof(buf), fp) == NULL) {
			fclose(fp);
			return BBS_ENODIR;
		}
		if(!strncmp(buf, "# Title=", 8)) {
			title = buf + 8;
			if (!hasannperm(title, &currentuser, &board)) {
				fclose(fp);
				return BBS_ENODIR;
			}
			break;
		}
	}

	xml_header(NULL);
	printf("<bbs0an path='%s' v='%d' ", path, 1030);
	if (board.id)
		printf(" brd='%s'", board.name);
	printf(">");
	print_session();
	
	char name[STRLEN], fpath[1024], *id = NULL, *ptr;
	struct stat st;
	while (fgets(buf, sizeof(buf), fp) != NULL) {
		if (!strncmp(buf, "Name=", 5)) {
			strlcpy(name, trim(buf + 5), sizeof(name));
			if (strlen(name) > ANN_TITLE_LENGTH) {
				id = name + ANN_TITLE_LENGTH;
				if (!hasannperm(name + ANN_TITLE_LENGTH, &currentuser, &board))
					continue;
				name[ANN_TITLE_LENGTH -  1] = '\0';
				if (!strncmp(id, "BM: ", 4))
					id += 4;
				if ((ptr = strchr(id, ')')) != NULL)
					*ptr = '\0';
			} else {
				id = NULL;
			}
			if (fgets(buf, sizeof(buf), fp) == NULL || strncmp(buf, "Path=~", 6)) {
				break;
			} else {
				printf("<ent path='%s' t='", trim(buf + 6));
				snprintf(fpath, sizeof(fpath), "0Announce%s%s", path, buf + 6);
				if (stat(fpath, &st) != 0 || (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode))) {
					printf("e'");
				} else if (S_ISREG(st.st_mode)) {
					printf("f'");
				} else {
					printf("d'");
				}
				if (id != NULL)
					printf(" id='%s'", id);
				printf(" time='%s'>", format_time(st.st_mtime, TIME_FORMAT_XML));
				xml_fputs4(trim(name), 0);
				printf("</ent>");
			}
		}
	}
	fclose(fp);
	puts("</bbs0an>");
	return 0;
}
Ejemplo n.º 13
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;
}
Ejemplo n.º 14
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();
}
Ejemplo n.º 15
0
int main()
{
        FILE *fp;
        char buf[1024], title[80], board[80], dir[80], first_file[80], userid[16];
        struct shortfile *x1;
        struct fileheader x, x0;
        int sum=0, total=0, sumfirst=0;
        init_all();
        strsncpy(board, getparm("board"), 32);
        strsncpy(title, getparm("title"), 42);
        x1=getbcache(board);
        if(x1==0)
                http_fatal("错误的讨论区");
        strcpy(board, x1->filename);
        if(!has_read_perm(&currentuser, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal("错误的讨论区");
        if (!canenterboard (currentuser.userid, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal ("您已经被取消了进本板的权限");
        sprintf(buf, "bbsman?board=%s&mode=1", board);
        sprintf(dir, "boards/%s/.DIR", board);
        fp=fopen(dir, "r");
        if(fp==0)
                http_fatal("错误的讨论区目录");
        printf("<body background=%s bgproperties=fixed>",mytheme.bgpath);
        printf("<center>%s -- 同主题展开阅读 <a href=bbsdoc?board=%s>[讨论区: %s] </a>[主题 '%s']</center>\n",
               BBSNAME, board, board,nohtml(title));
        //		printf("<table width=100%% bgcolor=#65c8aa border=0 cellpadding=0 cellspacing=0 height=1><tr><td></table>");
        //	printf("<table border=1><tr><td>编号<td>作者<td>日期<td>标题\n");
        while(1) {
                if(fread(&x, sizeof(x), 1, fp)==0)
                        break;
                sum++;
                if(!strncmp(title, x.title, 40) ||
                                (!strncmp(title, x.title+4, 40) && !strncmp(x.title, "Re: ", 4))) {
                        if(total==0)
                                strcpy(first_file, x.filename);
                        strcpy(userid, x.owner);
                        /*			printf("<tr><td>%d", sum);
                        			printf("<td>%s", userid_str(x.owner));
                        			if(!(x.accessed[0]&(FILE_MARKED|FILE_DIGEST))) {
                        				char buf2[20];
                        				sprintf(buf2, "&box%s=on", x.filename);
                        				if(strlen(buf)<500) strcat(buf, buf2);
                        			}
                        			printf("<td>%6.6s", Ctime(atoi(x.filename+2))+4);
                        			printf("<td><a href=bbscon?board=%s&file=%s&num=%d>%s</a>\n", 
                        				board, x.filename, sum-1, void1(x.title));*/
                        if (userid[0]=='-')
                                continue;
                        else
                                show_file(board, &x, sum-1);
                        total++;
                        if(total==1)
                                sumfirst=sum-1;
                }
        }
        fclose(fp);
        printf("\n本主题共有文章 %d 篇 \n", total);
        printf("<a href=bbsdoc?board=%s&start=%d>本讨论区</a> ", board, sumfirst);
        if(total>0) {
                if(has_BM_perm(&currentuser, board))
                        printf("<a onclick='return confirm(\"确定同主题全部删除?\")' href=%s>同主题删除</a>", buf);
        }
        //printf("</center>");
        http_quit();
}
Ejemplo n.º 16
0
int bbstopic_act(char * info)
{
    char board[80], topic[256], curr[256];
    int boardmode, start;
    int total, cnt, i, tmp, ismail, slen;
    struct fileheader fh[WMLP_TPOST_PER_PAGE], fhs[WMLP_TPOST_PER_PAGE], fh1[WMLP_TPOST_PER_PAGE];
    struct shortfile * b;
    char buf[256], buf2[256];
    char * ptr;
    FILE * fp;
    if (loginok)
    {
        wmlmode (u_info, READING);
    }
    strncpy (board, getparm("board"), 79);
    strncpy (topic, getparm("topic"), 255);
    strncpy (curr, getparm("curr"), 255);
    boardmode = atoi(getparm ("mode"));
    start = atoi(getparm("start"));
    ismail = !strcmp(board, WML_VB_MAIL);
    boardModeDir(board, boardmode, buf, buf2);
    b = getbcache(board);
    if (!*topic)
    {
        strcpy (info, "缺少主题。");
        return -1;
    }
    if (!loginok || (!ismail && (!has_read_perm(&currentuser, board) )))
    {
        strcpy (info, "权限不够。");
        return -2;
    }
    fp = fopen (buf, "rb");
    if (!fp)
    {
        sprintf (info, "无法打开索引。");
        return -1;
    }
    printf ("<card title=\"主题树 -- %s\">", BBSNAME);
    if (ismail)
    {
        printf ("<p><anchor><go href=\"bbsdoc.wml?board=%s\" />信箱</anchor></p>", WML_VB_MAIL);
    }
    else
    {
        printf ("<p>板面:<anchor><go href=\"bbsdoc.wml?board=%s&amp;mode=%d\" />%s/%s</anchor></p>", b->filename, boardmode, b->title + 11, b->filename);
    }
    w_hsprintf (buf, "%s", topic);
    printf ("<p>主题:%s</p>", buf);
    cnt = 0;
    slen = 0;
    start --;
    memset (fhs, 0, sizeof(fhs));
    while (tmp = fread(fh, sizeof(struct fileheader), WMLP_TPOST_PER_PAGE, fp))
    {
        for (i = 0; i < tmp; i++)
        {
            ptr = (fh + i)->title;
            if (!strncasecmp(ptr, "Re: ", 3))
            {
                ptr += 4;
            }
            if (!strncmp(topic, ptr, 56))
            {
                cnt++;
                if (start < 0 || start / WMLP_TPOST_PER_PAGE <= cnt / WMLP_TPOST_PER_PAGE)
                {
                    *(fhs + slen) = *(fh + i);
                    slen = slen % WMLP_TPOST_PER_PAGE + 1;
                    //循环使用好吧。
                }
                if (curr && !strcmp((fh + i)->filename, curr))
                {
                    start = (cnt - 1) / WMLP_TPOST_PER_PAGE * WMLP_TPOST_PER_PAGE;
                }
                if (cnt == WMLP_TPOST_PER_PAGE)
                {
                    memcpy (fh1, fhs, sizeof(fh1));
                }
            }
        }
    }
    if (start < 0)
    {
        if (cnt > WMLP_TPOST_PER_PAGE)
        {
            memcpy (fhs, fh1, sizeof(fh1));
            slen = WMLP_TPOST_PER_PAGE;
        }
        start = 0;
    }
    printf ("<p>同主题%d篇,以下显示%d至%d。</p>", cnt, start + 1, start + slen);
    for (i = 0; i < slen; i++)
    {
        ptr = ismail ? (((fhs + i)->accessed[0] & FILE_READ) ? "" : "N") : flag_str2 ((fhs + i)->accessed[0], brc_has_read((fhs + i)->filename));
        printf ("<p>%s %s ", strncasecmp((fhs + i)->title, "Re: ", 3) ? "T" : "R", ptr);
        strncpy (buf, (fhs + i)->owner, IDLEN + 1);
        for (ptr = buf; *ptr; ptr++)
        {
            if (!(isalnum(*ptr)))
            {
                *ptr = 0;
                break;
            }
        }
        printf ("<anchor><go href=\"bbsqry.wml?userid=%s\" />%s</anchor> ", buf, buf);
        printf ("<anchor><go href=\"bbscon.wml?board=%s&amp;mode=%d&amp;file=%s\" />", board, boardmode, (fhs + i)->filename);
        datetime (buf, atoi((fhs + i)->filename + 2));
        w_hprintf ("%s", buf);
        printf ("</anchor></p>");
    }
    if (cnt > WMLP_TPOST_PER_PAGE)
    {
        printf ("<p>");
        strcpy (buf, urlencode2(topic));
        for (i = 0; i <= cnt / WMLP_TPOST_PER_PAGE; i++)
        {
            if (i == 0 || i == cnt / WMLP_TPOST_PER_PAGE || abs(i - (start / WMLP_TPOST_PER_PAGE)) < 3)
            {
                if (i == start / WMLP_TPOST_PER_PAGE)
                {
                    printf ("%d ", i + 1);
                }
                else
                {
                    printf ("<anchor><go href=\"bbstopic.wml?board=%s&amp;mode=%d&amp;topic=%s&amp;start=%d\" />%d</anchor> ", board, boardmode, buf, (i * WMLP_TPOST_PER_PAGE) + 1, i + 1);
                }
            }
        }
        printf ("</p>");
    }
    return 0;
}