unit MainWebModuleUnit;interfaceuses
Windows, SysUtils, Classes, HTTPApp, IniFiles ;const
PW_SUCCEED=0;
PW_ERROR=1;
PW_NOFILE=2;
PW_NOUSER=3;type
TMainWebModule = class(TWebModule)
procedure MainWebModuleDefaultWebActionItemAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainWebModule: TMainWebModule;implementation{$R *.dfm}
function GetUserFile:String;
begin
GetUserFile:='C:\Program Files\Serv-U\ServUDaemon.ini';
end;function CompareUser(AUser,AUserStr:String):Boolean;
var
ATemp,BTemp:String;
begin
ATemp:=Copy(AUserStr,6,Length(AUserStr)-6);
BTemp:=Copy(ATemp,1,Pos('|',ATemp)-1);
if AUser=BTemp then
CompareUser:=True
else
CompareUser:=False;
end;function ChangPassword(User, OldPassword, NewPassword:String):Integer;
var
IniChangePassword:TIniFile;
SectionsList:TStringList;
i:Integer;
FindUser:Boolean;
begin
FindUser:=False;
if FileExists(GetUserFile) then
begin
SectionsList:=TStringList.Create;
IniChangePassword:=TIniFile.Create(GetUserFile);
IniChangePassword.ReadSections(SectionsList);
for i:=0 to SectionsList.Count-1 do
if CompareUser(User,SectionsList.Strings[i]) then
begin
FindUser:=True;
if IniChangePassword.ReadString(SectionsList.Strings[i],'Password','')=OldPassword then
begin
IniChangePassword.WriteString(SectionsList.Strings[i],'Password',NewPassword);
ChangPassword:=PW_SUCCEED;
end
else
ChangPassword:=PW_ERROR;
end;
if not FindUser then
ChangPassword:=PW_NOUSER;
IniChangePassword.Free;
SectionsList.Free;
end
else
ChangPassword:=PW_NOFILE;
end;procedure TMainWebModule.MainWebModuleDefaultWebActionItemAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
ChangePasswordReturn:Integer;
begin
if Request.GetFieldByName('User')='' then
Response.Content:='请输入用户名!'
else if Request.GetFieldByName('OldPassword')='' then
Response.Content:='请输入原密码!'
else if Request.GetFieldByName('NewPassword')='' then
Response.Content:='请输入新密码!'
else
begin
ChangePasswordReturn:=ChangPassword(Request.GetFieldByName('User'),Request.GetFieldByName('OldPassword'),Request.GetFieldByName('NewPassword'));
Case ChangePasswordReturn of
PW_SUCCEED:Response.Content:='密码更新成功!请牢记你的新密码!';
PW_ERROR:Response.Content:='原密码错误!不能更改密码!';
PW_NOFILE:Response.Content:='没有找到用户数据文件!';
PW_NOUSER:Response.Content:='无此用户!';
end;
end;
end;end.
Windows, SysUtils, Classes, HTTPApp, IniFiles ;const
PW_SUCCEED=0;
PW_ERROR=1;
PW_NOFILE=2;
PW_NOUSER=3;type
TMainWebModule = class(TWebModule)
procedure MainWebModuleDefaultWebActionItemAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainWebModule: TMainWebModule;implementation{$R *.dfm}
function GetUserFile:String;
begin
GetUserFile:='C:\Program Files\Serv-U\ServUDaemon.ini';
end;function CompareUser(AUser,AUserStr:String):Boolean;
var
ATemp,BTemp:String;
begin
ATemp:=Copy(AUserStr,6,Length(AUserStr)-6);
BTemp:=Copy(ATemp,1,Pos('|',ATemp)-1);
if AUser=BTemp then
CompareUser:=True
else
CompareUser:=False;
end;function ChangPassword(User, OldPassword, NewPassword:String):Integer;
var
IniChangePassword:TIniFile;
SectionsList:TStringList;
i:Integer;
FindUser:Boolean;
begin
FindUser:=False;
if FileExists(GetUserFile) then
begin
SectionsList:=TStringList.Create;
IniChangePassword:=TIniFile.Create(GetUserFile);
IniChangePassword.ReadSections(SectionsList);
for i:=0 to SectionsList.Count-1 do
if CompareUser(User,SectionsList.Strings[i]) then
begin
FindUser:=True;
if IniChangePassword.ReadString(SectionsList.Strings[i],'Password','')=OldPassword then
begin
IniChangePassword.WriteString(SectionsList.Strings[i],'Password',NewPassword);
ChangPassword:=PW_SUCCEED;
end
else
ChangPassword:=PW_ERROR;
end;
if not FindUser then
ChangPassword:=PW_NOUSER;
IniChangePassword.Free;
SectionsList.Free;
end
else
ChangPassword:=PW_NOFILE;
end;procedure TMainWebModule.MainWebModuleDefaultWebActionItemAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
ChangePasswordReturn:Integer;
begin
if Request.GetFieldByName('User')='' then
Response.Content:='请输入用户名!'
else if Request.GetFieldByName('OldPassword')='' then
Response.Content:='请输入原密码!'
else if Request.GetFieldByName('NewPassword')='' then
Response.Content:='请输入新密码!'
else
begin
ChangePasswordReturn:=ChangPassword(Request.GetFieldByName('User'),Request.GetFieldByName('OldPassword'),Request.GetFieldByName('NewPassword'));
Case ChangePasswordReturn of
PW_SUCCEED:Response.Content:='密码更新成功!请牢记你的新密码!';
PW_ERROR:Response.Content:='原密码错误!不能更改密码!';
PW_NOFILE:Response.Content:='没有找到用户数据文件!';
PW_NOUSER:Response.Content:='无此用户!';
end;
end;
end;end.
解决方案 »
- 关于两个edit完全相同的问题
- Developer Express控件问题,困扰我太久了
- 使用ClientDataSet做内存表,增大字段长度后性能下降问题。
- 最近下了个 pas 可以作成dpk包得 如何更改dpk安装到组件面板上的名称呢 ?该控件会注册再新组件面板页
- 怎么开发CORBA客户端?
- 在程序中把多个不同的元素比如:文本,图片,声音保存到一个文件中,然后再读出来!
- 1)"金山快译“那样的导航条,他是如何控制
- 急!!关于统计数据的表达式
- 什么书比较适合想学好delphi人?
- 有谁能找到Epson LQ1600KIII的Windows2000Server版驱动程序
- 银河网络招聘delhpi以及VC程序员数名,在浙江省衢州市工作.外地人员可提供住宿.(全职)
- Delphi里如何才能准确地获得中文字符串的长度?
调用 ServUChangPassword.dll 的也面代码如下!<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head><body><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="GET" action="http://LocalHost/test/ServUChangPassword/ServUChangPassword.dll">
<p align="center">用户名:<input type="text" name="User" size="20"><br>原密码:<input type="text" name="OldPassword" size="20"><br>
新密码:<input type="text" name="NewPassword" size="20"><br><input type="submit" value="提交" name="B1"><input type="reset" value="全部重写" name="B2">
</form>
<p align="center"> </td>
</tr>
</table></body></html>
请输入用户名!如果把MainWebModuleDefaultWebActionItemAction过程修改如下后执行!
procedure TMainWebModule.MainWebModuleDefaultWebActionItemAction(
Sender: TObject; Request: TWebRequest; Response: TWebResponse;
var Handled: Boolean);
var
ChangePasswordReturn:Integer;
begin
ChangePasswordReturn:=ChangPassword(Request.GetFieldByName('User'),Request.GetFieldByName('OldPassword'),Request.GetFieldByName('NewPassword'));
Case ChangePasswordReturn of
PW_SUCCEED:Response.Content:='密码更新成功!请牢记你的新密码!';
PW_ERROR:Response.Content:='原密码错误!不能更改密码!';
PW_NOFILE:Response.Content:='没有找到用户数据文件!';
PW_NOUSER:Response.Content:='无此用户!';
end;
end;
无论怎么输入!都返回~!
密码更新成功!请牢记你的新密码!
Request.GetFieldByName('User')是个空值!!!
怎么回事呀????有高手知道吗?
Request.QueryFields.Values['User']
想用Request.content,就该用POST方法