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/inccats.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,allcats,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 = ""
alldata = ""
if request.form("act")="changepos" then
	currentorder = Int(Request.Form("selectedq"))
	neworder = Int(Request.Form("newval"))
	if subCats then
		sSQL = "SELECT sectionID,sectionName,sectionDescription,tsName,tsID FROM sections LEFT OUTER JOIN topsections ON topsections.tsID=sections.topSection ORDER BY tsOrder,sectionOrder"
	else
		sSQL = "SELECT sectionID,sectionName,sectionDescription FROM sections ORDER BY sectionOrder"
	end if
	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 sections SET sectionOrder="&theorder&" WHERE sectionID="&alldata(0,rowcounter)
		cnn.Execute(sSQL)
	NEXT
	response.write "<meta http-equiv=""refresh"" content=""1; url=admincats.asp"">"
elseif request.form("posted")="1" then
	if request.form("act")="delete" then
		sSQL = "DELETE FROM cpnAssign WHERE cpaType=1 AND cpaAssignment='"&request.form("id")&"'"
		cnn.Execute(sSQL)
		sSQL = "DELETE FROM sections WHERE sectionID=" & request.form("id")
		cnn.Execute(sSQL)
		sSQL = "DELETE FROM multiSections WHERE pSection=" & request.form("id")
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admincats.asp"">"
	elseif request.form("act")="domodify" then
		sSQL = "UPDATE sections SET sectionName='"&replace(request.form("secname"),"'","''")&"',sectionDescription='"&replace(request.form("secdesc"),"'","''")&"',topSection="&request.form("topSection")&",sectionImage='"&replace(request.form("secimage"),"'","''")&"' WHERE sectionID="&Request.Form("id")
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admincats.asp"">"
	elseif request.form("act")="doaddnew" then
		sSQL = "INSERT INTO sections (sectionName,sectionDescription,topSection,sectionImage) VALUES ('"&replace(request.form("secname"),"'","''")&"','"&replace(request.form("secdesc"),"'","''")&"',"&request.form("topSection")&",'"&replace(request.form("secimage"),"'","''")&"')"
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admincats.asp"">"
	elseif request.form("act")="dodiscounts" then
		sSQL = "INSERT INTO cpnAssign (cpaCpnID,cpaType,cpaAssignment) VALUES ("&request.form("assdisc")&",1,'"&request.form("id")&"')"
		cnn.Execute(sSQL)
		response.write "<meta http-equiv=""refresh"" content=""3; url=admincats.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=admincats.asp"">"
	end if
end if
%>
<script Language="JavaScript">
<!--
function formvalidator(theForm)
{
  if (theForm.secname.value == "")
  {
    alert("Please enter a value in the field \"Category Name\".");
    theForm.secname.focus();
    return (false);
  }
  if (theForm.secdesc.value.length > 255)
  {
    alert("A maximum of 255 characters are allowed in the field \"Category Description\".");
    theForm.secdesc.focus();
    return (false);
  }
<% if subCats then %>
  if (theForm.topSection.selectedIndex == 0)
  {
    alert("Please select a value from \"Top Category\".");
    theForm.topSection.focus();
    return (false);
  }
<% end if %>
  return (true);
}
//-->
</script>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="" align="center">
<% if request.form("posted")="1" AND request.form("act")="modify" then
		sSQL = "SELECT sectionID,sectionName,sectionDescription,topSection,sectionImage FROM sections WHERE sectionID="&Request.Form("id")
		rs.Open sSQL,cnn,0,1
		alldata=rs.getrows
		rs.Close
		if subCats then
			sSQL = "SELECT tsID,tsName FROM topsections ORDER BY tsName"
			rs.Open sSQL,cnn,0,1
			allcats=rs.getrows
			rs.Close
		end if
%>
        <tr>
		<form name="mainform" method="POST" action="admincats.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="2" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Use this page to update your store categories.</b><br>&nbsp;</td>
			  </tr>
			  <tr>
				<td width="50%" align="center" valign="top"><b>Category Name</b>
                </td>
				<td width="50%" align="center" valign="top"><b>Category Description</b>
                </td>
			  </tr>
			  <tr>
				<td width="50%" align="center" valign="top"><input type="text" name="secname" size="30" value="<%=replace(alldata(1,0),"""","&quot;")%>">
                </td>
				<td width="50%" rowspan="5" align="center" valign="top"><textarea name="secdesc" cols="30" rows="6" wrap=virtual><%=alldata(2,0)%></textarea>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Category Image</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><input type="text" name="secimage" size="30" value="<%if NOT IsNull(alldata(4,0)) then response.write replace(alldata(4,0),"""","&quot;")%>">
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Top Category</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><%
						if subCats then
							response.write "<select name='topSection' size='1'>"
							response.write "<option value='0'>Please Select</option>"
							for rowcounter=0 to UBOUND(allcats,2)
								response.write "<option value='"&allcats(0,rowcounter)&"'"
								if Int(allcats(0,rowcounter))=Int(alldata(3,0)) then response.write " selected"
								response.write ">"&allcats(1,rowcounter)&"</option>"&vbCrLf
							next
							response.write "</select>"
						else
							response.write "Not Applicable<input type='hidden' name='topSection' value='0'>"
						end if %>
                </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
		if subCats then
			sSQL = "SELECT tsID,tsName FROM topsections ORDER BY tsName"
			rs.Open sSQL,cnn,0,1
			if NOT rs.EOF then allcats=rs.getrows
			rs.Close
		end if
%>
        <tr>
		        <form name="mainform" method="POST" action="admincats.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="2" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Enter your new category details here.</b><br>&nbsp;</td>
			  </tr>
			  <tr>
				<td width="50%" align="center" valign="top"><b>Category Name</b>
                </td>
				<td width="50%" align="center" valign="top"><b>Category Description</b>
                </td>
			  </tr>
			  <tr>
				<td width="50%" align="center" valign="top"><input type="text" name="secname" size="30" value="">
                </td>
				<td width="50%" rowspan="5" align="center" valign="top"><textarea name="secdesc" cols="30" rows="6" wrap=virtual></textarea>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Category Image</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><input type="text" name="secimage" size="30" value="">
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><b>Top Category</b>
                </td>
			  </tr>
			  <tr>
				<td align="center" valign="top"><%
						if subCats then
							response.write "<select name='topSection' size='1'>"
							response.write "<option value='0'>Please Select</option>"
							if IsArray(allcats) then
								for rowcounter=0 to UBOUND(allcats,2)
									response.write "<option value='"&allcats(0,rowcounter)&"'"
									response.write ">"&allcats(1,rowcounter)&"</option>"&vbCrLf
								next
							end if
							response.write "</select>"
						else
							response.write "Not Applicable<input type='hidden' name='topSection' value='0'>"
						end if %>
                </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 sectionName FROM sections WHERE sectionID="&request.form("id")
		rs.Open sSQL,cnn,0,1
		thisname=rs("sectionName")
		rs.Close
		alldata=""
		sSQL = "SELECT cpaID,cpaCpnID,cpnWorkingName,cpnSitewide,cpnEndDate,cpnType FROM cpnAssign INNER JOIN coupons ON cpnAssign.cpaCpnID=coupons.cpnID WHERE cpaType=1 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="admincats.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 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="admincats.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="2" bgcolor="">
			  <tr> 
                <td width="100%" colspan="2" align="center"><br><b>Update Successful !</b><br><br>You will now be forwarded  
				to the category admin page.<br><br>
                        If that does not happen automatically then please <A href="admincats.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="2" 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,minpos,maxpos)
	Dim reqtext,i
	reqtext="<select name='newpos" & currpos & "' size='1' onChange='javascript:validate_index("&currpos&");'>"
	for i = minpos to maxpos
		reqtext = reqtext & "<option value='"&i&"'"
		if currpos=i then reqtext=reqtext&" selected"
		reqtext = reqtext & ">"&i&"</option>"
	next
	writeposition = reqtext & "</select>"
end function
		if subCats then
			sSQL = "SELECT sectionID,sectionName,sectionDescription,tsName,tsID FROM sections LEFT OUTER JOIN topsections ON topsections.tsID=sections.topSection ORDER BY tsOrder,sectionOrder"
		else
			sSQL = "SELECT sectionID,sectionName,sectionDescription FROM sections ORDER BY sectionOrder"
		end if
		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=1"
		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+"[mainform.newpos"+currindex+".selectedIndex].value");
	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="admincats.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="2" bgcolor="">
			  <tr> 
                <td width="100%" colspan="5" align="center"><br><b>Use this page to update your store categories.</b><br>&nbsp;</td>
			  </tr>
			  <tr>
				<td width="5%" align="center"><b>Order</b></td>
				<td width="80%" align="left"><b>Category Name</b></td>
				<td width="5%" align="center"><b>Discounts</b></td>
				<td width="5%" align="center"><b>Modify</b></td>
				<td width="5%" align="center"><b>Delete</b></td>
			  </tr>
<%
	if IsArray(alldata) then
		currts=-1
		firstid=1
		lastid=UBOUND(alldata,2)+1
		for rowcounter=0 to UBOUND(alldata,2)
			if subCats then
				if currts<>alldata(4,rowcounter) then
					response.write "<tr><td align='center' colspan='5'>"
					if currts<>-1 then response.write "<hr width='50%'><br>"
					response.write "<strong>"
					if subCats then
						if IsNull(alldata(3,rowcounter)) then
							response.write "<font color='#FF0000'>Error, no Top Category</font>"
						else
							response.write "== " & alldata(3,rowcounter) & " =="
						end if
					end if
					response.write "</strong></td></tr>"
					currts=alldata(4,rowcounter)
					firstid=rowcounter+1
					lastid=rowcounter
					for index=rowcounter to UBOUND(alldata,2)
						if currts=alldata(4,index) then lastid=lastid+1 else exit for
					next
				end if
			end if
%>
<tr>
<td align="right"><%=writeposition(rowcounter+1,firstid,lastid)%>
</td>
<td><%=alldata(1,rowcounter) & " (" & alldata(0,rowcounter) & ")"%></td>
<td><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" value="Assign" onClick="discounts('<%=alldata(0,rowcounter)%>')"></td>
<td><input type=button value="Modify" onClick="modrec('<%=alldata(0,rowcounter)%>')"></td>
<td><input type=button value="Delete" onClick="delrec('<%=alldata(0,rowcounter)%>')"></td></tr>
<%		next
	else
%>
			  <tr> 
                <td width="100%" colspan="5" align="center"><br><b>There are no 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 category</b>&nbsp;&nbsp;<input type="button" value="New 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>