C
coolong
Unregistered / Unconfirmed
GUEST, unregistred user!
unit domainUser ;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, Project1_TLB, StdVcl,ADODB,SysUtils,IniFiles ,IdGlobal;
type
TDomainUser = class(TASPObject, IDomainUser)
protected
procedure OnEndPage ; safecall ;
procedure OnStartPage(const AScriptingContext: IUnknown) ; safecall ;
function AddUser1(n: OleVariant): OleVariant ; safecall ; //新建用户
function DelUser1(n: OleVariant): OleVariant ; safecall ; //删除用户
function existuser(n: OleVariant): OleVariant ; safecall ; //判断用户
end ;
implementation
uses ComServ ;
const //建议采用INI 文件来管理
path1:string='D:/Program Files/Serv-U' ;
const
sourfile:string='c:/';
const
webpath:string='F:/web/www' ;
const
data1:string='f:/web/data/userList.mdb' ; //select id,name1,pass1,path2,path3,date1,date2,other from user
const
modi1:string='F:/web/data/modi.txt' ;
procedure TDomainUser.OnEndPage ;
begin
inherited OnEndPage ;
end ;
procedure TDomainUser.OnStartPage(const AScriptingContext: IUnknown) ;
begin
inherited OnStartPage(AScriptingContext) ;
end ;
function TDomainUser.DelUser1(n: OleVariant): OleVariant ;
begin
result:=false ;
end ;
function TDomainUser.AddUser1(n: OleVariant): OleVariant ;
var tt:tadoquery ;
p:string ;
sqlstr:string ;
file1:TIniFile ;
i:integer;
v:string;
begin
result:=false ;
p:=n ;
//加数据库
if existuser(p) then exit ;
try
tt:=tadoquery.Create(nil) ;
sqlstr:='Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=' ;
sqlstr:=sqlstr+data1+' ;Persist Security Info=False' ;
tt.ConnectionString := sqlstr ;
tt.SQL.text := 'insert into user1 (name1,pass1,path2,path3,date1,date2,other) ' ;
tt.SQL.Add(' values('+quotedstr(p)+','+quotedstr(p)+','+quotedstr(p)+','+quotedstr(p)
+','+quotedstr(DateToStr(date))+','+quotedstr(DateToStr(date))+','+quotedstr(p)+')') ;
tt.ExecSQL ;
tt.Close ;
tt.free ;
//加默认目录
CreateDir(webpath+'/'+p) ;
//加默认文档
copyfileto('c:/boot.ini',webpath+'/'+p+'/boot.ini');
//加FTP
file1:=tinifile.Create(path1+'/ServUDaemon.ini') ;
{
[Domain1]
User1=test|1|0
Password=test
HomeDir=F:/web/www/test
LoginMesFile=欢迎光临...
RelPaths=1
ChangePassword=1
DiskQuota=1|20480000|1724560
MaxUsersLoginPerIP=2
SpeedLimitUp=30720
SpeedLimitDown=30720
TimeOut=600
Access1=F:/web/www/test|RWMLCDP
}
i:=1;
while true do
begin
v:=file1.ReadString('domain1','User'+inttostr(i),v);
response.write(v); //看一下里面的内容
if v='' then break;
inc(i);
v:='';
end;
// i就是当前FTP用户的编号
response.write(inttostr(i));
file1.WriteString('Domain1','user11','user11|1|0'); //这个地方不对 可能是这个目录的权限问题 错误显示 错误 '8000ffff' 灾难性故障
file1.Destroy ;
result:=true ;
except
tt.Close ;
tt.Free ;
end ;
end ;
function TDomainUser.existuser(n: OleVariant): OleVariant ;
var I:tadoquery ;
p:string ;
sqlstr:string ;
begin
result:=false ;
p:=n ;
if n='' then exit ;
sqlstr:='Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=' ;
sqlstr:=sqlstr+data1+' ;Persist Security Info=False' ;
try
i:=tadoquery.Create(nil) ;
i.ConnectionString:=sqlstr ;
sqlstr:='select * from user1 where name1='+QuotedStr(p) ; //判断用户
i.SQL.Text:=sqlstr ;
i.Open ;
if i.Eof then exit ;
result:=true ;
i.close ;
i.Free ;
except
i.close ;
i.Free ;
end ;
end ;
initialization
TAutoObjectFactory.Create(ComServer, TDomainUser, Class_DomainUser,
ciMultiInstance, tmApartment) ;
end.
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, Project1_TLB, StdVcl,ADODB,SysUtils,IniFiles ,IdGlobal;
type
TDomainUser = class(TASPObject, IDomainUser)
protected
procedure OnEndPage ; safecall ;
procedure OnStartPage(const AScriptingContext: IUnknown) ; safecall ;
function AddUser1(n: OleVariant): OleVariant ; safecall ; //新建用户
function DelUser1(n: OleVariant): OleVariant ; safecall ; //删除用户
function existuser(n: OleVariant): OleVariant ; safecall ; //判断用户
end ;
implementation
uses ComServ ;
const //建议采用INI 文件来管理
path1:string='D:/Program Files/Serv-U' ;
const
sourfile:string='c:/';
const
webpath:string='F:/web/www' ;
const
data1:string='f:/web/data/userList.mdb' ; //select id,name1,pass1,path2,path3,date1,date2,other from user
const
modi1:string='F:/web/data/modi.txt' ;
procedure TDomainUser.OnEndPage ;
begin
inherited OnEndPage ;
end ;
procedure TDomainUser.OnStartPage(const AScriptingContext: IUnknown) ;
begin
inherited OnStartPage(AScriptingContext) ;
end ;
function TDomainUser.DelUser1(n: OleVariant): OleVariant ;
begin
result:=false ;
end ;
function TDomainUser.AddUser1(n: OleVariant): OleVariant ;
var tt:tadoquery ;
p:string ;
sqlstr:string ;
file1:TIniFile ;
i:integer;
v:string;
begin
result:=false ;
p:=n ;
//加数据库
if existuser(p) then exit ;
try
tt:=tadoquery.Create(nil) ;
sqlstr:='Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=' ;
sqlstr:=sqlstr+data1+' ;Persist Security Info=False' ;
tt.ConnectionString := sqlstr ;
tt.SQL.text := 'insert into user1 (name1,pass1,path2,path3,date1,date2,other) ' ;
tt.SQL.Add(' values('+quotedstr(p)+','+quotedstr(p)+','+quotedstr(p)+','+quotedstr(p)
+','+quotedstr(DateToStr(date))+','+quotedstr(DateToStr(date))+','+quotedstr(p)+')') ;
tt.ExecSQL ;
tt.Close ;
tt.free ;
//加默认目录
CreateDir(webpath+'/'+p) ;
//加默认文档
copyfileto('c:/boot.ini',webpath+'/'+p+'/boot.ini');
//加FTP
file1:=tinifile.Create(path1+'/ServUDaemon.ini') ;
{
[Domain1]
User1=test|1|0
Password=test
HomeDir=F:/web/www/test
LoginMesFile=欢迎光临...
RelPaths=1
ChangePassword=1
DiskQuota=1|20480000|1724560
MaxUsersLoginPerIP=2
SpeedLimitUp=30720
SpeedLimitDown=30720
TimeOut=600
Access1=F:/web/www/test|RWMLCDP
}
i:=1;
while true do
begin
v:=file1.ReadString('domain1','User'+inttostr(i),v);
response.write(v); //看一下里面的内容
if v='' then break;
inc(i);
v:='';
end;
// i就是当前FTP用户的编号
response.write(inttostr(i));
file1.WriteString('Domain1','user11','user11|1|0'); //这个地方不对 可能是这个目录的权限问题 错误显示 错误 '8000ffff' 灾难性故障
file1.Destroy ;
result:=true ;
except
tt.Close ;
tt.Free ;
end ;
end ;
function TDomainUser.existuser(n: OleVariant): OleVariant ;
var I:tadoquery ;
p:string ;
sqlstr:string ;
begin
result:=false ;
p:=n ;
if n='' then exit ;
sqlstr:='Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=' ;
sqlstr:=sqlstr+data1+' ;Persist Security Info=False' ;
try
i:=tadoquery.Create(nil) ;
i.ConnectionString:=sqlstr ;
sqlstr:='select * from user1 where name1='+QuotedStr(p) ; //判断用户
i.SQL.Text:=sqlstr ;
i.Open ;
if i.Eof then exit ;
result:=true ;
i.close ;
i.Free ;
except
i.close ;
i.Free ;
end ;
end ;
initialization
TAutoObjectFactory.Create(ComServer, TDomainUser, Class_DomainUser,
ciMultiInstance, tmApartment) ;
end.