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 lock_scr(void) /* Leeward 98.02.22 */ { char passbuf[STRLEN]; if (!strcmp(getCurrentUser()->userid, "guest")) return 1; modify_user_mode(LOCKSCREEN); clear(); /* * lock_monitor(); */ while (1) { move(19, 32); clrtobot(); prints("\033[1m\033[32m%s\033[m", BBS_FULL_NAME); move(21, 0); clrtobot(); getdata(21, 0, "屏幕现在已经锁定,要解除锁定,请输入密码:", passbuf, 39, NOECHO, NULL, true); move(22, 32); if (!checkpasswd2(passbuf, getCurrentUser())) { prints("\033[1m\033[31m密码输入错误...\033[m\n"); pressanykey(); } else { prints("\033[1m\033[31m屏幕现在已经解除锁定\033[m\n"); /* * pressanykey(); */ break; } } return 0; }
static int set_smsg_getdata(struct _select_def *conf,int pos,int len) { int i; for (i=0; i<sm_num; i++) { if (s_m[i].context) free(s_m[i].context); } bzero(s_m, sizeof(struct smsmsg) * BBS_PAGESIZE); if (conf->item_count - conf->page_pos < BBS_PAGESIZE) conf->item_count = count_sql_smsmsg(getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, sm_msgtxt, getSession()); i = get_sql_smsmsg(s_m, getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, conf->page_pos-1, BBS_PAGESIZE,sm_msgtxt,sm_desc, getSession()); if (i <= 0) { conf->page_pos = 0; sm_dest[0]=0; sm_type = -1; sm_msgtxt[0]=0; i = get_sql_smsmsg(s_m, getCurrentUser()->userid, sm_dest, 0, 0, sm_type, 0, conf->page_pos-1, BBS_PAGESIZE,sm_msgtxt,sm_desc, getSession()); if (i <= 0) return SHOW_QUIT; } return SHOW_CONTINUE; }
static int set_al_getdata(struct _select_def *conf,int pos,int len) { int i; for(i=0;i<al_num;i++){ if( a_l[i].memo ) free(a_l[i].memo); } bzero( a_l, sizeof(struct addresslist) * BBS_PAGESIZE ); if( conf->item_count - conf->page_pos < BBS_PAGESIZE ) conf->item_count = count_sql_al(getCurrentUser()->userid, al_dest, al_group, al_msgtxt); i = get_sql_al(a_l, getCurrentUser()->userid, al_dest, al_group, conf->page_pos-1, BBS_PAGESIZE,al_order, al_msgtxt); if( i <= 0){ conf->pos = 1; al_dest[0]=0; al_group[0]=0; //sm_type = -1; al_msgtxt[0]=0; i = get_sql_al(a_l, getCurrentUser()->userid, al_dest, al_group, 0, BBS_PAGESIZE,al_order, al_msgtxt); if(i <= 0) return SHOW_QUIT; } return SHOW_CONTINUE; }
int smsmsg_read(void) { struct _select_def group_conf; int i; POINT *pts; sm_dest[0]=0; s_m = (struct smsmsg *) malloc(sizeof(struct smsmsg) * BBS_PAGESIZE); if (s_m == NULL) return -1; bzero(&group_conf,sizeof(struct _select_def)); pts = (POINT *) malloc(sizeof(POINT) * BBS_PAGESIZE); for (i = 0; i < BBS_PAGESIZE; i++) { pts[i].x = 2; pts[i].y = i + 3; } group_conf.item_per_page = BBS_PAGESIZE; group_conf.flag = LF_VSCROLL | LF_BELL | LF_MULTIPAGE | LF_LOOP; group_conf.prompt = "◆"; group_conf.item_pos = pts; group_conf.title_pos.x = 0; group_conf.title_pos.y = 0; group_conf.pos=1; group_conf.page_pos=1; group_conf.on_select = set_smsg_select; group_conf.show_data = set_smsg_show; group_conf.pre_key_command = set_smsg_prekey; group_conf.show_title = set_smsg_refresh; group_conf.get_data = set_smsg_getdata; group_conf.key_command = set_smsg_key; bzero(s_m, sizeof(struct smsmsg) * BBS_PAGESIZE); group_conf.item_count = count_sql_smsmsg(getCurrentUser()->userid, NULL, 0, 0, -1, 0, NULL, getSession()); i = get_sql_smsmsg(s_m, getCurrentUser()->userid, NULL, 0, 0, -1, 0, 0, BBS_PAGESIZE, NULL,sm_desc, getSession()); if (i <= 0) { free(s_m); return -1; } clear(); list_select_loop(&group_conf); for (i=0; i<sm_num; i++) { if (s_m[i].context) free(s_m[i].context); } free(pts); free(s_m); s_m = NULL; chk_smsmsg(1, getSession()); return 1; }
void call_kickoff(chatcontext * pthis, const char *arg) { /* kick ID off BBS, by Luzi, 97.11.1 */ char msg[STRLEN]; struct user_info *uin; if (!HAS_PERM(getCurrentUser(), PERM_SYSOP)) { printchatline(pthis, "*** 你不是站长 ***"); return; } if (!*arg) { printchatline(pthis, "*** 请输入你要踢下站的 ID ***"); return; } else if (!strcasecmp(arg, getCurrentUser()->userid)) sprintf(msg, "*** Faint!你要把自己踢下站啊?***"); else { uin = t_search(arg, false); if (uin == NULL) { sprintf(msg, "%s 并没有上站", arg); } else { bbslog("user", "kick %s out of bbs", uin->userid); kill(uin->pid, SIGHUP); return; } } printchatline(pthis, msg); }
static int load_highrecord(int level,struct high_record* hr,int myrecord) { int fd,ret; bzero(hr,sizeof(*hr)); if (level==-1) { hr->shortest=-1; return 0; } if (myrecord!=-1) fd=open(RECORD_FILE,O_RDWR|O_CREAT,0644); else fd=open(RECORD_FILE,O_RDONLY|O_CREAT,0644); if (fd==-1) { bbslog("3error","Box:can't open %s:%s",RECORD_FILE,strerror(errno)); return -1; } lseek(fd,sizeof(*hr)*(level-1),SEEK_SET); if (myrecord!=-1) readw_lock(fd,0,SEEK_SET,sizeof(*hr)*MAXDATA); else readw_lock(fd,sizeof(*hr)*(level-1),SEEK_SET,sizeof(*hr)); read(fd,hr,sizeof(*hr)); ret=0; if (myrecord!=-1) { if (hr->shortest>myrecord||hr->shortest<=0) { int i; int count; struct high_record allrecord[MAXDATA]; count=0; lseek(fd,0,SEEK_SET); read(fd,&allrecord,sizeof(*hr)*MAXDATA); for (i=0;i<MAXDATA;i++) { if (!strcasecmp(allrecord[i].userid,getCurrentUser()->userid)) count++; } if (count>20) ret = count; else { strcpy(hr->userid,getCurrentUser()->userid); hr->shortest=myrecord; lseek(fd,sizeof(*hr)*(level-1),SEEK_SET); write(fd,hr,sizeof(*hr)); ret=1; } } } if (myrecord!=-1) un_lock(fd,0,SEEK_SET,sizeof(*hr)*MAXDATA); else un_lock(fd,sizeof(*hr)*(level-1),SEEK_SET,sizeof(*hr)); close(fd); return ret; }
void chat_sendmsg(chatcontext * pthis, const char *arg) { /* send msg in chatroom , by alex, 96.9.5 */ char userid[IDLEN + 1]; char msg[STRLEN * 2]; struct user_info *uin; int state; nextword(&arg, userid, sizeof(userid)); if (!userid[0]) { printchatline(pthis, "\x1b[37m*** \x1b[32m请输入你要发消息的 ID\x1b[37m ***\x1b[m"); return; } else if (!*arg) { printchatline(pthis, "\x1b[37m*** \x1b[32m请输入你要发的消息\x1b[37m ***\x1b[m"); return; } else if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) { /* Leeward 98.07.30 */ sprintf(msg, "\x1b[32m你没有发信息的权限\x1b[m"); } else { uin = t_search(userid, false); if (uin == NULL) { sprintf(msg, "\x1b[32m%s\x1b[37m 并没有上站\x1b[m", userid); } else if (LOCKSCREEN == uin->mode) /* Leeward 98.02.28 */ sprintf(msg, "\x1b[32m%s\x1b[37m已经锁定屏幕,请稍候再发或给他(她)写信.\n", uin->userid); else { if (!canmsg(getCurrentUser(), uin)) sprintf(msg, "\x1b[32m%s\x1b[37m已经关闭接受讯息的呼叫器.\n", uin->userid); else if (false == canIsend2(getCurrentUser(),uin->userid)) sprintf(msg, "\x1b[32m%s\x1b[37m拒绝接受你的讯息.\n", uin->userid); /*Haohmaru.99.6.6,检查是否被ignore */ else { if (get_unreadcount(uin->userid) > MAXMESSAGE) sprintf(msg, "对方尚有一些讯息未处理,请稍候再发或给他(她)写信...\n"); else { /* 保存所发msg的目的uid 1998.7.5 by dong */ strcpy(getSession()->MsgDesUid, uin->userid); state = do_sendmsg(uin, arg, 2); if (state == 1) sprintf(msg, "\x1b[37m已经发消息给 \x1b[32m%s\x1b[37m 了\x1b[m", uin->userid); else if (state == -2) sprintf(msg, "\x1b[37m对方已经离线了...\x1b[m"); else sprintf(msg, "\033[37对方不接受你的消息...\033[m"); } } } } printchatline(pthis, msg); }
void call_user(chatcontext * pthis, const char *arg) { /* invite user online to chatroom */ char msg[STRLEN * 2]; struct user_info *uin; int state; if (!*arg) { printchatline(pthis, "\033[37m*** \033[32m请输入你要邀请的 ID\033[37m ***\033[m"); return; } if (!strcasecmp(arg, getCurrentUser()->userid)) sprintf(msg, "\033[32m你不用邀请自己啊\033[m"); else if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) /* Leeward 98.07.30 */ sprintf(msg, "\033[32m你没有发信息的权限\033[m"); else { uin = t_search(arg, false); if (uin == NULL) sprintf(msg, "\033[32m%s\033[37m 并没有上站\033[m", arg); else if (LOCKSCREEN == uin->mode) /* Leeward 98.02.28 */ sprintf(msg, "\033[32m%s\033[37m已经锁定屏幕,请稍候再邀请或给他(她)写信.\n", uin->userid); else if (!canmsg(getCurrentUser(), uin)) sprintf(msg, "%s 已经关闭接受讯息的呼叫器.\n", uin->userid); else { if (get_unreadcount(uin->userid) > MAXMESSAGE) sprintf(msg, "对方尚有一些讯息未处理,请稍候再邀请或给他(她)写信...\n"); else { sprintf(msg, "到聊天广场的 %s 聊天室 聊聊天", pthis->chatroom); /* 保存所发msg的目的uid 1998.7.5 by dong */ strcpy(getSession()->MsgDesUid, uin->userid); state = do_sendmsg(uin, msg, 1); if (state == 1) sprintf(msg, "\033[37m已经帮你邀请 %s 了\033[m", uin->userid); else if (state == -2) sprintf(msg, "\033[37m对方已经离线了...\033[m"); else sprintf(msg, "\033[37对方不接受你的消息...\033[m"); } } } printchatline(pthis, msg); }
void call_mail(chatcontext * pthis, const char *arg) { /* added by Luzi, 1997/12/22 */ fileheader mailheader; FILE *fpin; char b2[STRLEN]; char *t; char direct[PATHLEN]; if (chkmail() == 0) { /* check mail */ printchatline(pthis, "\033[32m*** 没有新的信件 ***\033[m"); return; } setmailfile(direct, getCurrentUser()->userid, DOT_DIR); fpin = fopen(direct, "rb"); if (fpin == NULL) return; printchatline(pthis, "\033[32m【当前新的信件如下】\033[m"); while (fread(&mailheader, sizeof(fileheader), 1, fpin)) { if ((mailheader.accessed[0] & FILE_READ) == 0) { strcpy(b2, mailheader.owner); if ((t = strchr(b2, ' ')) != NULL) *t = '\0'; sprintf(genbuf, "\033[31m %-20.20s ★ %.46s \033[m", b2, mailheader.title); printchatline(pthis, genbuf); } } fclose(fpin); }
static int canread(int level, char *path, char * fname, char *title) { char buf[PATHLEN+20]; if(strlen(path)+strlen(fname) > PATHLEN) return 0; sprintf(buf,"%s/%s",path,fname); #ifdef FB2KPC if(!strncmp(path,FB2KPC,strlen(FB2KPC))){ if(fb2kpc_is_owner(buf)) return 1; if(strstr(title,"<secret>")) return 0; }else{ #endif if(level & PERM_BOARDS) return 1; #ifdef FB2KPC } #endif if(dashd(buf)){ strcat(buf,"/.allow"); if(!dashf(buf)) return 1; if(!seek_in_file(buf,getCurrentUser()->userid)) return 0; return 1; } return 1; }
int winmine_main() { strcpy(recfile,"mine.rec"); strcpy(userid,getCurrentUser()->userid); modify_user_mode(WINMINE); winmine(); return 0; }
/* int printuserent(chatcontext * pthis, struct user_info *uentp) { static char uline[256]; static int cnt; char pline[50]; if (!uentp) { if (cnt) printchatline(pthis, uline); bzero(uline, 256); cnt = 0; return 0; } if (!uentp->active || !uentp->pid) return 0; if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && uentp->invisible) return 0; #if 0 if (kill(uentp->pid, 0) == -1) return 0; #endif sprintf(pline, " %s%-13s\033[m%c%-10s", myfriend(uentp->uid, NULL) ? "\033[32m" : "", uentp->userid, uentp->invisible ? '#' : ' ', modestring(uentp->mode, uentp->destuid, 0, NULL)); if (cnt < 2) strcat(pline, "│"); strcat(uline, pline); if (++cnt == 3) { printchatline(pthis, uline); memset(uline, 0, 256); cnt = 0; } return 0; } */ int print_friend_ent(struct user_info *uentp, chatcontext * pthis, int pos) { /* print one user & status if he is a friend */ char pline[50],buf[80]; if (!uentp->active || !uentp->pid) return 0; if (!HAS_PERM(getCurrentUser(), PERM_SEECLOAK) && uentp->invisible) return 0; #if 0 if (kill(uentp->pid, 0) == -1) return 0; #endif /* */ if (!myfriend(uentp->uid, NULL,getSession())) return 0; sprintf(pline, " %-13s%c%-10s", uentp->userid, uentp->invisible ? '#' : ' ', modestring(buf,uentp->mode, uentp->destuid, 0, NULL)); if (pthis->apply_count < 2) strcat(pline, "│"); strcat(pthis->apply_buf, pline); if (pthis->apply_count == 2) { printchatline(pthis, pthis->apply_buf); memset(pthis->apply_buf, 0, 256); pthis->apply_count = 0; } else pthis->apply_count++; return COUNT; }
/*游戏读资料出档案*/ void pip_read_file(void) { FILE *fs; char buf[200]; #ifdef MAPLE sprintf(buf, "home/%s/new_chicken", getCurrentUser()->userid); #else sprintf(buf, "home/%c/%s/new_chicken", toupper(getCurrentUser()->userid[0]), getCurrentUser()->userid); #endif // END MAPLE if ((fs = fopen(buf, "r"))!=NULL) { fread(&d, sizeof(d), 1, fs); fclose(fs); } }
static int help_key(struct _select_def *conf, int key) { switch(key){ case 's': { clear(); move(5,0); prints("\033[1;32m提示:\033[m 在帮助主界面中按f可以取消搜索显示当前所有的帮助"); getdata(6,0, "请输入搜索内容:", help_search, 21, DOECHO, NULL, false); if( help_search[0] ){ conf->pos = 1; conf->page_pos = 1; return SHOW_DIRCHANGE; } return SHOW_REFRESH; } case 'a': if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){ if( add_help(*((int *)conf->arg), -1) < 0 ) return SHOW_REFRESH; return SHOW_DIRCHANGE; } case 'e': if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){ if( add_help(*((int *)conf->arg), conf->pos - conf->page_pos) < 0 ) return SHOW_REFRESH; return SHOW_DIRCHANGE; } case 'd': if( HAS_PERM(getCurrentUser(), PERM_SYSOP) ){ if( del_help(s_help[conf->pos-conf->page_pos].id) < 0 ) return SHOW_REFRESH; return SHOW_DIRCHANGE; } case 'f': if( help_search[0] ){ help_search[0]=0; return SHOW_DIRCHANGE; } return SHOW_CONTINUE; default: break; } return SHOW_CONTINUE; }
static void ann_write_bmlog(char *path) { char *ptr, board[STRLEN]; if ((ptr = strstr(path, "groups/")) != NULL) ann_get_board(ptr, board, sizeof(board)); if (board[0] != '\0') bmlog(getCurrentUser()->userid, board, 13, 1); }
int pandora() { strncpy(user, getCurrentUser()->userid, 20); modify_user_mode(BBSNET); main_loop(); return 0; }
int winmineg_main() { ganyingshi=1; strcpy(recfile,"mine2.rec"); strcpy(userid,getCurrentUser()->userid); modify_user_mode(WINMINE); winmine(); return 0; }
/* 2001/5/6 modified by wwj 聊天室看msg的函数 */ void chat_show_allmsgs(chatcontext * pthis, const char *arg) { char fname[STRLEN]; FILE *fp; char buf[MAX_MSG_SIZE], showmsg[MAX_MSG_SIZE*2]; int line, cnt, i, j=0, count; struct msghead head; line = atoi(arg); if (line < screen_lines - 1) line = screen_lines - 1; if (line > 300) line = 300; gettmpfilename(fname, "chatmsg"); //sprintf(fname, "tmp/%s.msg", getCurrentUser()->userid); fp = fopen(fname, "w"); count = get_msgcount(0, getCurrentUser()->userid); for (i=0;i<count;i++) if (i>=count-line) { j++; load_msghead(0, getCurrentUser()->userid, i, &head); load_msgtext(getCurrentUser()->userid, &head, buf); translate_msg(buf, &head, showmsg,getSession()); fprintf(fp, "%s", showmsg); } fclose(fp); if (count) { fp = fopen(fname, "rb"); sprintf(buf, "【最近 %d 条消息】", j); printchatline(pthis, buf); while (!feof(fp)) { bzero(buf, sizeof(buf)); fgets(buf, sizeof(buf), fp); if (!buf[0]) break; cnt = strlen(buf) - 1; buf[cnt] = 0; /* delete \n */ printchatline(pthis, buf); } fclose(fp); } else { printchatline(pthis, "***** 没有任何的讯息存在!!*****"); } unlink(fname); }
int bbsnet_main() { strncpy(user, getCurrentUser()->userid, 20); modify_user_mode(BBSNET); init_data(); main_loop(); return 0; }
int save_key() { FILE* fp; char fname[STRLEN]; sethomefile(fname, getCurrentUser()->userid, "definekey"); fp=fopen(fname, "wb"); if (fp==NULL) return -1; fwrite(keymem, keymem_total*sizeof(struct key_struct), 1, fp); fclose(fp); truncate(fname, keymem_total*sizeof(struct key_struct)); return 0; }
static int cancel_article(char *board, char *file) { struct fileheader header; char dirname[MAXPATHLEN]; char *basename; time_t time; int fd, ent; char old_path[255]; if (file == NULL || strlen(file) < 3) return 0; basename = (file[1]=='/') ? (file + 2) : file; if (basename[0] != 'M' || basename[1] != '.' || (time = atoi(basename + 2)) <= 0) return 0; getcwd(old_path, 255); chdir(BBSHOME); setbdir(DIR_MODE_NORMAL,dirname,board); if ((fd = open(dirname, O_RDWR)) == -1) { chdir(old_path); return 0; } ent = search_record_back(fd, sizeof(struct fileheader),0,cmp_filename, file, &header,1); if (ent) { struct write_dir_arg delarg; struct userec user; init_write_dir_arg(&delarg); delarg.fd=fd; delarg.ent=ent; getCurrentUser() = &user; strcpy(user.userid, "<innd>"); do_del_post(getCurrentUser(),&delarg,&header,board,DIR_MODE_NORMAL,0,getSession()); free_write_dir_arg(&delarg); } close(fd); chdir(old_path); return 0; }
static int bbs_can_access_vote(char *limitpath) { struct votelimit userlimit; userlimit.numlogins=0; userlimit.numposts=0; userlimit.stay=0; userlimit.day=0; get_record(limitpath,&userlimit,sizeof(userlimit),1); if ((getCurrentUser()->numposts < userlimit.numposts || getCurrentUser()->numlogins < userlimit.numlogins || getCurrentUser()->stay < userlimit.stay * 60 * 60 || (time(NULL) - getCurrentUser()->firstlogin) < userlimit.day * 24 * 60 * 60)) { return 0; } return 1; }
static int save_clock_data() { FILE *fp; char fname[STRLEN]; sethomefile(fname,getCurrentUser()->userid,"clock.data"); fp=fopen(fname,"wb"); if(fp==NULL) return 0; fwrite(clock_data,clock_total*sizeof(struct clock_struct),1,fp); fclose(fp); truncate(fname,clock_total*sizeof(struct clock_struct)); return 1; }
void call_listen(chatcontext * pthis, const char *arg) { /* added by Luzi 1997.11.28 */ char path[40]; char uident[IDLEN + 1]; char ignoreuser[IDLEN + 1]; int nIdx; if (!*arg) { printchatline(pthis, "*** 请输入用户的ID ***"); } else if (!strcasecmp(arg, getCurrentUser()->userid)) printchatline(pthis, "*** 这是你自己的ID ***"); else { strncpy(uident, arg, IDLEN + 1); uident[IDLEN] = 0; if (!searchuser(uident)) /* change getuser -> searchuser, by dong, 1999.10.26 */ printchatline(pthis, "*** 没有这个ID ***"); else { sethomefile(path, getCurrentUser()->userid, "/ignores"); nIdx = search_record(path, ignoreuser, IDLEN + 1, (RECORD_FUNC_ARG) cmpinames, uident); if (nIdx <= 0) printchatline(pthis, "*** 该用户的聊天讯息没有被忽略啊 ***"); else if (delete_record(path, IDLEN + 1, nIdx, NULL, NULL) == 0) { bbslog("user", "listen %s", uident); printchatline(pthis, "*** 已恢复对该用户聊天讯息的接收 ***"); sprintf(uident, "/listen %s\n", uident); chat_send(pthis, uident); } else { bbslog("3error", "listen %s failed", uident); printchatline(pthis, "*** system error ***"); } } } }
void set_rec(chatcontext * pthis, const char *arg) { /* set recorder */ char fname[STRLEN]; time_t now; now = time(0); /* if(!HAS_PERM(getCurrentUser(),PERM_SYSOP)) return; */ /*sprintf(fname, "tmp/%s.chat", getCurrentUser()->userid);*/ sethomefile(fname,getCurrentUser()->userid,"chatrec"); if (!pthis->rec) { if ((pthis->rec = fopen(fname, "a")) == NULL) return; printchatline(pthis, "\033[5m\033[32mRecord Start ...\033[m"); move(0, 0); clrtoeol(); prints ("\033[44m\033[33m 房间: \033[36m%-10s \033[33m话题:\033[36m%-51s\033[31m%2s\033[m", pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : " "); fprintf(pthis->rec, "发信人: %s (%s) 房间: %s\n话 题: %s\x1b[m\n\n", getCurrentUser()->userid, getCurrentUser()->username, pthis->chatroom, pthis->topic); fprintf(pthis->rec, "本段由 %s", getCurrentUser()->userid); fprintf(pthis->rec, "所录下,时间: %s", ctime(&now)); bbslog("user", "start record room %s", pthis->chatroom); } else { move(0, 0); clrtoeol(); prints ("\033[44m\033[33m 房间: \033[36m%-10s \033[33m话题:\033[36m%-51s\033[31m%2s\033[m", pthis->chatroom, pthis->topic, (pthis->rec) ? "录" : " "); fprintf(pthis->rec, "发信人: %s (%s) 房间: %s\n话 题: %s\x1b[m\n\n", getCurrentUser()->userid, getCurrentUser()->username, pthis->chatroom, pthis->topic); printchatline(pthis, "\033[5m\033[32mRecord Stop ...\033[m"); fprintf(pthis->rec, "结束时间:%s\n", ctime(&now)); fclose(pthis->rec); pthis->rec = NULL; mail_file(getCurrentUser()->userid, fname, getCurrentUser()->userid, "录音结果", 1, NULL); my_unlink(fname); bbslog("user", "stop record room %s", pthis->chatroom); } }
int check_top(int score) { int i,j,lasttopn; lasttopn = topn; load_board(); if (topn<lasttopn) return -1; for (i=0;i<topn;i++) if (!strcmp(topid[i],getCurrentUser()->userid)) { if (score<=topscore[i]) return 0; topn--; for (j=i;j<topn;j++) { strcpy(topid[j],topid[j+1]); topscore[j] = topscore[j+1]; } i--; } for (i=0;i<topn;i++) { if (score>topscore[i]) { if (topn<100) topn++; for (j=topn-1;j>i;j--) { strcpy(topid[j], topid[j-1]); topscore[j] = topscore[j-1]; } strcpy(topid[i], getCurrentUser()->userid); topscore[i] = score; return 1; } } if (topn<100) { strcpy(topid[topn], getCurrentUser()->userid); topscore[topn] = score; topn++; return 1; } 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; }
void CAuthHelperTest::TestLocalLogin_AsDomainUser() { QSKIP ("method is not implemented", SkipAll); UserInfo user = getCurrentUser(); CAuthHelper auth; if ( isWinOs() && ! isHostInWindowsDomain() ) QVERIFY ( !auth.AuthUser( GetId_ToLocalLogin() ) ); else { QVERIFY ( auth.AuthUser( GetId_ToLocalLogin() ) ); QCOMPARE( auth.getUserName() , user.name ); QCOMPARE( auth.getUserDomain() , getCurrentDomain() ); } }
int fb2kpc_is_owner(char *path) { char *c; char owner[IDLEN+1]; if(strlen(path) < strlen(FB2KPC)+3) return 0; c=path+strlen(FB2KPC); if(*c=='/') c++; c+=2; strncpy(owner, c, IDLEN); owner[IDLEN]='\0'; if((c=strchr(owner,'/'))!=NULL) *c='\0'; if(strcasecmp(owner,getCurrentUser()->userid)) return 0; return 1; }