如何用ASP代码实现虚拟主机-ASP技术-3P代码网
繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 如何用ASP代码实现虚拟主机

如何用ASP代码实现虚拟主机

2006-05-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:创建虚拟主机大体牵扯到用户、站点、目录、FTP、DNS等几项内容,此外,可能还有EMAIL。QWEB组件对此做了较全面的封装,需要的可以和qaymuic@163.com联系。 以下是创建一个虚拟主机的代码: config.XML(配置信息)...

创建虚拟主机大体牵扯到用户、站点、目录、FTP、DNS等几项内容,此外,可能还有EMAIL。QWEB组件对此做了较全面的封装,需要的可以和qaymuic@163.com联系。

以下是创建一个虚拟主机的代码:

config.XML(配置信息)

Administrator

xxxxxx

IUSR_MACHINE

cocoo.net

dnsadmin

yyyyy

10.1.143.227

tryit

http://hanhong.cocoo.net

global.asa(配置文件)

index.ASP(申请页面)

<%

user=trim(request("user"))

pass=trim(request("pass"))

email=trim(request("email"))

if user"" then

if pass="" or instr(email,"@")

免费空间申请

用户名:

密 码:

电子邮件:

active.ASP(确认页面,建立站点、开通FTP、EMAIL、配置DNS纪录)

<%

user=request("user")

id=request("id")

SET UU=SERVER.CREATEOBJECT("QWEB.MEMBER")

SET GG=SERVER.CREATEOBJECT("QWEB.USER")

SET z1=SERVER.CreateObject("QWEB.DIR")

set bb=server.createobject("MDUsercom.MDUser")

Set mUserInfo =server.createobject("MDUsercom.MDUserInfo")

set ff=createobject("qweb.dns")

UU.LOGON application("admin") & "@" & application("domain"),application("adminpass")

gg.LOGOn application("admin") & "@" & application("domain"),application("adminpass")

SET RR=GG.user(user,application("group"))

if gg.iserr then

msg1= "获取用户资料时发生错误:" & gg.errstring

else

if gg.value("description",rr)id or (gg.value("accountdisabled",rr)=false) then

msg1= "激活失败,请您从邮箱内提示的地址连接,或帐户在此之前已经被激活"

else

mpath=session.sessionid

z1.CREATE SERVER.MapPath("free/" & mpath),user,application("readuser")

if z1.iserr then

msg1="在创建用户目录时发生错误:" & z1.errstring

else

z1.CREATE SERVER.MapPath("free/" & mpath & "/mail"),user,application("readuser")

if z1.iserr then

msg1="在创建用户邮件目录时发生错误:" & z1.errstring

z1.delete SERVER.MapPath("free/" & mpath)

else

SET SS=z1.CREATESITE(user & "." & application("domain"),SERVER.MapPath("free/" & mpath))

if z1.iserr then

msg1="在创建站点时发生错误:" & z1.errstring

z1.delete SERVER.MapPath("free/" & mpath & "/mail")

z1.delete SERVER.MapPath("free/" & mpath)

else

z1.createftpdir user,SERVER.MapPath("free/" & mpath)

if z1.iserr then

msg1="在创建FTP目录时发生错误:" & z1.errstring

z1.delete SERVER.MapPath("free/" & mpath & "/mail")

z1.delete SERVER.MapPath("free/" & mpath)

set site1=z1.getsite(user & "." & application("domain"))

z1.deletesite site1

else

ff.LOGOn application("domain"),application("dnsip"),application("dnsadmin"),application("dnsadminpass")

ff.arecord(user & "." & application("domain"))=application("dnsip")

if ff.iserr then

msg1="在写入DNS记录时发生错误:" & ff.errstring

z1.delete SERVER.MapPath("free/" & mpath & "/mail")

z1.delete SERVER.MapPath("free/" & mpath)

set site1=z1.getsite(user & "." & application("domain"))

z1.deletesite site1

z1.deleteftpdir user

else

bb.LoadUserDll

bb.inituserinfo muserinfo

muserinfo.fullname=user

muserinfo.mailbox=user

muserinfo.domain=application("domain")

muserinfo.MailDir=SERVER.MapPath("free/" & mpath & "/mail")

muserinfo.password=request("pass")

muserinfo.MaxDiskSpace=25000000

muserinfo.ApplyQuotas=true

kk=bb.adduser(muserinfo)

if kk"0" then

msg1="在创建用户邮箱时发生错误:" & kk

z1.delete SERVER.MapPath("free/" & mpath & "/mail")

z1.delete SERVER.MapPath("free/" & mpath)

set site1=z1.getsite(user & "." & application("domain"))

z1.deletesite site1

z1.deleteftpdir user

ff.arecord(user & "." & application("domain"))=""

else

gg.value("accountexpirationdate",rr)=gg.value("accountexpirationdate",rr)+366

gg.value("accountdisabled",rr)=false

gg.value("EmailAddress",rr)=user & "@" & application("domain")

gg.value("HomeDirectory",rr)=SERVER.MapPath("free/" & mpath)

if gg.iserr then

msg1="在设置用户属性时发生错误:" & gg.errstring

z1.delete SERVER.MapPath("free/" & mpath & "/mail")

z1.delete SERVER.MapPath("free/" & mpath)

set site1=z1.getsite(user & "." & application("domain"))

z1.deletesite site1

z1.deleteftpdir user

ff.arecord(user & "." & application("domain"))=""

bb.DeleteUser user & "@" & application("domain"),511

bb.FreeUserDll

else

bb.FreeUserDll

session("isok")="true"

msg1="激活成功,您站点的域名是http://" & user & "." & application("domain") & "

"

msg1=msg1 & "FTP地址:ftp://" & user & "." & application("domain") & "

"

msg1=msg1 & "用户名: " & user & "

"

msg1=msg1 & "邮箱:" & user & "@" & application("domain") & "

"

msg1=msg1 & "密码:是您注册时填写的密码。

登录

"

end if

end if

end if

end if

end if

end if

end if

end if

end if

UU.LOGOff

set gg=nothing

SET UU=nothing

SET z1=nothing

set bb=nothing

Set mUserInfo =nothing

set ff=nothing

response.write msg1

%>

LOGOn.ASP(域名重指向)

<% user=trim(request("user"))

pass=trim(request("pass"))

IP=trim(request("IP"))

if user"" then

SET GG=SERVER.CREATEOBJECT("QWEB.USER")

gg.LOGOn application("admin") & "@" & application("domain"),application("adminpass")

SET RR=GG.USER(user,application("group"))

if gg.iserr then

response.write "用户不存在!"

else

gg.changepassword pass,"mypass",rr

if gg.iserr then

response.write "密码错误!"

else

gg.changepassword "mypass",pass,rr

set ff=createobject("qweb.dns")

ff.LOGOn application("domain"),application("dnsip"),application("dnsadmin"),application("dnsadminpass")

if ip="" then

ff.arecord(user & "." & application("domain"))=application("dnsip")

else

ff.arecord(user & "." & application("domain"))=ip

end if

if ff.iserr then

response.write "设置失败,请重试!"

else

response.write "更新成功!"

end if

set ff=nothing

end if

end if

set gg=nothing

end if

%>

管 理

用户名:

密 码:

把我的域名指向以下IP地址,如果为空则指向您的虚拟目录:

责任编辑:admin
相关文章