Ejemplo n.º 1
0
int
oneboardscript(struct boardmem *brd)
{
	char bmbuf[IDLEN * 4 + 4], *ptr;
	int i, limit, brdnum, hasicon;
	struct boardaux *boardaux = getboardaux(getbnumx(brd));
	updatewwwindex(brd);
	brdnum = getbnumx(brd);
	hasicon = brd->wwwicon;
	if (hasicon)
		hasicon += hideboard_x(brd) ? 1 : 0;
	printf("new abrd(%d,'%s','%s',%d,%d,%d,%d,%d,",
	       brdnum, brd->header.filename, scriptstr(brd->header.title),
	       hasicon, brd->total, brd->score,
	       (brd->header.flag & VOTE_FLAG) ? 1 : 0,
	       (brd->header.
		level & PERM_POSTMASK) ? 2 : ((brd->header.
					       flag & CLOSECLUB_FLAG) ? 1 : 0));

	ptr = userid_str(bm2str(bmbuf, &(brd->header)));
	if (!*ptr)
		printf("'ипнч╟ФжВ',");
	else
		printf("'%s',", ptr);
	printf("'%s ',", scriptstr(boardaux->intro));
	limit = 8;
	if ((ptr = strstr(brd->header.filename, "admin"))) {
		if (strlen(ptr) == 5)
			limit = 4;
	}
	if ((brd->header.flag & CLOSECLUB_FLAG))
		printf("''");
	else {
		limit = min(limit, boardaux->nlastmark);
		printf("new Array(");
		for (i = 0; i < limit; i++) {
			struct lastmark *lm = &boardaux->lastmark[i];
			printf("new alm(%d,'%s','%s',%d)",
			       lm->thread, scriptstr(lm->title), 
			       lm->authors, lm->marked ? 1 : 0);
			if (i < limit - 1)
				printf(",");
		}
		printf(")");
	}
	printf(")");
	return 0;
}
Ejemplo n.º 2
0
int
bm_printboard(struct boardmem *bmem, char *who)
{
	if (chk_BM_id(who, &bmem->header) && has_view_perm_x(currentuser, bmem)) {
		printf("<a href=bbsdoc?B=%d>", getbnumx(bmem));
		printf("%s", bmem->header.filename);
		printf("</a> ");
	}
	return 0;
}
Ejemplo n.º 3
0
//secstr == NULL: all boards
//secstr == "": boards that doesnn't belong to any group
//return the bnum of one of the match boards
static int
searchlist_alphabetical(const char *sectitle, const char *secstr, char *match,
			int showintro, int *bnum)
{
	struct boardmem *(data[MAXBOARD]), *bx;
	int i, len = 0, total = 0;
	if (secstr) {
		len = strlen(secstr);
		if (len == 0)
			len = 1;
	}
	for (i = 0; i < MAXBOARD && i < shm_bcache->number; i++) {
		bx = &shm_bcache->bcache[i];
		if (secstr && strncmp(bx->header.sec1, secstr, len)
		    //&& strncmp(bx->header.sec2, secstr, len)
		    )
			continue;
		if (!strcasestr(bx->header.filename, match) &&
		    !strcasestr(bx->header.title, match) &&
		    !strcasestr(getboardaux(i)->intro, match))
			continue;
		if (has_view_perm_x(currentuser, bx)) {
			*bnum = i;
			data[total] = bx;
			total++;
		}
	}
	if (!total)
		return 0;

	printhr();
	printf("<b>·ÖÇø: <a href=boa?secstr=%s>%s</a></b>", secstr,
	       nohtml(sectitle));
	qsort(data, total, sizeof (struct boardmem *), (void *) cmpboard);
	printf("<table width=100%%>\n");
	for (i = 0; i < total; i++) {
		if (showintro || (i && i % 3 == 0))
			printf("</tr>");
		if (showintro || i % 3 == 0)
			printf("\n<tr valign=top bgcolor=%x>",
			       0xf0f0d0 | (unsigned) (i % 2) * 0x0f0f0f);
		printf
		    ("<td><a href='javascript:setEl(\"%s\")'><nobr>%s(%s)</nobr></a></td>",
		     data[i]->header.filename, data[i]->header.filename,
		     nohtml(data[i]->header.title));
		if (showintro) {
			struct boardaux *baux;
			baux = getboardaux(getbnumx(data[i]));
			if (baux != NULL)
				printf("<td>%s</td>", nohtml(baux->intro));
		}
	}
	printf("</table>\n");
	return total;
}
Ejemplo n.º 4
0
int
showExLinks2009(const struct sectree *sec, int num)
{
	char bname[30], buf[256], *line, *ptr;
	struct boardmem *x1;
	FILE *fp;
	char sitename[32], url[STRLEN], logo[32];
	
	if(sec == &sectree || !strcmp(sec->basestr,"0"))
		strcpy(bname, "sysop");
	else
		sprintf(bname, "%sadmin", sec->basestr);
	
	x1 = getboard2(bname);
	if(!x1 || !x1->wwwlink)
		return 0;
	sprintf(buf, MY_BBS_HOME "/ftphome/root/boards/%s/link/config.ini", bname);
	fp = fopen(buf, "r");
	if(fp == NULL)
		return 0;
	printf("<script language=javascript>\n\tvar links = new Array(\n");
	while(fgets(buf, sizeof(buf), fp)) {
		if(strchr("\r\n#", buf[0]))
			continue;
		line = buf;
		ptr = strchr(line, '\t');
		if(ptr) {
			*ptr = 0;
			strncpy(sitename, line, sizeof(sitename)-1);
		} else
			continue;
		line = ++ptr;
		ptr = strchr(line, '\t');
		if(ptr) {
			*ptr = 0;
			strncpy(url, line, sizeof(url)-1);
		} else
			continue;
		line = ++ptr;
		ptr = strchr(line, '\r');  // in case of windows format \r\n
		if(ptr == NULL)
			ptr = strchr(line, '\n');
		if(ptr)
			*ptr = 0;
		strncpy(logo, line, sizeof(logo)-1);

		printf("\tnew aLink('%s', '%s', '%s'),\n", sitename, url, logo);
	}
	printf("\tnew aLink(-1, -1, -1)\n);\n");
	printf("printExLinks(%d, %d);\n", getbnumx(x1), num);
	printf("</script>");
	fclose(fp);
	return 0;
}
Ejemplo n.º 5
0
int
bbsdenyadd_main()
{
	int i;
	char exp[80], board[80], *userid;
	int dt;
	struct userec *x;
	struct boardmem *x1;
	html_header(1);
	check_msg();
	if (!loginok || isguest)
		http_fatal("您尚未登录, 请先登录");
	changemode(READING);
	getparmboard(board, sizeof(board));
	strsncpy(exp, getparm("exp"), 30);
	dt = atoi(getparm("dt"));
	if (!(x1 = getboard(board)))
		http_fatal("错误的讨论区");
	if (!has_BM_perm(currentuser, x1))
		http_fatal("你无权进行本操作");
	loaddenyuser(board);
	userid = getparm("userid");
	if (userid[0] == 0)
		return show_form(board);
	if (getuser(userid, &x) <= 0)
		http_fatal("错误的使用者帐号");
	if (!has_post_perm(x, x1))
		http_fatal("这个人本来就没有post权");
	strcpy(userid, x->userid);
	if (!(currentuser->userlevel & PERM_SYSOP) && (dt > 14))
		http_fatal("封禁时间大于14天,超过了权限,若需要,请联系站长");
	if (dt < 1 || dt > 99)
		http_fatal("请输入被封天数(1-99)");
	if (exp[0] == 0)
		http_fatal("请输入封人原因");
	for (i = 0; i < denynum; i++)
		if (!strcasecmp(denyuser[i].id, userid))
			http_fatal("此用户已经被封");
	if (denynum > 40)
		http_fatal("太多人被封了");
	strsncpy(denyuser[denynum].id, userid, 13);
	strsncpy(denyuser[denynum].exp, exp, 30);
	denyuser[denynum].free_time = now_t + dt * 86400;
	denynum++;
	savedenyuser(board);
	printf("封禁 %s 成功<br>\n", userid);
	tracelog("%s deny %s %s", currentuser->userid, board, userid);
	inform(board, userid, exp, dt);
	printf("[<a href=bbsdenyall?B=%d>返回被封帐号名单</a>]", getbnumx(x1));
	http_quit();
	return 0;
}
Ejemplo n.º 6
0
int
genhotboard2009(struct hotboard *hb, const struct sectree *sec, int max)
{
	int count = 0, i, j, len;
	struct boardmem *bmem[MAXHOTBOARD], *x, *x1;
	if (max < 3 || max > MAXHOTBOARD)
		max = 10;
	if (max == hb->max && hb->uptime > shm_bcache->uptime)
		return hb->count;
	len = strlen(sec->basestr);
	for (i = 0; i < MAXBOARD && i < shm_bcache->number; i++) {
		x = &(shm_bcache->bcache[i]);
		if (x->header.filename[0] <= 32 || x->header.filename[0] > 'z')
			continue;
		if (hideboard_x(x))
			continue;
		if (strncmp(sec->basestr, x->header.sec1, len) &&
		    strncmp(sec->basestr, x->header.sec2, len))
			continue;
		for (j = 0; j < count; j++) {
			if (x->score > bmem[j]->score)
				break;
			if (x->score == bmem[j]->score
			    && x->inboard > bmem[j]->inboard)
				break;
		}
		for (; j < count; j++) {
			x1 = bmem[j];
			bmem[j] = x;
			x = x1;
		}
		if (count < max)
			bmem[count++] = x;
	}
	for (i = 0; i < count; i++) {
		strsncpy(hb->bname[i], bmem[i]->header.filename,
			 sizeof (hb->bname[0]));
		strsncpy(hb->title[i], bmem[i]->header.title,
			 sizeof (hb->title[0]));
		hb->bnum[i] = getbnumx(bmem[i]);
	}
	hb->max = max;
	hb->count = count;
	hb->uptime = now_t;
	hb->sec = sec;
	return count;
}
Ejemplo n.º 7
0
int
bbsbkndoc_main()
{
	FILE *fp;
	char board[80], bkn[80], dir[160], *ptr, genbuf[STRLEN];
	struct boardmem *x1;
	struct fileheader x;
	int i, start, total;
	html_header(1);
	printf("<script src=" BBSJS "></script>\n");
	changemode(BACKNUMBER);
	//check_msg();
	getparmboard(board, sizeof(board));
	strsncpy(bkn, getparm("bkn"), 32);
	ptr = bkn;
	while (*ptr) {
		if (*ptr != 'B' && *ptr != '.' && !isdigit(*ptr))
			http_fatal("错误的过刊号");
		ptr++;
	}
	if (strlen(bkn) < 3)
		http_fatal("错误的过刊号");

	x1 = getboard(board);
	if (x1 == 0)
		nosuchboard(board, "bbsbkndoc");
	else {
		updateinboard(x1);
		strcpy(board, x1->header.filename);
		sprintf(dir, "boards/.backnumbers/%s/%s", board, bkn);
		if (!file_exist(dir))
			http_fatal("没有这卷过刊");
		sprintf(dir, "boards/.backnumbers/%s/%s/.DIR", board, bkn);
		fp = fopen(dir, "r");
		total = file_size(dir) / sizeof (struct fileheader);
		start = getdocstart(total, w_info->t_lines);
		printf("<body topmargin=0>");
		printf("<nobr><center>\n");
		sprintf(genbuf, "阅览过刊 文章数[%d]", total);
		printboardtop(x1, 5, genbuf);
		if (total <= 0)
			http_fatal("本卷过刊目前没有文章");
		printf("<table cellSpacing=0 cellPadding=2>\n");
		printf
		    ("<tr class=docbgcolor><td>序号<td>状态<td>作者<td>日期<td>标题<td>星级<td>评价</td>\n");
		if (fp) {
			fseek(fp, (start - 1) * sizeof (struct fileheader),
			      SEEK_SET);
			for (i = 0; i < w_info->t_lines; i++) {
				char filename[255];
				char *ptr;
				if (fread(&x, sizeof (x), 1, fp) <= 0)
					break;
				if (x.accessed & FH_HIDE) {
					printf
					    ("<tr><td>%d<td>&nbsp;<td>不详<td>不详<td>-本文已经被删除-<td>\n",
					     start + i);
					continue;
				}
				ptr = flag_str2(x.accessed, 1);
				sprintf(filename,
					"boards/.backnumbers/%s/%s/%s", board,
					bkn, fh2fname(&x));
				printf("<tr><td>%d<td>%s<td>%s", start + i, ptr,
				       userid_str(x.owner));
				printf("<td>%12.12s", Ctime(x.filetime) + 4);
				x.title[40] = 0;
				printf
				    ("<td><a href=bbsbkncon?B=%d&bkn=%s&file=%s&num=%d>%s%s </a>%s",
				     getbnumx(x1), bkn, fh2fname(&x), start + i - 1,
				     strncmp(x.title, "Re: ", 4) ? "○ " : "",
				     void1(titlestr(x.title)),
				     size_str(eff_size(filename)));
				printf("<td><font color=%s>%d</font>\n",
				       x.staravg50 ? "red" : "black",
				       x.staravg50 / 50);
				printf("<td><font color=%s>%d人</font>\n",
				       x.hasvoted ? "red" : "black",
				       x.hasvoted);
			}
			printf("</table>");
			printhr();
			fclose(fp);
		}
		sprintf(genbuf, "bbsbkndoc?B=%d&bkn=%s", getbnumx(x1), bkn);
		bbsdoc_helper(genbuf, start, total, w_info->t_lines);
		printf("<table><tr><td><form name=form1 action=bbsbkndoc>\n");
		printf("<input type=hidden name=B value=%d>", getbnumx(x1));
		printf("<input type=hidden name=bkn value=%s>", bkn);
		printf
		    ("<input type=submit value=跳转到> 第 <input type=text name=start size=4> 篇");
		printf("</form>\n");
		printf("</td><td><form name=form2 action=bbsdoc>\n");
		printf
		    ("<input type=submit value=跳转到><input type=text name=board size=5> 讨论区");
		printf("</form></td></tr></table>\n");
		showfile(MY_BBS_HOME "/wwwtmp/googleanalytics");
		printf("</body>");
		http_quit();
	}
	return 0;
}
Ejemplo n.º 8
0
int
bbsbknsel_main()
{
	FILE *fp;
	char board[80], dir[160], genbuf[STRLEN];
	struct boardmem *x1;
	struct bknheader x;
	int i, start, total;
	html_header(1);
	printf("<script src=" BBSJS "></script>\n");
	//check_msg();
	changemode(SELBACKNUMBER);
	getparmboard(board, sizeof (board));
	x1 = getboard(board);
	if (x1 == 0)
		nosuchboard(board, "bbsbknsel");
	else {
		strcpy(board, x1->header.filename);
		sprintf(dir, "boards/.backnumbers/%s/.DIR", board);
		fp = fopen(dir, "r");
		if (fp == NULL)
			http_fatal("错误的讨论区");
		total = file_size(dir) / sizeof (struct bknheader);
		start = getdocstart(total, w_info->t_lines);
		printf("<body topmargin=0><nobr><center>\n");
		sprintf(genbuf, "选择过刊 过刊数[%d]", total);
		printboardtop(x1, 5, genbuf);
		if (total <= 0) {
			fclose(fp);
			http_fatal("本讨论区目前没有过刊");
		}
		printf("<table cellSpacing=0 cellPadding=2>\n");
		printf
		    ("<tr class=docbgcolor><td>序号</td><td>讨论区</td><td>建立日期</td><td>标题              </td></tr>\n");
		if (fp) {
			fseek(fp, (start - 1) * sizeof (struct bknheader),
			      SEEK_SET);
			for (i = 0; i < w_info->t_lines; i++) {
				if (fread(&x, sizeof (x), 1, fp) <= 0)
					break;
				printf("<tr><td>%d</td><td>%s</td>",
				       start + i, x.boardname);
				if (!i)
					printf("<td><nobr>%12.12s</td>",
					       Ctime(x.filetime) + 4);
				else
					printf("<td>%12.12s</td>",
					       Ctime(x.filetime) + 4);
				printf
				    ("<td><a href=bbsbkndoc?B=%d&bkn=%s&num=%d>○ %s </a></td></tr>",
				     getbnumx(x1), bknh2bknname(&x), start + i - 1,
				     void1(titlestr(x.title)));
			}
			printf("</table>");
			printhr();
			fclose(fp);
		}
		printf("选择过刊 过刊数[%d] ", total);
		sprintf(genbuf, "bbsbknsel?B=%d", getbnumx(x1));
		bbsdoc_helper(genbuf, start, total, w_info->t_lines);
		printdocform("bbsbknsel", getbnumx(x1));
		http_quit();
	}
	return 0;
}