分享_【在线用户登录信息(分割电脑名和IP,登录日期和时刻)+组织架构+操作员备注】脚本分享_使用经验
学习.交流
专业源于专注
www. onlyit. cn   
学习交流 文件下载 手册资料 交流QQ群

    

 1  1/1   1  
作者
内容
fwj3861  [个人空间]
QQ名  越南-叶子(121305301)


注册  2010-09-09
发贴数  535
精华贴  10
原创贴  20
来自  越南
状态  正常

级别  贵宾
#1»发布于2022-12-13 15:04

之前分享的脚本没有分割登录电脑名和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; 
};



附件(登录后才可下载):2212131503_49.csp  说明: 原文件:在线用户.csp   大小:6622 Byte

        于 2022-12-13 15:04 被 fwj3861 修改




官方认证第三方服务团队  樊文俊(越南-叶子) QQ:121305301 TEL:+84869350626
承接越南北部-河内周边省份-OIT部署和维护服务(24小时上门或远程服务)
服务介绍:http://www.onlyit.cn/onlyit_service.html


 1  1/1   1  

登录后方可发贴


[ 电话: 0571-85462761 王先生 QQ: 124520435 加入软件QQ群 - 杭州 - 浙ICP备19051128号-1 网安 33010402003225 ]