How to implement virtual host with ASP code

Source: Internet
Author: User
Tags config ftp mail trim
Virtual Host
Create a virtual host is involved in the user, site, directory, FTP, DNS and other content, in addition, there may be email. The Qweb component is packaged in a more comprehensive way and needs to be contacted with Qaymuic@163.com.

Here is the code to create a virtual host:

Config.xml (configuration information)

<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 (configuration file)

<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 (Application page)

<%
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 ' > Fill in error </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 ' > Cannot create User:" & 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 Network <anyone@anyone.net>"
Cc.receiver=email
Cc.sendashtml=true
cc.subject= "Registration Confirmation"
cc.body= "<a href= '" & Application ("WebDir") & "/active.asp?user=" & user & "&id=" & session. SessionID & "&pass=" & Pass & ' > Thank you for registering, please activate your account within 24 hours ("& (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 ' > Unable to send registration information </font>"
Else
Response.Write "<font color= ' Red ' > registered successfully, please check the mail within 24 hours, activate the account .</font>"
Response.End
End If
Set cc=nothing
Set ff=nothing
End If
Set gg=nothing
End If
End If
%>
&LT;H1 align= "center" > Free Space Application <form name= "Form1" method= "Post" action= "<% =request. ServerVariables ("Script_name")%> ">
<p> User name:
<input type= "text" name= "user" >
</p>
<p> Password:
<input type= "password" name= "pass" >
</p>
<p> e-Mail:
<input type= "text" name= "email" >
</p>
<p>
<input type= "Submit" name= "submit" value= "Apply Now" >
</p>
</form>
<p align= "center" > </p>


Active.asp (Confirmation page, set up site, open FTP, EMAIL, configure DNS records)

<%
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&q



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.