<!--#include file="dbname.asp"-->
<!--#include file="script/xmlHttp.asp"-->
<%
If Session("admin")="" Then
	Response.Write("false")
	Response.End
End If

Function SaveFile(ByVal sFile, ByVal sData)
	Dim fso, txt
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	Set txt = fso.CreateTextFile(Server.MapPath(sFile), True) 
	txt.Write(sData)
	Set txt = Nothing
	Set fso = Nothing
End Function

Function MoveFile(ByVal sFile, ByVal tFile)
	If sFile="" Or tFile="" Then
		MoveFile=-1
		Exit Function
	End If
	On Error Resume Next : Err.Clear
	Dim fso, sfil, tfil
	sfil = Server.MapPath(sFile)
	tfil = Server.MapPath(tFile)
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	fso.MoveFile sfil, tfil
	Set fso = Nothing
	MoveFile = Err.Number
End Function

Function MoveFolder(ByVal sFolder, ByVal tFolder)
	If sFolder="" Or tFolder="" Then
		MoveFolder=-1
		Exit Function
	End If
	On Error Resume Next : Err.Clear
	Dim fso, sfld, tfld
	sfld = Server.MapPath(sFolder)
	tfld = Server.MapPath(tFolder)
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	fso.MoveFolder sfld, tfld
	Set fso = Nothing
	MoveFolder = Err.Number
End Function

Dim Action, strUrl, strHost, UserName
Dim diradm, dbname, dir_db, strData
Action = Trim(Request.QueryString("action"))
UserName = Trim(Request.QueryString("username"))
strHost = "http://www.021buy.net"
If Action="checkuser" Then
	strUrl = strHost &"/userchk.asp?username="& UserName &"&timer="& Timer()
	strHtml = HttpRequest(strUrl, "get", "")
	strData = FindString(strHtml, "<![CDATA[", "]]>")
	strData = Escape(RemoveHtml(strData))
	Response.Write(strData)
ElseIf Action="register" Then
	strUrl = strHost &"/reg.asp?action=save&wid=0&timer="& Timer()
	strPars = "username="& Server.URLEncode(Trim(UnEscape(Request.Form("username"))))
	strPars = strPars &"&password="& Server.URLEncode(Trim(UnEscape(Request.Form("password"))))
	strPars = strPars &"&password1="& Server.URLEncode(Trim(UnEscape(Request.Form("repasswd"))))
	strPars = strPars &"&email2="& Server.URLEncode(Trim(UnEscape(Request.Form("usermail"))))
	strPars = strPars &"&realname="& Server.URLEncode(Trim(UnEscape(Request.Form("realname"))))
	strPars = strPars &"&sex="& Server.URLEncode(Trim(UnEscape(Request.Form("usersex"))))
	strPars = strPars &"&province="& Server.URLEncode(Trim(UnEscape(Request.Form("province"))))
	strPars = strPars &"&city="& Server.URLEncode(Trim(UnEscape(Request.Form("provcity"))))
	strPars = strPars &"&address="& Server.URLEncode(Trim(UnEscape(Request.Form("address"))))
	strPars = strPars &"&mobile="& Server.URLEncode(Trim(UnEscape(Request.Form("mobphone"))))
	strPars = strPars &"&usertel="& Server.URLEncode(Trim(UnEscape(Request.Form("telphone"))))
	strPars = strPars &"&userqq="& Server.URLEncode(Trim(UnEscape(Request.Form("usermsn"))))
	strPars = strPars &"&mywebsite="& Server.URLEncode(Replace(Trim(UnEscape(Request.Form("website"))),"http://",""))
	strPars = strPars &"&widno="& Server.URLEncode(Trim(UnEscape(Request.Form("widno"))))
	strHtml = HttpRequest(strUrl, "post", strPars)
	strData = FindString(strHtml, "<tr ><td>", "</td></tr>")
	strData = Trim(RemoveHtml(strData))
	If InStr(strData,"ÄúÒÑ¾­×¢²á³É¹¦")>0 Then
		Call SaveFile("install.lck", Request.Form("username"))
		Response.Write("true")
	End If
	
	dbname = Trim(Request.Form("dbname"))
	diradm = Trim(Request.Form("diradm"))
	dbname = Replace(Replace(dbname, "\",""), "/","")
	diradm = Replace(Replace(diradm, "\",""), "/","")
	If dbname<>"" Then
		dir_db = Mid(db, 1, InStr(db, "/"))
		strData = "<% Const db = """& dir_db & dbname &""" %"&">"
		Call MoveFile(db, dir_db & dbname)
		Call SaveFile("dbname.asp", strData)
	End If
	If diradm<>"" Then
		strData = "<!--#include file="""& diradm &"/dbname.asp""-->"& vbCrLf
		strData = strData &"<% Const diradm = """& diradm &"/"" %"&">"
		Call MoveFolder(".", "../" & diradm)
		Call SaveFile("../diradm.asp", strData)
	End If
End If
%>