之前分享的脚本没有分割登录电脑名和IP信息,更新脚本如下: 主窗口脚本文件【main_win_open】添加增加控件脚本 int main() { menu_add_csp("MainMenu",26,'x26','在线用户','在线用户'); return 1; }; 新建脚本文件【在线用户】,或导入附件脚本文件 int test() { return 1; }; int main() { int i,yhsl,count,j; string sql,yhbh,userIds,uid,relauserid,relauserids; uid = get_user_id() get_online_user(); yhsl = db_row_count() userIds=""; for(i=0;i<yhsl;i++); { db_go_row(i) yhbh = db_res(0) if(userIds=="") { userIds="'"+yhbh+"'"; } else { userIds=userIds+",'"+yhbh+"'"; } }; if(is_super_user() == '1') //限定超级用户 { sql="select p.unit_id as 组织架构,a.user_id as 用户账号,a.user_name as 用户名称,a.ip as 登录电脑名,a.ip as 登录IP,a.machine_id as 登录电脑机器标识,"; sql=sql+"substring(a.login_time,0,9) as 登录日期,substring(a.login_time,9,15) as 登录时刻,p.note_info as 用户备注 from mup_login_log as a,mup_user p"; sql=sql+" where login_time = (select max(login_time) from mup_login_log as b where b.user_id = a.user_id) and p.user_id = a.user_id and a.user_id in("+ userIds +")"; db_run_query_thr(sql) count = db_row_count() for(j=0;j<count;j++); { db_go_row(j) db_add_field('登录电脑名') db_set_value_ext('登录电脑名',str_get_sub(db_res(3),0,str_pos(db_res(3)," "))) db_add_field('登录IP') db_set_value_ext('登录IP',str_get_sub(db_res(4),str_pos(db_res(4)," ")+1,strlen(db_res(4))-str_pos(db_res(4)," "))) db_add_field('登录日期') db_set_value_ext('登录日期', fmt_date(db_res(6),"yyyy年mm月dd日")) db_add_field('登录时刻') db_set_value_ext('登录时刻', fmt_date(db_res(7),"hh:mi:ss")) db_map("mup_unit","组织架构","组织架构"); }; db_show('【在线用户】登录信息') }; //获取操作员和所属下级操作员的账号信息,组合成多用户查询条件 sql="select p.rela_user_id as 下级用户,a.user_id as 用户账户 from mup_login_log as a,mup_user_rela p"; sql=sql+" where login_time = (select max(login_time) from mup_login_log as b where b.user_id = a.user_id) and p.user_id = a.user_id and a.user_id ='"+ uid +"'"; sql=sql+" and p.rela_user_id in("+ userIds +")"; db_run_query_thr(sql) count = db_row_count() relauserids=""; for(i=0;i<count;i++); { db_go_row(i) relauserid = db_res(0) if(relauserids=="") { relauserids="'"+uid+"','"+relauserid+"'"; } else { relauserids=relauserids+",'"+relauserid+"'"; } }; //【下级用户有设置才能看到所属下级操作员的在线信息】 if(is_super_user() == '0') //限定非超级用户 { sql="select p.unit_id as 组织架构,a.user_id as 用户账号,a.user_name as 用户名称,a.ip as 登录电脑名,a.ip as 登录IP,a.machine_id as 登录电脑机器标识,"; sql=sql+"substring(a.login_time,0,9) as 登录日期,substring(a.login_time,9,15) as 登录时刻,p.note_info as 用户备注 from mup_login_log as a,mup_user p"; sql=sql+" where login_time = (select max(login_time) from mup_login_log as b where b.user_id = a.user_id) and p.user_id = a.user_id and a.user_id in("+ relauserids +")"; db_run_query_thr(sql) count = db_row_count() for(j=0;j<count;j++); { db_go_row(j) db_add_field('登录电脑名') db_set_value_ext('登录电脑名',str_get_sub(db_res(3),0,str_pos(db_res(3)," "))) db_add_field('登录IP') db_set_value_ext('登录IP',str_get_sub(db_res(4),str_pos(db_res(4)," ")+1,strlen(db_res(4))-str_pos(db_res(4)," "))) db_add_field('登录日期') db_set_value_ext('登录日期', fmt_date(db_res(6),"yyyy年mm月dd日")) db_add_field('登录时刻') db_set_value_ext('登录时刻', fmt_date(db_res(7),"hh:mi:ss")) db_map("mup_unit","组织架构","组织架构"); }; db_show('【本次登录】和【下级用户登录】信息') }; // msg('hello,world'); return 1; }; |