HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/web/homefly/inc/inctopcats.asp
<%
'This code is copyright (c) Internet Business Solutions SL, all rights reserved.
'The contents of this file are protect under law as the intellectual property
'of Internet Business Solutions SL. Any use, reproduction, disclosure or copying
'of any kind without the express and written permission of Internet Business 
'Solutions SL is forbidden.
'Author: Vince Reid, vince@virtualred.net
if Session("loggedon") <> "virtualstore" then response.end
Dim sSQL,rs,alldata,alladmin,success,cnn,rowcounter,errmsg,subCats
success=true
Set rs = Server.CreateObject("ADODB.RecordSet")
Set cnn=Server.CreateObject("ADODB.Connection")
cnn.open sDSN
sSQL = "SELECT adminSubCats FROM admin"
rs.Open sSQL,cnn,0,1
subCats=(Int(rs("adminSubCats"))=1)
rs.Close
sSQL = ""
if request.form("act")="changepos" then
	currentorder = Int(Request.Form("selectedq"))
	neworder = Int(Request.Form("newval"))
	sSQL = "SELECT tsID FROM topsections ORDER BY tsOrder"
	rs.Open sSQL,cnn,0,1
	alldata=rs.getrows
	rs.Close
	FOR rowcounter=0 TO ubound(alldata,2)
		theorder = rowcounter+1
		if currentorder = theorder then
			theorder = neworder
		elseif (currentorder > theorder) AND (neworder <= theorder) then
			theorder = theorder + 1
		elseif (currentorder < theorder) AND (neworder >= theorder) then
			theorder = theorder - 1
		end if
		sSQL="UPDATE topsections SET tsOrder="&theorder&" WHERE tsID="&alldata(0,rowcounter)
		cnn.Execute(sSQL)
	NEXT
	response.write "<meta http-equiv=""refresh"" content=""2; url=admintopcats.asp"">"
elseif request.form("posted")="1" then
	if request.form("act")="delete" then
		sSQL = "DELETE FROM cpnAssign WHERE cpaType=0 AND cpaAssignment='"&request.form("id")&"'"
		cnn.Execute(sSQL)
		sSQL = "DELETE FROM topsections WHERE tsID=" & request.form("id")
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admintopcats.asp"">"
	elseif request.form("act")="domodify" then
		sSQL = "UPDATE topsections SET tsName='"&replace(request.form("secname"),"'","''")&"',tsDescription='"&replace(request.form("secdesc"),"'","''")&"',tsImage='"&replace(request.form("secimage"),"'","''")&"' WHERE tsID="&Request.Form("id")
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admintopcats.asp"">"
	elseif request.form("act")="doaddnew" then
		sSQL = "SELECT MAX(tsOrder) AS mxOrder FROM topsections"
		rs.Open sSQL,cnn,0,1
		mxOrder = rs("mxOrder")
		rs.Close
		if IsNull(mxOrder) OR mxOrder="" then mxOrder=1 else mxOrder=mxOrder+1
		sSQL = "INSERT INTO topsections (tsName,tsDescription,tsImage,tsOrder) VALUES ('"&replace(request.form("secname"),"'","''")&"','"&replace(request.form("secdesc"),"'","''")&"','"&replace(request.form("secimage"),"'","''")&"',"&mxOrder&")"
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admintopcats.asp"">"
	elseif request.form("act")="dodiscounts" then
		sSQL = "INSERT INTO cpnAssign (cpaCpnID,cpaType,cpaAssignment) VALUES ("&request.form("assdisc")&",0,'"&request.form("id")&"')"
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admintopcats.asp"">"
	elseif request.form("act")="deletedisc" then
		sSQL = "DELETE FROM cpnAssign WHERE cpaID="&request.form("id")
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admintopcats.asp"">"
	end if
end if
%>
<script Language="JavaScript">
<!--
function formvalidator(theForm)
{
  if (theForm.secname.value == "")
  {
    alert("Please enter a value in the field \"Top Category Name\".");
    theForm.secname.focus();
    return (false);
  }
  if (theForm.secdesc.value.length > 255)
  {
    alert("A maximum of 255 characters are allowed in the field \"Top Category Description\".");
    theForm.secdesc.focus();
    return (false);
  }
  return (true);
}
//-->
</script>
      <table border="0" cellspacing="<%=maintablespacing%>" cellpadding="<%=maintablepadding%>" width="<%=maintablewidth%>" bgcolor="<%=maintablebg%>" align="center">
<% if request.form("posted")="1" AND request.form("act")="modify" then 
		sSQL = "SELECT tsID,tsName,tsDescription,tsImage FROM topsections WHERE tsID="&Request.Form("id")
		rs.Open sSQL,cnn,0,1
		alldata=rs.getrows
		rs.Close
%>
        <tr>
		<form name="mainform" method="POST" action="admintopcats.asp" onSubmit="return formvalidator(this)">
		  <td width="100%">
			<input type="hidden" name="posted" value="1">
			<input type="hidden" name="act" value="domodify">
			<input type="hidden" name="id" value="<%=Request.Form("id")%>">
            <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Use this page to update your top categories.</b><br>&nbsp;</td>
			  </tr>
			  <tr>
				<td width="40%" align="center" valign="top"><b>Top Category Name</b>
                </td>
				<td width="60%" align="center" valign="top"><b>Top Category Description</b>
                </td>
			  </tr>
			  <tr>
				<td width="40%" align="center" valign="top"><input type="text" name="secname" size="30" value="<%=replace(alldata(1,0),"""","&quot;")%>">
                </td>
				<td width="60%" rowspan="3" align="center" valign="top"><textarea name="secdesc" cols="30" rows="5" wrap=virtual><%=alldata(2,0)%></textarea>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Top Category Image</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><input type="text" name="secimage" size="30" value="<%if NOT IsNull(alldata(3,0)) then response.write replace(alldata(3,0),"""","&quot;")%>">
                </td>
			  </tr>
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><input type="submit" value="Submit"><br>&nbsp;</td>
			  </tr>
			  <tr> 
                <td width="100%" colspan="2" align="center"><br>
                          <a href="admin.asp"><b>Admin Home</b></a><br>
                          &nbsp;</td>
			  </tr>
            </table></td>
		  </form>
        </tr>
<% elseif request.form("posted")="1" AND request.form("act")="addnew" then %>
        <tr>
		<form name="mainform" method="POST" action="admintopcats.asp" onSubmit="return formvalidator(this)">
		  <td width="100%">
			<input type="hidden" name="posted" value="1">
			<input type="hidden" name="act" value="doaddnew">
            <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Enter your new top category details here.</b><br>&nbsp;</td>
			  </tr>
			  <tr>
				<td width="40%" align="center" valign="top"><b>Top Category Name</b>
                </td>
				<td width="60%" align="center" valign="top"><b>Top Category Description</b>
                </td>
			  </tr>
			  <tr>
				<td width="40%" align="center" valign="top"><input type="text" name="secname" size="30" value="">
                </td>
				<td width="60%" rowspan="3" align="center" valign="top"><textarea name="secdesc" cols="30" rows="5" wrap=virtual></textarea>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Top Category Image</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><input type="text" name="secimage" size="30" value="">
                </td>
			  </tr>
			  <tr>
                <td width="100%" colspan="2" align="center"><br><input type="submit" value="Submit"><br>&nbsp;</td>
			  </tr>
			  <tr> 
                <td width="100%" colspan="2" align="center"><br>
                          <a href="admin.asp"><b>Admin Home</b></a><br>
                          &nbsp;</td>
			  </tr>
            </table></td>
		  </form>
        </tr>
<% elseif request.form("act")="discounts" then 
		sSQL = "SELECT tsName FROM topsections WHERE tsID="&request.form("id")
		rs.Open sSQL,cnn,0,1
		thisname=rs("tsName")
		rs.Close
		alldata=""
		sSQL = "SELECT cpaID,cpaCpnID,cpnWorkingName,cpnSitewide,cpnEndDate,cpnType FROM cpnAssign INNER JOIN coupons ON cpnAssign.cpaCpnID=coupons.cpnID WHERE cpaType=0 AND cpaAssignment='" & request.form("id") & "'"
		rs.Open sSQL,cnn,0,1
		if NOT rs.EOF then alldata=rs.GetRows
		rs.Close
		alldata2=""
		tdt = Date()
		sSQL = "SELECT cpnID,cpnWorkingName,cpnSitewide FROM coupons WHERE cpnSitewide=0 AND cpnEndDate >="&datedelim&DatePart("m",tdt) & "/" & DatePart("d",tdt) & "/" & DatePart("yyyy",tdt)&datedelim
		rs.Open sSQL,cnn,0,1
		if NOT rs.EOF then alldata2=rs.GetRows
		rs.Close
%>
<script language="JavaScript">
<!--
function delrec(id) {
cmsg = "Sure you want to delete this assignment?\n"
if (confirm(cmsg)) {
	document.mainform.id.value = id;
	document.mainform.act.value = "deletedisc";
	document.mainform.submit();
}
}
// -->
</script>
        <tr>
		<form name="mainform" method="POST" action="admintopcats.asp">
		  <td width="100%">
			<input type="hidden" name="posted" value="1">
			<input type="hidden" name="act" value="dodiscounts">
			<input type="hidden" name="id" value="<%=request.form("id")%>">
            <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="4" align="center"><b>Assign Discounts to Top Category &quot;<%=thisname%>&quot;.</b><br>&nbsp;</td>
			  </tr>
<%	gotone=false
	if IsArray(alldata2) then
		thestr = "<tr><td colspan='4' align='center'>Assign Discount / Coupon: <select name='assdisc' size='1'>"
		for index=0 to UBOUND(alldata2,2)
			alreadyassign=false
			if IsArray(alldata) then
				for index2=0 to UBOUND(alldata,2)
					if alldata2(0,index)=alldata(1,index2) then alreadyassign=true
				next
			end if
			if NOT alreadyassign then
				thestr = thestr & "<option value='"&alldata2(0,index)&"'>"&alldata2(1,index)&"</option>" & vbCrLf
				gotone=true
			end if
		next
		thestr = thestr & "</select> <input type='submit' value='Go'></td></tr>"
	end if
	if gotone then
		response.write thestr
	else
%>
			  <tr> 
                <td width="100%" colspan="4" align="center"><br><b>No coupons / discounts are available to assign</td>
			  </tr>
<%
	end if
	if IsArray(alldata) then
%>
			  <tr> 
                <td width="100%" colspan="4" align="center"><br><b>Discounts currently assigned to &quot;<%=thisname%>&quot;.</b><br>&nbsp;</td>
			  </tr>
			  <tr> 
                <td><b>Working Name</b></td>
				<td><b>Discount Type</b></td>
				<td><b>Expires</b></td>
				<td align="center"><b>Delete</b></td>
			  </tr>
<%
		for index=0 to UBOUND(alldata,2)
			prefont = ""
			postfont = ""
			if alldata(3,index)=1 OR alldata(4,index)-Date() < 0 then
				prefont = "<font color=""#FF0000"">"
				postfont = "</font>"
			end if
%>
			  <tr> 
                <td><%=prefont & alldata(2,index) & postfont %></td>
				<td><%	if alldata(5,index)=0 then
							response.write prefont & "Free Standard Shipping" & postfont
						elseif alldata(5,index)=1 then
							response.write prefont & "Flat Rate Discount" & postfont
						elseif alldata(5,index)=2 then
							response.write prefont & "Percentage Discount" & postfont
						end if %></td>
				<td><%=prefont & alldata(4,index) & postfont%></td>
				<td align="center"><input type="button" name="discount" value="Delete Assignment" onClick="delrec('<%=alldata(0,index)%>')"></td>
			  </tr>
<%
		next
	else
%>
			  <tr> 
                <td width="100%" colspan="4" align="center"><br><b>No coupons / discounts currently assigned</td>
			  </tr>
<%
	end if
%>
			  <tr>
                <td width="100%" colspan="4" align="center"><br>&nbsp;</td>
			  </tr>
			  <tr> 
                <td width="100%" colspan="4" align="center"><br>
                          <a href="admin.asp"><b>Admin Home</b></a><br>
                          &nbsp;</td>
			  </tr>
            </table></td>
		  </form>
        </tr>
<% elseif request.form("act")="changepos" then %>
        <tr>
          <td width="100%" align="center">
			<p>&nbsp;</p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
			<p><b>Updating . . . . . . . </b></font></p>
			<p>&nbsp;</p>
			<p>If you are not automatically forwarded, please <a href="admintopcats.asp">click here</a>.</p>
			<p>&nbsp;</p>
			<p>&nbsp;</p>
		  </td>
		</tr>
<% elseif request.form("posted")="1" AND success then %>
        <tr>
          <td width="100%">
			<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Update Successful !</b><br><br>You will now be forwarded  
				to the top categories admin page.<br><br>
                        If that does not happen automatically then please <A href="admintopcats.asp"><b>click 
                        here</b></a>.<br>
                        <br>
				<img src="../images/clearpixel.gif" width="350" height="3">
                </td>
			  </tr>
			</table></td>
        </tr>
<% elseif request.form("posted")="1" then %>
        <tr>
          <td width="100%">
			<table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><font color="#FF0000"><b>Operation Failed ! !</b></font><br><br><%=errmsg%><br><br>
				<a href="javascript:history.go(-1)"><b>Click here to go back.</b></a></td>
			  </tr>
			</table></td>
        </tr>
<% else 
function writeposition(currpos,maxpos)
	Dim reqtext,i
	reqtext="<select name='newpos" & currpos & "' size='1' onChange='javascript:validate_index("&currpos&");'>"
	for i = 1 to maxpos
		reqtext = reqtext & "<option value='"&i&"'"
		if currpos=i then reqtext=reqtext&" selected"
		reqtext = reqtext & ">"&i&"</option>"
	next
	writeposition = reqtext & "</select>"
end function
		sSQL = "SELECT tsID,tsName,tsDescription FROM topsections ORDER BY tsOrder"
		rs.Open sSQL,cnn,0,1
		if NOT rs.EOF then alldata=rs.getrows
		rs.Close
		allcoupon=""
		sSQL = "SELECT DISTINCT cpaAssignment FROM cpnAssign WHERE cpaType=0"
		rs.Open sSQL,cnn,0,1
		if NOT rs.EOF then allcoupon=rs.getrows
		rs.Close
%>
<script language="JavaScript">
<!--
function validate_index(currindex)
{
	var i = eval("mainform.newpos"+currindex+".selectedIndex")+1;
	mainform.newval.value = i;
	mainform.selectedq.value = currindex;
	mainform.act.value = "changepos";
	if(i==mainform.selectedq.value){
		alert("No change in position");
		return (false);
	}
	mainform.submit();
}
function modrec(id) {
	document.mainform.id.value = id;
	document.mainform.act.value = "modify";
	document.mainform.submit();
}
function newrec(id) {
	document.mainform.id.value = id;
	document.mainform.act.value = "addnew";
	document.mainform.submit();
}
function discounts(id) {
	document.mainform.id.value = id;
	document.mainform.act.value = "discounts";
	document.mainform.submit();
}
function delrec(id) {
cmsg = "Sure you want to delete this record?\n"
if (confirm(cmsg)) {
	document.mainform.id.value = id;
	document.mainform.act.value = "delete";
	document.mainform.submit();
}
}
// -->
</script>
        <tr>
		  <form name="mainform" method="POST" action="admintopcats.asp">
		  <td width="100%">
			<input type="hidden" name="posted" value="1">
			<input type="hidden" name="act" value="xxxxx">
			<input type="hidden" name="id" value="xxxxx">
			<input type="hidden" name="selectedq" value="1">
			<input type="hidden" name="newval" value="1">
            <table width="100%" border="0" cellspacing="0" cellpadding="3" bgcolor="">
			  <tr> 
                <td width="100%" colspan="5" align="center"><br><b>Use this page to update your top categories.</b><br>&nbsp;</td>
			  </tr>

			  <tr> 
                <td width="100%" colspan="5" align="left"><br>Your admin settings <b>are<% if NOT subCats then response.write " NOT"%></b> set to use top categories and sub categories.<br>
				<% if NOT subCats then %>
				This means that these settings will be ignored.<br>
                          <% end if %> To change this please <a href="adminmain.asp">click 
                          here</a>.<br>
                          &nbsp;</td>
			  </tr>
			  <tr>
				<td width="10%" align="center"><b>Order</b></td>
				<td width="60%" align="left"><b>Top Category Name</b></td>
				<td width="10%" align="center"><b>Discounts</b></td>
				<td width="10%" align="center"><b>Modify</b></td>
				<td width="10%" align="center"><b>Delete</b></td>
			  </tr>
<%
	if IsArray(alldata) then
		for rowcounter=0 to UBOUND(alldata,2)
%>
			  <tr>
				<td align="center"><%=writeposition(rowcounter+1,UBOUND(alldata,2)+1)%>
                </td>
				<td><%=alldata(1,rowcounter)%>
                </td>
				<td align="center"><input <%
				if IsArray(allcoupon) then
					for index=0 to UBOUND(allcoupon,2)
						if Int(allcoupon(0,index))=alldata(0,rowcounter) then
							response.write "style=""color: #FF0000"""
							exit for
						end if
					next
				end if
				%> type="button" name="discount" value="Assign" onClick="discounts('<%=alldata(0,rowcounter)%>')">
                </td>
				<td align="center"><input type="button" name="modify" value="Modify" onClick="modrec('<%=alldata(0,rowcounter)%>')">
                </td>
				<td align="center"><input type="button" name="delete" value="Delete" onClick="delrec('<%=alldata(0,rowcounter)%>')">
                </td>
			  </tr>
<%		next
	else
%>
			  <tr> 
                <td width="100%" colspan="5" align="center"><br><b>There are no top categories currently configured.<br>&nbsp;</td>
			  </tr>
<%
	end if
%>
			  <tr> 
                <td width="100%" colspan="5" align="center"><br><b>Click here to add a new top category</b>&nbsp;&nbsp;<input type="button" value="New Top Category" onClick="newrec()"><br>&nbsp;</td>
			  </tr>
			  <tr> 
                <td width="100%" colspan="5" align="center"><br>
                          <a href="admin.asp"><b>Admin Home</b></a><br>
				<img src="../images/clearpixel.gif" width="350" height="3"></td>
			  </tr>
            </table></td>
		  </form>
        </tr>
<% end if
cnn.Close
%>
      </table>