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; }
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; }