int bbsinfo_main(void) { if (!loginok) return BBS_ELGNREQ; parse_post_data(); char *type = getparm("type"); xml_header("bbs"); if (*type != '\0') { printf("<bbsinfo "); print_session(); printf(">%s</bbsinfo>", check_info()); } else { printf("<bbsinfo post='%d' login='******' stay='%d' " "since='%s' host='%s' year='%d' month='%d' " "day='%d' gender='%c' ", currentuser.numposts, currentuser.numlogins, currentuser.stay / 60, getdatestring(currentuser.firstlogin, DATE_XML), currentuser.lasthost, currentuser.birthyear, currentuser.birthmonth, currentuser.birthday, currentuser.gender); print_session(); printf(" last='%s'><nick>", getdatestring(currentuser.lastlogin, DATE_XML)); xml_fputs(currentuser.username, stdout); printf("</nick></bbsinfo>"); } return 0; }
static void post_add(FILE *fp, const struct userec *user, fb_time_t now) { fprintf(fp, "\033[1;37m%s \033[m(\033[1;33m%s\033[m) 共上站 " "\033[1;32m%d\033[m 次 [\033[1;3%dm%s\033[m]\n", user->userid, user->username, user->numlogins, (user->gender == 'F') ? 5 : 6, horoscope(user->birthmonth, user->birthday)); fprintf(fp, "上 次 在:[\033[1;32m%s\033[m] 从 [\033[1;32m%s\033[m] " "到本站一游。\n", getdatestring(user->lastlogin, DATE_ZH), (user->lasthost[0] == '\0' ? "(不详)" : user->lasthost)); fprintf(fp, "离站时间:[\033[1;32m%s\033[m] ", getdatestring(user->lastlogout, DATE_ZH)); int exp = countexp(user); int perf = countperf(user); #ifdef SHOW_PERF fprintf(fp, "表现值:%d(\033[1;33m%s\033[m)\n", perf, cperf(perf)); #else fprintf(fp, "表现值:[\033[1;33m%s\033[m]\n", cperf(perf)); #endif #ifdef ALLOWGAME fprintf(fp, "银行存款: [\033[1;32m%d元\033[m] " "目前贷款: [\033[1;32m%d元\033[m](\033[1;33m%s\033[m) " "经验值:[\033[1;32m%d\033[m](\033[1;33m%s\033[m)。\n", user->money, user->bet, cmoney(user->money - user->bet), exp, cexpstr(exp)); fprintf(fp, "文 章 数: [\033[1;32m%d\033[m] " "奖章数: [\033[1;32m%d\033[m](\033[1;33m%s\033[m) 生命力:" "[\033[1;32m%d\033[m] 网龄[\033[1;32m%"PRIdFBT"天\033[m]\n\n", user->numposts, user->nummedals, cnummedals(user->nummedals), compute_user_value(user), (now - user->firstlogin) / 86400); #else fprintf(fp, "文 章 数:[\033[1;32m%d\033[m] 经 验 值:" #ifdef SHOWEXP "%d(\033[1;33m%-10s\033[m)" #else "[\033[1;33m%-10s\033[m]" #endif " 生命力:[\033[1;32m%d\033[m] 网龄[\033[1;32m%d天\033[m]\n\n", user->numposts, #ifdef SHOWEXP exp, #endif cexpstr(exp), compute_user_value(user), (now - user->firstlogin) / 86400); #endif }
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; }
int main() { struct shortfile data[MAXBOARD], *x; int i, total=0; int all=0;//所有品味文章的用户数 init_all(); getdatestring(time(0), NA); printf("<body background=/bg_1.gif bgproperties=fixed>"); printf("<center>%s -- 当前板面在线人数排行 (%s)\n<hr>\n", BBSNAME, datestring); for(i=0; i<MAXBOARD; i++) { x=&(shm_bcache->bcache[i]); if(x->filename[0]<=32 || x->filename[0]>'z') continue; if(!has_read_perm(¤tuser, x->filename)) continue; memcpy(&data[total], x, sizeof(struct shortfile)); total++; all+=*((int*)(x->filename+72)); } qsort(data, total, sizeof(struct shortfile), cmpboard); printf("<table><tr><td>排名<td>板面名称<td>中文名称<td>在线人数<td>百分比"); for(i=0; i<total; i++) { printf("<tr><td>%3d", i+1); printf("<td>%s", data[i].filename); printf("<td>%s", data[i].title+8); printf("<td align=right>%d", *((int*)(data[i].filename+72))); printf("<td align=right>%5.2f%%", (*((int*)(data[i].filename+72)))*100.0/all); } return 1; }
int main() { attach_init(); if(!loginok)return 0; if(!HAS_PERM(PERM_CHATCLOAK))return 0; FILE *fp; char buf[80]; int i,j,l; if(!(fp=fopen(gettshirtfile(""),"r"))) http_fatal("无法打开文件"); fseek(fp,0,0); printf("\"订单编号\",\"用户\",\"订单日期\",\"结算日期\",\"销售代表\",\"地址\",\"电话1\",\"电话2\",\"备注\","); for(i=0;i<10;i++) printf("\"样式%d\",\"尺码%d\",\"数量%d\",",i+1,i+1,i+1); printf("\"计件\",\"计价\"\x0d\x0a"); for(i=0;;i++) { if(!(fread(&ts,sizeof(ts),1,fp)))break; getdatestring(ts.torder,NA); strcpy(buf,datestring); *(buf+22)=0; printf("\"%d\",\"%s\",\"%s\",",i,ts.userid,buf); getdatestring(ts.tapprove,NA); strcpy(buf,datestring); *(buf+22)=0; printf("\"%s\",\"%s\",",(ts.tapprove)?buf:"",ts.approved); tsoutput(ts.addr); printf(","); tsoutput(ts.tel); printf(","); tsoutput(ts.tel2); printf(","); tsoutput(ts.memo); printf(","); for(j=0;j<10;j++) printf("\"%d\",\"%d\",\"%d\",",ts.t[j].style,ts.t[j].size,ts.t[j].count); printf("\"%d\",\"%.2f\"\x0d\x0a",ts.flag,getprice(ts)); } fclose(fp); return 0; }
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; }
int check_submit_form() { FILE *fp; fp=fopen("new_register", "a"); if(fp==0) http_fatal("注册文件错误,请通知SYSOP"); getdatestring(time(0),NA); fprintf(fp, "usernum: %d, %s\n", getusernum(currentuser.userid)+1, datestring); fprintf(fp, "userid: %s\n", currentuser.userid); fprintf(fp, "realname: %s\n", getparm("realname")); fprintf(fp, "dept: %s\n", getparm("dept")); fprintf(fp, "addr: %s\n", getparm("address")); fprintf(fp, "phone: %s\n", getparm("phone")); fprintf(fp, "regip: %s\n", fromhost); fprintf(fp, "----\n" ); fclose(fp); printf("您的注册单已成功提交. 站长检验过后会给您发信, 请留意您的信箱."); }
int main() { int i, no=0; char brd[100], buf[256]; init_all(); printf("<body background=/bg_1.gif bgproperties=fixed>"); printf("<nobr><center>%s -- 精华区下载服务<hr color=green>\n", BBSNAME); printf("【注】各板面精华区以压缩格式存储,请下载后用winzip等工具解压到某一目录后阅读。压缩包每周更新一次。<br>"); printf("<table border=1>\n"); printf("<tr><td>序号<td>名称<td>大小(字节)<td>更新时间\n"); for(i=0; i<MAXBOARD; i++) { strsncpy(brd, shm_bcache->bcache[i].filename, 60); sprintf(buf, "%s%s.html.tar.gz", DIGESTPATH, brd); if(!file_exist(buf)) continue; no++; getdatestring(file_time(buf), NA); printf("<tr><td>%d<td><a href=/digest/%s.html.tar.gz>%s</a><td align=right>%d<td>%s\n", no, brd, brd, file_size(buf), datestring); } printf("</table>"); }
void msgline() { char buf[256], buf2[STRLEN * 2]; void display_buffer(); extern int talkrequest; int tmpshow; time_t now; if (ismsgline <= 0) return; now = time(0); tmpshow = showansi; showansi = 1; if (talkrequest) { talkreply(); clear(); showansi = 0; display_buffer(); showansi = 1; } strcpy(buf, "[1;33;44m"); if (chkmail()) strcat(buf, "¡¾[5;32mÐÅ[m[1;33;44m¡¿"); else strcat(buf, "¡¾ ¡¿"); strcat(buf, "ÐÅÏä [[32m°´[31mCtrl-Q[32mÇó¾È[33m] "); sprintf( buf2, "[[32m%s[33m][[32m%4.4d[33m,[32m%3.3d[33m][[32m%d[33m] [[32m%2s[33m]", insert_character ? "²åÈë" : "¸Äд", currln + 1, currpnt + 1, linelen-1, enabledbchar ? "Ë«" : "µ¥"); strcat(buf, buf2); sprintf(buf2, "\033[1;33m¡¾\033[1;32m%.23s\033[33m¡¿\033[m", getdatestring(now, DATE_ZH) + 6); strcat(buf, buf2); move(t_lines - 1, 0); clrtoeol(); prints("%s", buf); showansi = tmpshow; }
int draw_pic() { char *blk[10] = { "£ß", "£ß", "¨x", "¨y", "¨z", "¨{", "¨|", "¨}", "¨~", "¨€" }; FILE *fp; int cr = 0, tm, i, item, j, aver=0; int pic[24]; char buf[80]; time_t now; for (i=0;i<24 ;i++ ) { pic[i]=0; } now = time(0); getdatestring(now); if ((fp = fopen(AVEFLE, "r")) == NULL) return -1; else { bzero(&pic, sizeof(pic)); i=0; while (fgets(buf, 50, fp) != NULL) { cr = atoi(index(buf, ':')+1); tm = atoi(buf); pic[tm] = (cr>pic[tm]) ? cr : pic[tm]; aver+=cr; i++; max = (max > cr) ? max : cr; } aver=aver/i+1; fclose(fp); } if ((fp = fopen(AVEPIC, "w")) == NULL) return -1; item=(max/MAX_LINE)+1; fprintf(fp,"\n[1;36m ©°¡ª¡ª\241\252¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª ³¬¹ý 1000 ½«²»ÏÔʾǧλÊý×Ö ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª©´\n"); for (i = MAX_LINE; i >= 0; i--) { fprintf(fp, "[1;37m%4d[36m©¦[32m", (i+1)*item); for (j = 0; j < 24; j++) { if ((item * i > pic[j]) && (item * (i-1) <= pic[j])&& pic[j]) { if(pic[j]<1000) fprintf(fp, "[35m%-3d[32m", (pic[j])); else fprintf(fp, "[33m%-3d[32m", (pic[j]-1000)); continue; } if(pic[j]-item*i<item && item*i<pic[j]) fprintf(fp,"%s ", blk[((pic[j]-item * i)*10)/item]); else if(pic[j]-item * i>=item) fprintf(fp,"%s ",blk[9]); else fprintf(fp," "); } fprintf(fp,"[1;36m©¦[m"); fprintf(fp, "\n"); } time(&now); fprintf(fp, "[1;37m 0 [36m©¸¡ª¡ª[37m%-12.12sƽ¾ù¸ºÔØÈËÊýͳ¼Æ[36m ¡ª¡ª [37m%s[36m ¡ª¡ª©¼[m\n", BBSNAME,datestring); fprintf(fp, "[1;36m 00 01 02 03 04 05 06 07 08 09 10 11 [31m12 13 14"); fprintf(fp, " 15 16 17 18 19 20 21 22 23[m\n\n"); fprintf(fp, " [1;36m 1 [32m¡ö[36m = [37m%3d [36m ƽ¾ùÉÏÕ¾ÈËÊý£º[37m%4d[36m ×î¸ßÔÚÏßÈËÊý£º[37m%4d[m\n",item,aver,max); fclose(fp); }
static int edit_article(const char *file, const char *content, const char *ip) { if (file == NULL || content == NULL || ip == NULL) return BBS_EINTNL; int fd = open(file, O_RDWR); if (fd < 0) return BBS_EINTNL; fb_flock(fd, LOCK_EX); char buf[4096]; ssize_t bytes = read(fd, buf, sizeof(buf)); if (bytes >= 0) { // skip header. char *ptr = buf, *e = buf + bytes; int n = 3; while (ptr != e && n >= 0) { if (*ptr == '\n') --n; ++ptr; } int begin = ptr - buf; if (bytes == sizeof(buf)) { lseek(fd, -sizeof(buf), SEEK_END); bytes = read(fd, buf, sizeof(buf)); if (bytes < sizeof(buf)) { fb_flock(fd, LOCK_UN); restart_close(fd); return BBS_EINTNL; } e = buf + bytes; } ptr = e - 2; // skip last '\n' while (ptr >= buf && *ptr != '\n') --ptr; if (ptr >= buf) { if (!strncmp(ptr + 1, "\033[m\033[1;36m※ 修改", 17)) { e = ptr + 1; --ptr; while (ptr >= buf && *ptr != '\n') --ptr; } } lseek(fd, begin, SEEK_SET); size_t len = strlen(content); size_t size = begin + len; int ret = safer_write(fd, content, len); if (ret == 0 && ptr != e) ret = safer_write(fd, ptr, e - ptr); len = snprintf(buf, sizeof(buf), "\033[m\033[1;36m※ 修改:·%s 于 " "%22.22s·HTTP [FROM: %-.20s]\033[m\n", currentuser.userid, getdatestring(time(NULL), DATE_ZH), mask_host(ip)); if (ret == 0) ret = safer_write(fd, buf, len); size += (e - ptr) + len; ftruncate(fd, size); fb_flock(fd, LOCK_UN); restart_close(fd); if (ret == 0) return 0; return BBS_EINTNL; } return BBS_EINTNL; }
int bbslogin_main(void) { char fname[STRLEN]; char buf[256], id[IDLEN + 1], pw[PASSLEN]; struct userec user; if (parse_post_data() < 0) return BBS_EINVAL; strlcpy(id, getparm("id"), sizeof(id)); if (*id == '\0') return login_screen(); strlcpy(pw, getparm("pw"), sizeof(pw)); if (loginok && !strcasecmp(id, currentuser.userid)) { const char *ref = get_login_referer(); printf("Location: %s\n\n", ref); return 0; } if (getuserec(id, &user) == 0) return BBS_ENOUSR; user.numlogins++; if (strcasecmp(id, "guest")) { int total; time_t stay, recent, now, t; if (!checkpasswd(user.passwd, pw)) { sprintf(buf, "%-12.12s %s @%s\n", user.userid, getdatestring(time(NULL), DATE_ZH), fromhost); sethomefile(fname, user.userid, "logins.bad"); file_append(fname, buf); file_append("logins.bad", buf); return BBS_EWPSWD; } total = check_multi(&user); if (!HAS_PERM2(PERM_SYSOPS, &user) && total >= 2) return BBS_ELGNQE; if (!HAS_PERM2(PERM_LOGIN, &user)) return BBS_EACCES; now = time(NULL); // Do not count frequent logins. if (now - user.lastlogin < 20 * 60 && user.numlogins >= 100) user.numlogins--; if (total > 1) { recent = user.lastlogout; if (user.lastlogin > recent) recent = user.lastlogin; stay = now - recent; if (stay < 0) stay = 0; } else { stay = 0; } t = user.lastlogin; user.lastlogin = now; user.stay += stay; #ifdef CHECK_FREQUENTLOGIN if (!HAS_PERM(PERM_SYSOPS) && abs(t - time(NULL)) < 10) { report("Too Frequent", user.userid); return BBS_ELFREQ; } #endif strlcpy(user.lasthost, fromhost, sizeof(user.lasthost)); save_user_data(&user); currentuser = user; } log_usies("ENTER", fromhost, &user); if (!loginok && strcasecmp(id, "guest")) wwwlogin(&user, getparm("ref")); return 0; }
void disply_userinfo( struct userec *u ) { int num, exp; char buf[80]; //#ifdef REG_EXPIRED time_t now; #ifndef AUTOGETPERM //#endif #endif move(2, 0); clrtobot(); now = time (0); set_safe_record(); // prints("���Ĵ��� : %-14s", u->userid); // prints("���Ĵ��� : \033[%dm%-14s\033[37m%", GetAuthUserDispColor(u->userid),u->userid); prints("���Ĵ��� : "); PrintColorUser(u->userid); prints("\033[37m"); prints(" �dz� : %-20s", u->username); prints(" �Ա� : %s", (u->gender == 'M' ? "��" : "Ů")); prints("\n��ʵ���� : %-40s", u->realname); prints(" �������� : %d/%d/%d", u->birthmonth, u->birthday, u->birthyear + 1900); prints("\n��ססַ : %-38s", u->address); { int tyear,tmonth,tday; tyear = u->birthyear+1900; tmonth = u->birthmonth; tday = u->birthday; countdays(&tyear,&tmonth,&tday,now); prints("�ۼ��������� : %d\n",abs(tyear)); } prints("�����ʼ����� : %s\n", u->email); prints("��ʵ E-mail : %s\n", u->reginfo); if HAS_PERM (PERM_ADMINMENU) prints("Ident ���� : %s\n", u->ident); prints("������ٻ��� : %-22s", u->lasthost); prints("�ն˻���̬ : %s\n", u->termtype); getdatestring(u->firstlogin,NA); prints("�ʺŽ������� : %s[��� %d ��]\n", datestring,(now-(u->firstlogin))/86400); getdatestring(u->lastlogin,NA); prints("����������� : %s[��� %d ��]\n", datestring,(now-(u->lastlogin))/86400); #ifndef AUTOGETPERM /*#ifndef REG_EXPIRED getdatestring(u->lastjustify,NA); prints("���ȷ������ : %s\n",(u->lastjustify==0)? "δ��ע��" :datestring); #else if(u->lastjustify == 0) prints("���ȷ�� : δ��ע��\n"); else { prints("���ȷ�� : ����ɣ���Ч����: "); nextreg = u->lastjustify + REG_EXPIRED * 86400; getdatestring(nextreg,NA); sprintf(genbuf,"%14.14s[%s]������ %d ��\n", datestring ,datestring+23,(nextreg - now) / 86400); prints(genbuf); } #endif*/ #endif #ifdef ALLOWGAME prints("������Ŀ : %-20d ������Ŀ : %d\n",u->numposts,u->nummedals); prints("˽������ : %d ��\n", u->nummails); prints("������д�� : %dԪ ���� : %dԪ (%s)\n", u->money,u->bet,cmoney(u->money-u->bet)); #else prints("������Ŀ : %-20d \n", u->numposts); #ifdef ALLOW_MEDALS int sum = 0; int i; for(i = 1; i <= 7; i++){ sum += (u -> nummedals >> (i << 2)) & 0x0f; } prints ("������Ŀ : %d\n", sum); #endif prints("˽������ : %d �� \n", u->nummails); #endif prints("��վ���� : %d �� ", u->numlogins); prints("��վ��ʱ�� : %d Сʱ %d ����\n",u->stay/3600,(u->stay/60)%60); exp = countexp(u); prints("����ֵ : %d (%s) ", exp, cexp(exp)); exp = countperf(u); prints("����ֵ : %d (%s)\n", exp, cperf(exp)); strcpy(genbuf, "bTCPRD#@XWBA#VS-DOM-F0s2345678"); for (num = 0; num < strlen(genbuf) ; num++) if (!(u->userlevel & (1 << num))) genbuf[num] = '-'; prints("ʹ����Ȩ�� : %s\n", genbuf); prints("\n"); if (u->userlevel & PERM_SYSOP) { prints(" ���DZ�վ��վ��, ��л���������Ͷ�.\n"); } else if (u->userlevel & PERM_BOARDS) { prints(" ���DZ�վ�İ���, ��л���ĸ���.\n"); } else if (u->userlevel & PERM_LOGINOK) { prints(" ����ע������Ѿ����, ��ӭ���뱾վ.\n"); } else if (u->lastlogin - u->firstlogin < 3 * 86400) { prints(" ������·, ���Ķ� BBSHelp ������.\n"); } else { prints(" ע����δ�ɹ�, ��ο���վ��վ����˵��.\n"); } if(HAS_PERM(PERM_LOOKADMIN)) { sprintf(buf, "ADMINQuery '%s'", u->userid); report(buf); } /* added report for all users */ else //if(HAS_PERM(PERM_LOOKADMIN)) { sprintf(buf, "ADMINQuery2 '%s'", u->userid); report(buf); } }
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 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); }
main(int argc, char *argv[]) { FILE *fp; FILE *op; char buf[256], *p,bname[20]; char date[80]; int mode; int c[3]; int max[3]; unsigned int ave[3]; int now,sec; int i, j,k; char *blk[10] = { "£ß", "£ß", "¨x", "¨y", "¨z", "¨{", "¨|", "¨}", "¨~", "¨€", }; mode=atoi(argv[1]); sprintf(buf,"%s/use_board", BBSHOME); if ((fp = fopen(buf, "r")) == NULL) { printf("cann't open use_board\n"); return 1; } sprintf(buf,"%s/0Announce/bbslist/todayboard%d", BBSHOME, ( mode == 1 ) ? 2 : 1); if ((op = fopen(buf, "w")) == NULL) { printf("Can't Write file\n"); return 1; } fillboard(); now=time(0); getdatestring(now); sprintf(date,"%14.14s",datestring); while (fgets(buf, 256, fp)) { if(strlen(buf)<57) continue; if(strstr(buf,date)!=buf) continue; if ( !strncmp(buf+23, "USE", 3)) { p=strstr(buf,"USE"); p+=4; p=strtok(p," "); strcpy(bname,p); if ( p = (char *)strstr(buf+48, "Stay: ")) { sec=atoi( p + 6); } else sec=0; record_data(bname,sec); } } fclose(fp); qsort(st, numboards, sizeof( st[0] ), brd_cmp); ave[0]=0; ave[1]=0; ave[2]=0; max[1]=0; max[0]=0; max[2]=0; for(i=0;i<numboards;i++) { ave[0]+=st[i].times; ave[1]+=st[i].sum; ave[2]+=st[i].times==0?0:st[i].sum/st[i].times; if(max[0]<st[i].times) { max[0]=st[i].times; } if(max[1]<st[i].sum) { max[1]=st[i].sum; } if(max[2]<(st[i].times==0?0:st[i].sum/st[i].times)) { max[2]=(st[i].times==0?0:st[i].sum/st[i].times); } } c[0]=max[0]/30+1; c[1]=max[1]/30+1; c[2]=max[2]/30+1; numboards++; st[numboards-1].times=ave[0]/numboards; st[numboards-1].sum=ave[1]/numboards; strcpy(st[numboards-1].boardname,"Average"); strcpy(st[numboards-1].expname,"×Üƽ¾ù"); if(mode==1) { fprintf(op,"[1;37mÃû´Î %-21.21s%-24.24s %5s %8s %10s[m\n","ÌÖÂÛÇøÃû³Æ","ÖÐÎÄÐðÊö","ÈË´Î","ÀÛ»ýʱ¼ä","ƽ¾ùʱ¼ä"); }else { fprintf(op," [1;37m1 [m[34m%2s[1;37m= %d (×ÜÈË´Î) [1;37m1 [m[32m%2s[1;37m= %s (ÀÛ»ý×ÜʱÊý) [1;37m1 [m[31m%2s[1;37m= %d Ãë(ƽ¾ùʱÊý)\n\n", blk[9],c[0],blk[9],timetostr(c[1]),blk[9],c[2]); } for(i=0;i<numboards;i++) { if(!strcmp(st[i].boardname,"Others")) printf("ok"); if(mode==1) fprintf(op,"[1m%4d[m %-21.21s%-24.24s %5d %-.8s %10d\n",i+1,st[i].boardname,st[i].expname,st[i].times,timetostr(st[i].sum),st[i].times==0?0:st[i].sum/st[i].times); else { fprintf(op," [1;37mµÚ[31m%3d [37mÃû ÌÖÂÛÇøÃû³Æ£º[31m%s [35m%s[m\n",i+1,st[i].boardname,st[i].expname); fprintf(op,"[1;37m ©°¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª\n"); fprintf(op,"[1;37mÈ˴Ω¦[m[34m"); for(j=0;j<st[i].times/c[0];j++) { fprintf(op,"%2s",blk[9]); } fprintf(op,"%2s [1;37m%d[m\n",blk[(st[i].times%c[0])*10/c[0]],st[i].times); fprintf(op,"[1;37mʱ¼ä©¦[m[32m"); for(j=0;j<st[i].sum/c[1];j++) { fprintf(op,"%2s",blk[9]); } fprintf(op,"%2s [1;37m%s[m\n",blk[(st[i].sum%c[1])*10/c[1]],timetostr(st[i].sum)); j=st[i].times==0?0:st[i].sum/st[i].times; fprintf(op,"[1;37mƽ¾ù©¦[m[31m"); for(k=0;k<j/c[2];k++) { fprintf(op,"%2s",blk[9]); } fprintf(op,"%2s [1;37m%s[m\n",blk[(j%c[2])*10/c[2]],timetostr(j)); fprintf(op,"[1;37m ©¸¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª[m\n\n"); } if(!strcmp(st[i].boardname,"Others")) printf("ok"); } fclose(op); }
int wmllogin(char * buf) { char id[IDLEN + 2], pw[20]; struct userec *x; struct user_info * uol[MULTI_LOGINS]; char buf2[256], filename[256]; int i, kick; page_init(NULL); strncpy(id, getparm("id"), IDLEN + 1); strncpy(pw, getparm("pw"), 19); if (!*pw) { strncpy(pw, getparm("pw2"), 19); } kick = atoi(getparm("kick")) - 1; if (!strcasecmp(id, "SYSOP")) { strcpy (buf, "用户SYSOP登录受限。"); return -65536; } if(file_has_word(".bad_host", fromhost)) { sprintf (buf, "对不起, 本站不欢迎来自 [%s] 的登录。 若有疑问, 请与SYSOP联系,", fromhost); return -256; } if(loginok && strcasecmp(id, currentuser.userid)) { sprintf (buf, "系统检测到目前你的计算机上已经登录有一个帐号 %s,请先退出。", currentuser.userid); return 1; } x = getuser(id); if (!x) { strcpy (buf, "错误的使用者帐号"); return -1; } sprintf(buf2, "home/%c/%s/badhost", toupper(x->userid[0]), x->userid); if(bad_host(fromhost,buf2)) { sprintf (buf, "对不起,此帐号已被设定为不可从 [%s] 登录本站。",fromhost); return -257; } if(strcasecmp(id, "guest")) { if(!checkpasswd(x->passwd, pw)) { if(*pw) { sleep(2); getdatestring (time(0), NA); sprintf(buf2, "%-12.12s %-30s %s[Wap]\n",id, datestring, fromhost); sprintf(filename, "home/%c/%s/logins.bad", toupper(x->userid[0]), x->userid); f_append(filename, buf2); } sprintf (buf, "密码错误"); return -2; } if (check_login_limit(x)) { strcpy (buf, "此ID在24小时内上站次数过多,请稍候再来。"); return -4; } if(!user_perm(x, PERM_BASIC)) { strcpy (buf, "此帐号已被停机。若有疑问,请用其他帐号在sysop版询问。"); return -5; } if (check_multi_d(x, uol, kick)) { wml_httpheader(); wml_head(); printf ("<card title=\"登录 -- %s\">", BBSNAME); printf ("<p>用户%s已经在本站登录了%d个线程,你需要踢掉一个才能登录。<br />", x->userid, MULTI_LOGINS); for (i = 0; i < MULTI_LOGINS; i++) { printf ("#%d %s %s%s 发呆%d分<br />", i, uol[i]->from, uol[i]->mode >= 20000 ? "@" : "", ModeType(uol[i]->mode >= 20000 ? uol[i]->mode - 20000 : uol[i]->mode), (time(0) - uol[i]->idle_time) / 60); } printf ("踢掉哪个:<select name=\"inp_kick\">"); for (i = 0; i < MULTI_LOGINS; i++) { printf ("<option value=\"%d\">%d</option>", i + 1, i + 1); } printf ("</select><br />"); printf ("您的密码:<input type=\"password\" maxlength=\"8\" name=\"inp_pw\" /><br />"); printf ("<anchor><go href=\"login.wml?id=%s\" method=\"post\"><postfield name=\"pw\" value=\"$(inp_pw)\" /><postfield name=\"kick\" value=\"$(inp_kick)\" /></go>登录</anchor></p>", x->userid); return 0; } x->lastlogin = time(0); x->numlogins++; strsncpy(x->lasthost, fromhost, 17); save_user_data(x); currentuser = *x; } report("WapEnter"); int iutmpnum, iutmpkey; if (!wwwlogin(x, &iutmpnum, &iutmpkey))//0 : succeed { encodingtest(); sprintf(buf2, "%d", iutmpnum); headerCookie("utmpnum", buf2); sprintf(buf2, "%d", iutmpkey); headerCookie("utmpkey", buf2); headerCookie("utmpuserid", currentuser.userid); wml_httpheader(); } else { strcpy (buf, "抱歉,登录人数太多,请稍候再来:("); return -65537; } sprintf (buf, "用户 %s 登录成功。", x->userid); wml_head(); printf ("<card title=\"登录 -- %s\" ontimer=\"%s\">", BBSNAME, "bbsboa.wml"); printf ("<timer value=\"50\" />"); printf ("<p>"); w_hprintf(buf); printf ("</p>"); printf ("<p>跳转中……</p>"); printf ("<p><anchor><go href=\"%s\" />如果不能自动跳转,请使用此链接。</anchor></p>", "bbsboa.wml"); return 0; }