Example #1
0
static int
readuserallbrc(char *userid, char *userhost)
{
	char buf[STRLEN];
	int oldbrcexpired = brcexpired;
	if (!userid)
		return 0;
	brcexpired = 0;
	if (!*userid || !strcmp(userid, "guest")) {
		snprintf(buf, sizeof (buf), "guest.%s", userhost);
		if (!oldbrcexpired
		    && !strncmp(allbrcuser, buf, sizeof (allbrcuser))) return 0;
		strsncpy(allbrcuser, buf, sizeof (allbrcuser));
		brc_init(&allbrc, allbrcuser, NULL);

	} else {
		if (!oldbrcexpired
		    && !strncmp(allbrcuser, userid, sizeof (allbrcuser)))
			    return 0;
		sethomefile(buf, userid, "brc");
		strsncpy(allbrcuser, userid, sizeof (allbrcuser));
		brc_init(&allbrc, userid, buf);
	}
	return 0;
}
Example #2
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>");
}
Example #3
0
int
getformarg(char *buf, char *sec, char *qry, int len)
{
	char *t2, *t3;
	qry[0] = 0;
	sec[0] = 0;
	t2 = strtok(buf, "&");
	while (t2) {
		t3 = strchr(t2, '=');
		if (t3 != 0) {
			t3[0] = 0;
			t3++;
			__unhcode(t3);
			if (!strcmp(t2, "sec")) {
				strsncpy(sec, t3, len);
			}
			if (!strcmp(t2, "qry")) {
				strsncpy(qry, t3, len);
			}
		}
		t2 = strtok(NULL, "&");
	}
	if (!qry[0])
		return -1;
	while (qry[0] == ' ')
		memmove(qry, qry + 1, strlen(qry));
	if ((t2 = strchr(qry, ' ')))
		*t2 = 0;
	return 0;
}
Example #4
0
int
gentree(char *basestr, struct sectree *tree)
{
	int i, len;
	struct sectree *subsec;
	len = strlen(basestr);
	strsncpy(tree->basestr, basestr, sizeof (tree->basestr));
	strsncpy(tree->introstr, getintrostr(basestr), sizeof (tree->introstr));
	strsncpy(tree->des, getdes(basestr), sizeof (tree->des));
	tree->nsubsec = 0;
	bzero(tree->seccodes, sizeof (tree->seccodes));
	for (i = 0; i < npairs && tree->nsubsec <= MAXSUBSEC; i++) {
		if (pairs[i].seccode[0] == '*')
			continue;
		if (strlen(pairs[i].seccode) != len + 1)
			continue;
		if (strncmp(pairs[i].seccode, basestr, len))
			continue;
		subsec = malloc(sizeof (struct sectree));
		subsec->parent = tree;
		strsncpy(subsec->title, pairs[i].title, sizeof (subsec->title));
		gentree(pairs[i].seccode, subsec);
		tree->subsec[tree->nsubsec] = subsec;
		tree->seccodes[tree->nsubsec] = pairs[i].seccode[len];
		tree->nsubsec++;
	}
	return 0;
}
Example #5
0
int main()
{
        int type;
        char pw1[20], pw2[20], pw3[20];
        init_all();
        if(!loginok)
                http_fatal("����δ��¼, ���ȵ�¼");
        modify_mode(u_info,USERDEF+20000);	//bluetent
        type=atoi(getparm("type"));
        if(type==0) {
                printf("%s -- �޸����� [�û�: %s]<hr color=green>\n",
                       BBSNAME, currentuser.userid);
                printf("<form action=bbspwd?type=1 method=post>\n");
                printf("��ľ�����: <input maxlength=12 size=12 type=password name=pw1><br>\n");
                printf("���������: <input maxlength=12 size=12 type=password name=pw2><br>\n");
                printf("������һ��: <input maxlength=12 size=12 type=password name=pw3><br><br>\n");
                printf("<input type=submit value=ȷ���޸�>\n");
                http_quit();
        }
        strsncpy(pw1, getparm("pw1"), 13);
        strsncpy(pw2, getparm("pw2"), 13);
        strsncpy(pw3, getparm("pw3"), 13);
        if(strcmp(pw2, pw3))
                http_fatal("�������벻��ͬ");
        if(strlen(pw2)<2)
                http_fatal("������̫��");
        if(!checkpasswd(currentuser.passwd, pw1))
                http_fatal("���벻��ȷ");
        strcpy(currentuser.passwd, crypt1(pw2, pw2));
        save_user_data(&currentuser);
        printf("[%s] �����޸ijɹ�.", currentuser.userid);
}
Example #6
0
int
bbspassport_main()
{
	char id[IDLEN + 1], buf[384], site[256];
	struct userec *x;

	html_header(1);
	if (key_fail)
		http_fatal("�ڲ����� ��ϵά��!");
	strsncpy(buf, getparm("pp"), sizeof (buf));
	strsncpy(site, getparm("site"), sizeof (site));
	strsncpy(id, des3_decode(buf, 0), IDLEN + 1);
	if (id[0] && getuser(id, &x) > 0) {
		snprintf(buf, sizeof (buf), "http://%s?q=%s", site,
			 des3_encode(id, 1));
		redirect(buf);
		http_quit();
		return 0;
	}
	printf("<form name=lpassport method=post action=lpassport>\n");
	printf("<table width=100%%>\n");
	printf
	    ("<tr><td align=right>*���������:<td align=left><input name=id size=12 maxlength=%d >\n",
	     IDLEN);
	printf
	    ("<tr><td align=right>*����������:<td align=left><input type=password name=pw size=12 maxlength=%d>\n",
	     PASSLEN - 1);
	printf("<tr><td><td><input type=hidden name=site value=\"%s\">", site);
	printf("<tr><td align=right><input type=submit value=��¼>"
	       " <td align=left><input type=reset value=������д></table>");
	printf("</form>");
	http_quit();
	return 0;
}
Example #7
0
int
bbseva_main()
{
	char board[80], file[80];
	int star;
	html_header(1);
	check_msg();
	strsncpy(board, getparm("B"), 32);
	if (!board[0])
		strsncpy(board, getparm("board"), 32);
	strsncpy(file, getparm("F"), 20);
	if (!file[0])
		strsncpy(file, getparm("file"), 32);
	star = atoi(getparm("star"));
	if (!loginok)
		http_fatal("匆匆过客不能进行本项操作");
	changemode(READING);
	if(! getboard(board))
		http_fatal("错误的讨论区");
	if (hideboard(board))
		http_fatal("隐藏版面就不要评价文章啦!");
	if (star < 1 || star > 5)
		http_fatal("错误的参数");
	if (star == 1)
		star++;
	printf("<center>%s -- 评价文章 [使用者: %s]<hr>\n", BBSNAME,
	       currentuser.userid);
	printf("<table><td>");
	do_eva(board, file, star);
	printf("</td></table>");
	printf("[<a href='javascript:history.go(-1)'>返回</a>]");
	http_quit();
	return 0;
}
Example #8
0
void
savemyclass()
{
	struct brcinfo *brcinfo;
	struct boardmem *bx;
	char *ptr = getparm("myclass");
	bx = getboard2(ptr);
	if (!bx) {
		printf("<b>没有找到 %s 版,请用“搜索”功能搜索版面</b><br>\n",
		       ptr);
		return;
	}
	if (!has_read_perm_x(currentuser, bx)) {
		printf
		    ("<b>%s 版是一个封闭版面,请先向版务申请加入,或者用“搜索”功能另选其他版面</b><br>\n",
		     ptr);
		return;
	}
	brcinfo = brc_readinfo(currentuser->userid);
	strsncpy(brcinfo->myclass, bx->header.filename,
		 sizeof (brcinfo->myclass));
	ptr = strtrim(getparm("myclasstitle"));
	if (!strcmp(ptr, "版面标题"))
		brcinfo->myclasstitle[0] = 0;
	else
		strsncpy(brcinfo->myclasstitle, ptr,
			 sizeof (brcinfo->myclasstitle));
	brc_saveinfo(currentuser->userid, brcinfo);
	printf
	    ("<b>设置成功</b>(以后可以到菜单“个人工具箱”-->“设定底栏显示的版面”进行修改)<br>");
	printf("<script>top.f4.location.reload();</script>");
}
Example #9
0
int
readseclist(char *filename)
{
	FILE *fp;
	char buf[256], *ptr;
	int i;
	fp = fopen(filename, "rt");
	for (i = 0; i < MAXPAIRS; i++) {
		if (fgets(buf, sizeof (buf), fp) == NULL)
			break;
		if (buf[0] == '%')
			continue;
		ptr = strtok(buf, " \t\r\n");
		if (!ptr)
			continue;
		strsncpy(pairs[i].seccode, ptr, sizeof (pairs[i].seccode));
		ptr = strtok(NULL, "\t\r\n");
		if (!ptr)
			continue;
		strsncpy(pairs[i].title, ptr, sizeof (pairs[i].title));
		pairs[i].used = 0;
	}
	npairs = i;
	return 0;
}
Example #10
0
int
main()
{
	int i;
	struct boardmem x;
	if (initbbsinfo(&bbsinfo) < 0)
		return -1;
	shm_bcache = bbsinfo.bcacheshm;
	if (shm_bcache->number <= 0)
		return -1;
	initfilter(MY_BBS_HOME "/etc/filtertitle");
	srand(time(NULL));
	for (i = 0; i < shm_bcache->number; i++) {
		x = shm_bcache->bcache[i];
		if (!testperm(&x))
			continue;
		bzero(&lastmarklist[numlastmarkb], sizeof (lastmarklist[0]));
		strcpy(lastmarklist[numlastmarkb].board, x.header.filename);
		strcpy(lastmarklist[numlastmarkb].boardtitle, x.header.title);
		lastmarklist[numlastmarkb].bnum = i;
		lastmarklist[numlastmarkb].score = x.score;
		strsncpy(lastmarklist[numlastmarkb].sec1, x.header.sec1,
			 sizeof (lastmarklist[numlastmarkb].sec1));
		strsncpy(lastmarklist[numlastmarkb].sec2, x.header.sec2,
			 sizeof (lastmarklist[numlastmarkb].sec2));
		if (!(x.header.flag & CLOSECLUB_FLAG))
			readlastmark(&lastmarklist[numlastmarkb]);
		numlastmarkb++;
	}
	makeallseclastmark(&sectree);
	return 0;
}
Example #11
0
static int  parse_txtfile_line(char *line, SPA *spa) {
	int type;
	char *ptr;
	char *path, *bname, *fname;

	bzero(spa, sizeof(SPA));

	ptr = get_from_line(&line, &ptr, '\t');
	type = atoi(ptr);
	if(!type) //未知的文章类型
		return -1;
	
	ptr = get_from_line(&line, &ptr, '\t');
	strsncpy(spa->title, ptr, sizeof(spa->title)); //文章标题
	//printf("title:%s\t", title);
	
	ptr = get_from_line(&line, &ptr, '\t');
	path = ptr; // 文章路径
	//printf("path:%s\t", path);

	ptr = get_from_line(&line, &ptr, '\t');
	strsncpy(spa->owner, ptr, sizeof(spa->owner)); // 用户名
	//printf("%s\t", userid);
	
	if(type == 1) {
		// boards/sysop/M.1122334455.A
		// con?B=sysop&F=M.1122334455.A
		get_from_line(&path, &ptr,  '/');
		get_from_line(&path, &ptr, '/');
		bname = ptr; //版名
		get_from_line(&path, &ptr, '/');
		fname = ptr; //文件名
		if(!fname)
			return -1;
		snprintf(spa->hlink, sizeof(spa->hlink), "con?B=%s&F=%s", bname, fname);
#ifdef ENABLE_BLOG
	} else if(type == 2) {
		// blog/E/赤名莉香/1122334455
		// blogread?U=%s&T=1122334455
		fname = strrchr(path, '/');
		if(!fname)
			return -1;
		snprintf(spa->hlink, sizeof(spa->hlink), "blogread?U=%s&T=%s", spa->owner, ++fname);
#endif
	}
	if(type == 3) {
		// 0Announce/gourps/GROUP_0/sysop/M1122334455/M1122334456... \t userid
		// bbsanc?path=/groups/...&item=M1122334456
		get_from_line(&path, &ptr, '/');
		fname = strrchr(path, '/');
		if(!fname)
			return -1;
		*fname = 0;
		snprintf(spa->hlink, sizeof(spa->hlink), "bbsanc?path=/%s&item=/%s", path, ++fname);
		return 0;
	}
	return 0;
}
Example #12
0
int attach_init() {
	char *buf, buf2[1024], *t2, *t3;
	int n;
	srand(time(0)*2+getpid());
	chdir(BBSHOME);
	printf("Content-Type: application/octet-stream \n");
	printf("Content-Disposition: attachment; filename=tshirt.csv \n\n", CHARSET);
	n=atoi(getsenv("CONTENT_LENGTH"));
	if(n>5000000) n=5000000;
	buf=calloc(n+1, 1);
	if(buf==0) http_fatal("memory overflow");
	fread(buf, 1, n, stdin);
	buf[n]=0;
	t2=strtok(buf, "&");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			__unhcode(t3);
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, "&");
	}
	strsncpy(buf2, getsenv("QUERY_STRING"), 1024);
	t2=strtok(buf2, "&");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			__unhcode(t3);
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, "&");
	}
	strsncpy(buf2, getsenv("HTTP_COOKIE"), 1024);
	t2=strtok(buf2, ";");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, ";");
	}
	strsncpy(fromhost, getsenv("REMOTE_ADDR"), 32);
	seteuid(BBSUID);
	if(geteuid()!=BBSUID) http_fatal("uid error.");
	shm_init();
	loginok=user_init(&currentuser, &u_info);
        if(u_info==0){
             u_info=&guest;
        }
  return;
}
Example #13
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;
}
Example #14
0
int
bbsfind_main()
{
	char user[32], title3[80], title[80], title2[80];
	int day;
	html_header(1);
	//check_msg();
	changemode(READING);
	strsncpy(user, getparm("user"), 13);
	strsncpy(title, getparm("title"), 50);
	strsncpy(title2, getparm("title2"), 50);
	strsncpy(title3, getparm("title3"), 50);
	day = atoi(getparm("day"));
	printf("<body>");
	if (day == 0) {
		printf("%s -- 站内文章查询<hr>\n", BBSNAME);
		printf
		    ("<font color=red>用户查询请使用各版面上的 版内查询 功能,此查询主要供管理人员使用</font>"
		     "<br> 目前系统负载 %f。系统负载超过 1.5 或者上线人数超过 %d 时将不能进行查询。<br>"
		     "系统负载统计图和上线人数统计图可以到<a href=home?B=bbslists>bbslists版</a>查看<br>",
		     *system_load(), ONLINELIMIT);
		if (!loginok || isguest)
			printf("<b>您还没有登录,请先登录再使用本功能</b><br>");
		printf("<form action=bbsfind>\n");
		printf
		    ("文章作者: <input maxlength=12 size=12 type=text name=user> (不填查找所有作者)<br>\n");
		printf
		    ("标题含有: <input maxlength=60 size=20 type=text name=title>");
		printf
		    (" AND <input maxlength=60 size=20 type=text name=title2><br>\n");
		printf
		    ("标题不含: <input maxlength=60 size=20 type=text name=title3><br>\n");
		printf
		    ("查找最近: <input maxlength=5 size=5 type=text name=day value=7> 天以内的文章<br><br>\n");
		printf("<input type=submit value=提交查询></form>\n");
	} else {
		if (*system_load() >= 1.7 || count_online() > ONLINELIMIT)
			http_fatal
			    ("用户查询请使用各版面上的 版内查询 功能,此查询主要供管理人员使用。系统负载(%f)或上线人数(%d)过高, 请在上站人数较少的时间查询( 系统负载超过 1.5 或者上线人数超过 %d 时不能进行查询 )",
			     *system_load(), count_online(), ONLINELIMIT);
		if (!loginok || isguest)
			http_fatal("请先登录再使用本功能。");
		search(user, title, title2, title3, day * 86400);
	}
//	printSoukeForm();
	showfile(MY_BBS_HOME "/wwwtmp/googleanalytics");
	printf("</body>");
	http_quit();
	return 0;
}
Example #15
0
int
main(int n, char *cmd[])
{
	tcgetattr(0, &oldtty);
	cfmakeraw(&newtty);
	tcsetattr(0, TCSANOW, &newtty);
	if (n >= 2)
		strsncpy(userid, cmd[1], sizeof(userid));
	if (n >= 3)
		strsncpy(fromhost, cmd[2], sizeof(fromhost));
	winminelog("ENTER");
	winmine();
	tcsetattr(0, TCSANOW, &oldtty);
	return 0;
}
Example #16
0
static void
load_GoodBrd()			//´ÓÎļþÖлñÈ¡¶©ÔÄ°æÃ棬Ìî³äÊý¾Ý½á¹¹ GoodBrd
{
	char buf[STRLEN];
	FILE *fp;

	GoodBrd.num = 0;
	setuserfile(buf, ".goodbrd");
	if ((fp = fopen(buf, "r"))) {
		for (GoodBrd.num = 0; GoodBrd.num < GOOD_BRC_NUM;) {
			if (!fgets(buf, sizeof (buf), fp))
				break;
			strsncpy(GoodBrd.ID[GoodBrd.num], strtrim(buf),
				 sizeof (GoodBrd.ID[GoodBrd.num]));
			if (canberead(GoodBrd.ID[GoodBrd.num]))
				GoodBrd.num++;
		}
		fclose(fp);
	}
	if (GoodBrd.num == 0) {
		GoodBrd.num++;
		if (getbcache(DEFAULTBOARD))
			strcpy(GoodBrd.ID[0], DEFAULTBOARD);
		else
			strcpy(GoodBrd.ID[0], currboard);
	}
}
Example #17
0
int main()
{
        init_all();
        struct compact p;
        char board[STRLEN],path[STRLEN];
        strsncpy(board, getparm("board"), 20);
        sprintf(path,"compact/%s/compact",board);
        int   total=get_num_records(path,sizeof(p));
        if(total==0) {
                showinfo("该板尚无过刊.");
                return 1;
        }

        printf("<center>%s 过刊区<br>",board);
        printf("----------------------------------------------------------");
        printf("<table width=80% boarder=0 align=center>");
        printf("<tr><td>序号</td><td>名称</td><td>文章总数</td><td>建立日期</td></tr>");
        FILE *fp=fopen(path,"r");
        if(fp==0) {
                printf("文件读取错误,请重试.");
                return 1;
        }
        int  i=1;
        while(1) {
                if(fread(&p, sizeof(p), 1, fp)<=0)
                        break;
                printf("<tr><td>%d</td><td><a href=bbsdoc?board=%s&&mode=c&&num=%d>%s</a></td><td>%d</td><td>%6.6s</td></tr>\
                       ",i,board,i,p.name,p.total,ctime(&p.time)+4);
                i++;
        }

        printf("</table>");
        fclose(fp);
        return 0;
}
Example #18
0
void
win_checkrec()
{
	int n;
	win_loadrec();
	for (n = 0; n <= NUMREC; n++)
		if (!strcmp(topID[n], userid)) {
			if (stage == topStage[n] && steps < topSteps[n]) {
				topSteps[n] = steps;
				strcpy(topFROM[n], fromhost);
				win_sort();
			}
			if (stage > topStage[n]) {
				topStage[n] = stage;
				topSteps[n] = steps;
				strcpy(topFROM[n], fromhost);
				strcpy(prize[n], "δ");
				win_sort();
			}
			return;
		}
	if (stage > topStage[NUMREC - 1]
	    || (stage == topStage[NUMREC - 1]
		&& steps < topSteps[NUMREC - 1])) {
		strcpy(topID[NUMREC - 1], userid);
		topStage[NUMREC - 1] = stage;
		topSteps[NUMREC - 1] = steps;
		strsncpy(topFROM[NUMREC - 1], fromhost, sizeof (topFROM[0]));
		strcpy(prize[NUMREC - 1], "δ");
		win_sort();
		return;
	}
}
Example #19
0
int
bbsfdel_main()
{
	FILE *fp;
	int i, total = 0;
	char path[80], userid[80];
	struct override f[200];
	html_header(1);
	//check_msg();
	if (!loginok || isguest)
		http_fatal("您尚未登录,请先登录");
	changemode(GMENU);
	sethomefile(path, currentuser->userid, "friends");
	printf("<center>%s -- 好友名单 [使用者: %s]<hr>\n", BBSNAME,
	       currentuser->userid);
	strsncpy(userid, getparm("userid"), 13);
	if (userid[0] == 0) {
		printf("<form action=bbsfdel>\n");
		printf("请输入欲删除的好友帐号: <input type=text><br>\n");
		printf("<input type=submit>\n");
		printf("</form>");
		http_quit();
	}
	loadfriend(currentuser->userid);
	if (friendnum <= 0)
		http_fatal("您没有设定任何好友");
	if (!isfriend(userid))
		http_fatal("此人本来就不在你的好友名单里");
	for (i = 0; i < friendnum; i++) {
		if (strcasecmp(fff[i].id, userid)) {
			memcpy(&f[total], &fff[i], sizeof (struct override));
			total++;
		}
	}
Example #20
0
int
main(int argc,char *argv[])
{	
	FILE *fp;
	struct userec faint;
	if(argc!=3){
		printf("error,number of arguments!\n");
		return -1;
	}
	fp=fopen(MY_BBS_HOME "/.PASSWDS","r+");
	if(!fp){
		printf("error,can't open passwd file!\n");
		return -1;
	}
	if(!goodgbid(argv[1]))
		printf("warning,invalid userid %s\n",argv[1]);
	if(!goodgbid(argv[2]))
		printf("warning,invalid userid %s\n",argv[2]);
	while(fread(&faint,1,sizeof(faint),fp)==sizeof(faint)){
		if(strcmp(faint.userid,argv[1]))
			continue;
		strsncpy(faint.userid,argv[2],IDLEN+1);
		fseek(fp,- sizeof(faint),SEEK_CUR);
		fwrite(&faint,1,sizeof(faint),fp);
		fclose(fp);
		utime(MY_BBS_HOME "/.PASSFLUSH",NULL);
		return 0;
	}
	fclose(fp);
	printf("not found!\n");
	return 0;
}
Example #21
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();
}
Example #22
0
int
readlastmark(struct lastmarkl *lm)
{
	char buf[200], *ptr;
	FILE *fp;
	sprintf(buf, MY_BBS_HOME "/wwwtmp/lastmark/%s", lm->board);
	if ((fp = fopen(buf, "r")) == NULL)
		goto END;
	lm->count = 0;
	while (fgets(buf, 200, fp)) {
		if (dofilter(buf))
			continue;
		ptr = strchr(buf, '\t');
		if (ptr == NULL)
			break;
		ptr++;
		lm->thread[lm->count] = atoi(ptr);
		if (lm->thread[lm->count] == 0)
			break;
		ptr = strchr(ptr, '\t');
		if (!ptr)
			break;
		ptr++;
		strsncpy(lm->title[lm->count], ptr, sizeof (lm->title[0]));
		ptr = strchr(lm->title[lm->count], '\n');
		if (ptr)
			*ptr = 0;
		lm->count++;
		if (lm->count >= NBRDITEM)
			break;
	}
	fclose(fp);
      END:
	return lm->count;
}
Example #23
0
int save_plan(char *plan)
{
        char buf[10000];
        /* add by yiyo 过滤说明档多余字符
                char* p;
                int i;
         
                p = buf;
                i = 0;
                while (*p) {
                        if (13 != *p) {
                                buf[i] = *p;
                                i++;
                        }
                        p++;
                }
                buf[i] = 0;
        /* add end by yiyo */
        fp=fopen(plan, "w");
        strsncpy(buf, getparm("text"), 9999);
        fprintf(fp, "%s", buf);
        fclose(fp);
        printf("个人说明档修改成功。");
        http_quit();
}
Example #24
0
int
main(int argn, char **argv)
{
	char buf[1024], sec[100], qry[100], manfile[100];
	int retv;
	strsncpy(buf, getsenv("QUERY_STRING"), sizeof (buf));
	if (strchr(buf, '&'))
		retv = getformarg(buf, sec, qry, 100);
	else if (strchr(buf, '+'))
		retv = geturlarg(buf, sec, qry, 100);
	else
		retv = -1;
	if (!retv)
		retv = testarg(sec, qry);
	if (!retv) {
		retv = getmanfile(sec, qry, manfile, sizeof (manfile));
		if (retv) {
			printheader();
			printf
			    ("找不到与<font color=red>%s</font>相关的文档<br><br>\n",
			     nohtml(qry));
		}
	}
	if (retv) {
		printheader();
		printsection();
		printform();
		return 0;
	}
	runman2html(manfile);
	return 0;
}
Example #25
0
int main()
{
        char buf[512];
        char file[80];
        char keystr[80]; //关键字
        int has=1;
        init_all();
        if(!loginok)
                http_fatal("您尚未登录");
        modify_mode(u_info,FTPSEARCH);
        strsncpy(keystr, getparm("keystr"), 80);
        printf("<body background=/bg_1.gif bgproperties=fixed>");
        if(!strlen(keystr)) {
                printf("<table width=600 align=center><tr height=150><td align=center valign=bottom style='font-size:14px'><font color=blue>局域网FTP搜索引擎<p><p></font></td></tr>");
                printf("<tr><td align=center style='font-size:14px'><form name=ftpsearch>请输入关键字:<input name=keystr type=text size=50 maxlength=80><input type=submit value=搜索> (<font color=red>%d</font>人在线)</form><script language=javascript>document.ftpsearch.keystr.focus();</script></td></tr>", countuser());
                printf("<tr><td><table><tr>");
                printf("<td><a href=bbsmyftp?type=4>我要加盟</a></td>");
                if(SiteInList(fromhost))
                        printf("<td> | <a href=bbsmyftp>管理站点数据</a> | <a href=bbsmyftp?type=3>已上传数据的站点列表</a></td>");
                printf("</tr></table></td></tr>");
                printf("</tr><tr><td width=80%%>【说明】 本搜索引擎用来查找南开大学校内教育网和宿舍网FTP站点的数据。<br>各位站长可以自行上传自己的站点数据,服务器端对原始数据进行重新编码以供搜索。<br>因该引擎仅依照编码后的数据进行搜索,故不会对网络负载产生影响。</td></tr>");
                printf("</table>");
        } else {
                sprintf(file, "tmp/%d.tmp", getpid());
                search(keystr, file);
                printf("</pre>");
                unlink(file);
        }
        http_quit();
}
Example #26
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;
}
Example #27
0
int
bbsfind_main()
{
	char user[32], title3[80], title[80], title2[80];
	int day;
	html_header(1);
	check_msg();
	changemode(READING);
	strsncpy(user, getparm("user"), 13);
	strsncpy(title, getparm("title"), 50);
	strsncpy(title2, getparm("title2"), 50);
	strsncpy(title3, getparm("title3"), 50);
	day = atoi(getparm("day"));
	printf("<body>");
	if (day == 0) {
		printf("%s -- 站内文章查询<hr>\n", BBSNAME);
		printf
		    ("目前系统负载 %f。系统负载超过 5.0 或者上线人数超过 4000 时将不能进行查询。<br>"
		     "系统负载统计图和上线人数统计图可以到<a href=%sbbslists>bbslists版</a>查看<br>",
		      *system_load(),showByDefMode());
		if (!loginok || isguest)
			printf("<b>您还没有登录,请先登录再使用本功能</b><br>");
		printf("<form action=bbsfind>\n");
		printf
		    ("文章作者: <input maxlength=12 size=12 type=text name=user> (不填查找所有作者)<br>\n");
		printf
		    ("标题含有: <input maxlength=60 size=20 type=text name=title>");
		printf
		    (" AND <input maxlength=60 size=20 type=text name=title2><br>\n");
		printf
		    ("标题不含: <input maxlength=60 size=20 type=text name=title3><br>\n");
		printf
		    ("查找最近: <input maxlength=5 size=5 type=text name=day value=7> 天以内的文章<br><br>\n");
		printf("<input type=submit value=提交查询></form>\n");
	} else {
		if (*system_load() >= 5.0 || count_online() > 4000)
			http_fatal
			    ("系统负载(%f)或上线人数(%d)过高, 请在上站人数较少的时间查询.",
			     *system_load(), count_online());
		if (!loginok || isguest)
			http_fatal("请先登录再使用本功能。");
		search(user, title, title2, title3, day * 86400);
	}
	printf("</body>");
	http_quit();
	return 0;
}
Example #28
0
int
verifyInvite(char *email)
{
	char inviter[30], code[30], t[30];
	char invitefn[256];
	char ivemail[80];
	strsncpy(inviter, getparm("inviter"), sizeof (inviter));
	strsncpy(code, getparm("code"), sizeof (code));
	strsncpy(t, getparm("t"), sizeof (t));
	sprintf(invitefn, INVITATIONDIR "/%s/%s.%s", inviter, t, code);
	close(open(invitefn, O_RDWR));	//touch new
	if (!file_exist(invitefn) ||
	    readstrvalue(invitefn, "toemail", ivemail, sizeof (ivemail)) < 0)
		return 0;
	if (strcasecmp(email, ivemail))
		return 0;
	return 1;
}
Example #29
0
int
postInvite(char *userid, char *inviter)
{
	struct userec *x, tmpu;
	char buf[256];
	FILE *fp;
	if (getuser(inviter, &x) <= 0)
		return -1;
	loadfriend(userid);
	if (friendnum < MAXFRIENDS - 1) {
		strsncpy(fff[friendnum].id, x->userid, sizeof (fff[0].id));
		strsncpy(fff[friendnum].exp, inviter, sizeof (fff[0].exp));
		friendnum++;
		sethomefile(buf, userid, "friends");
		fp = fopen(buf, "w");
		fwrite(fff, sizeof (struct override), friendnum, fp);
		fclose(fp);
	}
Example #30
0
int
geturlarg(char *buf, char *sec, char *qry, int len)
{
	char *t2;
	qry[0] = 0;
	sec[0] = 0;
	t2 = strtok(buf, "+");
	if (!t2)
		return -1;
	__unhcode(t2);
	strsncpy(sec, t2, len);
	t2 = strtok(NULL, "+");
	if (!t2)
		return -1;
	__unhcode(t2);
	strsncpy(qry, t2, len);
	return 0;
}