This is the listing that someone posted claiming to have the admin.asp down perfect. I don't have the link but here is what I copied:
BTW - I don't use that. I attach to the tables directly with Access, or I gen T-SQL in excell to load data. The web interface is way to slow if you wnat to load lots of data...
OK, here is the listing:
<% option explicit
'Are we try to login?
If Request("password") = "secret" then
Session("AdminOK") = True
End If
'Are we trying to save a new department?
If Request("savenewdepartment") <> "" then
Dim NewDepartmentID
if request("DepartmentIDP") = "" then
NewDepartmentID =
Visit.Catalog.AddDepartment(Request("name"))
else
NewDepartmentID =
Visit.Catalog.AddDepartment(Request("name"), _
Request("DepartmentIDP"))
end if
End If
' are we trying to save a product?
If Request("saveproduct") <> "" then
' get the product back...
Set Product = Visit.Catalog.GetProductObject(Request("saveproduc t"))
' start looping the array of StructureIDs stored in the hidden fields...
Dim n
For n = 1 to Request("structureids").Count
' do we have a value, or is it null?
If Trim(Request("values")(n)) <> "" then
' store the value...
Product.Attrib(Request("structureids")(n)) = _
Request("values")(n)
Else
' set the value to null...
Product.Attrib(Request("structureids")(n)) = Empty
End If
Next
' cleanup...
Set Product = Nothing
End If
' are we trying to save a new product?
If Request("savenewproduct") <> "" Then
'we won't test this, we'll just try and add it...
Dim NewProductID
NewProductID = Visit.Catalog.AddProduct(Request("mfr"),
Request("name"), _
Request("details"), Request("department"),
Request("type"), _
Request("price"), Request("supplier"), Request("cost"),
_
Request("imageurl"), Request("desc"))
End If
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title><%=g_sitename%></title>
<LINK rel="stylesheet" type="text/css" href="../style.css">
</HEAD>
<BODY bgcolor=#ffffff>
Jo's Coffee Administration
<br><br>
<%
'Are we logged on
If Session("AdminOK") = "" then
'start a form
Response.Write "<center><form action="""
Response.Write Request("script_name")
Response.Write """ method=post>"
'Render a password box and button
Response.Write "Password:"
%>
<%
Response.Write "<input type=password name=password>"
%>
<%
Response.Write "<input type=submit value=""Login"">"
'end the form
Response.Write "</form></center>"
Else %>
<%
'admin content goes here
%>
<% Select Case LCase(Request.QueryString("action")) %>
<% ' do we want to edit a single product?
case "editproduct"%>
<form action="<%=request("script_name")%>" method=post id=form1
name=form1>
<center><table cellspacing=0 cellpadding=3>
<tr><td colspan=2 class=heading align=center>Edit
Product<br><br></td></tr>
<%
' get the product object...
Dim Product
Set Product = Visit.Catalog.GetProductObject(Request("id"))
' write the name of the product out...
Response.Write "<tr><td class=heading>"
Response.Write "Name: "
Response.Write "</td><td class=std>"
Response.Write Product.MfrName & " " & product.Name
Response.write "</td></tr>"
' get the attributes...
Dim Attributes, Value
Set Attributes = Product.Attributes
' loop the attributes rendering an edit field for each...
Do While Not Attributes.Eof
' render the name
Response.Write "<tr><td class=heading>"
Response.Write Attributes("Name") & ": "
Response.Write "</td><td>"
' get the current value for the attribute...
value = Product.Attrib(Attributes("StructureID"))
' what kind of edit field do we want?
Select Case Attributes("Datatype")
case atString
Response.Write "<input type=text name=values value="""
Response.write value
Response.Write """>"
case atLong
Response.Write "<input type=text name=values value="""
Response.write value
Response.Write """ size=5>"
case atDate
Response.Write "<input type=text name=values value="""
Response.write value
Response.Write """ size=10>"
case atDouble
Response.Write "<input type=text name=values value="""
Response.write value
Response.Write """ size=8>"
case atBoolean
Response.Write "<select name=values>"
Response.Write "<option value=0"
if value = 0 then Response.Write " selected"
Response.Write ">No</option>"
Response.Write "<option value=0"
if value = 1 then Response.Write " selected"
Response.Write ">Yes</option>"
Response.Write "</select>"
End Select
' we need to make an array holding the structure ID too...
Response.Write "<input type=hidden name=structureids value="""
Response.Write Attributes("StructureID")
Response.Write """>"
' finish the row...
Response.write "</td></tr>"
' next
Attributes.MoveNext
Loop
Attributes.Close
Set Attributes = Nothing
' finish...
Set Product = Nothing
%>
<tr><td colspan=2 align=center>
<br><input type=submit value="Save Changes" id=submit1 name=submit1>
</td></tr>
<input type=hidden name=saveproduct value= "<%=Request("id")%>" >
</table></center>
</form>
<%
'******BOTTOM OF PAGE 200**************
%>
<% ' do we want to edit products?
case "editproducts"
' display a list of the products for editing...
Dim Products
Set Products = Visit.Catalog.GetProducts
Do While Not Products.EOF
' draw the link...
Response.Write "<a href="""
Response.Write Request("script_name")
Response.Write "?action=editproduct&id=" & Products("ProductID")
Response.Write """>"
Response.Write Products("MfrName") & " " & Products("Name")
Response.Write "</a><br>"
' next
Products.MoveNext
Loop
Products.Close
Set Products = Nothing
%>
<% ' Do we want to add a department?
case "adddepartment" %>
<form action="<%=request("script_name")%>" method=post>
<center><table cellspacing=0 cellpadding=3>
<tr><td colspan=2 class=heading align=center>
Add Department
<br><br>
</td></tr>
<tr><td class=heading>Name: </td>
<td><input type=text name=name value="<%=request("name")%>"></tr>
<tr><td class=heading>Parent: </td>
<td>
<%
'page 133
RenderSelect Select_Departments, "DepartmentIDP"
%>
</tr>
<tr><td colspan=2 align=center>
<br><input type=submit value="Add Department">
</td></tr>
<input type=hidden name=savenewdepartment value=1>
</table></center>
</form>
<% ' do we want to add a product to the database...?
case "addproduct" %>
<form action="<%=request("script_name")%>" method=post>
<center><table cellspacing=0 cellpadding=3>
<tr><td colspan=2 class=heading align=center>Add
Product<br><br></td></tr>
<tr><td class=heading>Manufacturer: </td>
<td>
<% RenderSelect Select_Mfrs, "mfr" %>
</td></tr>
<tr><td class=heading>Name: </td>
<td>
<input type=text name=name value="<%=request("name")%>">
</td></tr>
<tr><td class=heading>Details: </td>
<td>
<textarea name=details rows=2 cols=40><%=request("details")%></textarea>
</td></tr>
<tr><td class=heading>Department: </td>
<td>
<% RenderSelect Select_Departments, "department" %>
</td></tr>
<tr><td class=heading>Type: </td>
<td>
<% RenderSelect Select_Types, "type" %>
</td></tr>
<tr><td class=heading>Price: </td>
<td>
<input type=text name=price value="<%=request("price")%>" size=10>
</td></tr>
<tr><td class=heading>Supplier: </td>
<td>
<% RenderSelect Select_Suppliers, "supplier" %>
</td></tr>
<tr><td class=heading>Cost: </td>
<td>
<input type=text name=cost value="<%=request("cost")%>" size=10>
</td></tr>
<tr><td class=std>Image URL: </td>
<td>
<input type=text name=imageurl value="<%=request("imageurl")%>">
</td></tr>
<tr><td class=std>Description: </td>
<td>
<textarea name=desc rows=5
cols=40><%=request("description")%></textarea>
</td></tr>
<tr><td colspan=2 align=center>
<br><input type=submit value="Add Product">
</td></tr>
<input type=hidden name=savenewproduct value=1>
</table></center>
</form>
<% case else
'Function to draw menu options
Sub RenderOption(name,action)
'Draw it out
Response.Write "<a href="""
Response.Write Request("script_name")
Response.Write "?action=" & action
Response.Write """>"
Response.Write name
Response.Write "</a><br>"
End Sub
'Render the menu options...
RenderOption "Add Department", "adddepartment"
RenderOption "Add Product", "addproduct"
RenderOption "Edit Products", "editproducts"
End Select %>
<%End If%>
<%
If Not IsEmpty(m_visit) Then
m_visit.ShutDown
Set m_visit = Nothing
End If
%>
</BODY>
</HTML>
|