TIPTOP ERP系统用户可视化界面修改账号密码
客制一支作业p_pw,用于登录用户自行更改密码
--------------------华--------------------丽---------------------分--------------------割--------------------线--------------------
代码下载地址:http://pan.baidu.com/share/link?shareid=87591&uk=4060653789
画面档代码,代码复制到编辑器中请保存为p_pw.per
SCHEMA ds
LAYOUT
VBOX
FOLDER
PAGE page01 (TEXT="Main")
GRID
{
Oldpassword [old ]
Newpassword [new ]
REPassword [renew ]
}
END --GRID
END --PAGE
END --FOLDER
END --VBOX
END --LAYOUT
TABLES azb_file
ATTRIBUTES
old = FORMONLY.old;
new = FORMONLY.new;
renew = FORMONLY.renew;
END
--------------------华--------------------丽---------------------分--------------------割--------------------线--------------------
4GL代码,复制到编辑器中,保存为p_pw.4gl
# Prog. Version..: '3.10.02-06.08.23(00005)' #
# Pattern name...: p_pw.4gl
# Descriptions...: 可视化界面修改用户密码
# Date & Author..: 2012/09/24 By Condor
DATABASE ds
GLOBALS "../../config/top.global"
DEFINE p_row,p_col SMALLINT,
g_oldpwd VARCHAR(50),
g_newpwd VARCHAR(50),
g_repwd VARCHAR(50)
MAIN
OPTIONS
FORM LINE FIRST + 2, #鐣潰闁嬪鐨勪綅缃?
MESSAGE LINE LAST, #瑷婃伅椤ず鐨勪綅缃?
PROMPT LINE LAST, #鎻愮ず瑷婃伅鐨勪綅缃?
INPUT NO WRAP #杓稿叆鐨勬柟寮? 涓嶆墦杞?
DEFER INTERRUPT #鎿峰彇涓柗閸?
IF (NOT cl_user()) THEN
EXIT PROGRAM
END IF
WHENEVER ERROR CALL cl_err_msg_log
IF (NOT cl_setup("CZZ")) THEN
EXIT PROGRAM
END IF
LET p_row = ARG_VAL(1)
LET p_col = ARG_VAL(2)
CALL cl_used(g_prog,g_time,1) RETURNING g_time #No:MOD-580088 HCN 20050818 #No.FUN-6A0081
LET p_row = 2 LET p_col = 4
OPEN WINDOW p_pw_w AT p_row,p_col WITH FORM "czz/42f/p_pw"
ATTRIBUTE (STYLE = g_win_style CLIPPED) #No:FUN-580092 HCN
CALL cl_ui_init()
LET g_action_choice = ""
CALL p_pw_i()
CALL p_pw_menu()
CLOSE WINDOW p_pw_w
CALL cl_used(g_prog,g_time,2) RETURNING g_time #No:MOD-580088 HCN 20050818 #No.FUN-6A0081
END MAIN
FUNCTION p_pw_menu()
MENU ""
BEFORE MENU
ON ACTION pwd
CALL p_pw_modify()
ON ACTION exit
LET g_action_choice = "exit"
EXIT MENU
ON ACTION controlg
CALL cl_cmdask()
ON IDLE g_idle_seconds
CALL cl_on_idle()
CONTINUE MENU
COMMAND KEY(INTERRUPT)
LET INT_FLAG=FALSE
LET g_action_choice = "exit"
EXIT MENU
END MENU
END FUNCTION
FUNCTION p_pw_i()
INPUT g_oldpwd,g_newpwd,g_repwd FROM old,new,renew
#INPUT g_newpwd FORM new
#INPUT g_repwd FORM renew
BEFORE INPUT
CALL cl_set_comp_entry("old,new,renew",TRUE)
AFTER FIELD renew
IF g_repwd <> g_newpwd THEN
CALL cl_err('','czz-101',1)
NEXT FIELD new
END IF
ON ACTION CANCEL
LET g_action_choice = "exit"
CALL cl_set_act_visible("pwd", FALSE)
EXIT INPUT
END INPUT
IF INT_FLAG THEN
LET INT_FLAG = 0
CLOSE WINDOW p_pw_w
CALL cl_used(g_prog,g_time,2) RETURNING g_time
EXIT PROGRAM
END IF
END FUNCTION
FUNCTION p_pw_modify()
DEFINE
l_script STRING,
l_execute STRING,
l_return STRING
DEFINE
ch base.Channel,
l_status SMALLINT,
l_index SMALLINT,
l_temp STRING,
l_text STRING
RUN "rm -rf /u1/topprod/tiptop/asf/4gl/pwd"
RUN "rm -rf /u1/topprod/tiptop/asf/4gl/pwd.log"
LET l_script = '#!usr/bin/expect ','\n',
' set old [lindex $argv 0]','\n',
' set new [lindex $argv 1]','\n',
' spawn passwd ','\n',
' expect "password:" ','\n',
' send "$old\\r" ','\n',
' sleep 1','\n',
' expect "password:"','\n',
' send "$new\\r" ','\n',
' sleep 1 ','\n',
' expect "password:"','\n',
' send "$new\\r" ','\n',
' expect eof','\n',
' exit'
RUN "echo '"||l_script||"' > /u1/topprod/tiptop/asf/4gl/pwd"
RUN "chmod 777 /u1/topprod/tiptop/asf/4gl/pwd"
RUN "chmod 777 /u1/topprod/tiptop/asf/4gl/pwd.log"
LET l_execute = "expect /u1/topprod/tiptop/asf/4gl/pwd ",g_oldpwd," ",g_newpwd," > /u1/topprod/tiptop/asf/4gl/pwd.log"
RUN l_execute
SLEEP 2
LET ch = base.Channel.create()
CALL ch.openFile('/u1/topprod/tiptop/asf/4gl/pwd.log','r')
LET l_status = ch.read(l_temp)
WHILE l_status
LET l_text = l_text.trim(),l_temp.trim()
LET l_status = ch.read(l_temp)
END WHILE
LET l_index = 0
LET l_index = l_text.getIndexOf('successfully',1)
IF l_index > 0 THEN
CALL cl_err('successfully','!',1)
EXIT PROGRAM
ELSE
LET l_index = l_text.getIndexOf('Authentication token manipulation error',1)
IF l_index > 0 THEN
CALL cl_err('','czz-102',1) #认证令牌操作错误
ELSE
LET l_index = l_text.getIndexOf('too short',1)
IF l_index > 0 THEN
CALL cl_err('','czz-103',1) #新输入的密码太短
ELSE
LET l_index = l_text.getIndexOf('Password unchanged',1)
IF l_index > 0 THEN
CALL cl_err('','czz-108',1) #密码未改变
ELSE
LET l_index = l_text.getIndexOf('too similar to the old',1)
IF l_index > 0 THEN
CALL cl_err('','czz-107',1) #新密码与旧密码太相似了
ELSE
LET l_index = l_text.getIndexOf('not contain enough DIFFERENT characters',1)
IF l_index > 0 THEN
CALL cl_err('','czz-104',1) #密码不包含足够的不同字符
ELSE
LET l_index = l_text.getIndexOf('too simplistic',1)
IF l_index > 0 THEN
CALL cl_err('','czz-105',1) #新密码太过简单化
ELSE
LET l_index = l_text.getIndexOf('based on a dictionary word',1)
IF l_index > 0 THEN
CALL cl_err('','czz-106',1) #新密码包含了基于字典中的单词
ELSE
CALL cl_err(l_text,'!',1)
END IF
END IF
END IF
END IF
END IF
END IF
END IF
#CALL cl_err(l_text,'!',1)
CALL p_pw_i()
IF g_action_choice = "exit" THEN
CALL cl_set_act_visible("pwd", FALSE)
END IF
CALL p_pw_menu()
IF INT_FLAG OR g_action_choice = "exit" THEN
EXIT PROGRAM
END IF
END IF
END FUNCTION
--------------------华--------------------丽---------------------分--------------------割--------------------线--------------------
效果图如下:
![](https://img-my.csdn.net/uploads/201210/23/1351000462_6118.jpg)