void setaidfile(char *buf, const char *bn, aidu_t aidu) { // try to load by AID int bid = 0; int n = 0, fd = 0; char bfpath[PATHLEN]; boardheader_t *bh = NULL; fileheader_t fh; buf[0] = 0; bid = getbnum(bn); if (bid <= 0) return; assert(0<=bid-1 && bid-1<MAX_BOARD); bh = getbcache(bid); if (!HasBoardPerm(bh)) return; setbfile(bfpath, bh->brdname, FN_DIR); n = search_aidu(bfpath, aidu); if (n < 0) return; fd = open(bfpath, O_RDONLY); if (fd < 0) return; lseek(fd, n*sizeof(fileheader_t), SEEK_SET); memset(&fh, 0, sizeof(fh)); if (read(fd, &fh, sizeof(fh)) > 0) { setbfile(buf, bh->brdname, fh.filename); if (!dashf(buf)) buf[0] = 0; } close(fd); }
void keeplog(FILE *fin, char *board, char *title, char *owner) { fileheader_t fhdr; char genbuf[256], buf[512]; FILE *fout; int bid; sprintf(genbuf, BBSHOME "/boards/%c/%s", board[0], board); stampfile(genbuf, &fhdr); if(!(fout = fopen(genbuf, "w"))) { perror(genbuf); return; } while(fgets(buf, 512, fin)) fputs(buf, fout); fclose(fin); fclose(fout); strncpy(fhdr.title, title, sizeof(fhdr.title) - 1); fhdr.title[sizeof(fhdr.title) - 1] = '\0'; strcpy(fhdr.owner, owner); sprintf(genbuf, BBSHOME "/boards/%c/%s/.DIR", board[0], board); append_record(genbuf, &fhdr, sizeof(fhdr)); /* XXX: bid of cache.c's getbnum starts from 1 */ if((bid = getbnum(board)) > 0) touchbtotal(bid); }
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> "); */ } }
static void load_default_board(choose_board_t *cbrd) { if (cbrd->gnum == 0) { cbrd->gnum = 1; int i = getbnum(DEFAULTBOARD, ¤tuser); if (i == 0) i = getbnum(currboard, ¤tuser); cbrd->gbrds->id = 1; cbrd->gbrds->pid = 0; cbrd->gbrds->pos = i - 1; cbrd->gbrds->flag = bcache[i - 1].flag; strlcpy(cbrd->gbrds->filename, bcache[i - 1].filename, sizeof(cbrd->gbrds->filename)); strlcpy(cbrd->gbrds->title, bcache[i - 1].title, sizeof(cbrd->gbrds->title)); } }
int normal_board(char* bname) { register int i; if (strcmp (bname, "Nankai_News") ==0) return 1; if (strcmp(bname, DEFAULTBOARD) == 0) return 1; if ((i = getbnum(bname)) == 0) return 0; if (bcache[i - 1].level & PERM_NOZAP) return 1; return (bcache[i - 1].level == 0); }
int haspostperm(char* bname) { register int i; if (digestmode) return 0; if ( deny_me(bname) && !HAS_PERM(PERM_SYSOP)) return 0; if (strcmp(bname, DEFAULTBOARD) == 0) return 1; if ( (!strcmp(bname, "Appeal")||(!strcmp(bname,"Complain"))) && strcmp(lookupuser.userid,"guest") && HAS_PERM(PERM_LOGINOK)) return 1; if ((i = getbnum(bname)) == 0) return 0; set_safe_record(); if (!HAS_PERM(PERM_POST)) return 0; return (HAS_PERM((bcache[i - 1].level & ~PERM_NOZAP) & ~PERM_POSTMASK)); }
int main(int argc, char **argv) { int ch, allboards = 0, i; boardheader_t *bptr; while( (ch = getopt(argc, argv, "ah")) != -1 ) switch( ch ){ case 'a': allboards = 1; break; case 'h': usage(); return 0; } chdir(BBSHOME); attach_SHM(); argc -= optind; argv += optind; now = time(NULL); if( allboards ){ for( i = 0 ; i < MAX_BOARD ; ++i ){ bptr = &bcache[i]; if( bptr->brdname[0] && !(bptr->brdattr & (BRD_TOP | BRD_GROUPBOARD)) && bptr->brdattr & BRD_HIDE ) chkhbf(bptr); } } else if( argc > 0 ){ int bid; for( i = 0 ; i < argc ; ++i ) if( (bid = getbnum(argv[i])) != 0 ) // XXX: bid start 1 chkhbf(getbcache(bid)); else fprintf(stderr, "%s not found\n", argv[i]); } else usage(); return 0; }
int load_newsfeeds() { int bid; FILE *fp, *fo; char str[128]; if (!(fp = fopen(INND_NEWSFEED, "r"))) { return 0; } if (!(fo = fopen(INND_BADFEED, "w"))) { return 0; } for(feedcount=0; fgets(str, 128, fp); feedcount++) { if(str[0]=='#') continue; sscanf(str,"%s %s %s", feedline[feedcount].group,feedline[feedcount].board, feedline[feedcount].server); /* XXX: bid of cache.c's getbnum starts from 1 */ bid=getbnum(feedline[feedcount].board); if(!bid) { fprintf(fo,"%s %s\n", feedline[feedcount].board, feedline[feedcount].group ); feedcount--; continue; /*移除沒有的看板i*/} strcpy(feedline[feedcount].board,bcache[bid-1].brdname); /*校正大小寫 */ istran[bid-1]=1; } fclose(fp); fclose(fo); qsort(feedline, feedcount, sizeof(newsfeed_t), newsfeed_cmp); return feedcount; }
int main(void) { FILE *fp, *ftmp; int i = 0, num; // char *currboard[3] = {"CCK-CHUHEN", "CCK-GENERAL", "CCK-FREE"}; // char *kingdom[3] = {"·¡º~¬Ó´Â", "±N«Ó«ÒÁp", "³p»»¤ý´Â"}; char file1[80], file2[80], line[256], str[256]; time_t dtime; boardheader_t brd; int brdfd; setgid(BBSGID); setuid(BBSUID); chdir(BBSHOME); attach_SHM(); time(&dtime); if ((brdfd = open(BBSHOME "/" FN_BOARD, O_RDONLY)) == -1){ perror("open " BBSHOME "/" FN_BOARD); return 0; } while(read(brdfd, &brd, sizeof(brd)) == sizeof(brd)) { const char* photo_fname = 0; const char* chess_name = 0; char kingdom_name[256]; int bid; // struct stat st; switch(brd.chesscountry){ case CHESSCODE_FIVE: photo_fname = "photo_fivechess"; chess_name = "¤¤l´Ñ"; break; case CHESSCODE_CCHESS: photo_fname = "photo_cchess"; chess_name = "¶H´Ñ"; break; case CHESSCODE_GO: photo_fname = "photo_go"; chess_name = "³ò´Ñ"; break; case CHESSCODE_REVERSI: photo_fname = "photo_reversi"; chess_name = "¶Â¥Õ´Ñ"; break; default: continue; } bid = getbnum(brd.brdname); setapath(str, brd.brdname); sprintf(file1, "%s/chess_list", str); printf("apath = %s\n", str); /* if (stat(file1, &st) == 0 && st.st_mtime > (dtime - UPDATE_FREQUENCY * 60)) continue; */ sprintf(file2, "%s/chess_list.tmp", str); if ((ftmp = fopen(file2, "w")) == NULL) continue; if ((fp = fopen(file1, "r"))) { char *p; char userid[IDLEN + 1], buf[256], name[11]; char date[11], other[IDLEN + 1]; int namelen; fgets(kingdom_name, 256, fp); fputs(kingdom_name, ftmp); chomp(kingdom_name); while (fgets(buf, sizeof(buf), fp)) { i = 0; strcpy(line, buf); p = strtok(buf, " "); name[0] = '\0'; if (p && *p != '#' && searchuser(p, userid)) { i = 1; if ((p = strtok(NULL, " "))) strlcpy(name, p, sizeof(name)); else i = 0; if ((p = strtok(NULL, " "))) strlcpy(date, p, sizeof(date)); else i = 0; if ((p = strtok(NULL, " "))) strlcpy(other, p, sizeof(other)); else i = 0; } if (!strcmp("°£¦W", name)) { sethomefile(buf, userid, photo_fname); unlink(buf); continue; } if (i == 0) { fprintf(ftmp, "%s", line); continue; } namelen = strlen(name); setapath(str, brd.brdname); sprintf(buf, "%s/chess_photo/.DIR", str); num = get_num_records(buf, sizeof(fileheader_t)); for (i = 1; i <= num; i++) { fileheader_t item; if (get_record(buf, &item, sizeof item, i) != -1) { FILE *fp1; if (!strncmp(item.title + 3, name, namelen) && (item.title[namelen + 3] == '\0' || item.title[namelen + 3] == ' ') ) { sethomefile(buf, userid, photo_fname); if ((fp1 = fopen(buf, "w"))) { sprintf(buf, "%s/chess_photo/%s", str, item.filename); f_suck6(fp1, buf); fprintf(fp1, "%d\n", bid); if (strcmp("«R¸¸", name)) fprintf(fp1, "<©ÒÄݤý°ê> %s (%s)\n", kingdom_name, chess_name); else fprintf(fp1, "<«R¸¸¤ý°ê> %s\n", kingdom_name); fprintf(fp1, "<²{¦b¶¥¯Å> %s\n", name); fprintf(fp1, "<¥[¤J¤é´Á> %s\n", date); if (strcmp("«R¸¸", name)) { int level; fprintf(fp1, "<¤ý°êµ¥¯Å> "); level = atoi(other); for (i = 0; i < level; i++) fprintf(fp1, "%s", "¡¹"); } else { chomp(other); fprintf(fp1, "<³Q½Ö«R¸¸> %s", other); } fprintf(fp1, "\n<¦Û§Ú»¡©ú> \n"); fclose(fp1); } break; } } } if (i > num) // level photo not found fprintf(ftmp, "%s", line); else fprintf(ftmp, "#%s", line); } fclose(fp); fclose(ftmp); rename(file2, file1); } else { fclose(ftmp); } } return 0; }
static void user_login() { char ans[4], i; char genbuf[200]; struct tm *ptime, *tmp; time_t now; int a; /*** Heat:廣告詞 char *ADV[17] = { "記得唷!! 5/12在台大二活地下室見~~~", "你知道Ptt之夜是什麼嗎? 5/12號就要上演耶 快去問吧!", "5/12 Ptt之夜即將引爆 能不去嗎? 在台大二活地下室咩", "不來就落伍了 啥? 就Ptt之夜啊 很棒的晚會唷 時間:5/12", "差點忘了提醒你 5/12我們有約 就台大二活地下室咩!!", "Ptt是啥 想知嗎? 5/12在台大二活地下室告訴你唷", "來來來....5/12快到台大二活地下室去拿獎品吧~~", "去去去...到台大二活地下室去 就5/12麻 有粉多獎品耶", "喂喂喂 怎還楞在這!!快呼朋引伴大鬧ptt", "Ptt最佳豬腳 換你幹幹看 5/12來吧....*^_^*", "幹什麼幹什麼?? 你怎麼不曉得啥是Ptt之夜..老土唷", "累了嗎? 讓我們來為你來一段精采表演吧.. 5/12 Ptt之夜", "世紀末最屁力的晚會 就在台大二活地下室 5/12不見不散 gogo", "到底誰比較帥(美) 來比比吧 5/12Ptt之夜 一較高下", "台大二活地下室 5/12 聽說會有一場很棒的晚會唷 Ptt之夜", "台大二活地下室 5/12 你能不來嗎?粉多網友等著你耶", "5/12 台大二活地下室 是各約網友見面的好地方呢", }; char *ADV[] = { "7/17 @LIVE 亂彈, 何欣穗 的 入場卷要送給 ptt 的愛用者!", "欲知詳情請看 PttAct 板!!", }; ***/ log_usies("ENTER", getenv("RFC931") /* fromhost */ ); setproctitle("%s: %s", margs, cuser.userid); /* resolve all cache */ resolve_garbage(); /* get ptt cache */ resolve_fcache(); resolve_boards(); /* 初始化 uinfo、flag、mode */ setup_utmp(LOGIN); mysrand(); /* 初始化: random number 增加user跟時間的差異 */ currmode = MODE_STARTED; enter_uflag = cuser.uflag; /* get local time */ time(&now); ptime = localtime(&now); tmp = localtime(&cuser.lastlogin); if((a = utmpshm->number) > fcache->max_user) { sem_init(FROMSEM_KEY, &fcache_semid); sem_lock(SEM_ENTER, fcache_semid); fcache->max_user = a; fcache->max_time = now; sem_lock(SEM_LEAVE, fcache_semid); } #ifdef INITIAL_SETUP if(!getbnum(DEFAULT_BOARD)) { strcpy(currboard, "尚未選定"); } else #endif { brc_initial(DEFAULT_BOARD); set_board(); } /* 畫面處理開始 */ if(!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST))) do_aloha("<<上站通知>> -- 我來啦!"); if(ptime->tm_mday == cuser.day && ptime->tm_mon + 1 == cuser.month) { more("etc/Welcome_birth", NA); currutmp->birth = 1; } else { more("etc/Welcome_login", NA); // pressanykey(); // more("etc/CSIE_Week", NA); currutmp->birth = 0; } if(cuser.userlevel) { /* not guest */ move(t_lines - 4, 0); prints(" 歡迎您第 \033[1;33m%d\033[0;37m 度拜訪本站," "上次您是從 \033[1;33m%s\033[0;37m 連往本站,\n" " 我記得那天是 \033[1;33m%s\033[0;37m。\n", ++cuser.numlogins, cuser.lasthost, Cdate(&cuser.lastlogin)); currutmp->mind=rand()%8; /* 初始心情 */ pressanykey(); if(currutmp->birth && tmp->tm_mday != ptime->tm_mday) { more("etc/birth.post", YEA); brc_initial("WhoAmI"); set_board(); do_post(); } setuserfile(genbuf, str_badlogin); if(more(genbuf, NA) != -1) { getdata(b_lines - 1, 0, "您要刪除以上錯誤嘗試的記錄嗎(Y/N)?[Y]", ans, 3, LCECHO); if(*ans != 'n') unlink(genbuf); } check_register(); strncpy(cuser.lasthost, fromhost, 16); cuser.lasthost[15] = '\0'; restore_backup(); } else if(!strcmp(cuser.userid, STR_GUEST)) { char *nick[13] = { "椰子", "貝殼", "內衣", "寶特瓶", "翻車魚", "樹葉", "浮萍", "鞋子", "潛水艇", "魔王", "鐵罐", "考卷", "大美女"}; char *name[13] = { "大王椰子", "鸚鵡螺", "比基尼", "可口可樂", "仰泳的魚", "憶", "高岡屋", "AIR Jordon", "紅色十月號", "批踢踢", "SASAYA椰奶", "鴨蛋", "布魯克鱈魚香絲"}; char *addr[13] = { "天堂樂園", "大海", "綠島小夜曲", "美國", "綠色珊瑚礁", "遠方", "原本海", "NIKE", "蘇聯", "男八618室", "愛之味", "天上", "藍色珊瑚礁"}; i = login_start_time % 13; sprintf(cuser.username, "海邊漂來的%s", nick[(int)i]); sprintf(currutmp->username, cuser.username); sprintf(cuser.realname, name[(int)i]); sprintf(currutmp->realname, cuser.realname); sprintf(cuser.address, addr[(int)i]); cuser.sex = i % 8; currutmp->pager = 2; pressanykey(); } else pressanykey(); if(!PERM_HIDE(currutmp)) cuser.lastlogin = login_start_time; reload_money(); passwd_update(usernum, &cuser); for(i = 0; i < NUMVIEWFILE; i++) if((cuser.loginview >> i) & 1) more(loginview_file[(int)i][0], YEA); }
static void a_delete(menu_t * pm, const char *backup_dir) { char fpath[PATHLEN], buf[PATHLEN], cmd[PATHLEN]; char ans[4]; fileheader_t backup, *fhdr = &(pm->header[pm->now - pm->page]); const char *msg_errsync = "刪除檔案失敗,請退回上層目錄後再重試一次", *msg_errsync2 = "檔案可能已被它人刪除,請退回上層目錄再重進確認", *msg_errbackup = "檔案已刪除但無法備份。請至 " BN_BUGREPORT "報告您試圖刪除檔案的位置。"; snprintf(fpath, sizeof(fpath), "%s/%s", pm->path, fhdr->filename); setadir(buf, pm->path); if (fhdr->filename[0] == 'H' && fhdr->filename[1] == '.') { getdata(b_lines - 1, 1, "您確定要刪除此精華區連線嗎(Y/N)?[N] ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') return; if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) { vmsg(msg_errsync); return; } } else if (dashl(fpath)) { getdata(b_lines - 1, 1, "您確定要刪除此 symbolic link 嗎(Y/N)?[N] ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') return; if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) { vmsg(msg_errsync); return; } unlink(fpath); } else if (dashf(fpath)) { getdata(b_lines - 1, 1, "您確定要刪除此檔案嗎(Y/N)?[N] ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') return; if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) { vmsg(msg_errsync); return; } switch(delete_file_content(buf, fhdr, backup_dir, NULL, 0)) { case DELETE_FILE_CONTENT_BACKUP_FAILED: vmsg(msg_errbackup); break; case DELETE_FILE_CONTENT_FAILED: vmsg(msg_errsync2); break; default: #ifndef USE_TIME_CAPSULE // When not using time capsule, .DIR content may be changed in // board (BN_DELETE/BN_JUNK) and need to be changed. However // since that's going to be deprecated in future, let's have a // simple workaround here. if (backup_dir) { const char *bn = NULL; if (strstr(backup_dir, "/" BN_JUNK "/")) bn = BN_JUNK; else if (strstr(backup_dir, "/" BN_DELETED "/")) bn = BN_DELETED; if (bn) setbtotal(getbnum(bn)); } #endif break; } } else if (dashd(fpath)) { // TODO(hungte) We should create a top level folder and move everything // inside. // XXX we also check PERM_MAILLIMIT here because RMAIL // may be not trusted... const char *save_bn = ( HasUserPerm(PERM_MAILLIMIT) && (currstat & RMAIL) ) ? BN_JUNK : BN_DELETED; getdata(b_lines - 1, 1, "您確定要刪除整個目錄嗎(Y/N)?[N] ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') return; if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) { vmsg(msg_errsync); return; } setapath(buf, save_bn); // XXX because this directory will hold folders from entire site, // let's allow it to use a large set of file names. if (stampadir(buf, &backup, 1) != 0) { vmsg("抱歉,系統目前無法刪除資料,請通知站務人員"); return; } snprintf(cmd, sizeof(cmd), "rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf); system(cmd); strlcpy(backup.owner, cuser.userid, sizeof(backup.owner)); strcpy(backup.title, "◆"); strlcpy(backup.title + 2, fhdr->title + 2, sizeof(backup.title) - 3); // restrict access if source is hidden if ((fhdr->filemode & FILE_BM) || (fhdr->filemode & FILE_HIDE)) backup.filemode |= FILE_BM; /* merge setapath(buf, save_bn); setadir(buf, buf); */ snprintf(buf, sizeof(buf), "man/boards/%c/%s/" FN_DIR, *save_bn, save_bn); append_record(buf, &backup, sizeof(backup)); } else { /* Ptt 損毀的項目 */ getdata(b_lines - 1, 1, "您確定要刪除此損毀的項目嗎(Y/N)?[N] ", ans, sizeof(ans), LCECHO); if (ans[0] != 'y') return; if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) return; } pm->num--; }
static void answer_key(struct evbuffer *buf, const char *key) { int bid; boardheader_t *bptr; if (isdigit(*key)) { char *p; if ((bid = atoi(key)) == 0 || bid > MAX_BOARD) return; if ((p = strchr(key, '.')) == NULL) return; bptr = getbcache(bid); if (!bptr->brdname[0] || BOARD_HIDDEN(bptr)) return; key = p + 1; if (strcmp(key, "isboard") == 0) evbuffer_add_printf(buf, "%d", (bptr->brdattr & BRD_GROUPBOARD) ? 0 : 1); else if (strcmp(key, "over18") == 0) evbuffer_add_printf(buf, "%d", (bptr->brdattr & BRD_OVER18) ? 1 : 0); else if (strcmp(key, "hidden") == 0) evbuffer_add_printf(buf, "%d", BOARD_HIDDEN(bptr) ? 1 : 0); else if (strcmp(key, "brdname") == 0) evbuffer_add(buf, bptr->brdname, strlen(bptr->brdname)); else if (strcmp(key, "title") == 0) evbuffer_add(buf, bptr->title + 7, strlen(bptr->title) - 7); else if (strcmp(key, "class") == 0) evbuffer_add(buf, bptr->title, 4); else if (strcmp(key, "BM") == 0) evbuffer_add(buf, bptr->BM, strlen(bptr->BM)); else if (strcmp(key, "parent") == 0) evbuffer_add_printf(buf, "%d", bptr->parent); else if (strcmp(key, "count") == 0) { char path[PATH_MAX]; setbfile(path, bptr->brdname, FN_DIR); evbuffer_add_printf(buf, "%d", get_num_records(path, sizeof(fileheader_t))); } else if (strcmp(key, "children") == 0) { if (!(bptr->brdattr & BRD_GROUPBOARD)) return; for (bid = bptr->firstchild[1]; bid > 0; bid = bptr->next[1]) { bptr = getbcache(bid); evbuffer_add_printf(buf, "%d,", bid); } } else if (strncmp(key, "articles.", 9) == 0) { int offset, length; key += 9; if (!isdigit(*key) && *key != '-') return; offset = atoi(key); p = strchr(key, '.'); if (!p || (length = atoi(p+1)) == 0) length = DEFAULT_ARTICLE_LIST; article_list(buf, bptr, offset, length); } else if (strncmp(key, "article.", 8) == 0) { if (!is_valid_article_filename(key + 8)) return; char path[PATH_MAX]; struct stat st; int fd; setbfile(path, bptr->brdname, key + 8); if ((fd = open(path, O_RDONLY)) < 0) return; if (fstat(fd, &st) < 0 || st.st_size == 0 || evbuffer_add_file(buf, fd, 0, st.st_size) != 0) close(fd); } else if (strncmp(key, "articlestat.", 12) == 0) { if (!is_valid_article_filename(key + 12)) return; char path[PATH_MAX]; struct stat st; setbfile(path, bptr->brdname, key + 12); if (stat(path, &st) < 0) return; evbuffer_add_printf(buf, "%d-%d,%ld", (int) st.st_dev, (int) st.st_ino, st.st_size); } else if (strncmp(key, "articlepart.", 12) == 0) { answer_articleselect(buf, bptr, key + 12, select_article_part, NULL); } else if (strncmp(key, "articlehead.", 12) == 0) { answer_articleselect(buf, bptr, key + 12, select_article_head, NULL); } else if (strncmp(key, "articletail.", 12) == 0) { answer_articleselect(buf, bptr, key + 12, select_article_tail, NULL); } else return; } else if (strncmp(key, "tobid.", 6) == 0) { bid = getbnum(key + 6); bptr = getbcache(bid); if (!bptr->brdname[0] || BOARD_HIDDEN(bptr)) return; evbuffer_add_printf(buf, "%d", bid); #if HOTBOARDCACHE } else if (strncmp(key, "hotboards", 9) == 0) { for (bid = 0; bid < SHM->nHOTs; bid++) { bptr = getbcache(SHM->HBcache[bid] + 1); if (BOARD_HIDDEN(bptr)) continue; evbuffer_add_printf(buf, "%d,", SHM->HBcache[bid] + 1); } #endif } }
static void user_login() { char genbuf [200]; struct tm *ptime, *tmp; time_t now = time(0); int a; extern struct FROMCACHE *fcache; extern int fcache_semid; log_usies("ENTER", fromhost); setproctitle("%s: %s", cuser.userid, fromhost); /* ------------------------ */ /* 初始化 uinfo、flag、mode */ /* ------------------------ */ setup_utmp(LOGIN); currmode = MODE_STARTED; enter_uflag = cuser.uflag; /* get local time */ tmp = localtime(&cuser.lastlogin); update_data(); /* wildcat: update user data */ /* Ptt check 同時上線人數 */ resolve_fcache(); resolve_utmp(); if ((a = utmpshm->number) > fcache->max_user) { sem_init(FROMSEM_KEY, &fcache_semid); sem_lock(SEM_ENTER, fcache_semid); fcache->max_user = a; fcache->max_time = now; sem_lock(SEM_LEAVE, fcache_semid); } #ifdef INITIAL_SETUP if (getbnum(DEFAULT_BOARD) == 0) { strcpy(currboard, "尚未選定"); } else #endif { brc_initial(DEFAULT_BOARD); set_board(); } /* ------------ */ /* 畫面處理開始 */ /* ------------ */ if (!(HAS_PERM(PERM_SYSOP) && HAS_PERM(PERM_DENYPOST))) { char buf [256]; time_t now; time(&now); sprintf(buf, "<<上站通知>> -- 我來囉! - %s", Etime(&now)); do_aloha(buf); } time(&now); ptime = localtime(&now); #ifdef CAMERA film_out(FILM_LOGIN, 0); #else more("etc/Welcome_login", NA); #endif #if 0 /* wildcat : 搬家通知用 */ if (belong(BBSHOME "/etc/oldip", fromhost)) { more(BBSHOME "/etc/removal"); abort_bbs(); } #endif if ((cuser.day == ptime->tm_mday) && (cuser.month == (ptime->tm_mon + 1))) currutmp->birth = 1; else currutmp->birth = 0; if (cuser.userlevel) { /* not guest */ move(t_lines - 3, 0); prints(" 歡迎您第 [1;33m%d[0;37m 度拜訪本站,\ 上次您是從 [1;33m%s[0;37m 連往本站,\n\ 我記得那天是 [1;33m%s[0;37m。\n", ++cuser.numlogins, cuser.lasthost, Etime(&cuser.lastlogin)); pressanykey(NULL); /* Ptt */ if (currutmp->birth == 1) { #ifdef CAMERA film_out(FILM_WEL_BIRTH, 0); #else more("etc/Welcome_birth", YEA); #endif brc_initial("Greeting"); set_board(); do_post(); } sethomefile(genbuf, cuser.userid, str_badlogin); if (more(genbuf, NA) != -1) { if (getans2(b_lines, 0, "您要刪除以上錯誤嘗試的記錄嗎?", 0, 2, 'y') != 'n') unlink(genbuf); } check_register(); strncpy(cuser.lasthost, fromhost, 24); substitute_record(fn_passwd, &cuser, sizeof(cuser), usernum); cuser.lasthost[23] = '\0'; restore_backup(); }
static int show_board_info(const char *board) { int i; struct boardheader *bp; struct bstat *bs; char secu[40]; bp = getbcache(board); bs = getbstat(board); clear(); prints("版面详细信息:\n\n"); prints("number : %d\n", getbnum(bp->filename, ¤tuser)); prints("英文名称: %s\n", bp->filename); prints("中文名称: %s\n", (HAS_PERM(PERM_SPECIAL0)) ? bp->title : (bp->title + 11)); prints("版 主: %s\n", bp->BM); prints("所属讨论区: %s\n", bp->group ? bcache[bp->group - 1].filename : "无"); prints("是否目录: %s\n", (bp->flag & BOARD_DIR_FLAG) ? "目录" : "版面"); prints("可以 ZAP: %s\n", (bp->flag & BOARD_NOZAP_FLAG) ? "不可以" : "可以"); if (!(bp->flag & BOARD_DIR_FLAG)) { prints("在线人数: %d 人\n", bs->inboard); prints("文 章 数: %s\n", (bp->flag & BOARD_JUNK_FLAG) ? "不计算" : "计算"); prints("可以回复: %s\n", (bp->flag & BOARD_NOREPLY_FLAG) ? "不可以" : "可以"); //prints ("可以 ZAP: %s\n", // (bp->flag & BOARD_NOZAP_FLAG) ? "不可以" : "可以"); prints("匿 名 版: %s\n", (bp->flag & BOARD_ANONY_FLAG) ? "是" : "否"); #ifdef ENABLE_PREFIX prints ("强制前缀: %s\n", (bp->flag & BOARD_PREFIX_FLAG) ? "必须" : "不必"); #endif prints("俱 乐 部: %s\n", (bp->flag & BOARD_CLUB_FLAG) ? (bp-> flag & BOARD_READ_FLAG) ? "读限制俱乐部" : "普通俱乐部" : "非俱乐部"); prints("now id : %d\n", bs->nowid); prints("读写限制: %s\n", (bp->flag & BOARD_POST_FLAG) ? "限制发文" : (bp->level ==0) ? "没有限制" : "限制阅读"); } if (HAS_PERM(PERM_SPECIAL0) && bp->level != 0) { prints("权 限: "); strcpy(secu, "ltmprbBOCAMURS#@XLEast0123456789"); for (i = 0; i < 32; i++) { if (!(bp->level & (1 << i))) secu[i] = '-'; else { prints("%s\n ", permstrings[i]); } } prints("\n权 限 位: %s\n", secu); } prints("URL 地址: http://"BBSHOST"/bbs/doc?bid=%d\n", bp - bcache + 1); pressanykey(); return FULLUPDATE; }