예제 #1
0
파일: bbsqry.c 프로젝트: deepurple/bbssrc
int bm_printboardapi(struct boardmanager *bm,char *farg)
{
	if (getboard(bm->board)){
		sstrcat(farg, "\"%s\",",bm->board);
	}
	return 0;
}
예제 #2
0
파일: bbseva.c 프로젝트: bmybbs/bmybbs
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;
}
예제 #3
0
void
showmyclass()
{
	struct brcinfo *brcinfo;
	struct boardmem *bx;
	char *ptr = "";
	brcinfo = brc_readinfo(currentuser->userid);
	if ((bx = getboard(brcinfo->myclass))) {
		brc_initial(currentuser->userid, NULL);
		if (!brc_board_read(bx->header.filename, bx->lastpost))
			ptr = "<font color=red>";
		printf
		    ("<a href=home?B=%d target=f3 title='可以通过左侧工具栏--个人工具箱设置此处的版面'>%s%s%s</a> ",
		     getbnum(brcinfo->myclass), ptr,
		     brcinfo->myclasstitle[0] ? nohtml(brcinfo->
						       myclasstitle) :
		     nohtml(bx->header.title), ptr[0] ? "</font>" : "");
	} else {
// no one will use my class now
/*
		printf
		    ("<a href=bbsmyclass target=f3 title='点击此处设定自己的同学录'>我的班级</a> ");
*/
	}
}
예제 #4
0
파일: phpbbs_article.c 프로젝트: zhouqt/kbs
void bbs_make_article_array(zval * array, struct fileheader *fh, char *flags, size_t flags_len)
{
    const struct boardheader *bh;
    char title[ARTICLE_TITLE_LEN];
    add_assoc_string(array, "FILENAME", fh->filename, 1);
    if (fh->o_bid > 0 && ((bh = getboard(fh->o_bid)) != NULL))
        add_assoc_string(array, "O_BOARD", (char*)(bh->filename), 1); /* for compitible */
    else
        add_assoc_string(array, "O_BOARD", "", 1); /* for compitible */
    add_assoc_long(array, "O_BID", fh->o_bid);
    add_assoc_long(array, "O_ID", fh->o_id);
    add_assoc_long(array, "ID", fh->id);
    add_assoc_long(array, "GROUPID", fh->groupid);
    add_assoc_long(array, "REID", fh->reid);
    add_assoc_long(array, "POSTTIME", get_posttime(fh));
    add_assoc_stringl(array, "INNFLAG", fh->innflag, sizeof(fh->innflag), 1);
    add_assoc_string(array, "OWNER", fh->owner, 1);
    strcpy(title, fh->title);
    //process_control_chars(title,NULL);
    add_assoc_string(array, "TITLE", title, 1);
    /*    add_assoc_long(array, "LEVEL", fh->level);*/
    add_assoc_stringl(array, "FLAGS", flags, flags_len, 1);
    add_assoc_long(array, "ATTACHPOS", fh->attachment);
    add_assoc_long(array, "EFFSIZE", fh->eff_size);
    add_assoc_long(array, "IS_TEX", fh->accessed[1] & FILE_TEX);
#ifdef HAVE_REPLY_COUNT
    add_assoc_long(array, "REPLYCOUNT", fh->replycount);
    add_assoc_string(array, "LAST_OWNER", fh->last_owner, 1);
    add_assoc_long(array, "LAST_POSTTIME", fh->last_posttime);
#endif /* HAVE_REPLY_COUNT */
}
예제 #5
0
char *search(char *board, char me) {  // 0 = black, 1 = white
  int i, j, x, y, p, q;
  char *best_board = board;
  int best_score = -49;
  int this_score;

  // choose a piece to investigate
 
  for (x=0; x<7; x++)
    for (y=0; y<7; y++) {
      if (getboard(board,x,y) != me) continue;  // not my piece
      for (i=-2; i<=2; i++) 
	for (j=-2; j<=2; j++) {
	  char *new_board;
	  if (i==0 && j==0) continue;              
	  if (!inboard(x+i,y+j)) continue;        // not on the board
	  if (getboard(board,x+i,y+j) != '-') continue; // not empty
	  
	  new_board = copy_board(board);
	  
	  if ((abs(i) > 1) || (abs(j) > 1))   // this is an extension
	    setboard(new_board,x,y,'-');	  
	  setboard(new_board,x+i,y+j,me);

	  // claim the surrounding squares
	  
	  for (p=-1; p<=1; p++) 
	    for (q=-1; q<=1; q++) {
	      if (inboard(x+i+p,y+j+q) && 
		  (getboard(new_board,x+i+p,y+j+q) != '-'))
		setboard(new_board,x+i+p,y+j+q,me);
	    }
	  
	  if (me == 'b')
	    this_score = score(search(new_board,'w'),'b');
	  else
	    this_score = 50 - score(new_board,'b');
	  
	  if (this_score > best_score) {
	    best_score = this_score;
	    best_board = new_board;
	  }
	}
    }
  return best_board;
}
예제 #6
0
파일: bbsqry.c 프로젝트: deepurple/bbssrc
int
bm_printboard(struct boardmanager *bm, void *farg)
{
	if (getboard(bm->board)){
		printf("<a href=%s%s target=f3>", showByDefMode(), bm->board);
		hprintf("%s", bm->board);
		printf("</a> ");
		hprintf(" ");
	} 
	return 0;
}
예제 #7
0
파일: bbsdenyadd.c 프로젝트: lytsing/ytht
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;
}
예제 #8
0
/*
 * 记录分区十大到文件
 */
void writesechot(int secid)
{
    FILE *fp;
    char curfile[256], buf[256];
    char *p;
    int i;
#ifdef READ_SEC_TOP
    struct top_header curr_sectop[10];
    memset(curr_sectop,0,(10*sizeof(struct top_header)));
#endif /* READ_SEC_TOP */

    sprintf(curfile, "etc/posts/day_sec_%s", seccode[secid]);
    if ((fp = fopen(curfile, "w")) != NULL) {
         fprintf(fp, "                \033[34m-----\033[37m=====\033[41m 本日%s区十大热门话题 \033[m=====\033[34m-----\033[m\n\n", seccode[secid]);
        for (i = 0; i < sectopnum[secid]; i++) {
            strcpy(buf, ctime(&sectop[secid][i].date));
            buf[20] = NULL;
            p = buf + 4;

            fprintf(fp,"\033[37m第\033[31m%3d\033[37m 名 \033[37m信区 : \033[33m%-16s\033[37m【\033[32m%s\033[37m】"
                        "\033[36m%4d \033[37m人\033[35m%16s\n     \033[37m标题 : \033[44m\033[37m%-60.60s\033[m\n",
                        (i+1),sectop[secid][i].board,p,sectop[secid][i].number,
                        sectop[secid][i].userid,sectop[secid][i].title);
#ifdef READ_SEC_TOP
            if (i<10) {
                curr_sectop[i].bid=getbid(sectop[secid][i].board,NULL);
                curr_sectop[i].gid=sectop[secid][i].groupid;
            }
#endif /* READ_SEC_TOP */
        }
#ifdef READ_SEC_TOP
        /* 分区十大信息写入共享内存 */
        if (1) {
            const struct boardheader *bh;
            char path[PATHLEN];
            int k;
            for (k=0;k<10;k++) {
                if (!(bh=getboard(publicshm->sectop[secid][k].bid)))
                    continue;
                snprintf(path,PATHLEN,"boards/%s/.TOP.%u",bh->filename,publicshm->sectop[secid][k].gid);
                unlink(path);
            }
            setpublicshmreadonly(0);
            memcpy(publicshm->sectop[secid],curr_sectop,(10*sizeof(struct top_header)));
            setpublicshmreadonly(1);
        }
#endif /* READ_SEC_TOP */

        fclose(fp);
    }
}
예제 #9
0
파일: bbssel.c 프로젝트: deepurple/bbssrc
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);
    }
}
예제 #10
0
파일: bbsmybrd.c 프로젝트: bmybbs/bmybbs
int
read_submit()
{
	int i;
	char buf1[200];
	FILE *fp;
	struct boardmem *x;
	mybrdnum = 0;
	if (!strcmp(getparm("confirm1"), ""))
		http_fatal("参数错误");
	for (i = 0; i < parm_num; i++) {
		if (!strcasecmp(parm_val[i], "on")) {
			if (ismybrd(parm_name[i]))
				continue;
			if (mybrdnum >= GOOD_BRC_NUM)
				http_fatal("您试图预定超过%d个讨论区",
					   GOOD_BRC_NUM);
			if (!(x = getboard(parm_name[i]))) {
				printf("警告: 无法预定'%s'讨论区<br>\n",
				       nohtml(parm_name[i]));
				continue;
			}
			strsncpy(mybrd[mybrdnum], parm_name[i],
				 sizeof (mybrd[0]));
			mybrdnum++;
		}
	}
	sethomefile(buf1, currentuser.userid, ".goodbrd");
	fp = fopen(buf1, "w");
	for (i = 0; i < mybrdnum; i++)
		fprintf(fp, "%s\n", mybrd[i]);
	fclose(fp);
	saveuservalue(currentuser.userid, "mybrdmode", getparm("mybrdmode"));
	printf
	    ("<script>top.f2.location='bbsleft?t=%ld'</script>修改预定讨论区成功,您现在一共预定了%d个讨论区:<hr>\n",
	     now_t, mybrdnum);
	printf("[<a href='javascript:history.go(-2)'>返回</a>]");
	return 0;
}
예제 #11
0
int main(void) {
  char board[7][7];
  int i, j, k, b=0;
  char *boards[2];
  boards[0] = board;
  while (1) {
    for (i=0; i<7; i++) 
      if (1 != scanf("%s",board[i])) return 0;
    board[1] = search(board[0],'b');
    printf("Board %d.\n",++b);
    for (i=0; i<7; i++) { 
      for (k=0; k<2; k++) {
	for (j=0; j<7; j++)  
	  printf("%c",getboard(boards[k],i,j));
	printf("        ");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
예제 #12
0
파일: bbsclear.c 프로젝트: bmybbs/bmybbs
int
bbsclear_main()
{
	char board[80], start[80], buf[256];
	html_header(1);
	check_msg();
	strsncpy(board, getparm("B"), 32);
	if (!board[0])
		strsncpy(board, getparm("board"), 32);
	strsncpy(start, getparm("S"), 32);
	if (!start[0])
		strsncpy(start, getparm("start"), 32);
	if (!getboard(board))
		http_fatal("´íÎóµÄÌÖÂÛÇø");
	changemode(READNEW);
	brc_initial(currentuser.userid, board);
	brc_clear();
	brc_update(currentuser.userid);
	sprintf(buf, "%s%s&S=%s", showByDefMode(), board, start);
	refreshto(buf, 0);
	http_quit();
	return 0;
}
예제 #13
0
int
bbsbrdadd_main()
{
    FILE *fp;
    char file[200], board[200];
    int i;
    html_header(1);
    changemode(ZAP);
    strsncpy(board, getparm("B"), 32);
    if (!board[0])
        strsncpy(board, getparm("board"), 32);
    if (!loginok)
        http_fatal("超时或未登录,请重新login");
    readmybrd(currentuser.userid);
    if (mybrdnum >= GOOD_BRC_NUM)
        http_fatal("您预定讨论区数目已达上限,不能增加预定");
    if (ismybrd(board))
        http_fatal("你已经预定了这个讨论区");
    if (!getboard(board))
        http_fatal("此讨论区不存在");
    strcpy(mybrd[mybrdnum], board);
    mybrdnum++;
    sethomefile(file, currentuser.userid, ".goodbrd");
    fp = fopen(file, "w");
    if (fp) {
        for (i = 0; i < mybrdnum; i++)
            fprintf(fp, "%s\n", mybrd[i]);
        fclose(fp);
    } else
        http_fatal("Can't save");
    //printf("<script>top.f2.location='bbsleft?t=%d'</script>\n", now_t);
    printf("<script>top.f2.location.reload();</script>\n");
    printf
    ("预定讨论区成功<br><a href='javascript:history.go(-1)'>快速返回</a>");
    http_quit();
    return 0;
}
예제 #14
0
파일: bbsman.c 프로젝트: bmybbs/bmybbs
int
bbsman_main()
{
	int i, total = 0, mode;
	char board[80], tbuf[256], *cbuf;
	char dir[80];
	struct boardmem *brd;
	char *data= NULL;
	int size, last;
	int fd;
	html_header(1);
	check_msg();
	if (!loginok || isguest)
		http_fatal("请先登录");
	changemode(READING);
	strsncpy(board, getparm("board"), 60);
	mode = atoi(getparm("mode"));
	brd = getboard(board);
	if (brd == 0)
		http_fatal("错误的讨论区");
	if (!has_BM_perm(&currentuser, brd))
		http_fatal("你无权访问本页");
	if (mode <= 0 || mode > 5)
		http_fatal("错误的参数");
	printf("<table>");
	cbuf = "none_op";

	sprintf(dir, "boards/%s/.DIR", board);
	size = file_size(dir);
	if (!size)
		http_fatal("空讨论区");
	fd = open(dir, O_RDWR);
	if (fd < 0)
		http_fatal("空讨论区");
	MMAP_TRY {
		data =
		    mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
		close(fd);
		if (data == (void *) -1) {
			MMAP_UNTRY;
			http_fatal("无法读取文章列表");
		}
		last = 0;
		for (i = 0; i < parm_num && i < 40; i++) {
			if (!strncmp(parm_name[i], "box", 3)) {
				total++;
				if (mode == 1) {
#ifndef WWW_BM_DO_DEL
					do_set(data, size, parm_name[i] + 3,
					       FH_DEL, board);
#else
					do_del(board,parm_name[i]+3);
#endif
					cbuf = "delete";
				} else if (mode == 2) {
					do_set(data, size, parm_name[i] + 3,
					       FH_MARKED, board);
					cbuf = "mark";
				} else if (mode == 3) {
					do_set(data, size, parm_name[i] + 3,
					       FH_DIGEST, board);
					cbuf = "digest";
				} else if (mode == 5) {
					do_set(data, size, parm_name[i] + 3, 0, board);
					cbuf = "clear_flag";
				}
			}
		}
		printf("</table>");
	}
	MMAP_CATCH {
		close(fd);
	}
	MMAP_END {
		munmap(data, size);
	}
	if (total <= 0)
		printf("请先选定文章<br>\n");
	snprintf(tbuf, sizeof (tbuf), "WWW batch %s on board %s,total %d",
		 cbuf, board, total);
	securityreport(tbuf, tbuf);
	printf("<br><a href=bbsmdoc?board=%s>返回管理模式</a>", board);
	http_quit();
	return 0;
}
예제 #15
0
파일: bbsnot.c 프로젝트: bmybbs/bmybbs
int
bbsnot_main()
{
	FILE *fp;
	char buf[512], board[80], filename[128], notestr[STRLEN];
	struct boardmem *x;
	int mode;
	
	html_header(1);
	check_msg();
	changemode(READING);
	strsncpy(board, getparm("B"), 32);
	if (!board[0])
		strsncpy(board, getparm("board"), 32);
	if (!(x = getboard(board)))
		http_fatal("´íÎóµÄ°æÃæ");
	mode = atoi(getparm("mode"));
	switch (mode) {
	case 1:
		sprintf(filename, "vote/%s/notes", board);
		sprintf(notestr, "Ò»°ã±¸Íü¼");
		break;
/*	case '2':
		sprintf(filename, "vote/%s/secnotes", board);
		sprintf(notestr, "ÃØÃܱ¸Íü¼");
		break;
*/
	case 3:
	default:
		setbfile(filename, board, "introduction");
		sprintf(notestr, "°æÃæ¼ò½é");
		break;
	}
	
	printf("<center>\n");
	printf("%s -- %s [ÌÖÂÛÇø: %s]<hr>\n", notestr, BBSNAME, board);
	fp = fopen(filename, "r");
	if (fp == 0) {
		printf("<br>±¾ÌÖÂÛÇøÉÐÎÞ¡¸%s¡¹¡£\n", notestr);
		http_quit();
	}
	printf("<table border=1><tr><td class=f2>\n");
	while (1) {
		char *s;
		bzero(buf, 512);
		if (fgets(buf, 512, fp) == 0)
			break;
		while (1) {
			int i;
			s = strstr(buf, "$userid");
			if (s == 0)
				break;
			for (i = 0; i < 7; i++)
				s[i] = 32;
			for (i = 0; i < strlen(currentuser.userid); i++)
				s[i] = currentuser.userid[i];
		}
		fhhprintf(stdout, "%s", buf);
	}
	fclose(fp);
	printf("</table><hr>\n");
	printf("[<a href=%s%s>±¾ÌÖÂÛÇø</a>] ", showByDefMode(), board);
	if (has_BM_perm(&currentuser, x))
		printf("[<a href=bbsmnote?board=%s&mode=%d>±à¼­%s</a>]", board, mode, notestr);
	printf("</center>\n");
	http_quit();
	return 0;
}
예제 #16
0
int main(int argc, char *argv[])
{
	int argi;
	char *envarea = NULL;
	char **critconfig = NULL;
	int cccount = 0;
	char *hffile = "critical";

	critconfig = (char **)calloc(1, sizeof(char *));

	for (argi = 1; (argi < argc); argi++) {
		if (argnmatch(argv[argi], "--env=")) {
			char *p = strchr(argv[argi], '=');
			loadenv(p+1, envarea);
		}
		else if (argnmatch(argv[argi], "--area=")) {
			char *p = strchr(argv[argi], '=');
			envarea = strdup(p+1);
		}
		else if (strcmp(argv[argi], "--debug") == 0) {
			debug = 1;
		}
		else if (strcmp(argv[argi], "--tooltips") == 0) {
			usetooltips = 1;
		}
		else if (argnmatch(argv[argi], "--acklevel=")) {
			char *p = strchr(argv[argi], '=');
			critacklevel = atoi(p+1);
		}
		else if (argnmatch(argv[argi], "--config=")) {
			char *p = strchr(argv[argi], '=');

			critconfig[cccount] = strdup(p+1);
			cccount++;
			critconfig = (char **)realloc(critconfig, (1 + cccount)*sizeof(char *));
			critconfig[cccount] = NULL;
		}
		else if (argnmatch(argv[argi], "--hffile=")) {
			char *p = strchr(argv[argi], '=');
			hffile = strdup(p+1);
		}
	}

	if (!critconfig[0]) {
		critconfig = (char **)realloc(critconfig, 2*sizeof(char *));
		critconfig[0] = (char *)malloc(strlen(xgetenv("XYMONHOME")) + strlen(DEFAULT_CRITCONFIGFN) + 2);
		sprintf(critconfig[0], "%s/%s", xgetenv("XYMONHOME"), DEFAULT_CRITCONFIGFN);
		critconfig[1] = NULL;
	}

	redirect_cgilog("criticalview");

	setdocurl(hostsvcurl("%s", xgetenv("INFOCOLUMN"), 1));

	parse_query();
	load_hostnames(xgetenv("HOSTSCFG"), NULL, get_fqdn());
	load_all_links();
	fprintf(stdout, "Content-type: %s\n\n", xgetenv("HTMLCONTENTTYPE"));

	use_recentgifs = 1;

	if (getboard(mincolor) == 0) {
		int i;
		char *oneconfig, *onename;
		int *partcolor = NULL, *partprio = NULL;
		xtreePos_t hhandle;

		for (i=0; (critconfig[i]); i++) {
			oneconfig = strchr(critconfig[i], ':');
			load_critconfig(oneconfig ? oneconfig+1 : critconfig[i]);
			loadstatus(maxprio, maxage, mincolor, wantacked);

			/* Determine background color and max. priority */
			if (i == 0) {
				partcolor = (int *)malloc(sizeof(int));
				partprio = (int *)malloc(sizeof(int));
			}
			else {
				partcolor = (int *)realloc(partcolor, (i+1)*sizeof(int));
				partprio = (int *)realloc(partprio, (i+1)*sizeof(int));
			}
			partcolor[i] = COL_GREEN;
			partprio[i] = 0;

			for (hhandle = xtreeFirst(rbstate[i]); (hhandle != xtreeEnd(rbstate[i])); hhandle = xtreeNext(rbstate[i], hhandle)) {
				hstatus_t *itm;

				itm = (hstatus_t *)xtreeData(rbstate[i], hhandle);

				if (itm->color > partcolor[i]) partcolor[i] = itm->color;
				if (itm->config->priority > partprio[i]) partprio[i] = itm->config->priority;
			}

			if (partcolor[i] > pagecolor) pagecolor = partcolor[i];
		}

		for (i=0; (critconfig[i]); i++) {
			oneconfig = strchr(critconfig[i], ':'); 
			if (oneconfig) {
				*oneconfig = '\0';
				oneconfig++;
				onename = (char *)malloc(strlen("DIVIDERTEXT=") + strlen(critconfig[i]) + 1);
				sprintf(onename, "DIVIDERTEXT=%s", critconfig[i]);
				putenv(onename);
			}
			else {
				oneconfig = critconfig[i];
				putenv("DIVIDERTEXT=");
			}

			generate_critpage(rbstate[i], hostsonpage[i], stdout, 
					  (i == 0) ? (critconfig[1] ? "critmulti" : hffile) : "divider", 
					  (critconfig[i+1] == NULL) ? hffile : "divider",
					  partcolor[i], partprio[i]);
		}
	}
	else {
		fprintf(stdout, "Cannot load Xymon status\n");
	}

	return 0;
}
예제 #17
0
/*
 * mytype 0 本日
 *        1 本周
 *        2 本月
 *        3 本年
 *        4 祝福榜
 */
void writestat(int mytype)
{
	int i;
	char buf[256];
	char *p;
	char curfile[256];
	FILE *fp;

    struct top_header curr_top[10];

    sprintf(curfile, "etc/posts/%s", myfile[mytype]);
    if ((fp = fopen(curfile, "w")) != NULL) {
#ifdef BLESS_BOARD
        if (mytype == 4)
            fprintf(fp, "              \x1b[1;33m── \x1b[31m☆\x1b[33m☆\x1b[32m☆ \x1b[41;32m  \x1b[33m本日十大衷心祝福  \x1b[m\x1b[1;32m ☆\x1b[31m☆\x1b[33m☆ ──\x1b[m\n"
                        "                                                                         %s\x1b[m\n", surfix_bless[1]);
        else
#endif
            fprintf(fp, "                \033[34m-----\033[37m=====\033[41m 本%s \033[m=====\033[34m-----\033[m\n\n", mytitle[mytype]);

        memset(curr_top,0,(10*sizeof(struct top_header)));

        for (i = 0; i < topnum; i++) {

            strcpy(buf, ctime(&top[i].date));
            buf[20] = NULL;
            p = buf + 4;


#ifdef BLESS_BOARD
            if (mytype == 4)
                fprintf(fp,
                        "                                            %s \x1b[1;31m%4d\x1b[0;37m人      %s\x1b[m\n"
                        "\x1b[1m第\x1b[31m%2d \x1b[37m名 \x1b[4%dm %-51.51s\x1b[m \x1b[1;33m%-12s%s\x1b[m\n",
                        p, top[i].number, surfix_bless[(i+1) * 2], i+1, (i) / 2 + 1, top[i].title, top[i].userid, surfix_bless[(i+1) * 2 + 1]);
            else
#endif
            {
                fprintf(fp,"\033[37m第\033[31m%3d\033[37m 名 \033[37m信区 : \033[33m%-16s\033[37m【\033[32m%s\033[37m】"
                    "\033[36m%4d \033[37m人\033[35m%16s\n     \033[37m标题 : \033[44m\033[37m%-60.60s\033[m\n",
                    (i+1),top[i].board,p,top[i].number,top[i].userid,top[i].title);

                /* etnlegend, 2006.05.28, 阅读十大 ... */
                if(!mytype&&i<10){
                    curr_top[i].bid=getbid(top[i].board,NULL);
                    curr_top[i].gid=top[i].groupid;
                }

            }
        }

        if(!mytype){
            const struct boardheader *bh;
            char path[PATHLEN];
            int k;
            for(k=0;k<10;k++){
                if(!(bh=getboard(publicshm->top[k].bid)))
                    continue;
                snprintf(path,PATHLEN,"boards/%s/.TOP.%u",bh->filename,publicshm->top[k].gid);
                unlink(path);
            }
            setpublicshmreadonly(0);
            memcpy(publicshm->top,curr_top,(10*sizeof(struct top_header)));
            publicshm->top_version++;
            setpublicshmreadonly(1);
        }

#ifdef BLESS_BOARD
        if (mytype == 4)
            fprintf(fp, "                                                                         %s\x1b[m", surfix_bless[22]);
#endif
        fclose(fp);
    }
}
예제 #18
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;
}
int main()
{
  initscr();
  board *init,*goal;
  int i,j,t[valor],k;
  init=getboard();
  puts("\t\t\t*****JUEGO DEL 8-PUZZLE (PROFUNDIDAD)*****\n");
  printf("\n*INGRESA TU ESTADO INICIAL: \n\n");

  for(i=0;i<valor;i++)
   scanf("%d",&init->s[i]);

  int cnt=0;
  for(i=0;i<valor;i++)
  {
    int lcnt=0;
    for(j=i+1;j<valor;j++)
    {
     if(init->s[j]<init->s[i] && init->s[j]!=0)
       lcnt++;
    }
    cnt=cnt+lcnt;
  }
  goal=getboard();
  printf("\nMOVIMIENTOS:%d\n",cnt);
  if((cnt%2)==0)
  {
  	for(k=0;k<valor;k++)
  	{
  		goal->s[k]=k;
  	}
  }
  else
  {
  	for(k=0;k<valor;k++)
  	{
  		goal->s[k]=k;
  	}
  }
  printf("\n-TU ESTADO FINAL ES:\n\n");
  printboard(goal);
  printf("\n-TU ESTADO INICIAL ES:\n\n");
  printboard(init);
  printf("\nPRESIONA UNA TECLA HACIA EL ESTADO FINAL\n");
  getch();
  is_on_path(goal,init);
  init->to_goal=1;
  enq(init);
  spantree(init);
  flag=solve_by_bfs(init,init,goal);
  if(flag==1)
  {
  getpath(init,found);
  getch();
  printf("\nTU ESTADO FINAL ES INOPERABLE");
  getch();
  }
  else
  {
   printf("\nPROBLEMA COMPLEJO, PODRIA HBAER DESBORDAMIENTO DE MEMORIA");
   getch();
  }
  endwin();
  return 0;
}
예제 #20
0
파일: bbsmnote.c 프로젝트: bmybbs/bmybbs
int
bbsmnote_main()
{
	FILE *fp;
	char *ptr, path[256], buf[10000], board[256], notestr[40], buf2[128];
	struct boardmem *x;
	int mode;
	
	html_header(1);
	check_msg();
	printf("<center>\n");
	if (!loginok || isguest)
		http_fatal("´Ò´Ò¹ý¿Í£¬ÇëÏȵǼ");
	changemode(EDIT);
	strsncpy(board, getparm("board"), 30);
	x = getboard(board);
	mode = atoi(getparm("mode"));
	if (!has_BM_perm(&currentuser, x))
		http_fatal("ÄãÎÞȨ½øÐб¾²Ù×÷");
	switch (mode) {
	case 1:
		sprintf(path, "vote/%s/notes", board);
		sprintf(notestr, "Ò»°ã±¸Íü¼");
		break;
	case 2:
		sprintf(path, "vote/%s/secnotes", board);
		sprintf(notestr, "ÃØÃܱ¸Íü¼");
		break;
	case 3:
	default:
		setbfile(path, board, "introduction");
		sprintf(notestr, "°æÃæ¼ò½é");
		break;
	}
	if (!strcasecmp(getparm("type"), "update")){
		if (mode == 2){
			sprintf(buf2, "vote/%s/notespasswd", board);
			unlink(buf2);
		}
		save_note(path);
	}
	printf("%s -- ±à¼­%s [ÌÖÂÛÇø: %s]<hr>\n", BBSNAME, notestr, board);
	printf
	    ("<form name=form1 method=post action=bbsmnote?type=update&board=%s&mode=%d>\n",
	     board, mode);
	fp = fopen(path, "r");
	if (fp) {
		fread(buf, 9999, 1, fp);
		ptr = strcasestr(buf, "<textarea>");
		if (ptr)
			ptr[0] = 0;
		fclose(fp);
	}
	printf("<table border=1><tr><td>");
	printf
	    ("<textarea  onkeydown='if(event.keyCode==87 && event.ctrlKey) {document.form1.submit(); return false;}'  onkeypress='if(event.keyCode==10) return document.form1.submit()' name=text rows=20 cols=80 wrap=virtual>\n");
	printf("%s", nohtml(void1(buf)));
	printf("</textarea></table>\n");
	printf("<input type=submit value=´æÅÌ> ");
	printf("<input type=reset value=¸´Ô­>\n");
	printf("<hr>\n");
	http_quit();
	return 0;
}
예제 #21
0
파일: libann.c 프로젝트: marvelliu/lilacsrc
char * ann_numtopath(char *path, char *numpath, struct userec *user)
{
	int bid=0;
	char *c;
	char *ptr = NULL;
	const struct boardheader *bh = NULL;
    char filename[256];
    FILE *fp;
    char buf[256];
	int endfile=0;
    char currpath[256];
    char title[STRLEN];
	int ok;

	path[0]='\0';
	title[0]='\0';
	currpath[0]='\0';

	while(1){

		if(path[0]=='\0'){
			c=strchr(numpath, '-');
			if(c!=NULL)
				*c='\0';
			bid = atoi(numpath);

			if((bh=getboard(bid))==NULL) return NULL;

    		if (check_read_perm(user, bh) == 0)
		        return NULL;

		    snprintf(path,255,"0Announce/groups/%s",bh->ann_path);
			
			if(c==NULL)
				break;

			ptr = c + 1;

			continue;
		}else{
			if(ptr[0]=='\0') break;
			c = strchr(ptr, '-');
			if(c==NULL) endfile=1;
			else{
				*c='\0';
			}
			bid = atoi(ptr);
			if(c!=NULL) ptr = c+1;
			if(bid <=0) return NULL;
		}

	    snprintf(filename, sizeof(filename), "%s/.Names", path);

		ok = 0;
        if ((fp = fopen(filename, "r")) == NULL)
            return NULL;
        while (fgets(buf, sizeof(buf), fp) != NULL) {
            if ((c = strrchr(buf, '\n')) != NULL)
                *c = '\0';
            if (strncmp(buf, "Name=", 5) == 0) {
                strncpy(title, buf + 5, sizeof(title) - 1);
                title[sizeof(title) - 1] = '\0';
                continue;
            }else if (strncmp(buf, "Path=~/", 7) == 0){
                snprintf(currpath, sizeof(currpath), "%s/%s", path, buf + 7);
				continue;
			}else if (strncmp(buf, "Path=", 5) == 0){
                snprintf(currpath, sizeof(currpath), "%s/%s", path, buf + 5);
				continue;
			}else if(strncmp(buf, "Numb=", 5) == 0){
				if(bid != atoi(buf+5)){
					title[0]='\0';
					currpath[0]='\0';
					continue;
				}
            	if (ann_can_access(title, bh->filename, user) == 0) {
					break;
				}else{
					ok = 1;
					strcpy(path, currpath);
					break;
				}
			}else
				continue;
        }
        fclose(fp);
		if(!ok)
			return NULL;
		if(endfile)
			break;
    }
	if(path[0]=='/' || strncmp(path, "0Announce/groups/", 17) || strstr(path, "..") ) return NULL;
    return path;
}
예제 #22
0
static int bbs_bm_change(char *board, struct boardheader *newbh, struct boardheader *oldbh)
{
	int id,m,brd_num,n,i;
	int flag;
	struct userec *lookupuser;
	unsigned int newlevel;
	char *p;
	char obm[10][IDLEN+2];
	int obmnum=0,nbmnum=0;
	char nbm[10][IDLEN+2];
	char buf[200];

	for(i=0;i<10;i++){
		obm[i][0]='\0';
		nbm[i][0]='\0';
	}

	if(oldbh){
		for(p = strtok(oldbh->BM, " "),obmnum=0; p && obmnum < 10; p=strtok(NULL," "),obmnum++){
			strncpy(obm[obmnum], p, IDLEN+2);
			obm[obmnum][IDLEN+1]='\0';
		}
	}

	for(p = strtok(newbh->BM, " "),nbmnum=0; p && nbmnum < 10; p=strtok(NULL," "),nbmnum++){
		strncpy(nbm[nbmnum], p, IDLEN+2);
		nbm[nbmnum][IDLEN+1]='\0';
	}

	newbh->BM[0]='\0';

	for( i=0; i<obmnum; i++ ){
		flag = 2;

		if(!(id = getuser(obm[i],&lookupuser))){
			continue;
		}

		for(m=0;m<nbmnum;m++){
			if(!strcmp(obm[i],nbm[m]))
				flag = 0;
		}
		if(flag == 0) continue;

		newlevel = lookupuser->userlevel;

		brd_num = 0;

		if( lookupuser->userlevel & PERM_BOARDS ){
			for(n = 0; n < get_boardcount(); n++){
				if(chk_BM_instr(getboard(n+1)->BM, lookupuser->userid) == true )
					brd_num ++;
			}
		}

		if( brd_num == 1){
			newlevel &= ~PERM_BOARDS;
			newlevel &= ~PERM_CLOAK;
		}

		sprintf(buf,"免去 %s 的斑竹 %s", board, lookupuser->userid);
		//securityreport(buf, lookupuser, NULL);
		lookupuser->userlevel = newlevel;
	}

	for( i=0; i<nbmnum; i++ ){
		flag = 1;

		if(!(id = getuser(nbm[i],&lookupuser))){
			continue;
		}

		if( strlen(newbh->BM) + strlen(lookupuser->userid) >= BM_LEN - 2 )
			continue;

		for(m=0;m<obmnum;m++){
			if(!strcmp(nbm[i],obm[m])){
				flag = 0;
				if( newbh->BM[0] != '\0' )
					strcat(newbh->BM, " ");
				strcat(newbh->BM, lookupuser->userid);
			}
		}
		if(flag == 0) continue;

		newlevel = lookupuser->userlevel;

		if( newbh->BM[0] != '\0' )
			strcat( newbh->BM, " " );
		strcat(newbh->BM, lookupuser->userid);

		newlevel |= PERM_BOARDS;
		mail_file(getCurrentUser()->userid, "etc/forbm", lookupuser->userid, "新任斑竹必读", BBSPOST_LINK, NULL);

		sprintf(buf,"任命 %s 的斑竹 %s", board, lookupuser->userid);
		//securityreport(buf, lookupuser, NULL);
		lookupuser->userlevel = newlevel;
	}
    return 0;
}
예제 #23
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;
}
예제 #24
0
파일: bbsgdoc.c 프로젝트: bmybbs/bmybbs
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;
}
예제 #25
0
파일: genhot.c 프로젝트: xingskycn/kbs
int gen_commend_xml(const char *bname, const char *fn, int max)
{
    int dirfd;
    FILE *fp;
    FILE *fp1;
    struct fileheader dirfh;
    char dirpath[STRLEN];
    char dirfile[STRLEN];
    char xml_buf[1024]; //changed from 256 to 1024, for <brief> - atppp
    char buf[256];
    char url_buf[1024]; //changed from 256 to 1024, for <brief> - atppp
    struct stat st;
    int numrecords;
    int i, brieflen, len;
    char *c;
    struct boardheader *bh;

    setbfile(dirpath, bname, DIGEST_DIR);
    if (stat(dirpath, &st) < 0)
        return -1;
    numrecords = st.st_size / sizeof(struct fileheader) ;
    if (numrecords <= 0)
        return -1;

    if ((fp = fopen(fn, "w")) == NULL)
        return -1;

    fprintf(fp, "<?xml version=\"1.0\" encoding=\"GBK\"?>\n");
    fprintf(fp, "<hotsubjects>\n");

    dirfd = open(dirpath, O_RDONLY);
    if (dirfd >= 0) {
        if (numrecords > max)
            lseek(dirfd, sizeof(struct fileheader)*(numrecords - max), SEEK_SET);

        numrecords -= max;

        while (read(dirfd, &dirfh, sizeof(dirfh)) >= sizeof(dirfh)) {

            setbfile(dirfile, bname, dirfh.filename);

            if ((fp1=fopen(dirfile, "r"))==NULL)
                continue;

            numrecords ++;

            fprintf(fp, "<hotsubject>\n");
            fprintf(fp, "<title>%s</title>\n", encode_url(url_buf,encode_xml(xml_buf, dirfh.title, sizeof(xml_buf)),sizeof(url_buf)));
            fprintf(fp, "<author>%s</author>\n", encode_url(url_buf,dirfh.owner,sizeof(url_buf)));
            fprintf(fp, "<time>%ld</time>\n", get_posttime(&dirfh));
            fprintf(fp, "<board>%s</board>\n", encode_url(url_buf,bname,sizeof(url_buf)));
            fprintf(fp, "<id>%d</id>\n", dirfh.id);
            fprintf(fp, "<groupid>%d</groupid>\n", dirfh.groupid);
            bh = (struct boardheader *) getboard(dirfh.o_bid);
            fprintf(fp, "<o_board>%s</o_board>\n", encode_url(url_buf,(bh ? bh->filename : ""),sizeof(url_buf)));
            fprintf(fp, "<o_id>%d</o_id>\n",dirfh.o_id);
            if (fgets(buf, 255, fp1)) {
                if (! strncmp(buf, "发信人: ", 8)) {
                    if ((c=strchr(buf+8, ' ')) != NULL)
                        *c = 0;
                    fprintf(fp, "<owner>%s</owner>\n", buf+8);
                }
            }
            fprintf(fp, "<o_groupid>%d</o_groupid>\n<brief>", dirfh.o_groupid);
            for (i=0;i<3;i++) fgets(buf, 255, fp1);
            brieflen = 240;
            for (i=0;i<4;) {
                if (fgets(buf, 240, fp1)) {
                    if (buf[0] == '\n' || buf[0] == '\r' || buf[0]=='\0')
                        continue;
                    buf[240]=0;
                    /* etnlegend, 2006.09.17, 过滤控制字符... */
                    process_control_chars(buf,"\n");

                    len = strlen(buf);
                    if (!(len<brieflen-1)) {
                        strnzhcpy(buf,buf,brieflen);
                        len=brieflen;
                    }
                    fprintf(fp, "%s", encode_url(url_buf,encode_xml(xml_buf, buf, sizeof(xml_buf)),sizeof(url_buf)));
                    i++;

                    brieflen -= len;

                    if (brieflen<2)
                        break;
                } else
                    break;
            }
            fprintf(fp, " </brief>\n</hotsubject>\n");

            fclose(fp1);
        }
        close(dirfd);
    }

    fprintf(fp, "</hotsubjects>\n");
    fclose(fp);
    return 0;
}
void spantree(board *init)
{
  int i,j,mi,ni=-1;


  for(j=0;j<valor;j++)
  {
     if(init->s[j]==0)
     {
       mi=j;
       break;
     }
  }

  level++;
  if(level==5)
  {
    level--;
    return;
  }
  else
   init->children=moves[mi][4];

  for(i=0;i<init->children;i++)
  {
    board *temp=getboard();

    for(j=0;j<valor;j++)
    {
     if(init->s[j]==0)
     {
       mi=j;
       break;
     }
    }

    for(j=0;j<4;j++)
    {
    if(moves[mi][j]!=-1 && j>ni)
    {
     ni=j;
     break;
    }
    }

    switch((i+1))
    {
     case 1:
       init->c1=temp;
       copyarray(init->path,temp->path,init->pi);
       temp->pi=init->pi;
       temp->path[(temp->pi)++]=1;
       makemove(init,init->c1,mi,ni);
       spantree(init->c1);
       break;
     case 2:
       init->c2=temp;
       copyarray(init->path,temp->path,init->pi);
       temp->pi=init->pi;
       temp->path[(temp->pi)++]=2;
       makemove(init,init->c2,mi,ni);
       spantree(init->c2);
       break;
     case 3:
       init->c3=temp;
       copyarray(init->path,temp->path,init->pi);
       temp->pi=init->pi;
       temp->path[(temp->pi)++]=3;
       makemove(init,init->c3,mi,ni);
       spantree(init->c3);
       break;
     case 4:
       init->c4=temp;
       copyarray(init->path,temp->path,init->pi);
       temp->pi=init->pi;
       temp->path[(temp->pi)++]=4;
       makemove(init,init->c4,mi,ni);
       spantree(init->c4);
       break;
     default:
       printf("\nNO TIENE HIJOS");
    }

  }
     level--;
     return;
}