首页 > 网站 > 建站经验 > 正文

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

2019-11-02 14:14:03
字体:
来源:转载
供稿:网友

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

config.xml(配置信息)

<Root_Element>
<admin>Administrator</admin>
<adminpass>xxxxxx</adminpass>
<readuser>IUSR_MACHINE</readuser>
<domain>cocoo.net</domain>
<dnsadmin>dnsadmin</dnsadmin>
<dnsadminpass>yyyyy</dnsadminpass>
<dnsip>10.1.143.227</dnsip>
<group>tryit</group>
<webdir>http://hanhong.cocoo.net</webdir>
</Root_Element>


global.asa(配置文件)

<SCRIPT LANGUAGE=vbscript RUNAT=Server> 
Sub Application_OnStart
set ff=server.createobject("microsoft.xmldom")
ff.async=false
ff.load server.mappath("config.xml")
set rootElem = ff.documentElement 
for e1=0 to rootElem.childNodes.length-1 
application(trim(rootElem.childNodes.item(e1).nodeName))=trim(rootElem.childNodes.item(e1).text)
next
End Sub
</script>


index.asp(申请页面)

<% 
user=trim(request("user"))
pass=trim(request("pass"))
email=trim(request("email"))
if user<>"" then
if pass="" or instr(email,"@")<2 then
response.write "<font color='red'>填写错误</font>"
else
SET GG=SERVER.CREATEOBJECT("QWEB.USER")
gg.logon application("admin") & "@" & application("domain"),application("adminpass")
SET RR=GG.CREATE(user,application("group"))
if gg.iserr then
response.write "<font color='red'>不能创建用户:" & gg.errstring & "</font>"
else
gg.value("pwdLastSet",rr)=-1
gg.changepassword "", pass,rr
response.write gg.errstring
gg.value("accountdisabled",rr)=TRUE
gg.value("accountexpirationdate",rr)=now()+2
gg.value("description",rr)=session.SessionID
SET FF=CreateObject("QWEB.dns")
domainn=right(email,len(email)-instr(email,"@"))
SET cc=CREATEOBJECT("qmail.newmail")
cc.sender="AA网络<[email protected]>"
cc.receiver=email
cc.sendashtml=true
cc.subject="注册确认"
cc.body="<a href='" & application("webdir") & "/active.asp?user=" & user & "&id=" & session.SessionID & "&pass=" & pass & "'>谢谢您的注册,请在24小时内(" & (now()+1) & ")激活您的帐户。</a>"
vv=ff.mxrecord(application("dnsip"),domainn)
HH=SPLIT(VV," ")
FOR G=0 TO UBOUND(HH)
cc.smtpsvr=hh(g)
cc.send
if cc.errcode=true then exit for
next
if cc.errcode=false then
gg.delete rr
response.write "<font color='red'>无法发送注册信息</font>"

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表