/* * Create header for bounced mail */ int bounce_header(char *to) /* To: */ { /* * Open new mail */ if(mail_open('m') == ERROR) return ERROR; /* * Create RFC header */ fprintf(mail_file('m'), "From Mailer-Daemon %s\n", date(DATE_FROM, NULL) ); fprintf(mail_file('m'), "Date: %s\n", date(NULL, NULL) ); fprintf(mail_file('m'), "From: Mailer-Daemon@%s (Mail Delivery Subsystem)\n", cf_fqdn() ); fprintf(mail_file('m'), "To: %s\n", to); if(bounce_ccmail) fprintf(mail_file('m'), "Cc: %s\n", bounce_ccmail); /* Additional header may follow in message file */ return OK; }
static int inform(char *board, char *user, char *exp, int dt) { FILE *fp; char path[80], title[80], buf[512]; struct tm *tmtime; time_t daytime = now_t + (dt + 1) * 86400; tmtime = gmtime(&daytime); sprintf(title, "%s 被 %s 取消在%s的POST权", user, currentuser->userid, board); sprintf(path, "bbstmpfs/tmp/%d.tmp", thispid); fp = fopen(path, "w"); fprintf(fp, "【此篇文章是由自动发信系统所张贴】\n\n"); snprintf(buf, sizeof (buf), "被封原因: %s\n" "被封天数: %d\n" "解封日期: %d月%d日\n" "管理人员: %s\n" "解封办法: 联系版主提前解封或由系统自动解封\n" "如有异议,可向管理人员提出,或到Arbitration版投诉\n\n\n", exp, dt, tmtime->tm_mon + 1, tmtime->tm_mday, currentuser->userid); fputs(buf, fp); fclose(fp); securityreport(title, buf); post_article(board, title, path, "deliver", "自动发信系统", "自动发信系统", -1, 0, 0, "deliver", -1); if (!hideboard(board)) post_article("Penalty", title, path, "deliver", "自动发信系统", "自动发信系统", -1, 0, 0, "deliver", -1); mail_file(path, user, title, "deliver"); unlink(path); printf("系统已经发信通知了%s.<br>\n", user); return 0; }
// 自动发送到版面 // title 标题 // str 内容 // toboard 决定是否发送到版面 // userid 发送到的用户名,为null则不发送. // mode 分别奖惩,1表示BMS任命,0表示deliver处罚 // 2表示当前用户 int autoreport(char *title,char *str,int toboard,char *userid,int mode) { FILE *se; char fname[STRLEN]; int savemode; savemode = uinfo.mode; report(title, currentuser.userid); sprintf(fname,"tmp/AutoPoster.%s.%05d",currentuser.userid,uinfo.pid); if((se=fopen(fname,"w"))!=NULL) { fprintf(se,"%s",str); fclose(se); if(userid != NULL) { mail_file(fname,userid,title); } /* Modified by Amigo 2002.04.17. Set BMS announce poster as 'BMS'. */ // if(toboard) Postfile( fname,currboard,title,1); if (toboard) { if (mode == 1) { Postfile(fname, currboard, title, 3); } else if (mode == 2) { Postfile(fname, currboard, title, 2); } else { Postfile(fname, currboard, title, 1); } } /* Modify end. */ unlink(fname); modify_user_mode( savemode ); } return 0; //返回值现无意义 }
int msgmorebar(char *filename) { extern int showansi; char title[256]; int ch; showansi = 1; move(t_lines - 1, 0); clrtoeol(); prints("[0m[1;44;32mѶϢä¯ÀÀÆ÷ ±£Áô <[1;37mr[32m> Çå³ý <[1;37mc[1;32m> ¼Ä»ØÐÅÏä<[1;37mm[1;32m> [m"); move(t_lines - 1, 0); ch = morekey(); if (ch == 'C') { if (askyn("È·¶¨ÒªÇå³ýÂð£¿", NA, YEA) == YEA) { unlink(filename); } return ch; } else if (ch == 'M') { if (askyn("È·¶¨Òª¼Ä»ØÂð£¿", NA, YEA) == YEA) { sprintf(title, "[%s] ËùÓÐѶϢ±¸·Ý", getdatestring(time(NULL), DATE_ZH)); mail_file(filename, currentuser.userid, title); unlink(filename); } return ch; } else if (ch == 'H') { show_help("help/msghelp"); } clrtoeol(); refresh(); return ch; }
void autoreport(char* title,char* str, int toboard, char* userid) { FILE *se; char fname[STRLEN]; int savemode; struct boardheader fh; extern int cmpbnames(); search_record(BOARDS, &fh, sizeof(fh), cmpbnames, currboard); savemode = uinfo.mode; report(title); sprintf(fname,"tmp/%s.%s.%05d",BBSID,currentuser.userid,uinfo.pid); if((se=fopen(fname,"w"))!=NULL) { fprintf(se,"%s",str); fclose(se); if(userid != NULL) mail_file(fname,userid,title); if(toboard) Postfile( fname,currboard,title,1); if(userid!=NULL && fh.level == 0) Postfile(fname, "Punishment", title,2);//add by bluetent - 2002.11.5 unlink(fname); modify_user_mode( savemode ); } }
int msgmorebar(char *filename,int mode) { extern int showansi; char title[256]; char oldfilename[STRLEN]; char cmd[2*STRLEN]; int ch; time_t now; showansi = 1; move(t_lines - 1, 0); clrtoeol(); prints("[0m[1;44;32mѶϢä¯ÀÀÆ÷ ±£Áô <[1;37mr[32m> Çå³ý <[1;37mc[1;32m> ¼Ä»ØÐÅÏä<[1;37mm[1;32m> [m"); move(t_lines - 1, 0); ch = morekey(); if (ch == 'C') { if(mode==YEA) { strcpy(oldfilename,filename); strcat(oldfilename,".old"); strcpy(cmd,"mv "); strcat(cmd,filename); strcat(cmd," "); strcat(cmd,oldfilename); system(cmd); } else { unlink(filename); } return ch; } else if (ch == 'M') { now = time(0); getdatestring(now,NA); sprintf(title, "[%s] ËùÓÐѶϢ±¸·Ý", datestring); mail_file(filename, currentuser.userid, title); unlink(filename); return ch; } else if (ch == 'H') { show_help("help/msghelp"); } clrtoeol(); refresh(); return ch; }
void set_rec(chatcontext * pthis, const char *arg) { /* set recorder */ char fname[STRLEN]; time_t now; now = time(0); /* if(!HAS_PERM(getCurrentUser(),PERM_SYSOP)) return; */ /*sprintf(fname, "tmp/%s.chat", getCurrentUser()->userid);*/ sethomefile(fname,getCurrentUser()->userid,"chatrec"); if (!pthis->rec) { if ((pthis->rec = fopen(fname, "a")) == NULL) return; printchatline(pthis, "\033[5m\033[32mRecord Start ...\033[m"); move(0, 0); clrtoeol(); prints ("\033[44m\033[33m 房间: \033[36m%-10s \033[33m话题:\033[36m%-51s\033[31m%2s\033[m", pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : " "); fprintf(pthis->rec, "发信人: %s (%s) 房间: %s\n话 题: %s\x1b[m\n\n", getCurrentUser()->userid, getCurrentUser()->username, pthis->chatroom, pthis->topic); fprintf(pthis->rec, "本段由 %s", getCurrentUser()->userid); fprintf(pthis->rec, "所录下,时间: %s", ctime(&now)); bbslog("user", "start record room %s", pthis->chatroom); } else { move(0, 0); clrtoeol(); prints ("\033[44m\033[33m 房间: \033[36m%-10s \033[33m话题:\033[36m%-51s\033[31m%2s\033[m", pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : " "); fprintf(pthis->rec, "发信人: %s (%s) 房间: %s\n话 题: %s\x1b[m\n\n", getCurrentUser()->userid, getCurrentUser()->username, pthis->chatroom, pthis->topic); printchatline(pthis, "\033[5m\033[32mRecord Stop ...\033[m"); fprintf(pthis->rec, "结束时间:%s\n", ctime(&now)); fclose(pthis->rec); pthis->rec = NULL; mail_file(getCurrentUser()->userid, fname, getCurrentUser()->userid, "录音结果", 1, NULL); my_unlink(fname); bbslog("user", "stop record room %s", pthis->chatroom); } }
/* 创建以username为名,以passwd为密码的用户 */ void add_bbsid(char *username, char *passwd) { struct userec *newuser; int unum; char path[PATHLEN]; char buf[PATHLEN]; unum = getnewuserid(username); if (unum > MAXUSERS || unum <= 0) { clean_ipc(); error("%s: unum error", username); } strcpy(buf, username); unum = getuser(buf, &newuser); setpasswd(passwd, newuser); if (!strcmp(username, "SYSOP")) { newuser->flags = (char)1; strcpy(newuser->username, "系统管理员"); newuser->userdefine[0] = (unsigned int)3221224447U; newuser->userdefine[1] = (unsigned int)4294967295U; newuser->userlevel = (unsigned int)0xDAFFDFFF; } else if (!strcmp(username, "guest")) { newuser->flags = (char)9; newuser->userlevel = (unsigned int)536879104U; strcpy(newuser->username, "和谐"); newuser->userdefine[0] = (unsigned int)3221224447U; newuser->userdefine[1] = (unsigned int)4294967295U; } update_user(newuser, unum, 1); newbbslog(BBSLOG_USIES, "APPLY: %s uid %d from %s", newuser->userid, unum, "127.0.0.1"); bbslog("user", "%s", "new account"); usage("add user %s", username); sethomepath(path, newuser->userid); sprintf(buf, "/bin/mv -f %s %s/homeback/%s", path, BBSHOME, newuser->userid); system(buf); sprintf(buf, "/bin/mv -f %s %s/mailback/%s", path, BBSHOME, newuser->userid); system(buf); if (strcmp(username, "guest")) /* 不给 guest 发信 */ mail_file(DELIVER, "etc/tonewuser", newuser->userid, "致新注册用户的信", 0, NULL); }
int mailuser(struct userec* user,void* arg) { int i; if( read_userdata(user->userid, &ud) != 0) return 0; #ifdef HAVE_BIRTHDAY if(ud.birthmonth != birthmonth || ud.birthday != birthday) #endif return 0; i=rand()%birthfilenum; mail_file("SYSOP", filename[i], user->userid, "水木清华站恭祝您生日快乐", BBSPOST_LINK, NULL); return 0; };
/* * Bounce mail */ void bounce_mail(char *reason, RFCAddr *addr_from, Message *msg, char *rfc_to, Textlist *body) { char *to; FILE *in; to = s_rfcaddr_to_asc(addr_from, TRUE); if( bounce_header(to) == ERROR) return; BUF_COPY3(buffer, cf_p_configdir(), "/bounce.", reason); in = xfopen(buffer, R_MODE); print_file_subst(in, mail_file('m'), msg, rfc_to, body); fclose(in); mail_close('m'); return; }
// Recover user's talk log from abnormal exit. void tlog_recover(void) { char buf[256]; sethomefile(buf, currentuser.userid, "talk_log"); if (strcasecmp(currentuser.userid, "guest") == 0 || !dashf(buf)) return; screen_clear(); genbuf[0] = '\0'; //% getdata(0, 0, "\033[1;32m您有一个不正常断线所留下来的聊天记录, " getdata(0, 0, "\033[1;32m\xc4\xfa\xd3\xd0\xd2\xbb\xb8\xf6\xb2\xbb\xd5\xfd\xb3\xa3\xb6\xcf\xcf\xdf\xcb\xf9\xc1\xf4\xcf\xc2\xc0\xb4\xb5\xc4\xc1\xc4\xcc\xec\xbc\xc7\xc2\xbc, " //% "您要 .. (M) 寄回信箱 (Q) 算了?[Q]:\033[m", "\xc4\xfa\xd2\xaa .. (M) \xbc\xc4\xbb\xd8\xd0\xc5\xcf\xe4 (Q) \xcb\xe3\xc1\xcb\xa3\xbf[Q]\xa3\xba\033[m", genbuf, 2, DOECHO, YEA); if (genbuf[0] == 'M' || genbuf[0] == 'm') { //% mail_file(buf, currentuser.userid, "聊天记录"); mail_file(buf, currentuser.userid, "\xc1\xc4\xcc\xec\xbc\xc7\xc2\xbc"); } unlink(buf); return; }
static int bbs_bm_change(char *board, struct boardheader *newbh, struct boardheader *oldbh) { int id,m,brd_num,n,i; int flag; struct userec *lookupuser; unsigned int newlevel; char *p; char obm[10][IDLEN+2]; int obmnum=0,nbmnum=0; char nbm[10][IDLEN+2]; char buf[200]; for(i=0;i<10;i++){ obm[i][0]='\0'; nbm[i][0]='\0'; } if(oldbh){ for(p = strtok(oldbh->BM, " "),obmnum=0; p && obmnum < 10; p=strtok(NULL," "),obmnum++){ strncpy(obm[obmnum], p, IDLEN+2); obm[obmnum][IDLEN+1]='\0'; } } for(p = strtok(newbh->BM, " "),nbmnum=0; p && nbmnum < 10; p=strtok(NULL," "),nbmnum++){ strncpy(nbm[nbmnum], p, IDLEN+2); nbm[nbmnum][IDLEN+1]='\0'; } newbh->BM[0]='\0'; for( i=0; i<obmnum; i++ ){ flag = 2; if(!(id = getuser(obm[i],&lookupuser))){ continue; } for(m=0;m<nbmnum;m++){ if(!strcmp(obm[i],nbm[m])) flag = 0; } if(flag == 0) continue; newlevel = lookupuser->userlevel; brd_num = 0; if( lookupuser->userlevel & PERM_BOARDS ){ for(n = 0; n < get_boardcount(); n++){ if(chk_BM_instr(getboard(n+1)->BM, lookupuser->userid) == true ) brd_num ++; } } if( brd_num == 1){ newlevel &= ~PERM_BOARDS; newlevel &= ~PERM_CLOAK; } sprintf(buf,"免去 %s 的斑竹 %s", board, lookupuser->userid); //securityreport(buf, lookupuser, NULL); lookupuser->userlevel = newlevel; } for( i=0; i<nbmnum; i++ ){ flag = 1; if(!(id = getuser(nbm[i],&lookupuser))){ continue; } if( strlen(newbh->BM) + strlen(lookupuser->userid) >= BM_LEN - 2 ) continue; for(m=0;m<obmnum;m++){ if(!strcmp(nbm[i],obm[m])){ flag = 0; if( newbh->BM[0] != '\0' ) strcat(newbh->BM, " "); strcat(newbh->BM, lookupuser->userid); } } if(flag == 0) continue; newlevel = lookupuser->userlevel; if( newbh->BM[0] != '\0' ) strcat( newbh->BM, " " ); strcat(newbh->BM, lookupuser->userid); newlevel |= PERM_BOARDS; mail_file(getCurrentUser()->userid, "etc/forbm", lookupuser->userid, "新任斑竹必读", BBSPOST_LINK, NULL); sprintf(buf,"任命 %s 的斑竹 %s", board, lookupuser->userid); //securityreport(buf, lookupuser, NULL); lookupuser->userlevel = newlevel; } return 0; }
// ��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 ; }
void check_register_info() { struct userec *urec = ¤tuser; FILE *fout; char buf[192], buf2[STRLEN]; #ifdef MAILCHECK char ans[4]; #ifdef CODE_VALID int i; #endif #endif if (!(urec->userlevel & PERM_LOGIN)) { urec->userlevel = 0; return; } #ifdef NEWCOMERREPORT if (urec->numlogins == 1) { clear(); sprintf(buf, "tmp/newcomer.%s", currentuser.userid); if ((fout = fopen(buf, "w")) != NULL) { fprintf(fout, "��Һ�,\n\n"); fprintf(fout, "���� %s (%s), ���� %s\n", currentuser.userid, urec->username, fromhost); fprintf(fout, "����%s������վ����, ���Ҷ��ָ�̡�\n", (urec->gender == 'M') ? "С��" : "СŮ��"); move(2, 0); prints("�dz���ӭ %s ���ٱ�վ��ϣ�������ڱ�վ�ҵ������Լ���һƬ��գ�\n\n", currentuser.userid); prints("����������̵ĸ��˼��, ��վ����ʹ���ߴ���к�\n"); prints("(����������, д���ֱ�Ӱ� <Enter> ����)...."); getdata(6, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "\n\n���ҽ���:\n\n"); fprintf(fout, "%s\n", buf2); getdata(7, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); getdata(8, 0, ":", buf2, 75, DOECHO, YEA); if (buf2[0] != '\0') { fprintf(fout, "%s\n", buf2); } } } fclose(fout); sprintf(buf2, "������·: %s", urec->username); Postfile(buf, "newcomers", buf2, 2); unlink(buf); } pressanykey(); } #endif #ifdef PASSAFTERTHREEDAYS if (urec->lastlogin - urec->firstlogin < 3 * 86400) { if (!HAS_PERM(PERM_SYSOP)) { set_safe_record(); urec->userlevel &= ~(PERM_DEFAULT); urec->userlevel |= PERM_LOGIN; substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); ansimore("etc/newregister", YEA); return; } } #endif #ifndef FDQUAN //������� while (!HAS_PERM(PERM_BINDMAIL)) { clear(); if (HAS_PERM(PERM_REGISTER)) { while (askyn("�Ƿ��������", NA, NA)== NA) //add by eefree.06.7.20 { if (askyn("�Ƿ���дУ����Ϣ", NA, NA) == NA) { clear(); continue; } check_reg_extra(); return; } //add end. } check_reg_mail(); } #endif clear(); if (HAS_PERM(PERM_REGISTER)) return; #ifndef AUTOGETPERM if (check_register_ok()) { #endif set_safe_record(); urec->userlevel |= PERM_DEFAULT; substitut_record(PASSFILE, urec, sizeof(struct userec), usernum); return; #ifndef AUTOGETPERM } #endif #ifdef MAILCHECK #ifdef CODE_VALID sethomefile(buf, currentuser.userid, ".regpass"); if (dashf(buf)) { move(13, 0); prints("����δͨ�����ȷ��... \n"); prints("�����ڱ�������ע��ȷ������, \"��֤����\"����Ϊ���ȷ��\n"); prints("һ���� %d ���ַ�, ��Сд���в���, ��ע��.\n", RNDPASSLEN); prints("����ȡ�������������� [Enter] ��.\n"); prints("[1;33m��ע��, ����������һ����֤�������������������룡[m\n"); if ((fout = fopen(buf, "r")) != NULL) { fscanf(fout, "%s", buf2); fclose(fout); for (i = 0; i < 3; i++) { move(18, 0); prints("������ %d �λ���\n", 3 - i); getdata(19,0,"��������֤����: ",genbuf,(RNDPASSLEN+1),DOECHO,YEA); if (strcmp(genbuf, "") != 0) { if (strcmp(genbuf, buf2) != 0) continue; else break; } } } else i = 3; if (i == 3) { prints("������֤ʧ��! ����Ҫ��дע�ᵥ�����ȷ������ȷ���������\n"); getdata(22,0,"��ѡ��1.��ע�ᵥ 2.����ȷ���� [1]:",ans,2,DOECHO,YEA); if(ans[0] == '2') { send_regmail(¤tuser); pressanykey(); } else x_fillform(); } else { set_safe_record(); urec->userlevel |= PERM_DEFAULT; substitut_record(PASSFILE, urec,sizeof(struct userec), usernum); prints("������!! ����˳����ɱ�վ��ʹ����ע������,\n"); prints("������������ӵ��һ��ʹ���ߵ�Ȩ��������...\n"); unlink(buf); mail_file("etc/smail", "SYSOP", "��ӭ���뱾վ����"); pressanykey(); } return; } #endif if ( (!strstr(urec->email, BBSHOST)) && (!invalidaddr(urec->email)) && (!invalid_email(urec->email))) { move(13, 0); prints("���ĵ������� ����ͨ��������֤... \n"); prints(" ��վ�����ϼ�һ����֤�Ÿ���,\n"); prints(" ��ֻҪ�� %s ����, �Ϳ��Գ�Ϊ��վ�ϸ���.\n\n", urec->email); prints(" ��Ϊ��վ�ϸ���, �������и����Ȩ���!\n"); prints(" ��Ҳ����ֱ����дע�ᵥ��Ȼ��ȴ�վ�����ֹ���֤��\n"); getdata(21,0,"��ѡ��1.��ע�ᵥ 2.��ȷ���� [1]: ",ans,2,DOECHO,YEA); if(ans[0] == '2') { send_regmail(¤tuser); getdata(21,0,"ȷ�����Ѽij�, ��������Ŷ!! ",ans, 2, DOECHO, YEA); return; } } #endif /* Following line modified by Amigo 2002.04.23. Fill form only when no new letter. */ /* x_fillform();*/ if (!chkmail()) x_fillform(); }
int scan_register_form(char* regfile) { static char *field[] = {"usernum", "userid", "realname", "dept", "addr", "phone", "regip", NULL }; static char *finfo[] = {"帐号位置", "申请帐号", "真实姓名", "学校系级", "目前住址", "连络电话", "注册ip ", NULL }; static char *reason[] = {"请确实填写真实姓名(不可使用拼音).", "请详填学校院系与年级 (注明系和年级或者工作单位和工作部门).", "请填写完整的住址资料 (完整详细,能够通信).", "请详填连络电话 (固定电话需填写区号).", "请勿穿梭注册.", "请如实详细填写注册申请表.", "请用中文填写申请表.", "同一个用户注册了过多ID.", NULL }; struct userec uinfo; FILE *fn, *fout, *freg; char fdata[7][STRLEN]; char fname[STRLEN], buf[STRLEN]; char ans[5], *ptr, *uid; int n, unum; uid = currentuser.userid; char numofreason[2];//tdhlshx for refuse. int total; int iis; int realnumofrea[8];//add end stand_title("依序设定所有新注册资料"); sprintf(fname, "%s.tmp", regfile); move(2, 0); if (dashf(fname)) { move(1, 0); prints("其他 SYSOP 正在查看注册申请单, 请检查使用者状态.\n"); getdata(2, 0, "你确定没有其他 SYSOP 在审核注册单吗 ? [y/N]: ", ans, 2, DOECHO, YEA); if (ans[0] == 'Y' || ans[0] == 'y') f_cp(fname, regfile, O_APPEND); else { pressreturn(); return -1; } } rename(regfile, fname); if ((fn = fopen(fname, "r")) == NULL) { move(2, 0);//请管理员输入未通过原因: prints("系统错误, 无法读取注册资料档: %s\n", fname); pressreturn(); return -1; } memset(fdata, 0, sizeof(fdata)); while (fgets(genbuf, STRLEN, fn) != NULL) { if ((ptr = (char *) strstr(genbuf, ": ")) != NULL) { *ptr = '\0'; for (n = 0; field[n] != NULL; n++) { if (strcmp(genbuf, field[n]) == 0) { strcpy(fdata[n], ptr + 2); if ((ptr = (char *) strchr(fdata[n], '\n')) != NULL) *ptr = '\0'; } } } else if ((unum = getuser(fdata[1])) == 0) { move(2, 0); clrtobot(); prints("系统错误, 查无此帐号.\n\n"); for (n = 0; field[n] != NULL; n++) prints("%s : %s\n", finfo[n], fdata[n]); pressreturn(); memset(fdata, 0, sizeof(fdata)); } else { memcpy(&uinfo, &lookupuser, sizeof(uinfo)); move(1, 0); prints("帐号位置 : %d\n", unum); disply_userinfo(&uinfo); move(15, 0); printdash(NULL); for (n = 0; field[n] != NULL; n++) prints("%s : %s\n", finfo[n], fdata[n]); if (uinfo.userlevel & PERM_LOGINOK) { move(t_lines - 1, 0); prints("此帐号不需再填写注册单.\n"); igetkey(); ans[0] = 'D'; } else { getdata(t_lines - 1, 0, "是否接受此资料 (Y/N/Q/Del/Skip)? [S]: ", ans, 3, DOECHO, YEA); } move(1, 0); clrtobot(); switch (ans[0]) { case 'D': case 'd': break; case 'Y': case 'y': prints("以下使用者资料已经更新:\n"); n = strlen(fdata[5]); if (n + strlen(fdata[3]) > 60) { if (n > 40) fdata[5][n = 40] = '\0'; fdata[3][60 - n] = '\0'; } strncpy(uinfo.realname, fdata[2], NAMELEN); strncpy(uinfo.address, fdata[4], NAMELEN); sprintf(genbuf, "%s$%s@%s", fdata[3], fdata[5], uid); genbuf[STRLEN - 16] = '\0'; strncpy(uinfo.reginfo, genbuf, STRLEN - 17); #ifdef ALLOWGAME uinfo.money = 1000; #endif uinfo.lastjustify = time(0); substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum); sethomefile(buf, uinfo.userid, "register"); if (dashf(buf)) { sethomefile(genbuf, uinfo.userid, "register.old"); rename(buf, genbuf); } if ((fout = fopen(buf, "w")) != NULL) { for (n = 0; field[n] != NULL; n++) fprintf(fout, "%s: %s\n", field[n], fdata[n]); n = time(NULL); getdatestring(n,NA); fprintf(fout, "Date: %s\n", datestring); fprintf(fout, "Approved: %s\n", uid); fclose(fout); } mail_file("etc/s_fill", uinfo.userid, "恭禧你,你已经完成注册。"); mail_file("etc/fornewcomers",uinfo.userid,"欢迎加入 [33m"BBSNAME"[m 大家庭");//tdhlshx 新手FAQ信件 sethomefile(buf, uinfo.userid, "mailcheck"); unlink(buf); sprintf(genbuf, "让 %s 通过身份确认.", uinfo.userid); securityreport4(genbuf); break; case 'Q': case 'q': if ((freg = fopen(regfile, "a")) != NULL) { for (n = 0; field[n] != NULL; n++) fprintf(freg, "%s: %s\n", field[n], fdata[n]); fprintf(freg, "----\n"); while (fgets(genbuf, STRLEN, fn) != NULL) fputs(genbuf, freg); fclose(freg); } break; case 'N': case 'n': for(total=0; total<8; total++) realnumofrea[total]=0; for (n = 0; field[n] != NULL; n++) prints("%s: %s\n", finfo[n], fdata[n]); printdash(NULL); move(9, 0); prints("请依次输入退回申请表原因的序号并回车确认,直接回车结束.\n\n"); // prints("请选择/输入退回申请表原因, 按 <enter> 取消.\n\n"); for (n = 0; reason[n] != NULL; n++) prints("%d) %s\n", n, reason[n]); getdata(12+n,0,"退回原因:",numofreason,2,DOECHO,YEA); // getdata(12 + n, 0, "退回原因: ", buf, 60, DOECHO, YEA); if(numofreason[0]!='\0'&&numofreason[0]>='0'&&numofreason[0]<='7') { total=atoi(numofreason); realnumofrea[total]=1; move(14+n,0); prints("您已经选择的理由有:\n%d ",total); } while(numofreason[0]!='\0') { getdata(12+n,0,"退回原因:",numofreason,2,DOECHO,YEA); if(numofreason[0]>='0'&&numofreason[0]<='7') { total=atoi(numofreason); if(realnumofrea[total]==0) realnumofrea[total]=1; else realnumofrea[total]=0; move(14+n,0); clrtobot(); prints("您已经选择的理由有:\n"); for(iis=0; iis<8; iis++) { if(realnumofrea[iis]==1) prints("%d ",iis); } } } system("cp /home/bbs/etc/f_fill /home/bbs/tmp/fletter"); char FL[STRLEN]; sprintf(FL,"/home/bbs/tmp/fletter"); FILE * fail=fopen(FL,"a"); if(fail==NULL) { prints("Error,创建临时文件错误.请与系统维护联系或再次尝试!"); pressanykey(); return -1; } { fprintf(fail,"\n\n您被拒绝注册的原因大概如下:\n"); for(total=0; total<8; total++) { if(realnumofrea[total]==1) { strcpy(buf,reason[total]); fprintf(fail,"\n%s",buf); } } sprintf(genbuf,"很抱歉的告诉您,您这次注册失败.:("); strncpy(uinfo.address, genbuf, NAMELEN); substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum); fclose(fail); mail_file(FL,uinfo.userid, uinfo.address); system("rm -f /home/bbs/tmp/fletter"); } break; /*if (buf[0] != '\0') { if (buf[0] >= '0' && buf[0] < '0' + n) { strcpy(buf, reason[buf[0] - '0']); } sprintf(genbuf, "<注册失败> - %s", buf); strncpy(uinfo.address, genbuf, NAMELEN); substitute_record(PASSFILE, &uinfo, sizeof(uinfo), unum); mail_file("etc/f_fill", uinfo.userid, uinfo.address);*/ /* user_display( &uinfo, 1 ); */ /* pressreturn(); */ /* break; } move(10, 0); clrtobot(); prints("取消退回此注册申请表.\n");*/ /* run default -- put back to regfile */ default: if ((freg = fopen(regfile, "a")) != NULL) { for (n = 0; field[n] != NULL; n++) fprintf(freg, "%s: %s\n", field[n], fdata[n]); fprintf(freg, "----\n"); fclose(freg); } } memset(fdata, 0, sizeof(fdata)); } } fclose(fn); unlink(fname); return (0); }
int k_mail_file(char *fromid, char *tmpfile, char *userid, char *title, int unlinkmode, struct fileheader *fh) { mail_file(tmpfile, userid, title); unlink(tmpfile); }