bbstfind.c

来自「bbs server linux平台下软件源码」· C语言 代码 · 共 74 行

C
74
字号
/* * $Id: bbstfind.c,v 1.16 2003/04/24 14:32:56 stiger Exp $ */#include "bbslib.h"int main(){    FILE *fp;    char buf[1024], title[80], board[80], dir[80], first_file[80];    char brdencode[STRLEN];    bcache_t *x1;    struct fileheader x, x0;    int sum = 0, total = 0;    int title_len;    int groupid;    int same;    init_all();    strsncpy(board, getparm("board"), 32);    strsncpy(title, getparm("title"), 42);    groupid = atoi(getparm("groupid"));    x1 = getbcache(board);    if (x1 == 0)        http_fatal("错误的讨论区");    strcpy(board, x1->filename);    if (!check_read_perm(currentuser, x1))        http_fatal("错误的讨论区");    sprintf(dir, "boards/%s/.DIR", board);    fp = fopen(dir, "r");    if (fp == 0)        http_fatal("错误的讨论区目录");    encode_url(brdencode, board, sizeof(brdencode));    sprintf(buf, "bbsman?board=%s&mode=1", brdencode);    printf("<center>%s -- 同主题查找 [讨论区: %s] [主题 '%s']<hr class=\"default\">\n", BBSNAME, board, nohtml(title));    printf("<table border=\"1\"><tr><td>编号</td><td>作者</td><td>日期</td><td>标题</td></tr>\n");    title_len = strlen(title);    title_len = title_len > 40 ? 40 : title_len;    while (1) {        if (fread(&x, sizeof(x), 1, fp) == 0)            break;        sum++;        if (groupid == 0)            same = (!strncmp(title, x.title, title_len) || (!strncmp(title, x.title + 4, title_len) && !strncmp(x.title, "Re: ", 4)));        else            same = (x.groupid == groupid);        if (same) {            if (total == 0)                strcpy(first_file, x.filename);            printf("<tr><td>%d</td>", sum);            printf("<td>%s</td>", userid_str(x.owner));            if (!(x.accessed[0] & (FILE_MARKED | FILE_DIGEST))) {                char buf2[STRLEN];                snprintf(buf2, sizeof(buf2), "&box%s=on", x.filename);                if (strlen(buf) < 500)                    strcat(buf, buf2);            }            printf("<td>%6.6s</td>", wwwCTime(get_posttime(&x) + 4));            printf("<td><a href=\"/bbscon.php?board=%s&id=%d\">%s</a></td></tr>\n", brdencode, x.id, void1(x.title));            total++;        }    }    fclose(fp);    printf("</table><hr>\n共找到 %d 篇 \n", total);    printf("<a href=\"/bbsdoc.php?board=%s\">本讨论区</a> ", brdencode);    if (total > 0) {        printf("<a href=\"bbstcon?board=%s&file=%s\">本主题全部展开</a> ", brdencode, first_file);        if (has_BM_perm(currentuser, board))            printf("<a onclick=\"return confirm('确定同主题全部删除?')\" href=\"%s\">同主题删除</a>", buf);    }    http_quit();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?