static void logattempt(char *uid, char type) { /* '-' login failure ' ' success '!' not * exist '*' spamd */ char fname [PATHLEN]; char genbuf [200], datemsg[20]; sprintf(genbuf, "%c%-12s[%s] %s@%s", type, uid, Etime(&login_start_time), remoteusername, fromhost); f_cat(str_badlogin, genbuf); if (type == '-') { sprintf(genbuf, "[%s] %s", Etime(&login_start_time), fromhost); sethomefile(fname, uid, str_badlogin); f_cat(fname, genbuf); } /* 個人上站記錄 from myth */ if (type != '!') { strftime(datemsg, 20, "%Y/%m/%d %T", localtime(&login_start_time)); sprintf(genbuf, "%s %c%-8s %s@%s", datemsg, type, "BBS", remoteusername, fromhost); sethomefile(fname, uid, FN_LOGLOGIN); f_cat(fname, genbuf); } }
void SD_parse(char *rq, int fd) { char cmd[BUFSIZ], arg[BUFSIZ]; struct stat info; strcpy(arg,WPDirectory); if(sscanf(rq,"%s %s",cmd,arg+strlen(WPDirectory))!=2) { return ; } if(strcmp(cmd,"GET")!=0){ fprintf(stderr, "ClientRQ:%s \n", "501"); Err_501(fd); } else if(stat(arg,&info)==-1){ //not_exit(arg)){ fprintf(stderr, "ClientRQ:%s \n", "404"); Err_404(arg,fd); } else if(stat(arg,&info)!=-1 && S_ISDIR(info.st_mode) ){//(is_dir(arg)){ fprintf(stderr, "ClientRQ:%s \n", "direct"); s_dir(arg,fd); } else if(is_cgi(arg)){ fprintf(stderr, "ClientRQ:%s \n", "CGI"); r_prg(arg,fd); } else{ fprintf(stderr, "ClientRQ:%s \n", " else"); f_cat(arg,fd); } }
static int rebuild_list(struct user_info *up, char *arg, int p) { int pos = p - 1; /* add to sorted list */ if ((up->userid[0] == 0) || (!up->active)) return COUNT; if (!utmphead->listhead) { /* init the list head */ utmphead->list_prev[pos] = pos + 1; utmphead->list_next[pos] = pos + 1; utmphead->listhead = pos + 1; } else { int i; i = utmphead->listhead; if (strcasecmp(utmpshm->uinfo[i - 1].userid, up->userid) >= 0) { /* add to head */ utmphead->list_prev[pos] = utmphead->list_prev[i - 1]; utmphead->list_next[pos] = i; utmphead->list_prev[i - 1] = pos + 1; utmphead->list_next[utmphead->list_prev[pos] - 1] = pos + 1; utmphead->listhead = pos + 1; } else { int count; count = 0; i = utmphead->list_next[i - 1]; while ((strcasecmp(utmpshm->uinfo[i - 1].userid, up->userid) < 0) && (i != utmphead->listhead)) { i = utmphead->list_next[i - 1]; count++; if (count > USHM_SIZE) { bbslog("3system", "UTMP:rebuild maybe loop???"); f_cat("NOLOGIN", "系统故障,请稍后再来"); logloop(); exit(-1); } } utmphead->list_prev[pos] = utmphead->list_prev[i - 1]; utmphead->list_next[pos] = i; utmphead->list_prev[i - 1] = pos + 1; utmphead->list_next[utmphead->list_prev[pos] - 1] = pos + 1; } } return COUNT; }
static void ca_log(char *fmt, ...) { va_list ap; char msg[128]; va_start(ap, fmt); vsprintf(msg, fmt, ap); va_end(ap); f_cat(LOG_FILE, msg); fputs(msg, stdout); }
void log_usies(char *mode, char *msg) { char buf [256], data[256]; time_t now; time(&now); if (!msg) { sprintf(data, "Stay: %d (%s)", (now - login_start_time) / 60, cuser.username); msg = data; } sprintf(buf, "%s %s %-13s%s", Etime(&now), mode, cuser.userid, msg); f_cat(FN_USIES, buf); }
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; }