static int goodbye() { /* guessi.091228 減少畫面重繪 回傳XO_NONE */ if (vans("您確定要離開【 東方小城 】嗎? Y)再見 N)返回 [N] ") != 'y') return XO_NONE; #ifdef LOG_BMW /* lkchu.981201: 水球記錄處理 */ bmw_log(); #endif /* itoc.000407: 離站畫面一併簡化 */ if (!(cuser.ufo & UFO_MOTD)) { clear(); prints("親愛的 \033[32m%s(%s)\033[m,別忘了再度光臨【 %s 】\n以下是您在站內的註冊資料:\n", cuser.userid, cuser.username, str_site); acct_show(&cuser, 0); vmsg(NULL); } u_exit("EXIT "); /* guessi.060610 離站清空畫面 */ clear(); refresh(); exit(0); }
static int retrieve_backup(userec_t *user) { int uid; char src[PATHLEN], dst[PATHLEN]; char ans; if ((uid = searchuser(user->userid, user->userid))) { userec_t orig; passwd_sync_query(uid, &orig); strlcpy(user->passwd, orig.passwd, sizeof(orig.passwd)); setumoney(uid, user->money); passwd_sync_update(uid, user); return 0; } ans = vans("目前的 PASSWD 檔沒有此 ID,新增嗎?[y/N]"); if (ans != 'y') { vmsg("目前的 PASSWDS 檔沒有此 ID,請先新增此帳號"); return -1; } if (setupnewuser((const userec_t *)user) >= 0) { sethomepath(dst, user->userid); if (!dashd(dst)) { snprintf(src, sizeof(src), "tmp/%s", user->userid); if (!dashd(src) || !Rename(src, dst)) mkuserdir(user->userid); } return 0; } return -1; }
int TagPruner(int bid) { boardheader_t *bp=NULL; char direct[PATHLEN]; assert(bid >= 0); /* bid == 0 means in mailbox */ if (bid && currstat != RMAIL) { bp = getbcache(bid); if (is_readonly_board(bp->brdname)) return DONOTHING; setbdir(direct, bp->brdname); } else if(currstat == RMAIL) { sethomedir(direct, cuser.userid); } else { vmsg("抱歉,程式異常 - 請至 " BN_BUGREPORT " 報告您剛的詳細步驟。"); return FULLUPDATE; } if (IsEmptyTagList() || (currstat == READING && !(currmode & MODE_BOARD))) return DONOTHING; if (vans("刪除所有標記[N]?") != 'y') return READ_REDRAW; // ready to start. outmsg("處理中,請稍後..."); refresh(); // first, delete and backup all files apply_record(direct, _iter_delete_tagged, sizeof(fileheader_t), direct); // now, delete the header #ifdef SAFE_ARTICLE_DELETE if(bp && !(currmode & MODE_DIGEST) && bp->nuser >= SAFE_ARTICLE_DELETE_NUSER) safe_delete_range(currdirect, 0, 0); else #endif delete_range(currdirect, 0, 0); TagNum = 0; if (bid) setbtotal(bid); else if(currstat == RMAIL) setupmailusage(); return NEWDIRECT; }
static int goodbye() { /* itoc.010803: 秀張離站的圖 */ clear(); film_out(FILM_GOODBYE, 0); switch (vans("G)隨風而逝 M)報告站長 N)留言板 Q)取消?[Q] ")) { /* lkchu.990428: 內定改為不離站 */ case 'g': case 'y': break; case 'm': m_sysop(); break; case 'n': /* if (cuser.userlevel) */ if (HAS_PERM(PERM_POST)) /* Thor.990118: 要能post才能留言, 提高門檻 */ pad_draw(); break; case 'q': default: /* return XEASY; */ return 0; /* itoc.010803: 秀了 FILM_GOODBYE 要重繪 */ } #ifdef LOG_BMW bmw_log(); /* lkchu.981201: 水球記錄處理 */ #endif if (!(cuser.ufo & UFO_MOTD)) /* itoc.000407: 離站畫面一併簡化 */ { clear(); prints("親愛的 \033[32m%s(%s)\033[m,別忘了再度光臨【 %s 】\n" "以下是您在站內的註冊資料:\n", cuser.userid, cuser.username, str_site); acct_show(&cuser, 0); vmsg(NULL); } u_exit("EXIT "); exit(0); }
int del_classtable(int x, int y) { int p; p = (x - 1) + (y - 1) * 13; if (vans("是否要刪除 ? [y/N]") != 'y') { help_classtable(); return 0; } else { memset(&tmp_table[p], 0, sizeof(CLASS_TABLE2)); show_classtable(x, y, " "); } help_classtable(); return 0; }
static int goodbye() { /* itoc.010803: 秀張離站的圖 */ clear(); film_out(FILM_GOODBYE, 0); switch (vans("G)隨光而逝 M)報告站長 N)留言板 Q)取消?[Q] ")) { /* lkchu.990428: 內定改為不離站 */ case 'g': case 'y': break; case 'm': m_sysop(); break; case 'n': /* if (cuser.userlevel) */ if (HAS_PERM(PERM_POST)) /* Thor.990118: 要能post才能留言, 提高門檻 */ pad_draw(); break; case 'b': /* floatJ.090607: konami_code 彩蛋 */ if (konami_counter >= 6) more("etc/CharlieSP", MFST_NONE); case 'q': default: if(konami_counter >= 6) /* dust.091010: 在b這步按錯的話不必考慮嗎... */ konami_counter = 0; /* return XEASY; */ return 0; /* itoc.010803: 秀了 FILM_GOODBYE 要重繪 */ } #ifdef LOG_BMW bmw_log(); /* lkchu.981201: 水球記錄處理 */ #endif u_exit("EXIT "); exit(0); }
static int pad_draw() { int i, cc, fdr, color; FILE *fpw; Pad pad; char *str, buf[3][71]; /* itoc.註解: 不想用高彩度,太花 */ static char pcolors[6] = {31, 32, 33, 34, 35, 36}; /* itoc.010309: 留言板提供不同的顏色 */ color = vans("心情顏色 1) \033[41m \033[m 2) \033[42m \033[m 3) \033[43m \033[m " "4) \033[44m \033[m 5) \033[45m \033[m 6) \033[46m \033[m [Q] "); if (color < '1' || color > '6') return XEASY; else color -= '1'; do { buf[0][0] = buf[1][0] = buf[2][0] = '\0'; move(MENU_XPOS, 0); clrtobot(); outs("\n請留言 (至多三行),按[Enter]結束"); for (i = 0; (i < 3) && vget(16 + i, 0, ":", buf[i], 71, DOECHO); i++); cc = vans("(S)存檔觀賞 (E)重新來過 (Q)算了?[S] "); if (cc == 'q' || i == 0) return 0; } while (cc == 'e'); time(&(pad.tpad)); /* itoc.020812.註解: 改版面的時候要注意 struct Pad.msg[] 是否夠大 */ str = pad.msg; sprintf(str, "╭┤\033[1;46m %s - %s \033[m├", cuser.userid, cuser.username); for (cc = strlen(str); cc < 60; cc += 2) strcpy(str + cc, "─"); if (cc == 60) str[cc++] = ' '; sprintf(str + cc, "\033[1;44m %s \033[m╮\n" "│ \033[1;%dm%-70s\033[m │\n" "│ \033[1;%dm%-70s\033[m │\n" "╰ \033[1;%dm%-70s\033[m ╯\n", Btime(&(pad.tpad)), pcolors[color], buf[0], pcolors[color], buf[1], pcolors[color], buf[2]); f_cat(FN_RUN_NOTE_ALL, str); if (!(fpw = fopen(FN_RUN_NOTE_TMP, "w"))) return 0; fwrite(&pad, sizeof(pad), 1, fpw); if ((fdr = open(FN_RUN_NOTE_PAD, O_RDONLY)) >= 0) { Pad *pp; i = 0; cc = pad.tpad - NOTE_DUE * 60 * 60; mgets(-1); while (pp = mread(fdr, sizeof(Pad))) { fwrite(pp, sizeof(Pad), 1, fpw); if ((++i > NOTE_MAX) || (pp->tpad < cc)) break; } close(fdr); } fclose(fpw); rename(FN_RUN_NOTE_TMP, FN_RUN_NOTE_PAD); pad_view(); return 0; }
int main_classtable(void) { char c; int x = 1, y = 1; int fd; #ifdef HAVE_CLASSTABLEALERT classtable_free(); #endif usr_fpath(fpath_classtable, cuser.userid, FN_CLASSTABLE2); init_classtable(); show_icon_classtable(x, y, 1); do { c = vkey(); switch (c) { case 'q' : break; case KEY_DOWN : show_icon_classtable(x, y, 0); x++; if (x == 14) x = 1; show_icon_classtable(x, y, 1); break; case KEY_UP: show_icon_classtable(x, y, 0); x--; if (x == 0) x = 13; show_icon_classtable(x, y, 1); break; case KEY_LEFT: show_icon_classtable(x, y, 0); y--; if (y == 0) y = 6; show_icon_classtable(x, y, 1); break; case KEY_RIGHT : show_icon_classtable(x, y, 0); y++; if (y == 7) y = 1; show_icon_classtable(x, y, 1); break; case 'a' : add_classtable(x, y); break; case 'd' : del_classtable(x, y); break; case 'e' : edit_classtable(x, y); break; case 'i' : import_classtable(x, y); break; case 'c' : if (vans("確定刪除嗎?[y/N] ") == 'y') { memset(tmp_table, 0, sizeof(CLASS_TABLE2)*78); show_table(); } break; case '\n' : if (tmp_table[x+y*13-14].valid == 1) edit_classtable(x, y); else add_classtable(x, y); break; } } while (c != 'q'); fd = open(fpath_classtable, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd >= 0) { write(fd, tmp_table, sizeof(CLASS_TABLE2)*78); close(fd); } #ifdef HAVE_CLASSTABLEALERT classtable_main(); #endif vmsg(NULL); return 0; }
int import_classtable(int x, int y) { char atrn[256], sendform[512]; char cookie[80], condensation[9]; int cookie_len; int sockfd; int cc; char *xhead; char pool[2048], buf[1025]; FILE *fp; char *s; char fname[80], classtime[80]; char User[14], Password[14], ans, ansc; CLASS_TABLE2 classtable; if (!vget(b_lines, 0, "帳號(不加s) : " , User, sizeof(User), DOECHO) || !vget(b_lines, 0, "密碼 : " , Password, sizeof(Password), NOECHO)) return 0; ans = vans("是否覆蓋\原始資料 [y/N]: "); ansc = vans("中文課程簡稱 [y/N]: "); /* stage1 */ sprintf(sendform, "GET %s HTTP/1.0\r\n\r\n", CGI_stage1); if ((sockfd = dns_open(SERVER_student, HTTP_PORT)) < 0) { vmsg("無法與伺服器取得連結,查詢失敗"); return 1; } else { // vmsg("正在連接伺服器,請稍後 (1)............."); } write(sockfd, sendform, strlen(sendform)); shutdown(sockfd, 1); for (;;) { // *xhead = '\0'; xhead = pool; cc = read(sockfd, xhead, sizeof(pool)); if (*xhead != '\0' && cc > 0) { xhead[cc] = '\0'; s = strstr(xhead, "Cookie:"); if (s != NULL) { s[strlen(s) - strlen(strstr(s, "\n")) + 1] = '\0'; strcpy(cookie, s); break; } } else { vmsg("MISS"); return 1; } } close(sockfd); /* stage2 */ sprintf(atrn, "User=%s&Password=%s", User, Password); cookie_len = strlen(atrn); sprintf(sendform, "POST %s HTTP/1.0\r\n%sContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s\r\n\r\n", CGI_stage2, cookie, cookie_len, atrn); if ((sockfd = dns_open(SERVER_student, HTTP_PORT)) < 0) { vmsg("無法與伺服器取得連結,查詢失敗"); return 1; } else { // vmsg("正在連接伺服器,請稍後 (2)............."); } write(sockfd, sendform, strlen(sendform)); shutdown(sockfd, 1); for (;;) { // *xhead = '\0'; xhead = pool; cc = read(sockfd, xhead, sizeof(pool)); if (*xhead != '\0' && cc > 0) { xhead[cc] = '\0'; s = strstr(xhead, "有誤"); if (s != NULL) { vmsg("您輸入的帳號或密碼有誤!"); return 1; } } else { // vmsg("您輸入的帳號或密碼正確!"); break; } } close(sockfd); /* stage3 */ sprintf(sendform, "GET %s HTTP/1.0\r\n%s\r\n", CGI_stage3, cookie); if ((sockfd = dns_open(SERVER_student, HTTP_PORT)) < 0) { vmsg("無法與伺服器取得連結,查詢失敗\n"); return 1; } else { // vmsg("正在連接伺服器,請稍後 (3).............\n"); } write(sockfd, sendform, strlen(sendform)); shutdown(sockfd, 1); sprintf(fname, "tmp/%s.student", cuser.userid); fp = fopen(fname, "w"); if (fp) { for (;;) { // *xhead = '\0'; xhead = pool; cc = read(sockfd, xhead, sizeof(pool)); if (*xhead != '\0' && cc > 0) { xhead[cc] = '\0'; fputs(xhead, fp); } if (cc <= 0) { break; } } fclose(fp); } close(sockfd); /* stage4 */ fp = fopen(fname, "r"); memset(&classtable, 0, sizeof(CLASS_TABLE2)); if (fp) { while (fgets(buf, 1024, fp) != NULL) { s = strstr(buf, " <CENTER>"); if (s != NULL) // 課程編號 { s += 9; s[strlen(s) - strlen(strstr(s, "</CENTER>"))] = 0; strcpy(classtable.condensation, s); fgets(buf, 1024, fp); // 開課班別 s = strstr(buf, "<CENTER>"); s += 8; s[strlen(s) - strlen(strstr(s, "</CENTER>"))] = 0; strcat(classtable.condensation, "_"); strcat(classtable.condensation, s); fgets(buf, 1024, fp); // 選別 fgets(buf, 1024, fp); // 課名 s = strstr(buf, "<CENTER>"); s += 8; s[strlen(s) - strlen(strstr(s, "</CENTER>"))] = 0; strncpy(condensation, s, 8); condensation[8] = '\0'; strncpy(classtable.name, s, 28); strcat(classtable.name, "["); strcat(classtable.name, classtable.condensation); strcat(classtable.name, "]"); fgets(buf, 1024, fp); // 學分數 s = strstr(buf, "<CENTER>"); s += 8; s[strlen(s) - strlen(strstr(s, "</CENTER>"))] = 0; sprintf(sendform, "學分數 [%s]", s); fgets(buf, 1024, fp); // 期中評量 s = strstr(buf, "<CENTER>"); s += 8; s[strlen(s) - strlen(strstr(s, "</CENTER>"))] = 0; sprintf(classtable.other, "%s,期中評量 [%s]", sendform, s); fgets(buf, 1024, fp); // 空白 fgets(buf, 1024, fp); // 空白 fgets(buf, 1024, fp); // 時間 s = strstr(buf, ">"); s += 1; s[strlen(s) - strlen(strstr(s, "</TD>"))] = 0; strcpy(classtime, s); fgets(buf, 1024, fp); // 地點 s = strstr(buf, ">"); s += 1; s[strlen(s) - strlen(strstr(s, "</TD>"))] = 0; if (!strstr(s, "無資料")) s[strlen(s) - strlen(strstr(s, ","))] = 0; strcpy(classtable.room, s); // 時間分析 s = classtime; while (!strstr(s, "無資料") && strlen(s) > 3) { int p, x, y; x = atoi(s + 1); s[1] = '\0'; y = atoi(s); p = (x - 1) + (y - 1) * 13; if (tmp_table[p].valid == 0 || ans == 'y' || ans == 'Y') { classtable.x = x; classtable.y = y; classtable.valid = 1; if (strlen(classtable.teacher) <= 0) teacher_classtable(&classtable); // vmsg(classtable.teacher); memcpy(&tmp_table[p], &classtable, sizeof(CLASS_TABLE2)); if (ansc == 'y' || ansc == 'Y') { memcpy(tmp_table[p].condensation, condensation, sizeof(condensation)); show_classtable(x, y, condensation); } else show_classtable(x, y, classtable.condensation); } s += 4; } memset(&classtable, 0, sizeof(CLASS_TABLE2)); } } fclose(fp); unlink(fname); } show_icon_classtable(x, y, 1); help_classtable(); return 0; }