예제 #1
0
파일: bbsman.c 프로젝트: bmybbs/bmybbs
int
do_del(char *board, char *file)
{
	FILE *fp;
	int num = 0, filetime;
	char path[256], buf[256], dir[256], *id = currentuser.userid;
	struct fileheader f;
	filetime = atoi(file + 2);
	sprintf(dir, "boards/%s/.DIR", board);
	sprintf(path, "boards/%s/%s", board, file);
	fp = fopen(dir, "r");
	if (fp == 0)
		http_fatal("错误的参数");
	while (1) {
		if (fread(&f, sizeof (struct fileheader), 1, fp) <= 0)
			break;
		if (f.filetime == filetime) {
			del_record(dir, sizeof (struct fileheader), num);
			cancelpost(board, id, &f, !strcmp(id, f.owner));
			updatelastpost(board);
			fclose(fp);
			printf("<tr><td>%s  <td>标题:%s <td>删除成功.\n",
			       fh2owner(&f), nohtml(f.title));
			snprintf(buf, 256, "%s del %s %s %s",
				 currentuser.userid, board, fh2owner(&f),
				 f.title);
			newtrace(buf);
			return 0;
		}
		num++;
	}
	fclose(fp);
	printf("<tr><td><td>%s<td>文件不存在.\n", file);
	return -1;
}
예제 #2
0
파일: bbsman.c 프로젝트: bmybbs/bmybbs
int
do_set(char *dirptr, int size, char *file, int flag, char *board)
{
	char path[256], buf[256];
	struct fileheader *f;
	int om, og, nm, ng, filetime;
	int start;
	int total = size / sizeof(struct fileheader);
	filetime = atoi(file + 2);
	sprintf(path, "boards/%s/%s", board, file);

	start = Search_Bin(dirptr, filetime,0 , total - 1);
	if (start >= 0) {
		f = (struct fileheader*)(dirptr + start * sizeof(struct fileheader));
		om = f->accessed & FH_MARKED;
		og = f->accessed & FH_DIGEST;
		f->accessed |= flag;
		if (flag == 0) 
			f->accessed = 0;
		nm = f->accessed & FH_MARKED;
		ng = f->accessed & FH_DIGEST;
		printf("<tr><td>%s<td>标题:%s<td>标记成功.\n",
		       fh2owner(f), nohtml(f->title));
		buf[0] = 0;
		if ((!om) && (nm))
			snprintf(buf, 256, "%s mark %s %s %s",
				 currentuser.userid, board,
				 fh2owner(f), f->title);
		if ((om) && (!nm))
			snprintf(buf, 256, "%s unmark %s %s %s",
				 currentuser.userid, board,
				 fh2owner(f), f->title);
		if ((!og) && (ng))
			snprintf(buf, 256, "%s digest %s %s %s",
				 currentuser.userid, board,
				 fh2owner(f), f->title);
		if ((og) && (!ng))
			snprintf(buf, 256, "%s undigest %s %s %s",
				 currentuser.userid, board,
				 fh2owner(f), f->title);
		if (buf[0] != 0)
			newtrace(buf);
		return 0;
	}
	printf("<td><td><td>%s<td>文件不存在.\n", file);
	return -1;
}
예제 #3
0
int
bbsnewmail_main()
{
	FILE *fp;
	struct fileheader x;
	int total = 0, total2 = 0;
	char dir[80];
	if (!loginok || isguest)
		http_fatal("您尚未登录, 请先登录");
	sprintf(dir, "mail/%c/%s/.DIR", mytoupper(currentuser->userid[0]),
		currentuser->userid);

	if (cache_header(file_time(dir), 1))
		return 0;
	html_header(1);
	//check_msg();
	changemode(RMAIL);
//去掉了框架
	printf("<body topmargin=0 leftMargin=1 MARGINWIDTH=1 MARGINHEIGHT=0>" WWWLEFT_DIV);
	printf("<center>\n");
	printf
	    ("%s -- 未读邮件列表 [使用者: %s] [信箱容量: %dk, 已用空间: %dk]<hr>\n",
	     BBSNAME, currentuser->userid, max_mailsize(currentuser), get_mailsize(currentuser));
	fp = fopen(dir, "r");
	if (fp == 0)
		http_fatal("目前您的信箱没有任何信件");
	printf("<table border=1>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>发信人</td><td>日期</td><td>信件标题</td></tr>\n");
	while (1) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		total++;
		if (x.accessed & FH_READ)
			continue;
		printf("<tr><td>%d</td><td>N</td>", total);
		printf("<td>%s</td>", userid_str(fh2owner(&x)));
		printf("<td>%6.6s</td>", Ctime(x.filetime) + 4);
		printf("<td><a href=bbsmailcon?file=%s&num=%d>", fh2fname(&x),
		       total - 1);
		if (strncmp("Re: ", x.title, 4))
			printf("★ ");
		hprintf("%42.42s", void1(x.title));
		printf(" </a></td></tr>\n");
		total2++;
	}
	fclose(fp);
	printf("</table><hr>\n");
	printf("您的信箱共有%d封信件, 其中新信%d封.", total, total2);
	printf("</center>");
	showfile(MY_BBS_HOME "/wwwtmp/googleanalytics");
//	printf("</body>");
	//修改框架,页面底部
	printf(WWWFOOT_DIV "</body></html>\n");
	http_quit();
	return 0;
}
예제 #4
0
파일: bbsnewmail.c 프로젝트: bmybbs/bmybbs
int
bbsnewmail_main()
{	//modify by mintbaggio 20040829 for new www
	FILE *fp;
	struct fileheader x;
	int total = 0, total2 = 0;
	char dir[80];
	if (!loginok || isguest)
		http_fatal("您尚未登录, 请先登录");
	sprintf(dir, "mail/%c/%s/.DIR", mytoupper(currentuser.userid[0]),
		currentuser.userid);

	if(cache_header(file_time(dir),1))
		return 0;
	html_header(1);
	check_msg();
	changemode(RMAIL);
	printf("<body><center>\n");
	printf
	    ("<div class=rhead>%s -- 新邮件列表 [使用者: <span class=h11>%s</span>]<br>[信箱容量: <span class=h11>%d</span>k, 已用空间: <span class=h11>%dk</span>]</div><hr>\n",
	     BBSNAME, currentuser.userid, max_mail_size(), get_mail_size());
	fp = fopen(dir, "r");
	if (fp == 0)
		http_fatal("目前您的信箱没有任何信件");
	printf("<table border=1>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>发信人</td><td>日期</td><td>信件标题</td></tr>\n");
	while (1) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		total++;
		if (x.accessed & FH_READ)
			continue;
		printf("<tr><td>%d</td><td>N</td>", total);
		printf("<td>%s</td>", userid_str(fh2owner(&x)));
		printf("<td>%6.6s</td>", Ctime(x.filetime) + 4);
		printf("<td><a href=bbsmailcon?file=%s&num=%d>", fh2fname(&x),
		       total - 1);
		if (strncmp("Re: ", x.title, 4))
			printf("★ ");
		hprintf("%42.42s", void1(x.title));
		printf(" </a></td></tr>\n");
		total2++;
	}
	fclose(fp);
	printf("</table><hr>\n");
	printf("您的信箱共有%d封信件, 其中新信%d封.", total, total2);
	printf("</center></body>");
	http_quit();
	return 0;
}
예제 #5
0
파일: api_mail.c 프로젝트: bmybbs/api
int api_mail_list(ONION_FUNC_PROTO_STR)
{
	const char * str_startnum = onion_request_get_query(req, "startnum");
	const char * str_count    = onion_request_get_query(req, "count");
	const char * userid   = onion_request_get_query(req, "userid");
	const char * appkey   = onion_request_get_query(req, "appkey");
	const char * sessid   = onion_request_get_query(req, "sessid");
	const char * box_type  = onion_request_get_query(req, "box_type");

	if(!userid || !appkey || !sessid)
		return api_error(p, req, res, API_RT_WRONGPARAM);

	struct userec *ue = getuser(userid);
	if(!ue)
		return api_error(p, req, res, API_RT_NOSUCHUSER);

	int r = check_user_session(ue, sessid, appkey);
	if(r != API_RT_SUCCESSFUL) {
		free(ue);
		return api_error(p, req, res, r);
	}

	int startnum = (str_startnum) ? atoi(str_startnum) : 999999;
	int count = (str_count) ? atoi(str_count) : 20;

	char mail_dir[80];

	int box_type_i = (box_type != NULL && box_type[0] == '1') ? API_MAIL_SENT_BOX : API_MAIL_RECIEVE_BOX;
	if(box_type_i == API_MAIL_RECIEVE_BOX)
		setmailfile(mail_dir, ue->userid, ".DIR");
	else
		setsentmailfile(mail_dir, ue->userid, ".DIR");

	int total = file_size_s(mail_dir) / sizeof(struct fileheader);

	if(!total) {
		free(ue);
		return api_error(p, req, res, API_RT_MAILEMPTY);
	}

	FILE *fp = fopen(mail_dir, "r");
	if(fp==0) {
		free(ue);
		return api_error(p, req, res, API_RT_MAILDIRERR);
	}

	if(startnum == 0 || startnum > total-count+1)
		startnum = total - count + 1;
	if(startnum <= 0)
		startnum = 1;

	struct fileheader x;
	int i;
	struct bmy_article mail_list[count];
	memset(mail_list, 0, sizeof(struct bmy_article) * count);
	fseek(fp, (startnum - 1) * sizeof(struct fileheader), SEEK_SET);
	for(i=0; i<count; ++i) {
		if(fread(&x, sizeof(x), 1, fp) <= 0)
			break;

		mail_list[i].sequence_num = i + startnum;
		mail_list[i].mark = x.accessed;
		strncpy(mail_list[i].author, fh2owner(&x), sizeof(mail_list[i].author));
		mail_list[i].filetime = x.filetime;
		g2u(x.title, strlen(x.title), mail_list[i].title, sizeof(mail_list[i].title));
	}

	fclose(fp);

	char *s = bmy_mail_array_to_json_string(mail_list, count, 0, ue);

	api_set_json_header(res);
	onion_response_write0(res, s);
	free(s);
	free(ue);
	return OCS_PROCESSED;
}