<%
	Dim DBC, Command, SiteName, MyEGold, ContactEMail, ReferralCommission, MyCommission, MinimumPayout, AdvCommission
	Dim GoldMembershipCommission4FreeMembers, GoldMembershipCommission4GoldMembers, MemberDelay, VisitorPackages
	Dim PageCost4FreeMembers, PageCost4GoldMembers, BannerCost4aMonth, i, MemberID, AltPass, MessageOnTop
	Dim rsCommon, rsBanners, GoldFee, GoldMinimumPayout, GoldFreeVisitors, GoldBannerDays
	Dim MsgCostNonMembers, MsgCostFreeMembers, MsgCostGoldMembers, MsgBoldCost, MsgHighlightCost

'	If Request.ServerVariables("REMOTE_HOST") <> "213.226.9.138" And Request.ServerVariables("REMOTE_HOST") <> "63.240.230.5" Then
'		Response.Write "Upgrading ... Please come back after a few hours."
'		Response.End
'	End If

'Application(Prefix & "MyEGold") = 0
	If Str2Num(Application(Prefix & "MyEGold")) = 0 Then
		OpenConnection

		Set rsCommon = DBC.Execute("SELECT * FROM Admin")

		If Not rsCommon.EOF Then
			Application(Prefix & "SiteName")					= rsCommon("SiteName")
			Application(Prefix & "MyEGold")					= rsCommon("EGold")
			Application(Prefix & "ContactEMail")				= rsCommon("ContactEMail")
			Application(Prefix & "AltPass")					= rsCommon("AltPass")
			Application(Prefix & "MinimumPayout")				= FormatNumber(rsCommon("MinimumPayout"), 2)
			Application(Prefix & "MemberDelay")				= rsCommon("MemberDelay")
			Application(Prefix & "GoldMembershipCommission4FreeMembers")	= rsCommon("GoldMembershipCommission4FreeMembers")
			Application(Prefix & "GoldMembershipCommission4GoldMembers")	= rsCommon("GoldMembershipCommission4GoldMembers")
			Application(Prefix & "AdvCommission")				= rsCommon("AdvCommission")
			Application(Prefix & "PageCost4FreeMembers")			= rsCommon("PageCost4FreeMembers")
			Application(Prefix & "PageCost4GoldMembers")			= rsCommon("PageCost4GoldMembers")
			Application(Prefix & "ReferralCommission")				= rsCommon("ReferralCommission")
			Application(Prefix & "MyCommission")				= rsCommon("MyCommission")
			Application(Prefix & "BannerCost4aMonth")				= rsCommon("BannerCost4aMonth")
			Application(Prefix & "VisitorPackages")				= rsCommon("VisitorPackages")
			Application(Prefix & "MessageOnTop")				= rsCommon("MessageOnTop")

			Application(Prefix & "GoldFee")					= rsCommon("GoldFee")
			Application(Prefix & "GoldMinimumPayout")				= rsCommon("GoldMinimumPayout")
			Application(Prefix & "GoldFreeVisitors")				= rsCommon("GoldFreeVisitors")
			Application(Prefix & "GoldBannerDays")				= rsCommon("GoldBannerDays")

			Application(Prefix & "MsgBoldCost")				= rsCommon("MsgBoldCost")
			Application(Prefix & "MsgHighlightCost")				= rsCommon("MsgHighlightCost")

			Application(Prefix & "MsgCostNonMembers")				= rsCommon("MsgCostNonMembers")
			Application(Prefix & "MsgCostFreeMembers")				= rsCommon("MsgCostFreeMembers")
			Application(Prefix & "MsgCostGoldMembers")			= rsCommon("MsgCostGoldMembers")
		End If
	End If

	SiteName					= Application(Prefix & "SiteName")
	MyEGold					= Application(Prefix & "MyEGold")
	ContactEMail				= Application(Prefix & "ContactEMail")
	PageCost4FreeMembers			= Application(Prefix & "PageCost4FreeMembers")
	PageCost4GoldMembers			= Application(Prefix & "PageCost4GoldMembers")
	ReferralCommission				= Application(Prefix & "ReferralCommission")
	MyCommission				= Application(Prefix & "MyCommission")
	MinimumPayout				= Application(Prefix & "MinimumPayout")
	MemberDelay				= Application(Prefix & "MemberDelay")
	GoldMembershipCommission4FreeMembers	= Application(Prefix & "GoldMembershipCommission4FreeMembers")
	GoldMembershipCommission4GoldMembers	= Application(Prefix & "GoldMembershipCommission4GoldMembers")
	AdvCommission				= Application(Prefix & "AdvCommission")
	BannerCost4aMonth				= Application(Prefix & "BannerCost4aMonth")
	AltPass					= Application(Prefix & "AltPass")
	VisitorPackages				= Application(Prefix & "VisitorPackages")
	MessageOnTop				= Application(Prefix & "MessageOnTop")

	GoldFee					= Application(Prefix & "GoldFee")
	GoldMinimumPayout			= Application(Prefix & "GoldMinimumPayout")
	GoldFreeVisitors				= Application(Prefix & "GoldFreeVisitors")
	GoldBannerDays				= Application(Prefix & "GoldBannerDays")

	MsgBoldCost				= Application(Prefix & "MsgBoldCost")
	MsgHighlightCost				= Application(Prefix & "MsgHighlightCost")

	MsgCostNonMembers			= Application(Prefix & "MsgCostNonMembers")
	MsgCostFreeMembers			= Application(Prefix & "MsgCostFreeMembers")
	MsgCostGoldMembers			= Application(Prefix & "MsgCostGoldMembers")


	MemberID = Str2Num(Session(Prefix & "MemberID"))


	If DateDiff("d", Application(Prefix & "BannersFileCreateOn"), Date()) > 0 Then
		CreateBannersFile
	End If


	If Not IsEmpty(Request.QueryString("sponsor")) Then
		Session(Prefix & "SponsorEGold") = Trim(Request.QueryString("sponsor"))
	End If


	Sub OpenConnection()
		Set DBC = Server.CreateObject("ADODB.Connection")
		DBC.Open "DBQ=" & DataBaseFileName & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;"
	End Sub


	Sub PageHeader()

	Response.Expires = -1
%>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<html>
	<head>
	<title><%= SiteName %></title>
	<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	<link rel="stylesheet" href="common.css">
	</head>
	<body>
<%
	End Sub


	Sub PageBegin()

	PageHeader
%>
	<table border="0" width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td width="19" background="images/topbackground.gif">
			&nbsp;
		</td>
		<td width="206"><img src="images/defaultlogo.gif" alt="<%= SiteName %>"></td>
		<td align="center" background="images/topbackground.gif">
			<!--#include file="banners.asp"-->&nbsp;&nbsp;
		</td>
	</tr>
	</table>
	<table border=0 width="100%" cellpadding="0" cellspacing="0">
	<tr bgcolor="F7F3FF">
		<td>
			<img src="images/downline.gif" height=20 width=20></td>
		<td background="images/downline.gif">
<a href="default.asp"><img src="images/home.gif" border=0 alt=home height=20 width=56></a><%
If MemberID = 0 Then
Response.Write "<a href=addmember.asp><img src=images/join.gif border=0 alt=join height=20 width=47></a>"
Else
Response.Write "<img src=images/joinpassive.gif border=0 height=20 width=47>"
End If
%><a href="news.asp"><img src="images/news.gif" border=0 alt=news height=20 width=55></a></a><a href="log.asp"><img src="images/membersarea.gif" border=0 alt="member's area" height=20 width=115></a><a href="advertise.asp"><img src="images/advertisers.gif" border=0 alt=advertisers height=20 width=92></a><a href="faq.asp"><img src="images/faq.gif" border=0 alt=faq height=20 width=44></a><a href="msgboard.asp"><img src="images/messageboard.gif" border=0 alt="message board" height=20 width=115><a href="terms.asp"><img src="images/termsandconditions.gif" border=0 alt="terms & conditions" height=20 width=140></a><script language=JavaScript>document.write("<a href='mailto:<%= Escape(ContactEMail & "?subject=" & SiteName & "-") %>'>");</script><img src="images/contact.gif" border=0 alt=contact height=20 width=67></a></td>
	</tr>
	<tr>
		<td colspan=2>
			<table width="100%" cellpadding="2" cellspacing="0">
			<tr>
				<td background="images/line.gif" width="19">&nbsp;</td>
				<td align="center" valign="top" class=Odd>
					<br class="HalfBreak">
<%
	End Sub


	Sub PageEnd()
%>
					<br>
				</td>
				<td background="images/rightline.gif" width="15">&nbsp;</td>
			</tr>
			</table>
		</td>
	</tr>
	<tr class="Odd">
		<td colspan="2" background="images/doubleline.gif" height="25" align="center">
			Copyright 2003-2004 © &nbsp;&nbsp;<%= SiteName %>&nbsp;&nbsp; All Rights Reserved.
		</td>
	</tr>
	<tr class="Odd">
		<td colspan="2" align="center">
			<br>Website design and development by <a href="http://free-sign-up.com/LowCostScripts/" target="_blank">Low Cost Scripts</a><br><br>
		</td>
	</tr>
	</table>

	</body>
	</html>
<%
	End Sub


	Function IIf(cond, value1, value2)
		If cond Then IIf = value1 Else IIf = value2 End If
	End Function


	Function EscapeSQLData(s)
		If IsNull(s) Then
			EscapeSQLData = "''"
		Else
			EscapeSQLData = "'" & Replace(s, "'", "''") & "'"
		End If
	End Function


	Function Str2Num(s)
		If IsNull(s) Then
			Str2Num = 0
		Else
			If IsNumeric(s) Then
				Str2Num = CLng(s)
			Else
				Str2Num = 0
			End If
		End If
	End Function


	Function Str2Float(s)
		If IsNull(s) Then
			Str2Float = 0
		Else
			If IsNumeric(s) Then
				Str2Float = CDbl(s)
			Else
				Str2Float = 0
			End If
		End If
	End Function


	Function CurrentPath()
		Dim s
		s = Request.ServerVariables("SCRIPT_NAME")

		s = Left(s, InStrRev(s, "/"))

		CurrentPath = "http://" & Request.ServerVariables("SERVER_NAME") & s
	End Function


	Function CurrentFile()
		CurrentFile = "http://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME")
	End Function


	Function SendMail(ToMail, Subject, Body)

		On Error Resume Next

		Dim JMail
		Set JMail = Server.CreateObject("JMail.SMTPMail")

		JMail.ServerAddress = MailServerAddress

		JMail.Sender	= ContactEMail
		JMail.AddRecipient	ToMail
		JMail.Subject	= Subject
		JMail.Body	= Body
		JMail.Priority	= 1

		JMail.Execute

		SendMail = (Err = 0)

		Err.Clear
		On Error Goto 0

	End Function


	Function IsValidPayment()
		Dim MD, MD5String

		Set MD = New MD5

		MD5String =	Request.Form("PAYMENT_ID")		& ":" & _
				Request.Form("PAYEE_ACCOUNT")		& ":" & _
				Request.Form("PAYMENT_AMOUNT")		& ":" & _
				Request.Form("PAYMENT_UNITS")		& ":" & _
				Request.Form("PAYMENT_METAL_ID")		& ":" & _
				Request.Form("PAYMENT_BATCH_NUM")	& ":" & _
				Request.Form("PAYER_ACCOUNT")		& ":" & _
				MD.DigestStrToHexStr(AltPass)		& ":" & _
				Request.Form("ACTUAL_PAYMENT_OUNCES")	& ":" & _
				Request.Form("USD_PER_OUNCE")		& ":" & _
				Request.Form("FEEWEIGHT")			& ":" & _
				Request.Form("TIMESTAMPGMT")

		IsValidPayment = (MD.DigestStrToHexStr(MD5String) = Request.Form("V2_HASH"))

	End Function


	Sub CreateBannersFile()

		Dim fso, Stream, Count


		Set fso = Server.CreateObject("Scripting.FileSystemObject")

		If fso.FileExists(Server.MapPath("banners.asp")) Then
			Set Stream = fso.OpenTextFile (Server.MapPath("banners.asp"), 2, False, False)
		Else
			Set Stream = fso.OpenTextFile (Server.MapPath("../banners.asp"), 2, False, False)
		End If


		OpenConnection

		Set rsBanners = DBC.Execute("SELECT COUNT(*) FROM Banners " & _
			"WHERE Approved = 1 AND DateDiff('d', ValidTo, Date()) < 0")

		Count = rsBanners(0)

		Set rsBanners = DBC.Execute("SELECT URL, Banner FROM Banners " & _
			"WHERE Approved = 1 AND DateDiff('d', ValidTo, Date()) < 0")

		If rsBanners.EOF Then
			Stream.WriteLine "<%"

'			Stream.WriteLine vbTab & "Response.Write " & Chr(34) & "<br><font face=Tahoma size=1 color=white>We will rotate your banner here for only $" & Chr(34) & " & BannerCost4aMonth & " & Chr(34) & " / month</font>" & Chr(34)

			Stream.Write "%"
			Stream.WriteLine ">"
		Else
			Stream.WriteLine "<%"

			Stream.WriteLine vbTab & "Session(Prefix & " & Chr(34) & "BannerID" & Chr(34) & ") = Str2Num(Session(Prefix & " & Chr(34) & "BannerID" & Chr(34) & ")) + 1" & vbNewLine

			Stream.WriteLine vbTab & "If Session(Prefix & " & Chr(34) & "BannerID" & Chr(34) & ") > " & Count & " Then"
			Stream.WriteLine vbTab & vbTab & "Session(Prefix & " & Chr(34) & "BannerID" & Chr(34) & ") = 1"
			Stream.WriteLine vbTab & "End If" & vbNewLine


			Stream.WriteLine vbTab & "Select Case Session(Prefix & " & Chr(34) & "BannerID" & Chr(34) & ")"

			Do While Not rsBanners.EOF
				i = i + 1
					Stream.WriteLine vbTab & vbTab & "Case " & i
					Stream.WriteLine vbTab & vbTab & vbTab & "Response.Write " & Chr(34) & "<a href=" & rsBanners("URL") & " target=_blank>" & Chr(34)
					Stream.WriteLine vbTab & vbTab & vbTab & "Response.Write " & Chr(34) & "<img src=" & rsBanners("Banner") & " border=0></a>" & Chr(34)
				rsBanners.MoveNext
			Loop

			Stream.WriteLine vbTab & "End Select" & vbNewLine


'			Stream.WriteLine vbTab & "Response.Write " & Chr(34) & "<br><font face=Tahoma size=1 color=white>We will rotate your banner here for only $" & Chr(34) & " & BannerCost4aMonth & " & Chr(34) & " / month</font>" & Chr(34)

			Stream.Write "%"
			Stream.WriteLine ">"
		End If


		Set Stream = Nothing
		Set fso = Nothing


		Application(Prefix & "BannersFileCreateOn") = Date()
	End Sub


	Function Escape (str)
		Dim i, Escaped

		Escaped = ""

		For i = 0 To Len(str) - 1
			Escaped = Escaped & "%" & Right("0" & Hex(Asc(Mid(str, i+1, 1))), 2)
		Next

		Escape = Escaped
	End Function
%>