int show_onlinestate(char *userid) { int uid, i, uent, num = 0; struct user_info *uentp; uid = getuser(userid, NULL); if (uid <= 0 || uid > MAXUSERS) return 0; for (i = 0; i < 6; i++) { uent = uindexshm->user[uid - 1][i]; if (uent <= 0 || uent > MAXACTIVE) continue; uentp = &(shm_utmp->uinfo[uent - 1]); if (!uentp->active || !uentp->pid || uentp->uid != uid) continue; if (uentp->invisible && !USERPERM(currentuser, PERM_SEECLOAK)) continue; num++; if (num == 1) printf("目前在站上, 状态如下:\n"); if (uentp->invisible) printf("<font color=olive>C</font>"); printf("<font color=%s>%s</font> ", uentp->pid == 1 ? "magenta" : "blue", ModeType(uentp->mode)); if (num % 5 == 0) printf("<br>"); } return num; }
int main(int argc, char **argv) { int i,j,k; char * s; chdir(BBSHOME); resolve_boards(); resolve_ucache(); resolve_utmp(); memset(count, 0, 200*sizeof(int)); apply_ulist_addr((APPLY_UTMP_FUNC)check,NULL); for (i=0;i<200;i++)order[i]=i; for (i=0;i<200;i++) for (j=i+1;j<200;j++) if (count[order[i]]<count[order[j]]) { k=order[i]; order[i]=order[j]; order[j]=k; } j=0; for (i=0;i<200;i++) { s = ModeType(order[i]); if (s[0]&&strcmp(s,unknown)) { j++; printf("%2d %10s %4d %.2lf%%\n", j, s, count[order[i]], (double)count[order[i]]/total*100); } } return 0; }
static int full_user_list(struct user_info *uentp, struct fulluserlistarg* arg,int count) { struct user_info userinfo=*uentp; struct userec *lookupuser; zval* element; if (!userinfo.active || !userinfo.pid) { return 0; } if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && userinfo.invisible && strcmp(userinfo.userid, getCurrentUser()->userid)) { /*Haohmaru.99.4.24.让隐身者能看见自己 */ return 0; } if (count+1<arg->start) return COUNT; if (count+1-arg->start>=arg->num) return QUIT; MAKE_STD_ZVAL ( element ); array_init ( element ); add_assoc_bool ( element, "invisible", userinfo.invisible ); add_assoc_long ( element, "pid", userinfo.pid ); add_assoc_bool ( element, "isfriend", isfriend(userinfo.userid) ); add_assoc_string ( element, "userid", userinfo.userid, 1 ); add_assoc_string ( element, "username", userinfo.username, 1 ); if( getuser(userinfo.userid, &lookupuser) == 0 ) lookupuser=NULL; add_assoc_string ( element, "userfrom", HAS_PERM(getCurrentUser(), PERM_SYSOP)? userinfo.from: SHOW_USERIP(lookupuser, userinfo.from), 1 ); add_assoc_string ( element, "mode", ModeType(userinfo.mode), 1 ); add_assoc_long ( element, "idle", (long)(time(0) - userinfo.freshtime)/60 ); zend_hash_index_update(Z_ARRVAL_P(arg->return_value), count+1-arg->start, (void *) &element, sizeof(zval *), NULL); return COUNT; }
int main(int argc, char **argv) { if(argc<=1) return 0; mode = atoi(argv[1]); chdir(BBSHOME); resolve_boards(); resolve_ucache(); resolve_utmp(); apply_ulist_addr((APPLY_UTMP_FUNC)check,NULL); printf("%s: %d\n", ModeType(mode), count); return 0; }
static int printstatusstr(struct user_info *uentp, char *arg, int pos) { if (uentp->invisible == 1) { arg[0] = '1'; if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK)) return COUNT; } if (arg[1]==0) strcat(arg, "目前在站上,状态如下:\n"); if (uentp->invisible) strcat(arg, "<font class=\"c32\">隐身中</font> "); else { char buf[80]; if (uentp->pid == 1) { sprintf(buf, "<span class='blue'>%s</span> ", ModeType(uentp->mode)); } else { sprintf(buf, "%s ", ModeType(uentp->mode)); } strcat(arg, buf); } UNUSED_ARG(pos); return COUNT; }
void get_modes_name(struct key_struct* key, char* buf) { int i=0; buf[0]=0; if (key->status[0]==-1) { strcpy(buf, "无模式"); return; } if (!key->status[0]) { strcpy(buf, "全部模式"); return; } while (i<10&&key->status[i]) { strcat(buf, ModeType(key->status[i])); strcat(buf, " "); i++; } buf[strlen(buf)-1] = 0; return; }
int apiqry_main() { FILE *fp; char userid[14], filename[80], buf[512], output[4096],output_utf8[4096]; struct userec *x; struct user_info *u; int i, tmp2, num; json_header(); // changemode(QUERY); strsncpy(userid, getparm("U"), 13); if (!userid[0]) strsncpy(userid,getparm("userid"), 13); if (userid[0] == '\0') { printf("{\"User\":null}"); return 0; } x = getuser(userid); if (x == 0) { printf("{\"User\":null}"); return 0; } // ��ʼ����û����� sstrcat(output, "{\"User\":{"); // ��ʾ�������� sstrcat(output, "\"UserID\":\"%s\",\"UserNickName\":\"%s\",\"LoginCounts\":%d,\"PostCounts\":%d,\"LastLogin\":\"%s\",\"LastHost\":\"%s\",", x->userid, x->username, x->numlogins, x->numposts,Ctime(x->lastlogin), x->lasthost); // ��ʾ�������� if(!strcasecmp(x->userid, currentuser.userid)){ sstrcat(output, "\"Exp\":%d,\"ExpLevel\":\"%s\",\"Perf\":%d,\"PerfLevel\":\"%s\"",countexp(x), cexp(countexp(x)), countperf(x), cperf(countperf(x))); } // ��ʾ����վ�����Ϣ if(x->userlevel & PERM_BOARDS) { sstrcat(output, "\"BOARDBM\":["); sethomefile(filename, x->userid, "mboard"); new_apply_record(filename, sizeof(struct boardmanager), (void *)bm_printboardapi, output); sstrcat(output, "],"); } if((x->userlevel & PERM_SYSOP) && (x->userlevel&PERM_ARBITRATE)) sstrcat(output, "\"Job\":\"��վ������\","); else if(x->userlevel & PERM_SYSOP) sstrcat(output, "\"Job\":\"����վ��\","); else if(x->userlevel & PERM_OBOARDS) sstrcat(output, "\"Job\":\"ʵϰվ��\","); else if(x->userlevel & PERM_ARBITRATE) sstrcat(output, "\"Job\":\"���μ�ί\","); else if(x->userlevel & PERM_SPECIAL4) sstrcat(output, "\"Job\":\"����\","); else if(x->userlevel & PERM_WELCOME) sstrcat(output, "\"Job\":\"ϵͳ����\","); else if(x->userlevel & PERM_SPECIAL7) { if((x->userlevel & PERM_SPECIAL1) && !(x->userlevel & PERM_CLOAK)) sstrcat(output, "\"Job\":\"���γ���Ա\","); else sstrcat(output, "\"Job\":\"�������Ա\","); } else if(x->userlevel & PERM_ACCOUNTS) sstrcat(output, "\"Job\":\"�ʺŹ���Ա\","); // ��ʾ��ǰ״̬��null ���� array num = 0; sstrcat(output, "\"States\":"); for (i=0; i<MAXACTIVE; ++i) { u = &(shm_utmp->uinfo[i]); if(!strcmp(u->userid, x->userid)) { if(u->active == 0 || u->pid ==0 || (u->invisible && !HAS_PERM(PERM_SEECLOAK))) continue; ++num; if(num == 1) sstrcat(output, "["); if(u->mode != USERDF4){ if(u->invisible) sstrcat(output, "\"C%s\"", ModeType(u->mode)); else sstrcat(output, "\"%s\"", ModeType(u->mode)); } else // �Զ���״̬ sstrcat(output, "%s", u->user_state_temp); } if( (num>0) && (i == MAXACTIVE - 1)) sstrcat(output, "],"); } if (num == 0 ) { sstrcat(output, "\"null\","); if( x->lastlogout != NULL ) sstrcat(output, "\"LastLogout\":\"%s\",",Ctime(x->lastlogout)); else sstrcat(output, "\"LastLogout\":null,"); } // ��ʾ˵���� sethomefile(filename,x->userid,"plans"); fp = fopen(filename, "r"); sprintf(filename, "00%s-plan", x->userid); if (fp) { sstrcat(output, "\"PersonalIntro\":\""); // ��ʼ����˵���� while(1){ if(fgets(buf,256,fp) == 0) break; if (buf[strlen(buf) - 1] == '\n'){ int currentlength; currentlength = strlen(buf); buf[currentlength - 1] = '\\'; buf[currentlength] = 'n'; buf[currentlength + 1] = 0; } if(!strncmp(buf,"bigin 644",10)){ // errlog() // fdisplay_attach() } sstrcat(output, "%s", buf); } sstrcat(output, "\","); // ��������˵���� fclose(fp); } else //û�и���˵���� sstrcat(output, "\"PersonalIntro\":null,"); // ��ʾ�����ǩ show_special_api(x->userid, output); // ������� sstrcat(output, "}}"); g2u(output,sizeof(output), output_utf8,sizeof(output_utf8)); printf("%s", output_utf8); //http_quit(); return 0; }
int bbsqry_main() { FILE *fp; char userid[14], filename[80], buf[512]; struct userec *x; struct user_info *u; int i, tmp2, num; html_header(1); check_msg(); changemode(QUERY); strsncpy(userid, getparm("U"), 13); if (!userid[0]) strsncpy(userid, getparm("userid"), 13); printf("<body><center>"); printf("<div class=rhead>%s -- ��ѯ����</div><hr>\n", BBSNAME); if (userid[0] == 0) { printf("<form action=bbsqry>\n"); printf ("�������û���: <input name=userid maxlength=12 size=12>\n"); printf("<input type=submit value=��ѯ�û�>\n"); printf("</form><hr>\n"); http_quit(); } x = getuser(userid); if (x == 0) { int i, j = 0; printf("û������û������ѵ�����Щ:<p>"); printf("<table width=600>"); for (i = 0; i < shm_ucache->number; i++) if (strcasestr(shm_ucache->userid[i], userid) == shm_ucache->userid[i]) { j++; if (j % 6 == 1) printf("<tr>"); printf("<td>"); printf("<a href=bbsqry?userid=%s>%s</a>", shm_ucache->userid[i], shm_ucache->userid[i]); printf("</td>"); sprintf(buf, "bbsqry?userid=%s", shm_ucache->userid[i]); if (j % 6 == 0) printf("</tr>"); if (j >= 12 * 6) break; } printf("</table>"); if (!j) printf("�����ܣ��϶������ô��ˣ�����û���˰�"); if (j == 1) redirect(buf); printf("<p><a href=javascript:history.go(-1)>���ٷ���</a>"); http_quit(); } printf("</center><pre style='font-size:14px'>\n"); sprintf(buf, "%s ([33m%s[37m) ����վ [1;32m%d[m �Σ��������� [1;32m%d[m ƪ", x->userid, x->username, x->numlogins, x->numposts); hprintf("%s", buf); show_special_web(x->userid);//add by wjbta@bmy ����id��ʶ printf("\n"); hprintf("�ϴ��� [[1;32m%s[m] �� [[1;32m%s[m] ����վһ�Ρ�\n", Ctime(x->lastlogin), x->lasthost); mails(userid, &tmp2); hprintf("���䣺[[1;32m%s[m]��", tmp2 ? "��" : " "); if (!strcasecmp(x->userid, currentuser.userid)) { hprintf("����ֵ��[[1;32m%d[m]([33m%s[m) ", countexp(x), cexp(countexp(x))); hprintf("����ֵ��[[1;32m%d[m]([33m%s[m) ", countperf(x), cperf(countperf(x))); } hprintf("��������[[1;32m%d[m]��\n", count_life_value(x)); if (x->userlevel & PERM_BOARDS) { hprintf("���ΰ���"); sethomefile(filename, x->userid, "mboard"); new_apply_record(filename, sizeof (struct boardmanager), (void *) bm_printboard, NULL); if (x->userlevel & !strcmp(x->userid, "SYSOP")) hprintf("[[1;36mϵͳ����Ա[m]"); else if (x->userlevel & !strcmp(x->userid, "lanboy")) hprintf("[[1;36mϵͳ����Ա[m]"); else if ((x->userlevel&PERM_SYSOP) && (x->userlevel&PERM_ARBITRATE) ) hprintf("[[1;36m��վ������[m]"); else if (x->userlevel & PERM_SYSOP) hprintf("[[1;36m����վ��[m]"); else if (x->userlevel & PERM_OBOARDS) hprintf("[[1;36mʵϰվ��[m]"); else if (x->userlevel & PERM_ARBITRATE) hprintf("[[1;36m���μ�ί[m]"); else if (x->userlevel & PERM_SPECIAL4) hprintf("[[1;36m����[m]"); else if (x->userlevel & PERM_WELCOME) hprintf("[[1;36mϵͳ����[m]"); else if (x->userlevel & PERM_SPECIAL7) { if ( (x->userlevel & PERM_SPECIAL1) && !(x->userlevel & PERM_CLOAK) ) hprintf("[[1;36m���γ���Ա[m]"); else hprintf("[[1;36m�������Ա[m]"); } else if (x->userlevel & PERM_ACCOUNTS) hprintf ("[[1;36m�ʺŹ���Ա[m]"); hprintf("\n"); } num = 0; for (i = 0; i < MAXACTIVE; i++) { u = &(shm_utmp->uinfo[i]); if (!strcmp(u->userid, x->userid)) { if (u->active == 0 || u->pid == 0 || (u->invisible && !HAS_PERM(PERM_SEECLOAK))) continue; num++; if (num == 1) hprintf("Ŀǰ��վ��, ״̬����:\n"); if (u->invisible) hprintf("[36mC[37m"); if (u->mode != USERDF4) hprintf("\033[%dm%s[m ", u->pid == 1 ? 35 : 32, ModeType(u->mode)); else /* �Զ���״̬ */ hprintf("\033[%dm%s[m ", u->pid == 1 ? 35 : 32, u->user_state_temp); if (num % 5 == 0) printf("\n"); } } if (num == 0) { hprintf("Ŀǰ����վ��, �ϴ���վʱ�� [[1;32m%s[m]\n\n", x->lastlogout ? Ctime(x->lastlogout) : "�������ϻ��������߲���"); } printf("\n"); printf("</pre><table width=100%%><tr><td class=f2>"); sethomefile(filename, x->userid, "plans"); fp = fopen(filename, "r"); sprintf(filename, "00%s-plan", x->userid); fdisplay_attach(NULL, NULL, NULL, NULL); if (fp) { while (1) { if (fgets(buf, 256, fp) == 0) break; if (!strncmp(buf, "begin 644 ", 10)) { errlog("old attach %s", filename); fdisplay_attach(stdout, fp, buf, filename); continue; } fhhprintf(stdout, "%s", buf); } fclose(fp); } else { hprintf("[36mû�и���˵����[37m\n"); } printf("</td></tr></table>"); printf ("<br><br><a href=bbspstmail?userid=%s&title=û����>[�������]</a> ", x->userid); printf("<a href=bbssendmsg?destid=%s>[����ѶϢ]</a> ", x->userid); printf("<a href=bbsfadd?userid=%s>[�������]</a> ", x->userid); printf("<a href=bbsfdel?userid=%s>[ɾ������]</a>", x->userid); printf("<hr>"); printf("<center><form action=bbsqry>\n"); printf("�������û���: <input name=userid maxlength=12 size=12>\n"); printf("<input type=submit value=��ѯ�û�>\n"); printf("</form><hr>\n"); printf("</body>\n"); http_quit(); return 0; }
int set_modes(int *res) { struct _select_def group_conf; POINT *pts; char *s; int i,j,n; n=1; modest=0; modes[0][0]=0; modes[0][1]=res[0]==0; for (i=0; i<200; i++) { s=ModeType(i); if (s[0]&&!strchr(s,'?')&&!strchr(s,'W')) { modes[n][0]=i; modes[n][1]=0; if (res[0]!=-1) for (j=0; j<10; j++) { if (!res[j]) break; if (res[j]==i) { modes[n][1]=1; modest++; break; } } n++; } } bzero(&group_conf, sizeof(struct _select_def)); group_conf.item_count = n; //TODO: 窗口大小动态改变的情况?这里有bug pts = (POINT *) malloc(sizeof(POINT) * n); for (i = 0; i < n; i++) { pts[i].x = 2+20*(i/BBS_PAGESIZE); pts[i].y = i%BBS_PAGESIZE + 3; } group_conf.item_per_page = n; /* * 加上 LF_VSCROLL 才能用 LEFT 键退出 */ group_conf.flag = LF_BELL | LF_LOOP; group_conf.prompt = "◆"; group_conf.item_pos = pts; // group_conf.arg = &arg; group_conf.title_pos.x = 0; group_conf.title_pos.y = 0; group_conf.pos = 1; /* initialize cursor on the first mailgroup */ group_conf.page_pos = 1; /* initialize page to the first one */ group_conf.show_data = set_modes_show; group_conf.pre_key_command = set_modes_prekey; group_conf.key_command = set_modes_key; group_conf.show_title = set_modes_refresh; group_conf.get_data = set_modes_getdata; list_select_loop(&group_conf); free(pts); if (modes[0][1]) res[0]=0; else if (modest==0) res[0]=-1; else { j=0; for (i=1; i<n; i++) if (modes[i][1]) { res[j]=modes[i][0]; j++; } if (j<10) res[j]=0; } return 0; }
static int set_modes_show(struct _select_def *conf, int i) { i--; prints("%s%s\x1b[m", modes[i][1]?"*":" ", modes[i][0]?ModeType(modes[i][0]):"全部"); return SHOW_CONTINUE; }
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; }
int t_search_ulist(struct user_info* uentp, int (*fptr)(), int farg, int show, int doTalk) { int i, num; char col[14]; char col2[14]; resolve_utmp(); num = 0; for (i = 0; i < USHM_SIZE; i++) { *uentp = utmpshm->uinfo[i]; if ((*fptr) (farg, uentp)) { if (!uentp->active || !uentp->pid || isreject(uentp)) continue; if ( (uentp->invisible==0)||(uentp->uid == usernum) ||(uentp->invisible==1)&&(HAS_PERM(PERM_SYSOP|PERM_SEECLOAK)||canseeme(uentp))) { num++; } else { continue; } if (!show) continue; /* Efan: 增加奖章数 */ #ifdef ALLOW_MEDALS if (num == 1) prints ("目前 %s 状态如下: ", uentp->userid); #else if (num == 1) prints("目前 %s 状态如下: \n", uentp->userid); #endif //add by bluetent 2002-10-30 begin tmpmode=uentp->mode; if (tmpmode>20000) { tmpmode-=20000; iswwwmode=1; } else { iswwwmode=0; }; //add by bluetent 2002-10-30 end if ( uentp->mode>20000) strcpy(col2, "[1;44m"); else strcpy(col2, "[1;40m"); if ( uentp->invisible ) strcpy(col, "[1;36m"); else if ( tmpmode == POSTING || tmpmode == MARKET ) strcpy(col,"[1;32m"); else if ( tmpmode == FIVE || tmpmode == BBSNET) strcpy(col,"[1;33m"); else strcpy(col,"[1m"); if(doTalk) { prints("(%d) 状态: %s%s%-10s[m, 来自: %.20s[1m\n", num, col, col2, ModeType(tmpmode), (uentp->from[22]!='H'||hisfriend(uentp))?uentp->from:BBSIP_DOT); } else { prints("%s%s%-10s[1;37;40m ",col, col2,ModeType(tmpmode)); if ((num) % 5 == 0) outc('\n'); } } } if (show) outc('\n'); return num; }