Exemplo n.º 1
0
int
blogatom_main()
{
	char userid[IDLEN + 1];
	struct Blog blog;
	int n, i;

	printf("Content-type: text/xml; charset=utf-8\r\n\r\n");
	printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
	       "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"zh-CN\">");

	strsncpy(userid, getparm2("U", "userid"), sizeof (userid));
	if (openBlog(&blog, userid) < 0) {
		printf("<title>该 Blog 尚不存在</title>");
		printf("<link href=\"http://" MY_BBS_DOMAIN "\" />");
		goto END;
	}
	printf("<id>%s</id>", makeTag(&blog, NULL));
	printf("<title>%s</title>", nohtml(blog.config->title));
	printf("<link href=\"blog?U=%s\" />", blog.config->useridEN);
	printf("<link rel=\"self\" href=\"blogatom?U=%s\" />",
	       blog.config->useridEN);
	printf("<author><name>%s</name></author>", blog.config->useridUTF8);
	printf("<updated>%s</updated>", atomctime(&blog.indexFile.mtime));
	//tagline...
	//id...
	//generator...

	for (i = blog.nIndex - 1, n = 0; i >= 0 && n < 30; i--) {
		if (now_t - blog.index[i].fileTime > 7 * 24 * 3600 && n > 10)
			break;
		printEntry(&blog, i);
	}

	closeBlog(&blog);
      END:
	printf("</feed>");
	return 0;
}
Exemplo n.º 2
0
int
blogcomment_main()
{
	char userid[IDLEN + 1], tmpfile[80], who[32], by[120], *comment;
	char *ptr, *buffer;
	struct Blog blog;
	int fileTime;
	FILE *fp;

	// can't comment the bellow function, or will 500 error!
	printXBlogHeader();
	check_msg();
	strsncpy(userid, getparm2("U", "userid"), sizeof (userid));
	fileTime = atoi(getparm("T"));
	comment = getparm("comment");

	// add who by deli
	strsncpy(who, getparm("who"), sizeof (who));
	if ((ptr = strchr(who, '\n')))
		*ptr = 0;
	if ((ptr = strchr(who, '\r')))
		*ptr = 0;
	strcpy(who, strtrim(who));
	utf8cut(who, sizeof (who));
	// add end

	strsncpy(by, getparm("by"), sizeof (by));
	if ((ptr = strchr(by, '\n')))
		*ptr = 0;
	if ((ptr = strchr(by, '\r')))
		*ptr = 0;
	strcpy(by, strtrim(by));
	utf8cut(by, sizeof (by));
	if ((!loginok || isguest) && !strchr(by, '@')) {
		printf("填写的 Email 不正确。");
		printXBlogEnd();
		return 0;
	}
	if (openBlogW(&blog, userid) < 0) {
		printf("该用户尚未建立 blog。");
		printXBlogEnd();
		return 0;
	}

	sprintf(tmpfile, "bbstmpfs/tmp/%d.tmp", thispid);

	saveTidyHtml(tmpfile, comment, 1);
	buffer = readFile(tmpfile);
	unlink(tmpfile);
	if (!buffer) {
		closeBlog(&blog);
		printf("内存不足!");
		printXBlogEnd();
		return 0;
	}

	fp = fopen(tmpfile, "w");
	fprintf(fp, "F:%s\n", realfromhost);
	if (loginok && !isguest) {
		char idbuf[40];
		gb2utf8(idbuf, sizeof (idbuf), currentuser->userid);
		fprintf(fp, "B:%s %s\n", idbuf,
			urlencode(currentuser->userid));
	} else {
		fprintf(fp, "W:%s\n", who); // add by deli
		fprintf(fp, "B:%s\n", by);
	}
	if (*buffer != '\n')
		fprintf(fp, "\n");
	fputs(buffer, fp);
	fclose(fp);

	free(buffer);

	blogComment(&blog, fileTime, tmpfile);
	printComments(&blog, fileTime);

	closeBlog(&blog);
	printXBlogEnd();

	return 0;
}
Exemplo n.º 3
0
int
bbsgdoc_main()
{	//modity by macintosh 050516 for new www
	FILE *fp;
	char board[80], buf[128];
	struct boardmem *x1;
	struct fileheader x;
	int i, start, total;
	html_header(1);
	check_msg();
	printf("<script src=/function.js></script>\n");
	changemode(READING);
	strsncpy(board, getparm2("B", "board"), 32);
	x1 = getboard(board);
	if (x1 == 0)
		nosuchboard(board, "bbsgdoc");
	updateinboard(x1);
	strcpy(board, x1->header.filename);
	sprintf(buf, "boards/%s/.DIGEST", board);
	fp = fopen(buf, "r");
	if (fp == 0)
		http_fatal("错误的讨论区目录");
	total = file_size(buf) / sizeof (struct fileheader);
	start = getdocstart(total, w_info->t_lines);
/*	printf("<body topmargin=0>");
	printf("<nobr><center>\n"); */
	printf("<body topmargin=0 leftmargin=0>\n");
	printf("<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>\n"
		"<td><form name=form1 action=bbsgdoc>\n");
	printboardtop(x1, 4);

/*	printf("文章数[%d] ", total);
	printf("<a href=bbspst?board=%s>发表文章</a> ", board); */
	printf("<tr><td><a href=\"pst?B=%s\" class=\"btnsubmittheme\" title=\"发表文章 accesskey: p\" accesskey=\"p\">发表文章</a>\n", board);
	printf("文章数&lt;%d&gt; 在线&lt;%d&gt;</td>", total, x1->inboard);
	sprintf(buf, "bbsgdoc?board=%s", board);
//	bbsdoc_helper(buf, start, total, w_info->t_lines);
	printf("<td align=right><a href=\"gdoc?B=%s&S=%d\" title=\"第一页 accesskey: 1\" accesskey=\"1\">第一页</a>\n", board, 1);
	if(start > w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"上一页 accesskey: f\" accesskey=\"f\">上一页</a>\n", board, (start-w_info->t_lines));
	if(start < total-w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"下一页 accesskey: n\" accesskey=\"n\">下一页</a>\n", board, (start+w_info->t_lines));
	printf("<a href=\"gdoc?B=%s&S=%d\" title=\"最后一页 accesskey: l\" accesskey=\"l\">最后一页</a>\n", board, (total-w_info->t_lines+1)); 
	//add by macintosh 050519 for func "Go"
	printf("<input type=hidden name=B value=%s>", board);
	printf("<input name=Submit1 type=Submit class=sumbitgrey value=Go>\n"
		"<input name=S type=text style=\"font-size:11px;font-family:verdana;\" size=4></td>\n"
		"</tr></table></td></tr>\n");
	printf("</form></td>");
	if (NULL == fp)
		http_fatal("本讨论区目前没有文章");
	if (total <= 0) {
		fclose(fp);
		http_fatal("本讨论区文摘目前没有文章");
	}

/*	printhr();
	printf("<table border=0>\n");
	printf
	    ("<tr><td>序号</td><td>状态</td><td>作者</td><td>日期</td><td>标题</td><td>星级</td><td>评价</td></tr>\n");
*/
	printf("%s", "<tr><td width=40 class=\"level1\">&nbsp;</td>\n"
		"<td class=\"level1\"><TABLE width=\"95%\" cellpadding=2 cellspacing=0>\n"
		"<TBODY>\n");
	printf("%s", "<TR>\n"
		"<TD class=tdtitle>序号</TD>\n"
		"<TD class=tdtitle>状态</TD>\n"
		"<TD class=tduser>作者</TD>\n"
		"<TD align=center class=tdtitle>日期</TD>\n"
		"<TD align=center class=tdtitle>标题</TD>\n"
		"<TD class=tdtitle>星级</TD>\n"
		"<TD class=tdtitle>评价</TD>\n"
		"</TR>\n");
	
	fseek(fp, (start - 1) * sizeof (struct fileheader), SEEK_SET);
	for (i = 0; i < w_info->t_lines; i++) {
		if (fread(&x, sizeof (x), 1, fp) <= 0)
			break;
		printf("<tr><td class=tdborder>%d</td><td class=tdborder>%s</td><td class=tduser>%s</td>",
		       start + i, flag_str(x.accessed), userid_str(x.owner));
		printf("<td align=center class=tdborder>%12.12s</td>", Ctime(x.filetime) + 4);
		printf
		    ("<td class=tdborder><a href=bbsgcon?board=%s&file=%s&num=%d>%s%s</a></td><td class=tdborder>%d</td><td class=tdborder>%d人</td></tr>\n",
		     board, fh2fname(&x), start + i - 1, strncmp(x.title,
								 "Re: ",
								 4) ? "● " :
		     "", void1(titlestr(x.title)), x.staravg50 / 50,
		     x.hasvoted);
	}
	printf("</TR> </TBODY></TABLE></td></tr>\n");
/*	printhr();
  	printf("文章数[%d] ", total);
	printf("<a href=bbspst?board=%s>发表文章</a> ", board);
	bbsdoc_helper(buf, start, total, w_info->t_lines);
*/
	printf("<tr><td height=40 class=\"level1\">&nbsp;</td>\n"
		"<td height=40 class=\"level1\">\n"
		"<table width=\"95%\" height=\"100%\"  border=0 cellpadding=0 cellspacing=0 class=\"level1\">\n"
		"<td><form name=form2 action=bbsgdoc>\n");
	printf("<tr><td><a href=\"pst?B=%s\" class=\"btnsubmittheme\" title=\"发表文章 accesskey: p\" accesskey=\"p\">发表文章</a>\n", board);
	printf("文章数&lt;%d&gt; 在线&lt;%d&gt;</td>", total, x1->inboard);
	sprintf(buf, "bbsgdoc?board=%s", board);
	printf("<td align=right><a href=\"gdoc?B=%s&S=%d\" title=\"第一页 accesskey: 1\" accesskey=\"1\">第一页</a>\n", board, 1);
	if(start > w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"上一页 accesskey: f\" accesskey=\"f\">上一页</a>\n", board, (start-w_info->t_lines));
	if(start < total-w_info->t_lines+1) printf("<a href=\"gdoc?B=%s&S=%d\" title=\"下一页 accesskey: n\" accesskey=\"n\">下一页</a>\n", board, (start+w_info->t_lines));
	printf("<a href=\"gdoc?B=%s&S=%d\" title=\"最后一页 accesskey: l\" accesskey=\"l\">最后一页</a>\n", board, (total-w_info->t_lines+1)); 
	//add by macintosh 050519 for func "Go"
	printf("<input type=hidden name=B value=%s>", board);
	printf("<input name=Submit2 type=Submit class=sumbitgrey value=Go>\n"
		"<input name=S type=text style=\"font-size:11px;font-family:verdana;\" size=4></td>\n"
		"</tr></table></td></tr>\n");
	printf("</form></td>");
	fclose(fp);
//	printdocform("bbsgdoc", board);
	printf("</table></td></tr></table></body>\n");
	http_quit();
	return 0;
}
Exemplo n.º 4
0
#include "bbslib.h"

int
bbsmypic_main()
{
	char userid[sizeof (currentuser->userid)], filename[256];
	struct userec *x;
	struct mmapfile mf = { ptr:NULL };
	size_t size=0;
	
	strsncpy(userid, getparm2("U", "userid"), sizeof (userid));
	if (getuser(userid, &x) <= 0) {
		html_header(1);
		printf("啊,没这个人啊?!");
		http_quit();
	}
	sethomefile(filename, x->userid, "mypic");
	if (cache_header(file_time(filename), 3600*24*100)) {
		return 0;
	}
	MMAP_TRY {
		if (mmapfile(filename, &mf)) {
			strncpy(filename, HTMPATH "/defaultmypic.gif", sizeof(filename));
			if (mmapfile(filename, &mf)) {
				MMAP_UNTRY;
				http_fatal("错误的文件名");
			}
		}
		size = mf.size;
		printf("Content-type: %s\r\n", get_mime_type("mypic.gif"));
		printf("Content-Length: %d\r\n\r\n", mf.size);