static int bls_setfn(char *fn, size_t sz, const char *p) { *fn = 0; switch(bls_getcat(p)) { case BLS_GLOBAL: snprintf(fn, sz, "%s/" BLSCONF_PREFIX "U%08x", BLSCONF_GPATH, blrt.storename); return 1; case BLS_USER: setuserfile(fn, BLSCONF_UPATH); #ifndef DEFAULT_FOLDER_CREATE_PERM #define DEFAULT_FOLDER_CREATE_PERM (0755) #endif mkdir(fn, DEFAULT_FOLDER_CREATE_PERM); assert(strlen(fn) +8 <= sz); snprintf(fn + strlen(fn), sz - strlen(fn), "/" BLSCONF_PREFIX "G%08x", blrt.storename); return 1; } return 0; }
static void chat_load_alias() { char buf[256]; int i; chat_alias_count = 0; chat_aliases = (struct chatalias *) malloc(sizeof (struct chatalias) * MAXDEFINEALIAS); for (i = 0; i < MAXDEFINEALIAS; i++) chat_aliases[i].cmd[0] = 0; setuserfile(buf, "chatalias"); chat_alias_count = get_num_records(buf, sizeof (struct chatalias)); if (chat_alias_count > MAXDEFINEALIAS) chat_alias_count = MAXDEFINEALIAS; if (chat_alias_count != 0) get_records(buf, chat_aliases, sizeof (struct chatalias), 1, chat_alias_count); for (i = 0; i < chat_alias_count; i++) { if (chat_aliases[i].cmd[0] == 0) { chat_alias_count = i; break; } chat_aliases[i].cmd[8] = 0; chat_aliases[i].action[80] = 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); } }
static int common_pager_exit_handler(int r, const char *fpath) { // post processing switch(r) { case RET_DOSYSOPEDIT: r = FULLUPDATE; if (!check_sysop_edit_perm(fpath)) break; log_filef("log/security", LOG_CREAT, "%u %s %d %s admin edit file=%s\n", (int)now, Cdate(&now), getpid(), cuser.userid, fpath); veditfile(fpath); break; case RET_COPY2TMP: r = FULLUPDATE; if (HasUserPerm(PERM_BASIC)) { char buf[PATHLEN]; getdata(b_lines - 1, 0, "把這篇文章收入到暫存檔?[y/N] ", buf, 4, LCECHO); if (buf[0] != 'y') break; setuserfile(buf, ask_tmpbuf(b_lines - 1)); Copy(fpath, buf); } break; case RET_SELECTBRD: r = FULLUPDATE; if (currstat == READING) r = Select(); break; case RET_DOCHESSREPLAY: r = FULLUPDATE; if (HasUserPerm(PERM_BASIC)) ChessReplayGame(fpath); break; #if defined(USE_BBSLUA) && !defined(DISABLE_BBSLUA_IN_PAGER) case RET_DOBBSLUA: r = FULLUPDATE; // check permission again if (HasUserPerm(PERM_BASIC)) bbslua(fpath); break; #endif } return r; }
// Calculate numbers of signatures. void set_numofsig(void) { int sigln; char signame[NAME_MAX]; setuserfile(signame, "signatures"); sigln = countln(signame); numofsig = sigln / MAXSIGLINES; if ((sigln % MAXSIGLINES) != 0) ++numofsig; return; }
static void setup_utmp(int mode) { userinfo_t uinfo; char buf[80]; char remotebuf[1024]; time_t now = time(NULL); memset(&uinfo, 0, sizeof(uinfo)); uinfo.pid = currpid = getpid(); uinfo.uid = usernum; uinfo.mode = currstat = mode; uinfo.msgcount = 0; if(!(cuser.numlogins % 20) && cuser.userlevel & PERM_BM) check_BM(); /* Ptt 自動取下離職板主權力 */ uinfo.userlevel = cuser.userlevel; uinfo.lastact = time(NULL); postrecord.times = 0; /* 計算crosspost數 */ strcpy(uinfo.userid, cuser.userid); strcpy(uinfo.realname, cuser.realname); strcpy(uinfo.username, cuser.username); strncpy(uinfo.from, fromhost, 23); uinfo.five_win = cuser.five_win; uinfo.five_lose = cuser.five_lose; uinfo.five_tie = cuser.five_tie; uinfo.invisible = cuser.invisible % 2; uinfo.pager = cuser.pager % 5; uinfo.brc_id = 0; #ifdef WHERE uinfo.from_alias = where(fromhost); #else uinfo.from_alias = 0; #endif setuserfile(buf, "remoteuser"); strcpy(remotebuf, getenv("RFC931")); strcat(remotebuf, ctime(&now)); remotebuf[strlen(remotebuf)-1] = 0; add_distinct(buf, remotebuf); if(enter_uflag & CLOAK_FLAG) uinfo.invisible = YEA; getnewutmpent(&uinfo); #ifndef _BBS_UTIL_C_ friend_load(); #endif }
static int goodbrd_save(choose_board_t *cbrd) { load_default_board(cbrd); char file[HOMELEN]; setuserfile(file, ".goodbrd"); FILE *fp = fopen(file, "w"); if (fp) { fwrite(cbrd->gbrds, sizeof(*cbrd->gbrds), cbrd->gnum, fp); fclose(fp); return 0; } return -1; }
static void save_GoodBrd() // ±£´æÓû§¶©ÔĵİæÃæ { int i; FILE *fp; char fname[STRLEN]; if (GoodBrd.num <= 0) { GoodBrd.num = 1; if (getbcache(DEFAULTBOARD)) strcpy(GoodBrd.ID[0], DEFAULTBOARD); else strcpy(GoodBrd.ID[0], currboard); } setuserfile(fname, ".goodbrd"); if ((fp = fopen(fname, "wb+")) != NULL) { for (i = 0; i < GoodBrd.num; i++) fprintf(fp, "%s\n", GoodBrd.ID[i]); fclose(fp); } }
static void do_aloha(char *hello) { FILE *fp; char userid[80]; char genbuf[200]; setuserfile(genbuf, "aloha"); if((fp = fopen(genbuf, "r"))) { sprintf(genbuf, hello); while(fgets(userid, 80, fp)) { userinfo_t *uentp; int tuid; if((tuid = searchuser(userid)) && tuid != usernum && (uentp = (userinfo_t *)search_ulistn(cmpuids, tuid, 1)) && ((uentp->userlevel & PERM_SYSOP) || ((!currutmp->invisible || uentp->userlevel & PERM_SEECLOAK) && !(is_rejected(uentp) & 1)))) { my_write(uentp->pid, genbuf, uentp->userid, 2); } } fclose(fp); } }
void x_fillform() { char rname[NAMELEN], addr[STRLEN]; char phone[STRLEN], dept[STRLEN], assoc[STRLEN]; char ans[5], *mesg, *ptr; FILE *fn; time_t now; if (!strcmp("guest", currentuser.userid)) return; modify_user_mode(NEW); clear(); move(2, 0); clrtobot(); if (currentuser.userlevel & PERM_LOGINOK) { prints("���Ѿ���ɱ�վ��ʹ����ע������, ��ӭ���뱾վ������."); pressreturn(); return; } /* #ifdef PASSAFTERTHREEDAYS if (currentuser.lastlogin - currentuser.firstlogin < 3 * 86400) { prints("���״ε��뱾վδ������(72��Сʱ)...\n"); prints("�����Ĵ���Ϥһ�£����������Ժ�����дע�ᵥ��"); pressreturn(); return ; } #endif #ifdef PASSAFTERONEDAYS if (currentuser.lastlogin - currentuser.firstlogin < 86400) { prints("���״ε��뱾վδ��һ��(24��Сʱ)...\n"); prints("�����Ĵ���Ϥһ�£�����24Сʱ�Ժ�����дע�ᵥ��"); pressreturn(); return ; } #endif */ if ((fn = fopen("new_register", "r")) != NULL) { while (fgets(genbuf, STRLEN, fn) != NULL) { if ((ptr = strchr(genbuf, '\n')) != NULL) *ptr = '\0'; if ( strncmp(genbuf, "userid: ", 8) == 0 && strcmp(genbuf + 8, currentuser.userid) == 0) { fclose(fn); prints("վ����δ��������ע�����뵥, ���ȵ���������."); pressreturn(); return; } } fclose(fn); } strncpy(rname, currentuser.realname, NAMELEN); strncpy(addr, currentuser.address, STRLEN-8); dept[0] = phone[0] = assoc[0] = '\0'; while (1) { move(3, 0); clrtoeol(); prints("%s ����, ���ʵ��д���µ�����:\n", currentuser.userid); getfield(6, "��������", "��ʵ����", rname, NAMELEN); getfield(8, "ѧУԺϵ�꼶��˾ְ��", "ѧУϵ��", dept, STRLEN); getfield(10, "�������һ����ƺ���", "Ŀǰסַ", addr, STRLEN); getfield(12, "����������ʱ��", "����绰", phone, STRLEN); //getfield(14, "У�ѻ���ҵѧУ", "У �� ��", assoc, STRLEN); mesg = "���������Ƿ���ȷ, �� Q ����ע�� (Y/N/Quit)? [Y]: "; getdata(t_lines - 1, 0, mesg, ans, 3, DOECHO, YEA); if (ans[0] == 'Q' || ans[0] == 'q') return; if (ans[0] != 'N' && ans[0] != 'n') break; } strncpy(currentuser.realname, rname, NAMELEN); strncpy(currentuser.address, addr, STRLEN-8); if ((fn = fopen("new_register", "a")) != NULL) { now = time(NULL); getdatestring(now,NA); fprintf(fn, "usernum: %d, %s\n", usernum, datestring); fprintf(fn, "userid: %s\n", currentuser.userid); fprintf(fn, "realname: %s\n", rname); fprintf(fn, "dept: %s\n", dept); fprintf(fn, "addr: %s\n", addr); fprintf(fn, "phone: %s\n", phone); sprintf(assoc,"%s", fromhost); fprintf(fn, "regip: %s\n", assoc); fprintf(fn, "----\n"); fclose(fn); } setuserfile(genbuf, "mailcheck"); if ((fn = fopen(genbuf, "w")) == NULL) { fclose(fn); return; } fprintf(fn, "usernum: %d\n", usernum); fclose(fn); }
static void user_login(void) { char fname[STRLEN]; // SYSOP gets all permission bits when login. if (strcmp(currentuser.userid, "SYSOP") == 0) { currentuser.userlevel = ~0; substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); } fromhost[sizeof(fromhost) - 1] = 0; //added by iamfat 2004.01.05 to avoid overflow log_usies("ENTER", fromhost, ¤tuser); SpecialID(currentuser.userid, fromhost, sizeof(fromhost)); u_enter(); report("Enter", currentuser.userid); #ifdef USE_NOTEPAD notepad_init(); if (strcmp(currentuser.userid, "guest") != 0) { if (DEFINE(DEF_NOTEPAD)) { int noteln; if (lastnote> currentuser.notedate) currentuser.noteline = 0; noteln = countln("etc/notepad"); if (currentuser.noteline == 0) { shownotepad(); } else if ((noteln - currentuser.noteline)> 0) { screen_move(0, 0); ansimore2("etc/notepad", NA, 0, noteln - currentuser.noteline + 1); terminal_getchar(); screen_clear(); } currentuser.noteline = noteln; write_defnotepad(); } } #endif if (show_statshm("etc/hotspot", 0)) { screen_flush(); pressanykey(); } if ((vote_flag(NULL, '\0', 2 /* 检查读过新的Welcome 没 */) == 0)) { if (dashf("Welcome")) { ansimore("Welcome", YEA); vote_flag(NULL, 'R', 2 /* 写入读过新的Welcome */); } } else { ansimore("Welcome2", YEA); } show_statshm("0Announce/bbslist/day", 1); screen_flush(); screen_move_clear(-2); if (currentuser.numlogins < 1) { currentuser.numlogins = 0; //% prints("\033[1;36m☆ 这是您第 \033[33m1\033[36m 次拜访本站,请记住今天吧。\n"); prints("\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m1\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xbc\xc7\xd7\xa1\xbd\xf1\xcc\xec\xb0\xc9\xa1\xa3\n"); //% prints("☆ 您第一次连入本站的时间为 \033[33m%s\033[m ", format_time(time(NULL), TIME_FORMAT_ZH)); prints("\xa1\xee \xc4\xfa\xb5\xda\xd2\xbb\xb4\xce\xc1\xac\xc8\xeb\xb1\xbe\xd5\xbe\xb5\xc4\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(fb_time(), TIME_FORMAT_ZH)); } else { prints( //% "\033[1;36m☆ 这是您第 \033[33m%d\033[36m 次拜访本站,上次您是从 \033[33m%s\033[36m 连往本站。\n", "\033[1;36m\xa1\xee \xd5\xe2\xca\xc7\xc4\xfa\xb5\xda \033[33m%d\033[36m \xb4\xce\xb0\xdd\xb7\xc3\xb1\xbe\xd5\xbe\xa3\xac\xc9\xcf\xb4\xce\xc4\xfa\xca\xc7\xb4\xd3 \033[33m%s\033[36m \xc1\xac\xcd\xf9\xb1\xbe\xd5\xbe\xa1\xa3\n", currentuser.numlogins + 1, currentuser.lasthost); //% prints("☆ 上次连线时间为 \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); prints("\xa1\xee \xc9\xcf\xb4\xce\xc1\xac\xcf\xdf\xca\xb1\xbc\xe4\xce\xaa \033[33m%s\033[m ", format_time(currentuser.lastlogin, TIME_FORMAT_ZH)); } terminal_getchar(); setuserfile(fname, BADLOGINFILE); if (ansimore(fname, NA) != -1) { //% if (askyn("您要删除以上密码输入错误的记录吗", NA, NA) == YEA) if (askyn("\xc4\xfa\xd2\xaa\xc9\xbe\xb3\xfd\xd2\xd4\xc9\xcf\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3\xb5\xc4\xbc\xc7\xc2\xbc\xc2\xf0", NA, NA) == YEA) unlink(fname); } set_safe_record(); tui_check_uinfo(¤tuser); strlcpy(currentuser.lasthost, fromhost, sizeof(currentuser.lasthost)); if (login_start_time - currentuser.lastlogin >= 20 * 60 || !strcmp(currentuser.userid, "guest") || currentuser.numlogins < 100) { currentuser.numlogins++; } session_basic_info_t *res = get_my_sessions(); update_user_stay(¤tuser, true, session_basic_info_count(res) > 1); session_basic_info_clear(res); #ifdef ALLOWGAME if (currentuser.money> 1000000) { currentuser.nummedals += currentuser.money / 10000; currentuser.money %= 1000000; } if ((signed int) (currentuser.money - currentuser.bet) < -4990 && currentuser.numlogins < 10 && currentuser.numposts < 10 && currentuser.nummedals == 0) currentuser.money += 1000; #endif if (currentuser.firstlogin == 0) { currentuser.firstlogin = time(NULL) - 7 * 86400; } substitut_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); extern char currmaildir[]; setmdir(currmaildir, currentuser.userid); check_register_info(); }
int deal_gopherkey(char ch, int allnum, int pagenum) { char fname[STRLEN], fpath[STRLEN]; #ifdef INTERNET_EMAIL struct shortfile fhdr; #endif switch (ch) { case 'h': case 'H': show_help("help/announcereadhelp"); g_refresh(); break; case 'E': case 'e': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { vedit(fname, NA, YEA); unlink(fname); g_refresh(); } show_message(NULL); break; case '=': { tmpitem = nth_item(allnum - pagenum); move(2, 0); clrtobot(); prints("[1;44;37m"); printdash("BBS Gopher Îï¼þ»ù±¾×ÊÁÏ"); prints("[m"); prints("ÀàÐÍ£º%c (%s)\n", tmpitem->title[0], (tmpitem->title[0] == '0') ? "Îļþ" : "Ŀ¼"); prints("±êÌ⣺%s\n", tmpitem->title + 1); prints("·¾¶£º%s\n", tmpitem->file); prints("λÖãº%s\n", tmpitem->server); prints("ʹÓãº%d²º\n", tmpitem->port); pressanykey(); g_refresh(); } break; case Ctrl('P'): tmpitem = nth_item(allnum - pagenum); if (!HAS_PERM(PERM_POST)) break; setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { char bname[30]; clear(); if (get_a_boardname(bname, "ÇëÊäÈëҪתÌùµÄÌÖÂÛÇøÃû³Æ: ")) { move(1, 0); sprintf(fpath, "ÄãÈ·¶¨Òª×ªÌùµ½ %s °åÂð", bname); if (askyn(fpath, NA, NA) == 1) { move(2, 0); Postfile(fname, bname, tmpitem->title + 1, 2); sprintf(fpath, "[1mÒѾ°ïÄãתÌùµ½ %s °åÁË...[m", bname); prints(fpath); refresh(); sleep(1); } } } unlink(fname); g_refresh(); return 1; #ifdef INTERNET_EMAIL case 'U': case 'F': case 'u': case 'f': case 'z': case 'Z': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { strncpy(fhdr.title, tmpitem->title + 1, 70); strncpy(fhdr.filename, "gopher.tmp", STRLEN); sethomepath(fpath, currentuser.userid); // if (ch == 'Z' || ch == 'z') // a_download(fname); // else { switch (doforward(fpath, &fhdr, (ch == 'u' || ch == 'U') ? 1 : 0)) { case 0: show_message("ÎÄÕÂת¼ÄÍê³É!"); break; case -1: show_message("system error!!."); break; case -2: show_message("invalid address."); break; default: show_message("È¡Ïûת¼Ä¶¯×÷."); } // } refresh(); pressanykey(); g_refresh(); unlink(fname); return 1; } else return 1; break; #endif default: return 0; } return 1; }
//修改用户的档案 void x_edits() { char ans[7], buf[STRLEN]; int ch, num, confirm; const char *e_file[] = { "plans", "signatures", "notes", "logout", NULL }; //% "个人说明档", "签名档", "自己的备忘录", "离站的画面", //% "底部流动信息" const char *explain_file[] = { "\xb8\xf6\xc8\xcb\xcb\xb5\xc3\xf7\xb5\xb5", "\xc7\xa9\xc3\xfb\xb5\xb5", "\xd7\xd4\xbc\xba\xb5\xc4\xb1\xb8\xcd\xfc\xc2\xbc", "\xc0\xeb\xd5\xbe\xb5\xc4\xbb\xad\xc3\xe6", "\xb5\xd7\xb2\xbf\xc1\xf7\xb6\xaf\xd0\xc5\xcf\xa2", NULL }; set_user_status(ST_GMENU); screen_clear(); screen_move(1, 0); //% prints("编修个人档案\n\n"); prints("\xb1\xe0\xd0\xde\xb8\xf6\xc8\xcb\xb5\xb5\xb0\xb8\n\n"); for (num = 0; e_file[num] != NULL && explain_file[num] != NULL; num++) { prints("[[1;32m%d[m] %s\n", num + 1, explain_file[num]); } //% prints("[[1;32m%d[m] 都不想改\n", num + 1); prints("[[1;32m%d[m] \xb6\xbc\xb2\xbb\xcf\xeb\xb8\xc4\n", num + 1); //% getdata(num + 5, 0, "您要编修哪一项个人档案: ", ans, 2, DOECHO, YEA); getdata(num + 5, 0, "\xc4\xfa\xd2\xaa\xb1\xe0\xd0\xde\xc4\xc4\xd2\xbb\xcf\xee\xb8\xf6\xc8\xcb\xb5\xb5\xb0\xb8: ", ans, 2, DOECHO, YEA); if (ans[0] - '0' <= 0 || ans[0] - '0' > num || ans[0] == '\n' || ans[0] == '\0') return; ch = ans[0] - '0' - 1; setuserfile(genbuf, e_file[ch]); screen_move(3, 0); screen_clrtobot(); //% sprintf(buf, "(E)编辑 (D)删除 %s? [E]: ", explain_file[ch]); sprintf(buf, "(E)\xb1\xe0\xbc\xad (D)\xc9\xbe\xb3\xfd %s? [E]: ", explain_file[ch]); getdata(3, 0, buf, ans, 2, DOECHO, YEA); if (ans[0] == 'D' || ans[0] == 'd') { //% confirm = askyn("您确定要删除这个档案", NA, NA); confirm = askyn("\xc4\xfa\xc8\xb7\xb6\xa8\xd2\xaa\xc9\xbe\xb3\xfd\xd5\xe2\xb8\xf6\xb5\xb5\xb0\xb8", NA, NA); if (confirm != 1) { screen_move(5, 0); //% prints("取消删除行动\n"); prints("\xc8\xa1\xcf\xfb\xc9\xbe\xb3\xfd\xd0\xd0\xb6\xaf\n"); pressreturn(); screen_clear(); return; } unlink(genbuf); screen_move(5, 0); //% prints("%s 已删除\n", explain_file[ch]); prints("%s \xd2\xd1\xc9\xbe\xb3\xfd\n", explain_file[ch]); sprintf(buf, "delete %s", explain_file[ch]); report(buf, currentuser.userid); pressreturn(); screen_clear(); return; } set_user_status(ST_EDITUFILE); editor_e status = editor(genbuf, false, false, true, NULL); screen_clear(); if (status == EDITOR_SAVE) { //% prints("%s 更新过\n", explain_file[ch]); prints("%s \xb8\xfc\xd0\xc2\xb9\xfd\n", explain_file[ch]); sprintf(buf, "edit %s", explain_file[ch]); if (!strcmp(e_file[ch], "signatures")) { set_numofsig(); //% prints("系统重新设定以及读入您的签名档..."); prints("\xcf\xb5\xcd\xb3\xd6\xd8\xd0\xc2\xc9\xe8\xb6\xa8\xd2\xd4\xbc\xb0\xb6\xc1\xc8\xeb\xc4\xfa\xb5\xc4\xc7\xa9\xc3\xfb\xb5\xb5..."); } report(buf, currentuser.userid); } else { //% prints("%s 取消修改\n", explain_file[ch]); prints("%s \xc8\xa1\xcf\xfb\xd0\xde\xb8\xc4\n", explain_file[ch]); } pressreturn(); }
int Goodbye() { extern void movie(); char genbuf[200]; /* woju */ char ans[4]; setuserfile(genbuf, fn_writelog); if (more(genbuf, NA) != -1) { /* MH */ /* Àˬd¤ô²y°O¿ý®e¶q, ÁקK¦³¤H¡u¤Ù¿n¡v¤j¶q¤ô²y */ struct stat st; int writelog_limit; if (HAS_PERM(PERM_BM)) writelog_limit = MH_WRITELOGLIMIT_BM; else if (HAS_PERM(PERM_LOGINOK)) writelog_limit = MH_WRITELOGLIMIT_LOGINOK; else writelog_limit = MH_WRITELOGLIMIT_BASIC; do { char buf[80]; setuserfile(buf, fn_writelog); stat(buf, &st); if(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit) { my_outmsg_row("[1;41;37m±zªº¤ô²y°O¿ý¤w¶W¹L©w®e¶q¡AµLªk¿ï¾Ü¡u«O¯d¡v[0m", b_lines - 2); getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) (C/M)?[M]", ans, 3, LCECHO, 0); } else { getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) «O¯d(R) (C/M/R)?[R]", ans, 3, LCECHO, 0); } if (*ans == 'm') { fileheader mymail; char title[128], buf[80]; sethomepath(buf, cuser.userid); stampfile(buf, &mymail); mymail.savemode = 'H'; /* hold-mail flag */ mymail.filemode = FILE_READ; strcpy(mymail.owner, "[³Æ.§Ñ.¿ý]"); strcpy(mymail.title, "¼ö½u[37;41m°O¿ý[m"); if(mh_memoforward(cuser.userid, genbuf, &mymail, sizeof(mymail))) { sethomedir(title, cuser.userid); append_record(title, &mymail, sizeof(mymail)); /* MH: ³Æ§Ñ¿ý¥[¤W§@ªÌ¼ÐÃDµ¥¸ê°T...¤£µM¦b'x'Âà±H©Î¬Obuildirªº®ÉÔ ·|Äê±¼ */ #if 1 { FILE *src, *dst; char buf2[200]; time_t now; if((src = fopen(genbuf, "r")) == NULL) { sprintf(buf2, "errno: %d, genbuf:%s", errno, genbuf); log_usies("MH ", buf2); } if((dst = fopen(buf, "w")) == NULL) { sprintf(buf2, "errno: %d, buf:%s", errno, buf); log_usies("MH ", buf2); fclose(src); } now = time(NULL); sprintf(buf2, "§@ªÌ: %s\n¼ÐÃD: %s\n®É¶¡: %s\n", mymail.owner, mymail.title, ctime(&now)); fputs(buf2, dst); while(fgets(buf2, 199, src) != NULL) fputs(buf2, dst); fclose(src); fclose(dst); unlink(genbuf); } #else Rename(genbuf, buf); #endif } } else if (*ans == 'c') { char buf[80]; setuserfile(buf, fn_writelog); unlink(buf); } } while(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit && *ans != 'm' && *ans != 'c'); clear(); move(0, 0); prints("[1;44;33m °ª¶¯¤¤¾Ç-¬õ¼Ó¿v¹Ú [m"); movie(0); } /* */ getdata(b_lines - 1, 0, "±z½T©wnÂ÷¶}¡i " BOARDNAME " ¡j¶Ü(Y/N)¡H[N] ", genbuf, 3, LCECHO, 0); if (*genbuf != 'y') return 0; movie(999); if (cuser.userlevel) { getdata(b_lines - 1, 0, "(G)ÀH·¦Ó³u (M)¦«¹Ú¯¸ªø (N)¦X§@ªÀªº¨¥½×¼s³õ¡H[G] ", genbuf, 3, LCECHO, 0); if (genbuf[0] == 'm') mail_sysop(); else if (genbuf[0] == 'n') note(); } save_userrc(); #if 0 save_mailmsg(); #endif clear(); prints("[1;36m¿Ë·Rªº [33m%s(%s)[36m¡A§O§Ñ¤F¦A«×¥úÁ{[45;33m" " %s [40;36m¡I\n¥H¤U¬O±z¦b¯¸¤ºªºµù¥U¸ê®Æ:[0m\n", cuser.userid, cuser.username, BoardName); user_display(&cuser, 0); if (currmode) u_exit("EXIT "); pressanykey(); sleep(1); reset_tty(); exit(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); }
int showout() { int i, i2 = 0; char foo[1024]; char tmpfile[STRLEN]; char buf[20]; int notreload = 0; GOPHER newitem; while (1) { if (gopher_position < 0) { return; } print_gophertitle(); printgopher_title(); update_endline(); if (!notreload) { i = 0; if (get_con(g_main[gopher_position]->server, g_main[gopher_position]->port) == -1) { show_message(NULL); free(g_main[gopher_position]); gopher_position--; notreload = 0; continue; } enterdir(g_main[gopher_position]->file); show_message("¶Áȡ׼±¸ÖÐ"); for (i = 0; i < MAXGOPHERITEMS; i++) { if (readfield(a, foo, 1024) <= 0) { break; } if (foo[0] == '.' && foo[1] == '\r' && foo[2] == '\n') { break; } strncpy(newitem.title, foo, 70); if (readfield(a, foo, 1024) == 0) { break; } strncpy(newitem.file, foo, 80); if (readfield(a, foo, 1024) == 0) { break; } strncpy(newitem.server, foo, 40); if (readline(a, foo, 1024) == 0) { break; } newitem.port = atoi(foo); if (newitem.title[0] != newitem.file[0]) { break; } if (newitem.title[0] != '0' && newitem.title[0] != '1') { i--; continue; } refresh(); append_record(gophertmpfile, &newitem, sizeof(GOPHER)); sprintf(buf, "[1;3%dmת[3%dm»»[3%dm×Ê[3%dmÁÏ[3%dmÖÐ[m", (i % 7) + 1 ,((i + 1) % 7) + 1, ((i + 2) % 7) + 1, ((i + 3) % 7) + 1, ((i + 4) % 7) + 1); show_message(buf); } show_message(NULL); } else notreload = 0; if (i <= 0) { move(3, 0); clrtobot(); move(10, 0); clrtoeol(); prints(" [1;31mûÓÐÈκεÄ×ÊÁÏ...[m"); pressanykey(); free(g_main[gopher_position]); gopher_position--; continue; } close(a); move(0, 0); clrtobot(); setlistrange(i); i2 = choose(NA, g_main[gopher_position]->position, print_gophertitle, deal_gopherkey, show_gopher, do_gopher); if (i2 == -1) { free(g_main[gopher_position]); clear_gophertmpfile(); gopher_position--; continue; } g_main[gopher_position]->position = i2; get_record(gophertmpfile, &newitem, sizeof(GOPHER), i2 + 1); tmpitem = &newitem; if (newitem.title[0] == '0') { if (get_con(newitem.server, newitem.port) == -1) continue; enterdir(newitem.file); setuserfile(tmpfile, "gopher.tmp"); savetmpfile(tmpfile); ansimore(tmpfile, YEA); notreload = 1; unlink(tmpfile); continue; } else { GOPHER *newgi; clear_gophertmpfile(); gopher_position++; newgi = (GOPHER *) malloc(sizeof(GOPHER)); strncpy(newgi->server, tmpitem->server, 40); strncpy(newgi->file, tmpitem->file, 80); strncpy(newgi->title, tmpitem->title, 70); newgi->port = tmpitem->port; newgi->position = 0; g_main[gopher_position] = newgi; continue; } } }
// ��username�û�ͨ����֤�� added by interma@BMY 2005.5.12 static void register_success(int usernum, char *userid, char *realname, char *dept, char *addr, char *phone, char *assoc, char *email) { struct userec uinfo; FILE *fout, *fn; char buf[STRLEN]; int n; //int id = getuser(userid); usernum = getuser(userid); setuserfile(genbuf, "mailcheck"); if ((fn = fopen(genbuf, "w")) == NULL) { fclose(fn); return; } fprintf(fn, "usernum: %d\n", usernum); fclose(fn); memcpy(&uinfo, &lookupuser, sizeof (uinfo)); strsncpy(uinfo.userid, userid, sizeof (uinfo.userid)); strsncpy(uinfo.realname, realname, sizeof (uinfo.realname)); strsncpy(uinfo.address, addr, sizeof (uinfo.address)); sprintf(genbuf, "%s$%s@%s", dept, phone, userid); strsncpy(uinfo.realmail, genbuf, sizeof (uinfo.realmail)); strsncpy(uinfo.email, email, sizeof (uinfo.email)); uinfo.userlevel |= PERM_DEFAULT; // by ylsdd substitute_record(PASSFILE, &uinfo, sizeof (struct userec), usernum); sethomefile(buf, uinfo.userid, "sucessreg"); if ((fout = fopen(buf, "w")) != NULL) { fprintf(fout, "\n"); fclose(fout); } sethomefile(buf, uinfo.userid, "register"); if ((fout = fopen(buf, "w")) != NULL) { fprintf(fout, "%s: %d\n", "usernum", usernum); fprintf(fout, "%s: %s\n", "userid", userid); fprintf(fout, "%s: %s\n", "realname", realname); fprintf(fout, "%s: %s\n", "dept", dept); fprintf(fout, "%s: %s\n", "addr", addr); fprintf(fout, "%s: %s\n", "phone", phone); fprintf(fout, "%s: %s\n", "assoc", assoc); n = time(NULL); fprintf(fout, "Date: %s", ctime((time_t *) & n)); fprintf(fout, "Approved: %s\n", userid); fclose(fout); } mail_file("etc/s_fill", uinfo.userid, "������ͨ�������֤"); // ����ط��и�覴ã����Ƿ�����Ϊ���� mail_file("etc/s_fill2", uinfo.userid, "��ӭ����" MY_BBS_NAME "���ͥ"); sethomefile(buf, uinfo.userid, "mailcheck"); unlink(buf); sprintf(genbuf, "�� %s ͨ�����ȷ��.", uinfo.userid); securityreport(genbuf, genbuf); return ; }