DeleteAccount() { NAME namebuf; int rc; char ans[4]; move(2,0); clrtobot(); bbs_acctnames(&acctlist, NULL); namecomplete(NULL, acctlist, "Userid to delete: ", namebuf, sizeof(NAME)); if (namebuf[0] == '\0' || !is_in_namelist(acctlist, namebuf)) { bbperror(S_NOSUCHUSER, NULL); pressreturn(); return FULLUPDATE; } prints("Deleting user '%s'.\n", namebuf); getdata(5,0,"Are you sure (Y/N)? [N]: ",ans,sizeof(ans),DOECHO,0); if (ans[0] != 'Y' && ans[0] != 'y') { prints("Account not deleted.\n"); pressreturn(); return FULLUPDATE; } rc = bbs_delete_account(namebuf); if (rc == S_OK) prints("Account deleted.\n"); else bbperror(rc, "Account deletion failed"); pressreturn(); return FULLUPDATE; }
// pager与msg设定 // int x_userdefine() { int id; unsigned int newlevel; set_user_status(ST_USERDEF); if (!(id = getuser(currentuser.userid))) { screen_move_clear(3); //% prints("错误的使用者 ID..."); prints("\xb4\xed\xce\xf3\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf ID..."); pressreturn(); screen_clear(); return 0; } screen_move(1, 0); screen_clrtobot(); screen_move(2, 0); use_define = 1; //% newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES, newlevel = setperms(lookupuser.userdefine, "\xb2\xce\xca\xfd", NUMDEFINES, showperminfo); screen_move(2, 0); if (newlevel == lookupuser.userdefine) //% prints("参数没有修改...\n"); prints("\xb2\xce\xca\xfd\xc3\xbb\xd3\xd0\xd0\xde\xb8\xc4...\n"); else { lookupuser.userdefine = newlevel; currentuser.userdefine = newlevel; substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id); //% prints("新的参数设定完成...\n\n"); prints("\xd0\xc2\xb5\xc4\xb2\xce\xca\xfd\xc9\xe8\xb6\xa8\xcd\xea\xb3\xc9...\n\n"); } pressreturn(); screen_clear(); use_define = 0; return 0; }
// pager与msg设定 // int x_userdefine() { int id; unsigned int newlevel; set_user_status(ST_USERDEF); if (!(id = getuser(currentuser.userid))) { screen_move_clear(3); screen_printf("错误的使用者 ID..."); pressreturn(); screen_clear(); return 0; } screen_move(1, 0); screen_clrtobot(); screen_move(2, 0); use_define = 1; newlevel = setperms(lookupuser.userdefine, "参数", NUMDEFINES, showperminfo); screen_move(2, 0); if (newlevel == lookupuser.userdefine) screen_printf("参数没有修改...\n"); else { lookupuser.userdefine = newlevel; currentuser.userdefine = newlevel; substitut_record(PASSFILE, &lookupuser, sizeof(struct userec), id); screen_printf("新的参数设定完成...\n\n"); } pressreturn(); screen_clear(); use_define = 0; return 0; }
//#define MY_DEBUG // 执行命令cmdfile,参数为param1 static void exec_cmd(int umode, int pager, char *cmdfile, char *param1) { char buf[160]; char *my_argv[18], *ptr; fb_signal(SIGALRM, SIG_IGN); set_user_status(umode); screen_clear(); screen_move(2, 0); if (!dashf(cmdfile)) { //% prints("文件 [%s] 不存在!\n", cmdfile); prints("\xce\xc4\xbc\xfe [%s] \xb2\xbb\xb4\xe6\xd4\xda\xa3\xa1\n", cmdfile); pressreturn(); return; } sprintf(buf, "%s %s %s %d", cmdfile, param1, currentuser.userid, getpid()); report(buf, currentuser.userid); my_argv[0] = cmdfile; strcpy(buf, param1); if (buf[0] != '\0') ptr = strtok(buf, " \t"); else ptr = NULL; for (int i = 1; i < 18; i++) { if (ptr) { my_argv[i] = ptr; ptr = strtok(NULL, " \t"); } else { my_argv[i] = NULL; } } #ifdef MY_DEBUG for (i = 0; i < 18; i++) { if (my_argv[i] != NULL) prints ("my_argv[%d] = %s\n", i, my_argv[i]); else prints ("my_argv[%d] = (none)\n", i); } pressanykey (); #else child_pid = fork(); if (child_pid == -1) { //% prints("资源紧缺,fork() 失败,请稍后再使用"); prints("\xd7\xca\xd4\xb4\xbd\xf4\xc8\xb1\xa3\xac""fork() \xca\xa7\xb0\xdc\xa3\xac\xc7\xeb\xc9\xd4\xba\xf3\xd4\xd9\xca\xb9\xd3\xc3"); child_pid = 0; pressreturn(); return; } if (child_pid == 0) { execv(cmdfile, my_argv); exit(0); } else { waitpid(child_pid, NULL, 0); } #endif child_pid = 0; screen_clear(); }
int user_switchcase() { char newuserid[IDLEN+2]; modify_user_mode(USERDEF); clear(); if (count_user( )>1) { move(1,0); prints("��Ŀǰ��login��ֹһ��,���˳�����login������һ��\n"); pressreturn(); clear(); return 1; } if(HAS_PERM(PERM_BOARDS)){ move(1,0); prints("�Բ���Ŀǰ��֧�ְ������û�����Сд��������ϵ����������Ա,\n"); prints("�������а���Ȼ������ģ���������������"); pressreturn(); clear(); return 1; } getdata(0, 0, "�������µ��ʺ����� (Enter User ID): ", newuserid, IDLEN + 1, DOECHO, YEA); if(newuserid[0] == '\0'){ clear(); return 0; } if(!strcmp(currentuser.userid, newuserid)){ clear(); return 0; } if(strcasecmp(currentuser.userid, newuserid)){ move(1,0); prints("�µ��ʺ����ƺ�ԭ���ʺŲ�ͬ������ܸı��ʺŵĴ�Сд��"); pressreturn(); clear(); return 1; } if(HAS_PERM(PERM_PERSONAL)) dig_user_switchcase(newuserid); sprintf(genbuf,"mv %s/home/%C/%s %s/home/%C/%s", BBSHOME, toupper(currentuser.userid[0]),currentuser.userid, BBSHOME, toupper(newuserid[0]), newuserid); system(genbuf); sprintf(genbuf,"mv %s/mail/%C/%s %s/mail/%C/%s", BBSHOME, toupper(currentuser.userid[0]),currentuser.userid, BBSHOME, toupper(newuserid[0]), newuserid); system(genbuf); strcpy(currentuser.userid, newuserid); strcpy(uinfo.userid, newuserid); substitute_record(PASSFILE, ¤tuser, sizeof(currentuser), usernum); move(5,10); prints("���ʺŴ�Сд�ɹ���"); pressreturn(); return 0; }
SetTermtype() { TERM terminal; int rc; move(3,0); clrtobot(); if (getdata(3,0, "Enter new terminal type: ", terminal, sizeof terminal, DOECHO, 1) == -1) return FULLUPDATE; if(terminal[0] == '\0') return PARTUPDATE; if(term_init(terminal) == -1) { prints("Invalid terminal type.\n"); #ifndef REMOTE_CLIENT return PARTUPDATE; #endif } else { initscr(); clear(); } rc = bbs_set_terminal(terminal); if (rc == S_OK) prints("New terminal type was saved.\n"); else bbperror(rc, "New terminal type not saved."); pressreturn(); return FULLUPDATE; }
SetCharset() { CSET charset; int rc; move(3,0); clrtobot(); if (getdata(3,0, "Enter new charset: ", charset, sizeof charset, DOECHO, 1) == -1) return FULLUPDATE; if(charset[0] == '\0') return PARTUPDATE; if(conv_init(charset) == -1) { prints("Invalid character set.\n"); #ifndef REMOTE_CLIENT return PARTUPDATE; #endif } else { initscr(); clear(); } rc = bbs_set_charset(charset); if (rc == S_OK) prints("New character set was saved.\n"); else prints("New character set NOT saved.\n"); pressreturn(); return FULLUPDATE; }
int showmsg(char *text) { move(b_line - 1, 0); clrtoeol(); outs(text); return pressreturn(); }
int b_notes_edit() { char buf[STRLEN], buf2[STRLEN]; char ans[4]; int aborted; int notetype; if (!chkBM(currbp, ¤tuser)) return 0; clear(); move(1, 0); prints("�༭/ɾ������¼"); //ѯ�ʱ༭���ֱ���¼ while (1) { getdata(3, 0, "�༭��ɾ������������ (0) �뿪 (1) һ�㱸��¼ (2) ���ܱ���¼? [1] ", ans, 2, DOECHO, YEA); if (ans[0] == '0') return FULLUPDATE; if (ans[0] == '\0') strcpy(ans, "1"); if (ans[0] == '1' || ans[0] == '2') break; } makevdir(currboard); //��������¼Ŀ¼ if (ans[0] == '2') { setvfile(buf, currboard, "secnotes"); notetype = 2; } else { setvfile(buf, currboard, "notes"); notetype = 1; } sprintf(buf2, "(E)�༭ (D)ɾ�� %4s����¼? [E]: ", (notetype == 1) ? "һ��" : "����"); getdata(5, 0, buf2, ans, 2, DOECHO, YEA); //ѯ�ʱ༭����ɾ�� if (ans[0] == 'D' || ans[0] == 'd') { //ɾ������¼ move(6, 0); sprintf(buf2, "���Ҫɾ��%4s����¼", (notetype == 1) ? "һ��" : "����"); if (askyn(buf2, NA, NA)) { move(7, 0); prints("����¼�Ѿ�ɾ��...\n"); pressanykey(); unlink(buf); aborted = 1; } else aborted = -1; } else aborted = vedit(buf, NA, YEA); //�༭����¼ if (aborted == -1) { pressreturn(); } else { if (notetype == 1) setvfile(buf, currboard, "noterec"); else setvfile(buf, currboard, "notespasswd"); unlink(buf); } return FULLUPDATE; }
int x_cloak(void) { bool visible = session_toggle_visibility(); report("toggle cloak", currentuser.userid); screen_move_clear(-1); //% "隐身术已经 %s 了!" "停止" "启动" prints("\xd2\xfe\xc9\xed\xca\xf5\xd2\xd1\xbe\xad %s \xc1\xcb!", visible ? "\xcd\xa3\xd6\xb9" : "\xc6\xf4\xb6\xaf"); pressreturn(); return 0; }
/* load template, see also: orig_tmpl_init(). */ int tmpl_init_ex(int mode, const char *bname, struct a_template **pptemp) { int newmode=0; int ret; if (mode==1 || chk_BM(bname, getCurrentUser())) newmode = 1; ret = orig_tmpl_init((char*)bname, newmode, pptemp); if (ret == -2) { clear(); move(3,0); prints("模板程序已经更新过,请您重新登录,谢谢"); pressreturn(); } return ret; }
//取得genbuf中保存的用户所在的记录位置到*id中,为零表示不存在 int gettheuserid(int x, char *title, int *id) { screen_move(x, 0); usercomplete(title, genbuf); if (*genbuf == '\0') { screen_clear(); return 0; } if (!(*id = getuser(genbuf))) { screen_move_clear(x + 3); //% prints("错误的使用者代号"); prints("\xb4\xed\xce\xf3\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf\xb4\xfa\xba\xc5"); pressreturn(); screen_clear(); return 0; } return 1; }
user_id_t user_complete_id(int row, const char *prompt) { char name[IDLEN + 1]; user_complete(row, prompt, name, sizeof(name)); if (*name == '\0') { screen_clear(); return 0; } user_id_t id = getuser(name); if (!id) { screen_move_clear(row + 3); screen_printf("错误的使用者代号"); pressreturn(); return 0; } return id; }
int b_notes_edit() { char buf[STRLEN], buf2[STRLEN]; char ans[4]; int aborted; int notetype; if (!chkBM(currbp, ¤tuser)) return 0; clear(); move(0, 0); prints("�趨��\n\n (1)һ�㱸��¼\n (2)���ܱ���¼\n"); prints(" (3)����ǰ��\n (4)�Ƿ�ǿ��ʹ��ǰ\n"); while (1) { getdata(7, 0,"��ǰѡ��[1](0~4): ", ans, 2, DOECHO, YEA); if (ans[0] == '0') return FULLUPDATE; if (ans[0] == '\0') strcpy(ans, "1"); if (ans[0] >= '1' && ans[0] <= '4' ) break; } makevdir(currboard); //��������¼Ŀ¼ notetype = ans[0] - '0'; if (notetype == 2) { setvfile(buf, currboard, "secnotes"); } else if (notetype == 3) { setvfile(buf, currboard, "prefix"); } else if (notetype == 1) { setvfile(buf, currboard, "notes"); } else if (notetype == 4 ) { int pos; struct boardheader fh; pos = search_record(BOARDS, &fh, sizeof(fh), cmpbnames, currboard); if (askyn("�Ƿ�ǿ��ʹ��ǰ��", (fh.flag & BOARD_PREFIX_FLAG)?YEA:NA,NA)) { fh.flag |= BOARD_PREFIX_FLAG; } else { fh.flag &= ~BOARD_PREFIX_FLAG; } substitute_record(BOARDS, &fh, sizeof(fh), pos); return FULLUPDATE; } sprintf(buf2, "(E)�༭ (D)ɾ�� %4s? [E]: ", (notetype == 3)?"����ǰ��":(notetype == 1) ? "һ�㱸��¼" : "���ܱ���¼"); getdata(8, 0, buf2, ans, 2, DOECHO, YEA); //ѯ�ʱ༭����ɾ�� if (ans[0] == 'D' || ans[0] == 'd') { //ɾ������¼ move(9, 0); sprintf(buf2, "���Ҫɾ��ô��"); if (askyn(buf2, NA, NA)) { move(10, 0); prints("�Ѿ�ɾ��...\n"); pressanykey(); unlink(buf); aborted = 1; } else aborted = -1; } else aborted = vedit(buf, NA, YEA); //�༭����¼ if (aborted == -1) { pressreturn(); } else { if (notetype == 1) setvfile(buf, currboard, "noterec"); else setvfile(buf, currboard, "notespasswd"); unlink(buf); } return FULLUPDATE; }
/* the #ifdefs have been totally separated, for readability */ static int spawn1(int rerun, int pressret) { #if DISP_IBMPC int closed; #endif #if COMMON_SH_PROMPT register int s; char line[NLINE]; /* command line send to shell */ if ((s = ShellPrompt(&save_shell[0], line, rerun)) != TRUE) return s; #endif /* COMMON_SH_PROMPT */ /* take care of autowrite */ if (writeall(FALSE,1,FALSE,TRUE,TRUE) != TRUE) return FALSE; #if SYS_UNIX #if DISP_X11 (void)system_SHELL(line); #else ttclean(TRUE); (void)system_SHELL(line); TTflush(); ttunclean(); if (pressret) pressreturn(); TTopen(); TTkopen(); TTflush(); sgarbf = TRUE; #endif /* DISP_X11 */ return AfterShell(); #endif /* SYS_UNIX */ #if SYS_VMS TTputc('\n'); /* Already have '\r' */ TTflush(); s = sys(line); /* Run the command. */ mlforce("\r\n\n[End]"); /* Pause. */ TTflush(); (void)keystroke(); sgarbf = TRUE; return (s); #endif #if SYS_WIN31 mlforce("[Not in Windows 3.1]"); return FALSE; #endif #if SYS_MSDOS || SYS_OS2 || SYS_WINNT bottomleft(); TTputc('\n'); TTflush(); TTkclose(); #if DISP_IBMPC /* If we don't reset to 80x25, parts of the shell-output will go * astray. */ closed = term.t_ncol != 80 || term.t_nrow != 25; if (closed) TTclose(); #endif system(line); TTkopen(); /* if we are interactive, pause here */ if (pressret) { pressreturn(); } #if DISP_IBMPC /* Reopen the display _after_ the prompt, to keep the shell-output * in the same type of screen as the prompt. */ if (closed) TTopen(); #endif sgarbf = TRUE; return AfterShell(); #endif }
SetUserData() { NAME userid; ACCOUNT acct, nr; int rc; SHORT flags = 0; PASSWD passcfm; int x, y, grok; char genbuf[256], ans[4]; move(2,0); memset(&nr, 0, sizeof nr); bbs_acctnames(&acctlist, NULL); namecomplete(NULL, acctlist, "Userid to set: ", userid, sizeof(NAME)); if (userid[0] == '\0' || !is_in_namelist(acctlist, userid)) { bbperror(S_NOSUCHUSER, NULL); pressreturn(); return FULLUPDATE; } if ((rc = bbs_get_userinfo(userid, &acct)) != S_OK) { bbperror(rc, NULL); pressreturn(); return FULLUPDATE; } move(3,0); UserDisplay(&acct); getyx(&y, &x); getdata(++y,0,"Change any user information (Y/N)? [N]: ",ans,sizeof(ans), DOECHO, 0); if (ans[0] != 'Y' && ans[0] != 'y') { prints("Record not changed.\n"); pressreturn(); return FULLUPDATE; } sprintf(genbuf, "New userid [%s]: ", acct.userid); do { getdata(y+1, 0, genbuf, nr.userid, sizeof(nr.userid), DOECHO, 0); if (!nr.userid[0]) break; if (grok = CheckUserid(nr.userid)) { move(y+2, 0); prints("Invalid or taken userid. Try again.\n"); } else BITSET(flags, MOD_USERID); } while (grok); y++; do { getdata(y+1,0,"New Password: "******"Confirm Pass: "******"Passwords don't match. Try again.\n"); } else BITSET(flags, MOD_PASSWD); } while (grok); move(y+2, 0); clrtobot(); y+=2; sprintf(genbuf, "New username [%s]: ", acct.username); getdata(y++, 0, genbuf, nr.username, sizeof(nr.username), DOECHO, 0); if (nr.username[0]) BITSET(flags, MOD_USERNAME); sprintf(genbuf, "New terminal type [%s]: ", acct.terminal); getdata(y++, 0, genbuf, nr.terminal, sizeof(nr.terminal), DOECHO, 0); if (nr.terminal[0]) BITSET(flags, MOD_TERMINAL); sprintf(genbuf, "New charset [%s]: ", acct.charset); getdata(y++, 0, genbuf, nr.charset, sizeof(nr.charset), DOECHO, 0); if (nr.charset[0]) BITSET(flags, MOD_CHARSET); sprintf(genbuf, "New real name [%s]: ", acct.realname); getdata(y++, 0, genbuf, nr.realname, sizeof(nr.realname), DOECHO, 0); if (nr.realname[0]) BITSET(flags, MOD_REALNAME); sprintf(genbuf, "New address: "); getdata(y++, 0, genbuf, nr.address, sizeof(nr.address), DOECHO, 0); if (nr.address[0]) BITSET(flags, MOD_ADDRESS); sprintf(genbuf, "New mail address: "); getdata(y++, 0, genbuf, nr.email, sizeof(nr.email), DOECHO, 0); if (nr.email[0]) BITSET(flags, MOD_EMAIL); getdata(y, 0, "Are you sure (Y/N)? [N]: ", ans, sizeof(ans), DOECHO, 0); if (ans[0] == 'Y' || ans[0] == 'y') { rc = bbs_modify_account(acct.userid, &nr, flags); if (rc == S_OK) prints("User data was changed.\n"); else bbperror(rc, "User modify failed"); } else prints("User data not changed.\n"); pressreturn(); return FULLUPDATE; }
void new_register(void) { char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN]; #ifndef FDQUAN char code[IDLEN+1]; const char *verify_num; int sec; #endif if (dashf("NOREGISTER")) { ansimore("NOREGISTER", NA); pressreturn(); return; } ansimore("etc/register", NA); #ifndef FDQUAN if (!askyn("���Ƿ�ͬ�ⱾվAnnounce�澫����x-3Ŀ¼����վ��?", false, false)) return 0; #endif int tried = 0; prints("\n"); while (1) { if (++tried >= 9) { prints("\n�ݰݣ���̫���� <Enter> ��...\n"); refresh(); return; } #ifndef FDQUAN verify_num = generate_verify_num(); getdata(0, 0, "������������ʾ������: ", code, IDLEN + 1, DOECHO, YEA); #endif getdata(0, 0, "�������ʺ����� (Enter User ID, \"0\" to abort): ", userid, sizeof(userid), DOECHO, YEA); if (userid[0] == '0') return; const char *errmsg = invalid_userid(userid); if (errmsg != NULL) { outs(errmsg); continue; } #ifndef FDQUAN sec = random() % 5; prints("Ϊ����������ע���߳�ͻ...�����ĵȺ� %d ��...\n", sec); oflush(); sleep(sec); if (strcmp(verify_num, code)) { snprintf(log, sizeof(log), "verify '%s' error with code %s!=%s from %s", userid, verify_num, code, fromhost); report(log, currentuser.userid); prints("��Ǹ, ���������֤�벻��ȷ.\n"); continue; } snprintf(log, sizeof(log), "verify '%s' with code %s from %s ", userid, code, fromhost); report(log, currentuser.userid); #endif char path[HOMELEN]; sethomepath(path, userid); if (dosearchuser(userid, ¤tuser, &usernum) || dashd(path)) prints("���ʺ��Ѿ�����ʹ��\n"); else break; } for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) { passbuf[0] = '\0'; getdata(0, 0, "���趨�������� (Setup Password): ", passbuf, sizeof(passbuf), NOECHO, YEA); if (strlen(passbuf) < 4 || !strcmp(passbuf, userid)) { prints("����̫�̻���ʹ���ߴ�����ͬ, ����������\n"); continue; } strlcpy(passwd, passbuf, PASSLEN); getdata(0, 0, "��������һ���������� (Reconfirm Password): ", passbuf, PASSLEN, NOECHO, YEA); if (strncmp(passbuf, passwd, PASSLEN) != 0) { prints("�����������, ��������������.\n"); continue; } passwd[8] = '\0'; break; } if (tried > MAX_SET_PASSWD_TRIES) return; struct userec newuser; #ifdef ALLOWSWITCHCODE fill_new_userec(&newuser, userid, passwd, !convcode); #else fill_new_userec(&newuser, userid, passwd, true); #endif /* added by roly */ sprintf(genbuf, "/bin/rm -fr %s/mail/%c/%s", BBSHOME, toupper(newuser.userid[0]), newuser.userid) ; system(genbuf); sprintf(genbuf, "/bin/rm -fr %s/home/%c/%s", BBSHOME, toupper(newuser.userid[0]), newuser.userid) ; system(genbuf); /* add end */ int allocid = getnewuserid(); if (allocid > MAXUSERS || allocid <= 0) { prints("No space for new users on the system!\n\r"); return; } setuserid(allocid, newuser.userid); if (substitut_record(PASSFILE, &newuser, sizeof(newuser), allocid) == -1) { prints("too much, good bye!\n"); return; } if (!dosearchuser(newuser.userid, ¤tuser, &usernum)) { prints("User failed to create\n"); return; } snprintf(log, sizeof(log), "new account from %s", fromhost); report(log, currentuser.userid); prints("�����µ�¼ %s ����дע����Ϣ\n", newuser.userid); pressanykey(); return; }
static int set_al_key(struct _select_def *conf, int key) { switch(key){ case 'd': { char sql[100]; MYSQL s; char ans[4]; move(2,0); clrtoeol(); ans[0]=0; getdata(2, 0, "删除这条记录(Y/N) [N]: ", ans, 3, DOECHO, NULL, true); if(ans[0] != 'y' && ans[0]!='Y') return SHOW_REFRESH; mysql_init(&s); if (! my_connect_mysql(&s) ){ clear(); prints("%s\n",mysql_error(&s)); pressanykey(); mysql_close(&s); return SHOW_REFRESH; } sprintf(sql,"DELETE FROM addr WHERE id=%d;",a_l[conf->pos-conf->page_pos].id); if( mysql_real_query( &s, sql, strlen(sql) ) ){ clear(); prints("%s\n",mysql_error(&s)); pressanykey(); mysql_close(&s); return SHOW_REFRESH; } mysql_close(&s); return SHOW_DIRCHANGE; } case 's': { char ans[40]; clear(); move(0,0); ans[0]=0; prints(" 超级通讯录选择\n"); prints("\033[1;31m------------------------------------------------------------------------\033[m\n"); getdata(2, 0, "选择全部通讯录请按\033[1;32m1\033[m,输入条件选择请按\033[1;32m2\033[m,取消直接回车(1/2/0) [0]: ", ans, 3, DOECHO, NULL, true); if( ans[0] == '1' ){ conf->pos = 0; al_dest[0]=0; al_group[0]=0; //sm_type = -1; al_msgtxt[0]=0; return SHOW_DIRCHANGE; }else if(ans[0] == '2'){ move(3,0); getdata(3,0,"请输入要选择的通讯录姓名(回车选择所有):",ans,15, DOECHO,NULL,true); strncpy(al_dest, ans, 15); al_dest[14]=0; move(4,0); getdata(4,0,"请输入要选择的通讯录组名(回车选择所有):",ans,10, DOECHO,NULL,true); strncpy(al_group, ans, 10); al_group[9]=0; move(5,0); getdata(5,0,"请输入开始显示的通讯录序号 [0]:",ans,5, DOECHO,NULL,true); conf->page_pos = atoi(ans); if(conf->page_pos<=0) conf->page_pos=1; conf->pos=conf->page_pos; move(6,0); getdata(6,0,"请输入要通讯录备注内容包含文字(回车选择所有):",ans,21, DOECHO,NULL,true); strncpy(al_msgtxt, ans, 21); al_msgtxt[20]=0; return SHOW_DIRCHANGE; }else{ return SHOW_REFRESH; } break; } case 'f': { conf->pos = 0; al_dest[0]=0; al_group[0]=0; //sm_type = -1; al_msgtxt[0]=0; return SHOW_DIRCHANGE; } case 'a': { if( conf->item_count > MAXFRIENDS ){ clear(); prints("您的通讯录已经达到最大容量"); pressreturn(); return SHOW_REFRESH; } if(add_addresslist(NULL)){ return SHOW_DIRCHANGE; } return SHOW_REFRESH; } case 'e': { if(add_addresslist(a_l+conf->pos-conf->page_pos)){ return SHOW_DIRCHANGE; } return SHOW_REFRESH; } #ifdef SMS_SUPPORT case 'S': { if( (a_l+conf->pos - conf->page_pos)->mobile[0] && isdigit((a_l+conf->pos - conf->page_pos)->mobile[0]) ){ do_send_sms_func((a_l+conf->pos - conf->page_pos)->mobile, NULL); return SHOW_REFRESH; } break; } #endif case KEY_TAB: { al_order ++; if(al_order > AL_ORDER_COUNT) al_order = 0; return SHOW_DIRCHANGE; } case 'i': { char ans[4]; if( conf->item_count > MAXFRIENDS ){ clear(); prints("您的通讯录已经达到最大容量"); pressreturn(); return SHOW_REFRESH; } clear(); getdata(3, 0, "确实要导入好友名单? (Y/N) [N]: ", ans, 3, DOECHO, NULL, true); if(ans[0] != 'y' && ans[0] != 'Y'){ return SHOW_REFRESH; }else{ char fpath[STRLEN]; struct friends fh; struct addresslist al; FILE *fp; int suc=0; sethomefile(fpath, getCurrentUser()->userid, "friends"); if((fp=fopen(fpath, "r"))==NULL) return SHOW_REFRESH; while(fread(&fh, sizeof(fh), 1, fp)){ bzero(&al,sizeof(al)); if( fh.exp[0] ) strncpy(al.name, fh.exp, 15); else strncpy(al.name, fh.id, 15); al.name[14]=0; strncpy(al.bbsid, fh.id, 15); al.bbsid[14]=0; strcpy(al.group,"bbs"); move(10,0); clrtoeol(); prints("正在导入用户 %s......",fh.id); if(add_sql_al( getCurrentUser()->userid, &al, fh.exp )){ suc++; prints("成功"); } else prints("失败"); } fclose(fp); move(10,0); clrtoeol(); prints("成功导入 %d 个好友", suc); pressanykey(); return SHOW_DIRCHANGE; } } default: break; } return SHOW_CONTINUE; }
int uinfo_query(struct userec *u, int real, int unum) { struct userec newinfo; char ans[3], buf[STRLEN], genbuf[128]; char src[STRLEN], dst[STRLEN]; int i, fail = 0 ; #ifdef MAILCHANGED int netty_check = 0; #endif time_t now; struct tm *tmnow; memcpy(&newinfo, u, sizeof(currentuser)); getdata(t_lines - 1, 0, real ? "��ѡ�� (0)���� (1)������ (2)�趨���� (3) �� ID ==> [0]" : "��ѡ�� (0)���� (1)������ (2)�趨���� (3) ѡǩ���� ==> [0]", ans, 2, DOECHO, YEA); clear(); refresh(); now = time(0); tmnow = localtime(&now); i = 3; move(i++, 0); if (ans[0] != '3' || real) prints("ʹ���ߴ���: %s\n", u->userid); switch (ans[0]) { case '1': move(1, 0); prints("��������,ֱ�Ӱ� <ENTER> ����ʹ�� [] �ڵ����ϡ�\n"); sprintf(genbuf, "�dz� [%s]: ", u->username); getdata(i++, 0, genbuf, buf, NAMELEN, DOECHO, YEA); if (buf[0]) strncpy(newinfo.username, buf, NAMELEN); sprintf(genbuf, "��ʵ���� [%s]: ", u->realname); getdata(i++, 0, genbuf, buf, NAMELEN, DOECHO, YEA); if (buf[0]) strncpy(newinfo.realname, buf, NAMELEN); sprintf(genbuf, "��ס��ַ [%s]: ", u->address); getdata(i++, 0, genbuf, buf, STRLEN - 10, DOECHO, YEA); if (buf[0]) strncpy(newinfo.address, buf, NAMELEN); sprintf(genbuf, "�������� [%s]: ", u->email); getdata(i++, 0, genbuf, buf, 48, DOECHO, YEA); if (buf[0]) { #ifdef MAILCHECK #ifdef MAILCHANGED if(u->uid == usernum) netty_check = 1; #endif #endif strncpy(newinfo.email, buf, 48); } sprintf(genbuf, "�ն˻���̬ [%s]: ", u->termtype); getdata(i++, 0, genbuf, buf, 16, DOECHO, YEA); if (buf[0]) strncpy(newinfo.termtype, buf, 16); sprintf(genbuf, "������ [%d]: ", u->birthyear + 1900); getdata(i++, 0, genbuf, buf, 5, DOECHO, YEA); if ( buf[0] && atoi(buf) > 1920 && atoi(buf) < 1998) newinfo.birthyear = atoi(buf) - 1900; sprintf(genbuf, "������ [%d]: ", u->birthmonth); getdata(i++, 0, genbuf, buf, 3, DOECHO, YEA); if (buf[0] && atoi(buf) >= 1 && atoi(buf) <= 12) newinfo.birthmonth = atoi(buf); sprintf(genbuf, "������ [%d]: ", u->birthday); getdata(i++, 0, genbuf, buf, 3, DOECHO, YEA); if (buf[0] && atoi(buf) >= 1 && atoi(buf) <= 31) newinfo.birthday = atoi(buf); sprintf(genbuf, "�Ա�(M.��)(F.Ů) [%c]: ", u->gender); getdata(i++, 0, genbuf, buf, 2, DOECHO, YEA); if (buf[0]) { if (strchr("MmFf", buf[0])) newinfo.gender = toupper(buf[0]); } if (real) uinfo_change1(i,u,&newinfo); break; case '2': if (!real) { getdata(i++, 0, "������ԭ����: ", buf, PASSLEN, NOECHO, YEA); if (*buf == '\0' || !checkpasswd(u->passwd, buf)) { prints("\n\n�ܱ�Ǹ, ����������벻��ȷ��\n"); fail++; break; } } getdata(i++, 0, "���趨������: ", buf, PASSLEN, NOECHO, YEA); if (buf[0] == '\0') { prints("\n\n�����趨ȡ��, ����ʹ�þ�����\n"); fail++; break; } strncpy(genbuf, buf, PASSLEN); getdata(i++, 0, "����������������: ", buf, PASSLEN, NOECHO, YEA); if (strncmp(buf, genbuf, PASSLEN)) { prints("\n\n������ȷ��ʧ��, ���趨�����롣\n"); fail++; break; } buf[8] = '\0'; strncpy(newinfo.passwd, genpasswd(buf), ENCPASSLEN); break; case '3': if (!real) { sprintf(genbuf, "Ŀǰʹ��ǩ���� [%d]: ", u->signature); getdata(i++, 0, genbuf, buf, 16, DOECHO, YEA); if (atoi(buf) > 0) newinfo.signature = atoi(buf); } else { struct user_info uin; extern int t_cmpuids(); if(t_search_ulist(&uin, t_cmpuids, unum, NA, NA)!=0) { prints("\n�Բ��𣬸��û�Ŀǰ�������ϡ�"); fail++; } else if(!strcmp(lookupuser.userid,"SYSOP")) { prints("\n�Բ����㲻������ SYSOP �� ID��"); fail++; } else { getdata(i++,0,"�µ�ʹ���ߴ���: ",genbuf,IDLEN+1,DOECHO, YEA); if (*genbuf != '\0') { if (getuser(genbuf)) { prints("\n�Բ���! �Ѿ���ͬ�� ID ��ʹ����\n"); fail++; } else { strncpy(newinfo.userid, genbuf, IDLEN + 2); } } else fail ++; } } break; default: clear(); return 0; } if (fail != 0) { pressreturn(); clear(); return 0; } if (askyn("ȷ��Ҫ�ı���", NA, YEA) == YEA) { if (real) { char secu[STRLEN]; sprintf(secu, "�� %s �Ļ������ϻ����롣", u->userid); securityreport1(secu); } if (strcmp(u->userid, newinfo.userid)) { sprintf(src, "mail/%c/%s", toupper(u->userid[0]), u->userid); sprintf(dst, "mail/%c/%s", toupper(newinfo.userid[0]), newinfo.userid); rename(src, dst); sethomepath(src, u->userid); sethomepath(dst, newinfo.userid); rename(src, dst); sethomefile(src, u->userid, "register"); unlink(src); sethomefile(src, u->userid, "register.old"); unlink(src); setuserid(unum, newinfo.userid); } if(!strcmp(u->userid, currentuser.userid)) { extern int WishNum; strncpy(uinfo.username,newinfo.username,NAMELEN); WishNum = 9999; } #ifdef MAILCHECK #ifdef MAILCHANGED if ((netty_check == 1)&&!HAS_PERM(PERM_SYSOP)) { sprintf(genbuf, "%s", BBSHOST); if ( (!strstr(newinfo.email, genbuf)) && (!invalidaddr(newinfo.email)) && (!invalid_email(newinfo.email))) { strcpy(u->email, newinfo.email); send_regmail(u); } else { move(t_lines - 5, 0); prints("\n������ĵ����ʼ���ַ ��[1;33m%s[m��\n",newinfo.email); prints("ˡ���ܱ�վ���ϣ�ϵͳ����Ͷ��ע���ţ������������...\n"); pressanykey(); return 0; } } #endif #endif memcpy(u, &newinfo, (size_t)sizeof(currentuser)); #ifdef MAILCHECK #ifdef MAILCHANGED if ((netty_check == 1)&&!HAS_PERM(PERM_SYSOP)) { newinfo.userlevel &= ~(PERM_LOGINOK | PERM_PAGE | PERM_MESSAGE); sethomefile(src, newinfo.userid, "register"); sethomefile(dst, newinfo.userid, "register.old"); rename(src, dst); } #endif #endif substitute_record(PASSFILE, &newinfo, sizeof(newinfo), unum); } clear(); return 0; }
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); }
int bbsnet(struct _select_def *conf, int n) { time_t now; struct hostent *pHost = NULL; struct sockaddr_in remote; unsigned char buf[BUFSIZ]; int rc; int rv; int maxfdp1; fd_set readset; struct timeval tv; int tos = 020; /* Low delay bit */ int i; sig_t oldsig; int ret; int key; char buf1[40], buf2[40], c, buf3[40]; //增加的变量 int l; //判断是不是port int j; if (strcmp(host2[n], "般若波羅密") == 0) { //如果是自定义站点,等待输入ip或域名 memset(buf1, 0, sizeof(buf1)); move(22,2); prints("\033[1;32m连往: \033[m"); refresh(); j = 0; l = 0; for (i = 0; i < 30;) { c = igetch(); if (c == ' ' || c == '\015' || c == '\0' || c == '\n') break; if (c == ':') { l = 1; sprintf(buf3, "%c", c); prints("\033[0;1m"); prints(buf3); prints("\033[1;33m"); refresh(); strncpy(ip_zdh, buf1, 40); strncpy(ip[n], ip_zdh, 40); memset(buf1, 0, sizeof(buf1)); j = 0; i++; } if ((c >= '0' && c <= '9') || (((c == '.') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) && !l)) { sprintf(buf3, "%c", c); sprintf(buf2, "%s%c", buf1, c); sprintf(buf1, "%s", buf2); prints(buf3); refresh(); j++; i++; } if ((c == 8) && (j >= 1)) { buf1[j - 1] = '\0'; sprintf(buf3, "\033[D\033[1;33m_\033[%sm\033[D", l ? "1;33" : "0"); prints(buf3); refresh(); i--; j--; } } if (l == 0) { strncpy(ip_zdh, buf1, 40); strcpy(ip[n], ip_zdh); } else { port[n] = atoi(buf1); } } now = time(NULL); clear(); prints("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\n", host2[n], ip[n]); prints("\033[1;32m如果在 %d 秒内无法连上,穿梭程序将放弃连接。\033[m\n", TIME_OUT); if (setjmp(jb) == 0) { oldsig = signal(SIGALRM, bbsnet_timeout); alarm(TIME_OUT); pHost = gethostbyname(ip[n]); alarm(0); signal(SIGALRM, oldsig); } if (pHost == NULL) { prints("\033[1;31m查找主机名失败!\033[m\n"); pressreturn(); return -1; } if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { prints("\033[1;31m无法创建socket!\033[m\n"); pressreturn(); return -1; } bzero(&remote, sizeof(remote)); remote.sin_family = AF_INET; remote.sin_port = htons(port[n]); remote.sin_addr = *(struct in_addr *)pHost->h_addr_list[0]; prints("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\n"); process_bar(0, MAX_PROCESS_BAR_LEN); for (i = 0; i < MAX_PROCESS_BAR_LEN; i++) { if (i == 0) rv = NonBlockConnectEx(sockfd, (struct sockaddr *)&remote, sizeof(remote), 500, 1); else rv = NonBlockConnectEx(sockfd, (struct sockaddr *)&remote, sizeof(remote), 500, 0); if (rv == ERR_TCPLIB_TIMEOUT) { process_bar(i+1, MAX_PROCESS_BAR_LEN); continue; } else if (rv == 0) break; else { prints("\033[1;31m连接失败!\033[m\n"); pressreturn(); ret = -1; goto on_error; } } if (i == MAX_PROCESS_BAR_LEN) { prints("\033[1;31m连接超时!\033[m\n"); pressreturn(); ret = -1; goto on_error; } setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(int)); prints("\033[1;31m连接成功!\033[m\n"); bbsnet_report(host2[n], ip[n], now, 0); clear(); refresh(); bbsnet_send_winsize(sockfd); for (;;) { FD_ZERO(&readset); FD_SET(0, &readset); FD_SET(sockfd, &readset); maxfdp1 = sockfd + 1; tv.tv_sec = 1200; tv.tv_usec = 0; /*if ((rv = SignalSafeSelect(maxfdp1, &readset, NULL, NULL, &tv)) == -1)*/ if ((rv = select(maxfdp1, &readset, NULL, NULL, &tv)) == -1) { if (errno == EINTR) { while (msg_count) { msg_count--; r_msg(); } continue; } ret = -1; goto on_error; } if (rv == 0) { ret = -1; goto on_error; } if (FD_ISSET(sockfd, &readset)) { if ((rc = read(sockfd, buf, BUFSIZ)) < 0) { ret = -1; goto on_error; } else if (rc == 0) break; else if (strchr((void*)buf, 255)) /* 查找是否含有TELNET命令IAC */ telnetopt(sockfd, (void*)buf, rc); else { output((void*)buf, rc); oflush(); } } if (FD_ISSET(0, &readset)) { if ((rc = bbsnet_read(0, (void*)buf, BUFSIZ)) < 0) { ret = -1; goto on_error; } if (rc == 0) break; if ((key = list_select_remove_key(conf)) != KEY_INVALID) { if (key == KEY_ONSIZE) { bbsnet_send_winsize(sockfd); } } write(sockfd, buf, rc); } } bbsnet_report(host2[n], ip[n], now, 1); ret = 0; on_error: close(sockfd); clear(); redoscr(); return ret; }
int t_chat2() { int currchar; char inbuf[120]; BOOL page_pending = FALSE; int ch; char seedstr[STRLEN]; long seed; char rcvbuf[512]; int chatport; char *mycrypt(); if (check_page_perm() < 0) return C_FOOT; chatport = CHATPORT; #if 1 if (chatport == 0) chatport = 6177; #endif #if 0 #if defined(NSYSUBBS1) getdata(1, 0, _msg_chat_1, genbuf, 2, ECHONOSP); if (genbuf[0] == '2') chatport = CHATPORT + 1; #endif #endif /* initialize */ inbuf[0] = '\0'; currchar = 0; chat_line = 0; if (!getdata(1, 0, "Enter Chat id: ", mychatid, CHATIDLEN, ECHONOSP)) xstrncpy(mychatid, curuser.userid, CHATIDLEN); fixchatid(mychatid); if ((ac = ConnectServer(CHAT_SERVER, chatport)) < 0) { move(2, 0); outs(_msg_chat_3); refresh(); sprintf(genbuf, "bbschatd %d", chatport); outdoor(genbuf); sleep(2); if ((ac = ConnectServer(CHAT_SERVER, chatport)) < 0) { perror("connect failed"); pressreturn(); return C_FULL; } } /* receive ChatServer Hello Welcome VersionInfo */ net_gets(ac, genbuf, sizeof(genbuf)); /* receive Random Number for Checksum */ net_gets(ac, seedstr, sizeof(seedstr)); seed = atol(mycrypt(seedstr)); net_printf(ac, "USRID\t%s\t%ld\r\n", curuser.userid, seed); net_gets(ac, genbuf, sizeof(genbuf)); if (strncmp(genbuf, "+OK", 3)) /* lthuang */ { outs(_msg_chat_4); pressreturn(); return C_FULL; } uinfo.mode = CHATROOM; xstrncpy(uinfo.chatid, mychatid, sizeof(uinfo.chatid)); update_ulist(cutmp, &uinfo); /* set prompt */ strcpy(prompt, mychatid); strcat(prompt, ": "); prompt[SAYWORD_POINT] = '\0'; draw_chat_screen(); add_io(ac, 0); net_gets(ac, genbuf, sizeof(genbuf)); /* welcome !! */ genbuf[strlen(genbuf) - 1] = '\0'; printchatline(genbuf); #if 0 net_printf(ac, "JOIN\t%s\t%s\r\n", DEFAULT_CHANNAME, NOPASSWORD); net_gets(ac, genbuf, sizeof(genbuf)); #endif if (strcmp(mychatid, curuser.userid)) { net_printf(ac, "NICKNAME\t%s\r\n", mychatid); net_gets(ac, genbuf, sizeof(genbuf)); } /* Chat Main */ while (1) { ch = getkey(); if (PLINE != CUR_PLINE) { draw_chat_screen(); continue; } if (talkrequest) page_pending = TRUE; if (page_pending) page_pending = servicepage(0); if (msqrequest) { add_io(0, 0); msqrequest = FALSE; msq_reply(); add_io(ac, 0); continue; } if (ch == I_OTHERDATA) { if (!net_gets(ac, rcvbuf, sizeof(rcvbuf))) break; rcvbuf[strlen(rcvbuf) - 1] = '\0'; /* lthuang */ if (rcvbuf[0] == '/') { char *p, *nick; if ((p = strchr(rcvbuf, '\t')) != NULL) { *p = '\0'; if (cmp_wlist(iglist, rcvbuf + 1, strcmp)) continue; nick = p + 1; if ((p = strchr(nick, '\t')) != NULL) { *p = '\0'; if (cmp_wlist(iglist, nick, strcmp)) continue; strcpy(genbuf, nick); strcat(genbuf, ": "); genbuf[SAYWORD_POINT] = '\0'; strcat(genbuf, ++p); printchatline(genbuf); } } } #if 0 else if (rcvbuf[0] == '*') { sprintf(genbuf, "[1;37m%s[0m", rcvbuf); printchatline(genbuf); } #endif else printchatline(rcvbuf); } else if (isprint2(ch)) { if (SAYWORD_POINT + currchar - 1 >= t_columns - 3) { bell(); continue; } inbuf[currchar++] = ch; inbuf[currchar] = '\0'; move(PLINE, SAYWORD_POINT + currchar - 1); outc(ch); } else if (ch == '\n' || ch == '\r') { char *p = inbuf; currchar = 0; while (*p != '\0' && isspace((int)(*p))) p++; if (*p == '\0') continue; if (inbuf[0] == '/') dochatcommand(inbuf + 1); else { net_printf(ac, "SPEAK\t%s\r\n", inbuf); sprintf(genbuf, "%s%s", prompt, inbuf); printchatline(genbuf); } inbuf[0] = '\0'; /* show prompt */ move(PLINE, 0); clrtoeol(); outs(prompt); } else if (ch == CTRL('H') || ch == '\177') { if (currchar == 0) { bell(); continue; } move(PLINE, SAYWORD_POINT + --currchar); outs(" "); inbuf[currchar] = '\0'; } else if (ch == CTRL('C') || ch == CTRL('D')) { net_printf(ac, "QUIT\r\n"); /* lthuang */ break; } else if (ch == CTRL('R')) { msq_reply(); continue; } else if (ch == CTRL('Q')) { add_io(0, 0); t_query(); add_io(ac, 0); continue; } move(PLINE, currchar + SAYWORD_POINT); } add_io(0, 0); close(ac); uinfo.chatid[0] = '\0'; update_ulist(cutmp, &uinfo); free_wlist(&iglist, free); return C_FULL; }
static void tmp_npclose(FILE *fp) { char buf[NFILEN + 128]; int rc, term_status; (void) fflush(fp); (void) fclose(fp); if (stdout_fd != BAD_FD) { /* * write pipe, but not a filter. Editor has written data to temp * file, time now to exec "cmd" and hook its stdin to the file. * * It should be noted that exec'ing a process in the npclose() * phase of a write pipe is not exactly keeping in spirit with * the control flow in file.c :-) . However, the strategy used * here ensures that the launched process reads a temp file that * is completey flushed to disk. The only direct drawback with * this approach is that when the exec'd process exits, the user * does not receive a "[press return to continue]" prompt from * file.c . But, cough, we can work around that problem :-) . */ if ((stdout_fd = open(stdout_name, O_RDONLY|O_BINARY)) == BAD_FD) { /* oh my, put complaint in user's face. */ sprintf(buf, "[unable to open temp file \"%s\": %s]", stdout_name, strerror(errno)); lastditch_msg(buf); } else { handles[0] = (HANDLE) _get_osfhandle(stdout_fd); handles[1] = handles[2] = GetStdHandle(STD_OUTPUT_HANDLE); rc = (exec_shell(shcmd, handles, FALSE /* don't hide child window */ ) == BAD_PROC_HANDLE) ? FALSE : TRUE; if (! rc) { /* Shell process failed, put complaint in user's face. */ sprintf(buf, SHELL_ERR_MSG, get_shell()); lastditch_msg(buf); } else { /* now wait for app to exit */ (void) cwait(&term_status, (CWAIT_PARAM_TYPE) proc_handle, 0); TRACE(("...CreateProcess finished waiting in tmp_npclose\n")); close_proc_handle(); } /* * When closing descriptors shared between parent and child, * order is quite important when $shell == command.com . In * this situation, the descriptors can't be closed until the * exec'd process exits. */ close_fd(stdout_fd); } pressreturn(); /* cough */ sgarbf = TRUE; } tmp_cleanup(); }
static void cop_Arrest(void) { char uident[IDLEN + 1], police[IDLEN + 1], buf[256], title[STRLEN]; char *CrimeName[] = { "莫须有", "有伤风化", "小偷小摸", "破坏治安", "卖淫嫖娼", "杀人放火", "颠覆政府", "反社会反人类", "种族灭绝", NULL }; int CrimeTime[] = { 1, 2, 3, 4, 6, 8, 12, 16, 24 }; time_t currtime; mcUserInfo *mcuInfo; int num, tranum, crime = 0, bonus = 100; nomoney_show_stat("刑警队"); if (!seek_in_file(DIR_MC "policemen", currentuser->userid)) { showAt(12, 4, "警察执行任务,闲杂人等请回避,以免误伤。", YEA); return; } if (clubtest(ROBUNION) || clubtest(BEGGAR)) { showAt(12, 4, "《无间道》看多了吧你?", YEA); return; } if (myInfo->robExp < 50 || myInfo->begExp < 50) { showAt(12, 4, "新警察吧?先去练练基本功,不然就是送死了。党和国家培养你不容易啊!", YEA); return; } if (check_health(100, 12, 4, "你没有充沛的体力来执行任务。", YEA)) return; currtime = time(NULL); if (myInfo->WorkPoint < 7200) { showAt(12, 4, "不要着急,上级还没有行动指示。", YEA); return; } move(5, 4); prints("刚刚接到上级指示,马上要进行一次抓捕行动。"); if (!getOkUser("\n请选择你的目标:", uident, 6, 4)) { move(8, 4); prints("查无此人"); pressanykey(); return; } if (!strcmp(uident, currentuser->userid)) { showAt(8, 4, "牛魔王:“老婆~快来看神经病啦~”", YEA); return; } if (!seek_in_file(DIR_MC "criminals_list", uident)) { showAt(8, 4, "此人不在通缉名单上面。”", YEA); return; } myInfo->Actived += 10; move(10, 4); prints("你埋伏在大富翁世界的必经之路,等待目标的出现。"); sleep(1); sethomefile(buf, uident, "mc.save"); if (!file_exist(buf)) initData(1, buf); if((mcuInfo = loadData(buf, sizeof (mcUserInfo))) == (void*)-1) return; myInfo->lastActiveTime = currtime; myInfo->WorkPoint -= 7200; sleep(1); if (currtime > 3600 + mcuInfo->lastActiveTime) { myInfo->health -= 10; showAt(12, 4, "你等了整整一天,目标还是没有出现,只好放弃了。", YEA); return; } /* if (!(random() % 3)) { myInfo->health -= 10; showAt(12, 4, "你眼看老远处人影一晃,目标得到风声跑掉了。", YEA); return; } if ((myInfo->robExp + myInfo->begExp >= (mcuInfo->robExp + mcuInfo->begExp) * 5 + 50 || myInfo->luck - mcuInfo->luck >= 100 || (random() % 3)) && !(mcuInfo->robExp + mcuInfo->begExp >= (myInfo-> robExp + myInfo->begExp) * 5 + 50)) { */ num = myInfo->robExp + myInfo->begExp + (mcuInfo->robExp + mcuInfo->begExp) * 2; if (num > 150000) crime = 8; else if (num > 100000) crime = 7; else if (num > 50000) crime = 6; else if (num > 10000) crime = 5; else if (num > 5000) crime = 4; else if (num > 2000) crime = 3; else if (num > 1000) crime = 2; else if (num > 500) crime = 1; else crime = 0; tranum = MIN((myInfo->robExp + myInfo->begExp + mcuInfo->robExp + mcuInfo->begExp) / 250, (mcuInfo->robExp + mcuInfo->begExp) / 50); whoTakeCharge(8, police); if (!(strcmp(currentuser->userid, police))) bonus = 300; if (check_chance (myInfo->robExp + myInfo->begExp, mcuInfo->robExp + mcuInfo->begExp, myInfo->weapon, mcuInfo->armor, 200, bonus)) { myInfo->begExp += tranum + 10; myInfo->robExp += tranum + 10; myInfo->health = 0; myInfo->cash += mcuInfo->cash; mcuInfo->cash = 0; mcuInfo->begExp = MAX(0, mcuInfo->begExp - tranum - 10); mcuInfo->robExp = MAX(0, mcuInfo->robExp - tranum - 10); mcuInfo->luck = MAX(-100, mcuInfo->luck - 10); // mcuInfo->freeTime += (currtime + 10800); mcuInfo->freeTime = time(NULL) + CrimeTime[crime] * 3600; myInfo->luck = MIN(100, myInfo->luck + 10); del_from_file(DIR_MC "criminals_list", uident); prints("\n 远处有人走了过来,你定睛一看,正是你要抓的%s。" "\n 你跳出来拔出手枪大吼道:“不许动!你被捕了!”" "\n %s目瞪口呆,只好束手就擒。" "\n 你的胆识增加了! 你的身法增加了!" "\n 你的体力耗尽了!" "\n 你的人品增加了!" "\n 没收罪犯所有现金做为补助!", uident, uident); sprintf(title, "【警署】警方抓获通缉犯%s", uident); sprintf(buf, "警员%s耐心守候,孤身勇擒在榜通缉犯%s,特此公告,以示表彰。\n\n" "经%s法庭判决,被告%s%s罪名成立,判处%d小时有期徒刑。", currentuser->userid, uident, CENTER_NAME, uident, CrimeName[crime], CrimeTime[crime]); deliverreport(title, buf); sprintf(buf, "你被警员%s设伏抓获,没收所有现金,胆识身法下降。\n" "还被法庭判决%s罪,关押%d小时。\n" "不报此仇,誓不为人!", currentuser->userid, CrimeName[crime], CrimeTime[crime]); if (mcuInfo->GetLetter == 1) system_mail_buf(buf, strlen(buf), uident, "你被警方抓获", currentuser->userid); unloadData(mcuInfo, sizeof (mcUserInfo)); } else { myInfo->begExp = MAX(0, myInfo->begExp - tranum / 2); myInfo->robExp = MAX(0, myInfo->robExp - tranum / 2); myInfo->health = 0; mcuInfo->cash += myInfo->cash; myInfo->cash = 0; mcuInfo->robExp += tranum / 2; mcuInfo->begExp += tranum / 2; myInfo->freeTime = time(NULL) + CrimeTime[crime] * 1800 + 1800; prints("\n 远处有人走了过来,你定睛一看,正是你要抓的%s。" "\n 你跳出来拔出手枪大吼道:“不许动!你被捕了!”" "\n 正得意时,不料背后有人打了你一个闷棍。" "\n 你的胆识减少了!" "\n 你的身法减少了!" "\n 你昏了过去!", uident); sprintf(title, "【警署】警员%s受伤住院", currentuser->userid); sprintf(buf, "警员%s在执行任务的时候,被罪犯打伤住院。目前情况稳" "定,%d小时以后即可出院。", currentuser->userid, (CrimeTime[crime] + 1) / 2); deliverreport(title, buf); sprintf(buf, "条子%s设伏抓你,还好你艺高人胆大将其干掉,自己安然" "无恙。\n 顺手捞走了他身上的现金,胆识身法上升,太爽了!", currentuser->userid); if (mcuInfo->GetLetter == 1) system_mail_buf(buf, strlen(buf), uident, "你金蝉脱壳", currentuser->userid); unloadData(mcuInfo, sizeof (mcUserInfo)); unloadData(myInfo, sizeof (mcUserInfo)); unloadData(mcEnv, sizeof (MC_Env)); pressreturn(); Q_Goodbye(); } pressreturn(); // Q_Goodbye(); return; }
//修改用户的档案 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 fill_reg_form(void) { reginfo_t reg; if (!strcmp("guest", currentuser.userid)) return 0; set_user_status(ST_NEW); screen_clear(); screen_move(2, 0); screen_clrtobot(); if (currentuser.userlevel & PERM_REGISTER) { //% prints("您已经完成本站的使用者注册手续, 欢迎加入本站的行列."); prints("\xc4\xfa\xd2\xd1\xbe\xad\xcd\xea\xb3\xc9\xb1\xbe\xd5\xbe\xb5\xc4\xca\xb9\xd3\xc3\xd5\xdf\xd7\xa2\xb2\xe1\xca\xd6\xd0\xf8, \xbb\xb6\xd3\xad\xbc\xd3\xc8\xeb\xb1\xbe\xd5\xbe\xb5\xc4\xd0\xd0\xc1\xd0."); pressreturn(); return 0; } if (is_reg_pending(currentuser.userid)) { //% prints("站长尚未处理您的注册申请单, 您先到处看看吧."); prints("\xd5\xbe\xb3\xa4\xc9\xd0\xce\xb4\xb4\xa6\xc0\xed\xc4\xfa\xb5\xc4\xd7\xa2\xb2\xe1\xc9\xea\xc7\xeb\xb5\xa5, \xc4\xfa\xcf\xc8\xb5\xbd\xb4\xa6\xbf\xb4\xbf\xb4\xb0\xc9."); pressreturn(); return 0; } memset(®, 0, sizeof(reg)); strlcpy(reg.userid, currentuser.userid, sizeof(reg.userid)); strlcpy(reg.email, currentuser.email, sizeof(reg.email)); while (1) { screen_move(3, 0); clrtoeol(); //% prints("%s 您好, 请据实填写以下的资料:\n", currentuser.userid); prints("%s \xc4\xfa\xba\xc3, \xc7\xeb\xbe\xdd\xca\xb5\xcc\xee\xd0\xb4\xd2\xd4\xcf\xc2\xb5\xc4\xd7\xca\xc1\xcf:\n", currentuser.userid); do { //% getfield(6, "请用中文", "真实姓名", getfield(6, "\xc7\xeb\xd3\xc3\xd6\xd0\xce\xc4", "\xd5\xe6\xca\xb5\xd0\xd5\xc3\xfb", reg.realname, sizeof(reg.realname)); } while (strlen(reg.realname) < 4); do { //% getfield(8, "学校系级或所在单位", "学校系级", getfield(8, "\xd1\xa7\xd0\xa3\xcf\xb5\xbc\xb6\xbb\xf2\xcb\xf9\xd4\xda\xb5\xa5\xce\xbb", "\xd1\xa7\xd0\xa3\xcf\xb5\xbc\xb6", reg.dept, sizeof(reg.dept)); } while (strlen(reg.dept) < 6); do { //% getfield(10, "包括寝室或门牌号码", "目前住址", getfield(10, "\xb0\xfc\xc0\xa8\xc7\xde\xca\xd2\xbb\xf2\xc3\xc5\xc5\xc6\xba\xc5\xc2\xeb", "\xc4\xbf\xc7\xb0\xd7\xa1\xd6\xb7", reg.addr, sizeof(reg.addr)); } while (strlen(reg.addr) < 10); do { //% getfield(12, "包括可联络时间", "联络电话", getfield(12, "\xb0\xfc\xc0\xa8\xbf\xc9\xc1\xaa\xc2\xe7\xca\xb1\xbc\xe4", "\xc1\xaa\xc2\xe7\xb5\xe7\xbb\xb0", reg.phone, sizeof(reg.phone)); } while (strlen(reg.phone) < 8); //% getfield(14, "校友会或毕业学校", "校 友 会", getfield(14, "\xd0\xa3\xd3\xd1\xbb\xe1\xbb\xf2\xb1\xcf\xd2\xb5\xd1\xa7\xd0\xa3", "\xd0\xa3 \xd3\xd1 \xbb\xe1", reg.assoc, sizeof(reg.assoc)); char ans[3]; getdata(-1, 0, //% "以上资料是否正确, 按 Q 放弃注册 (Y/N/Quit)? [Y]: ", "\xd2\xd4\xc9\xcf\xd7\xca\xc1\xcf\xca\xc7\xb7\xf1\xd5\xfd\xc8\xb7, \xb0\xb4 Q \xb7\xc5\xc6\xfa\xd7\xa2\xb2\xe1 (Y/N/Quit)? [Y]: ", ans, sizeof(ans), DOECHO, YEA); if (ans[0] == 'Q' || ans[0] == 'q') return 0; if (ans[0] != 'N' && ans[0] != 'n') break; } reg.regdate = time(NULL); append_reg_list(®); return 0; }
static int set_smsg_key(struct _select_def *conf, int key) { switch (key) { case 'd': { char sql[100]; MYSQL s; char ans[4]; move(2,0); clrtoeol(); ans[0]=0; getdata(2, 0, "删除这条消息(Y/N) [N]: ", ans, 3, DOECHO, NULL, true); if (ans[0] != 'y' && ans[0]!='Y') return SHOW_REFRESH; mysql_init(&s); if (! my_connect_mysql(&s)) { clear(); prints("%s\n",mysql_error(&s)); pressanykey(); mysql_close(&s); return SHOW_REFRESH; } sprintf(sql,"DELETE FROM smsmsg WHERE id=%d;",s_m[conf->pos-conf->page_pos].id); if (mysql_real_query(&s, sql, strlen(sql))) { clear(); prints("%s\n",mysql_error(&s)); pressanykey(); mysql_close(&s); return SHOW_REFRESH; } mysql_close(&s); return SHOW_DIRCHANGE; } case 's': { char ans[40]; clear(); move(0,0); ans[0]=0; prints(" 超级短信选择\n"); prints("\033[1;31m------------------------------------------------------------------------\033[m\n"); getdata(2, 0, "选择全部短信请按\033[1;32m1\033[m,输入条件选择请按\033[1;32m2\033[m,取消直接回车(1/2/0) [0]: ", ans, 3, DOECHO, NULL, true); if (ans[0] == '1') { conf->page_pos = 0; sm_dest[0]=0; sm_type = -1; sm_msgtxt[0]=0; return SHOW_DIRCHANGE; } else if (ans[0] == '2') { move(3,0); getdata(3,0,"请输入要选择的短信来源(回车选择所有):",ans,15, DOECHO,NULL,true); strncpy(sm_dest, ans, 13); sm_dest[12]=0; move(4,0); getdata(4,0,"请输入要选择的短信类别(1表示发,2表示收,回车所有) [0]:",ans,3, DOECHO,NULL,true); if (ans[0] == '1') sm_type = 1; else if (ans[0] == '2') sm_type = 0; else sm_type = -1; move(5,0); getdata(5,0,"请输入开始显示的短信序号 [0]:",ans,5, DOECHO,NULL,true); conf->page_pos = atoi(ans); if (conf->page_pos <= 0) conf->page_pos=1; conf->pos=conf->page_pos; move(6,0); getdata(6,0,"请输入要短信内容包含文字(回车选择所有):",ans,21, DOECHO,NULL,true); strncpy(sm_msgtxt, ans, 21); sm_msgtxt[20]=0; return SHOW_DIRCHANGE; } else { return SHOW_REFRESH; } break; } case 'a': { conf->page_pos = 0; sm_dest[0]=0; sm_type = -1; sm_msgtxt[0]=0; return SHOW_DIRCHANGE; } case 'S': { if (! isdigit(s_m[conf->pos-conf->page_pos].dest[0])) return SHOW_CONTINUE; clear(); do_send_sms_func(s_m[conf->pos-conf->page_pos].dest, NULL); pressanykey(); return SHOW_REFRESH; } case 'r': { sm_desc = ! sm_desc; return SHOW_DIRCHANGE; } case 'z': { char ans[42]; clear(); prints("修改短消息前缀/后缀,这些会在发送的短消息内容前/后显示,占短消息字节"); if (getSession()->currentmemo->ud.smsprefix[0]) strcpy(ans, getSession()->currentmemo->ud.smsprefix); else ans[0]=0; move(2,0); prints("请输入新的前缀:"); multi_getdata(3, 0, 79, NULL, ans, 41, 6, false, 0); if (ans[0]) { strncpy(getSession()->currentmemo->ud.smsprefix, ans, 40); getSession()->currentmemo->ud.smsprefix[40]=0; } else getSession()->currentmemo->ud.smsprefix[0]=0; if (getSession()->currentmemo->ud.smsend[0]) strcpy(ans, getSession()->currentmemo->ud.smsend); else ans[0]=0; move(10,0); prints("请输入新的后缀:"); multi_getdata(11, 0, 79, NULL, ans, 41, 6, false, 0); if (ans[0]) { strncpy(getSession()->currentmemo->ud.smsend, ans, 40); getSession()->currentmemo->ud.smsend[40]=0; } else getSession()->currentmemo->ud.smsend[0]=0; write_userdata(getCurrentUser()->userid, &(getSession()->currentmemo->ud)); move(18,0); prints("修改成功"); pressreturn(); return SHOW_REFRESH; } case 'h': { clear(); prints(" 短信管理器帮助\n\n"); prints(" d 删除短信\n"); prints(" s 超级选择\n"); prints(" a 显示所有短信\n"); prints(" S 回复短信\n"); prints(" r 倒序排列\n"); prints(" z 更改短信前/后缀\n"); pressreturn(); return SHOW_REFRESH; } default: break; } return SHOW_CONTINUE; }
/** * Telnet register interface. */ void new_register(void) { char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN]; const char *errmsg; if (register_closed()) { ansimore("NOREGISTER", NA); pressreturn(); return; } ansimore("etc/register", NA); #ifndef FDQUAN //% if (!askyn("您是否同意本站Announce版精华区x-3目录所列站规?", false, false)) if (!askyn("\xc4\xfa\xca\xc7\xb7\xf1\xcd\xac\xd2\xe2\xb1\xbe\xd5\xbe""Announce\xb0\xe6\xbe\xab\xbb\xaa\xc7\xf8x-3\xc4\xbf\xc2\xbc\xcb\xf9\xc1\xd0\xd5\xbe\xb9\xe6?", false, false)) return; #endif int tried = 0; prints("\n"); while (1) { if (++tried >= MAX_NEW_TRIES) { //% outs("\n拜拜,按太多下 <Enter> 了...\n"); outs("\n\xb0\xdd\xb0\xdd\xa3\xac\xb0\xb4\xcc\xab\xb6\xe0\xcf\xc2 <Enter> \xc1\xcb...\n"); screen_flush(); return; } //% getdata(0, 0, "请输入帐号名称 (Enter User ID, \"0\" to abort): ", getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\xc3\xfb\xb3\xc6 (Enter User ID, \"0\" to abort): ", userid, sizeof(userid), DOECHO, YEA); if (userid[0] == '0') return; errmsg = register_invalid_user_name(userid); if (errmsg != NULL) { outs(errmsg); continue; } char path[HOMELEN]; sethomepath(path, userid); if (dosearchuser(userid, ¤tuser, &usernum) || dashd(path)) { //% outs("此帐号已经有人使用\n"); outs("\xb4\xcb\xd5\xca\xba\xc5\xd2\xd1\xbe\xad\xd3\xd0\xc8\xcb\xca\xb9\xd3\xc3\n"); continue; } #ifndef REG_CAPTCHA break; #else char link[STRLEN], attempt[CAPTCHA_LEN + 1], answer[CAPTCHA_LEN + 1]; int lnum; int pos = gen_captcha_link(link, sizeof(link), &lnum); if (pos < 0) return; prints("http://"BBSHOST"/captcha/%d.gif\n", lnum); //% getdata(0, 0, "请输入上图所包含的英文字母: ", attempt, sizeof(attempt), getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xc9\xcf\xcd\xbc\xcb\xf9\xb0\xfc\xba\xac\xb5\xc4\xd3\xa2\xce\xc4\xd7\xd6\xc4\xb8: ", attempt, sizeof(attempt), DOECHO, YEA); unlink(link); get_captcha_answer(pos, answer, sizeof(answer)); if (strcasecmp(answer, attempt) != 0) { //% outs("验证码输入错误...\n"); outs("\xd1\xe9\xd6\xa4\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3...\n"); continue; } else { break; } #endif // REG_CAPTCHA } for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) { passbuf[0] = '\0'; //% getdata(0, 0, "请设定您的密码 (Setup Password): ", passbuf, getdata(0, 0, "\xc7\xeb\xc9\xe8\xb6\xa8\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Setup Password): ", passbuf, sizeof(passbuf), NOECHO, YEA); errmsg = register_invalid_password(passbuf, userid); if (errmsg) { outs(errmsg); continue; } strlcpy(passwd, passbuf, PASSLEN); //% getdata(0, 0, "请再输入一次您的密码 (Confirm Password): ", passbuf, getdata(0, 0, "\xc7\xeb\xd4\xd9\xca\xe4\xc8\xeb\xd2\xbb\xb4\xce\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Confirm Password): ", passbuf, PASSLEN, NOECHO, YEA); if (strncmp(passbuf, passwd, PASSLEN) != 0) { //% prints("密码输入错误, 请重新输入密码\n"); prints("\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3, \xc7\xeb\xd6\xd8\xd0\xc2\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb\n"); continue; } passwd[8] = '\0'; break; } if (tried > MAX_SET_PASSWD_TRIES) return; struct userec user; init_userec(&user, userid, passwd, true); strlcpy(user.lasthost, fromhost, sizeof(user.lasthost)); if (create_user(&user) < 0) { outs("Failed to create user.\n"); return; } snprintf(log, sizeof(log), "new account from %s", fromhost); report(log, currentuser.userid); //% prints("请重新登录 %s 并填写注册信息\n", user.userid); prints("\xc7\xeb\xd6\xd8\xd0\xc2\xb5\xc7\xc2\xbc %s \xb2\xa2\xcc\xee\xd0\xb4\xd7\xa2\xb2\xe1\xd0\xc5\xcf\xa2\n", user.userid); pressanykey(); return; }
int more(char *filename, BOOL promptend) { FILE *fp; int chkey; int viewed, numbytes; int i, lines; int pageno, pagebreaks[MAXPAGE]; struct stat st; char buf[512]; BOOL dojump = FALSE; int jumpto = 0, dummy; if ((fp = fopen(filename, "r")) == NULL) return -1; if (fstat(fileno(fp), &st) == -1) return -1; i = 0; lines = 0; viewed = 0; pageno = 0; pagebreaks[0] = 0; clear(); /* read a line & process it until end of it */ while ((numbytes = readln(buf, sizeof(buf), fp)) != 0) { if (!dojump || (dojump && pageno < jumpto - 2)) { /* sarek:06/09/2002:引言上色,修正加空白後的第二層引言上色判斷 */ if ((buf[0] == '>' && buf[1] == ' ' && buf[2] == '>') || (buf[0] == '>' && buf[1] == '>') || (buf[0] == ':' && buf[1] == ' ' && buf[2] == ':') || (buf[0] == ':' && buf[1] == ':') ) { outs("[0;36m"); outs(buf); outs("[m"); } else if (buf[0] == '>' || buf[0] == ':') { outs("[0;32m"); outs(buf); outs("[m"); } else { outs(buf); } } viewed += numbytes; getyx(&i, &dummy); if (++lines == b_line) { if (++pageno < MAXPAGE) pagebreaks[pageno] = viewed; lines = 0; } /* if (i == b_line) */ if (i >= b_line) { if (dojump) { if (pageno < jumpto - 1) continue; dojump = FALSE; } move(b_line, 0); prints(_msg_more_1, (viewed * 100) / st.st_size, pageno); while ((chkey = igetkey()) != EOF) { #if 1 if (msqrequest) { msqrequest = FALSE; msq_reply(); continue; } if (chkey == CTRL('R')) msq_reply(); else #endif if (chkey == ' ' || chkey == KEY_RIGHT || chkey == KEY_PGDN) { clear(); i = 0; break; } else if (chkey == 'q' || chkey == KEY_LEFT) { move(b_line, 0); clrtoeol(); fclose(fp); return 0; } else if (chkey == '\r' || chkey == '\n' || chkey == KEY_DOWN) { scroll(); move(b_line - 1, 0); clrtoeol(); refresh(); i = b_line - 1; lines--; break; } else if (chkey == 'b' || chkey == KEY_PGUP) { if (pageno > 1 && pageno <= MAXPAGE) { pageno -= 2; viewed = pagebreaks[pageno - 1]; fseek(fp, viewed, SEEK_SET); clear(); lines = 0; i = 0; break; } } else if (isdigit(chkey)) { char nbuf[4]; nbuf[0] = chkey; nbuf[1] = '\0'; if (getdata_str(b_line, 0, "跳到第幾頁: ", nbuf, 4, ECHONOSP, nbuf)) { dojump = TRUE; jumpto = atoi(nbuf); pageno = jumpto; viewed = pagebreaks[pageno]; fseek(fp, viewed, SEEK_SET); clear(); lines = 0; i = 0; } break; } #if 0 else if (chkey == '/') { char grepstr[60]; long hit = 0; int cur_page = pageno + 1; int j = 0; if (!getdata(b_line, 0, "請輸入搜尋字串: ", grepstr, sizeof(grepstr), XECHO, NULL)) break; while ((numbytes = readln(fp, buf))) { viewed += numbytes; if (strstr(buf, grepstr)) { hit = ftell(fp) - numbytes; break; } if (++j == t_lines - 1) { if (cur_page < MAXPAGE - 1) pagebreaks[cur_page + 1] = viewed - numbytes; } else if (j == t_lines) { cur_page++; j = 0; } } if (hit) { pageno = cur_page; viewed = pagebreaks[pageno]; fseek(fp, viewed, SEEK_SET); clear(); i = linectr = 0; numbytes = readln(fp, buf); } else { move(b_line, 0); clrtoeol(); prints("[1;37;45m--More--(%d%% p.%d)[0;44m [→]:下一頁,[↓]:下一列,[B]:上一頁,[←][q]:中斷 more [m", (viewed * 100) / st.st_size, pageno + 1); } break; } #endif } /* while */ } /* if */ } /* while */ fclose(fp); if (promptend && st.st_size > 0) /* lthuang */ pressreturn(); return 0; }
int bbsnet(struct _select_def *conf, int n) { time_t now; struct hostent *pHost = NULL; struct sockaddr_in remote; unsigned char buf[BUFSIZ]; int rc; int rv; int maxfdp1; fd_set readset; struct timeval tv; int tos = 020; /* Low delay bit */ int i; sig_t oldsig; int ret; int key; now = time(NULL); clear(); prints("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\n", host1[n], ip[n]); prints("\033[1;32m如果在 %d 秒内无法连上,穿梭程序将放弃连接。\033[m\n", TIME_OUT); if (setjmp(jb) == 0) { oldsig = signal(SIGALRM, bbsnet_timeout); alarm(TIME_OUT); pHost = gethostbyname(ip[n]); alarm(0); signal(SIGALRM, oldsig); } if (pHost == NULL) { prints("\033[1;31m查找主机名失败!\033[m\n"); pressreturn(); return -1; } if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { prints("\033[1;31m无法创建socket!\033[m\n"); pressreturn(); return -1; } bzero(&remote, sizeof(remote)); remote.sin_family = AF_INET; remote.sin_port = htons(port[n]); remote.sin_addr = *(struct in_addr *)pHost->h_addr_list[0]; prints("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\n"); process_bar(0, MAX_PROCESS_BAR_LEN); for (i = 0; i < MAX_PROCESS_BAR_LEN; i++) { if (i == 0) rv = NonBlockConnectEx(sockfd, (struct sockaddr *)&remote, sizeof(remote), 500, 1); else rv = NonBlockConnectEx(sockfd, (struct sockaddr *)&remote, sizeof(remote), 500, 0); if (rv == ERR_TCPLIB_TIMEOUT) { process_bar(i+1, MAX_PROCESS_BAR_LEN); continue; } else if (rv == 0) break; else { prints("\033[1;31m连接失败!\033[m\n"); pressreturn(); ret = -1; goto on_error; } } if (i == MAX_PROCESS_BAR_LEN) { prints("\033[1;31m连接超时!\033[m\n"); pressreturn(); ret = -1; goto on_error; } setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(int)); prints("\033[1;31m连接成功!\033[m\n"); bbsnet_report(host1[n], ip[n], now, 0); clear(); refresh(); bbsnet_send_winsize(sockfd); for (;;) { FD_ZERO(&readset); FD_SET(0, &readset); FD_SET(sockfd, &readset); maxfdp1 = sockfd + 1; tv.tv_sec = 1200; tv.tv_usec = 0; /*if ((rv = SignalSafeSelect(maxfdp1, &readset, NULL, NULL, &tv)) == -1)*/ if ((rv = select(maxfdp1, &readset, NULL, NULL, &tv)) == -1) { if (errno == EINTR) { while (msg_count) { msg_count--; r_msg(); } continue; } ret = -1; goto on_error; } if (rv == 0) { ret = -1; goto on_error; } if (FD_ISSET(sockfd, &readset)) { if ((rc = read(sockfd, buf, BUFSIZ)) < 0) { ret = -1; goto on_error; } else if (rc == 0) break; else if (strchr((void*)buf, 255)) /* 查找是否含有TELNET命令IAC */ telnetopt(sockfd, (void*)buf, rc); else { output((void*)buf, rc); oflush(); } } if (FD_ISSET(0, &readset)) { if ((rc = bbsnet_read(0, (void*)buf, BUFSIZ)) < 0) { ret = -1; goto on_error; } if (rc == 0) break; if ((key = list_select_remove_key(conf)) != KEY_INVALID) if (key == KEY_ONSIZE) bbsnet_send_winsize(sockfd); write(sockfd, buf, rc); } } bbsnet_report(host1[n], ip[n], now, 1); ret = 0; on_error: close(sockfd); clear(); redoscr(); return ret; }