%
'::::::::::::::::::: Copyright 2000-2002 Iatek. All Rights Reserved. ::::::::::::::::::
' Generated by ASPapp.com. More information can be obtained at http://www.aspapp.com
':::: page structure
'-- variables are declared (dim)
'-- the "request_" and "validate_" subroutines for form output
'-- the "db_" subroutines for database SQL statements
'-- key database fields are requested
'-- the action variable is requested and handled
'-- main section (this ignores value of action variable)
'-- HTML begins: The 'i_header.asp' include file is displayed
'-- forms and content are displayed
'-- HTML ends: The 'i_footer.asp' include file is displayed
'-- close database resources
':::: recommended DATABASE SCHEMA for this page
' Cats:
' CatID: int identity|int: 4
' CatTypeId: int identity|int: 4
' Cat: text|varchar: 50
' ParentId: int identity|int: 4
' RelatedId: int identity|int: 4
' Description: longtext|memo: 536870910
' Links:
' LinkId: int identity|int: 4
' user_id: int identity|int: 4
' Title: text|varchar: 60
' URL: text|varchar: 120
' Description: longtext|memo: 536870910
' LinkTypeID: int identity|int: 4
' CatID: int identity|int: 4
' RegionID: int identity|int: 4
' Impressions: int identity|int: 4
' ClickThrus: int identity|int: 4
' Email: text|varchar: 50
' DateAdded: datetime: 8
' DateExpire: datetime: 8
' Priority: smallint: 2
' DownloadURL: text|varchar: 120
' DownloadFee: text|varchar: 40
' AvgRating: decimal: 19
' Ratings: int identity|int: 4
' Display: byte: 1
' LinkTypes:
' LinkTypeID: int identity|int: 4
' LinkType: text|varchar: 50
dim keywords
dim search_sql
dim Cat
dim Cat1
dim Cat2
dim Cat3
dim CatID
dim CatId1
dim CatId2
dim CatId3
dim ParentId
dim CatsList
dim title_sql
dim SubCatId
dim SubCat
dim view_rootcats_sql
dim view_subcats_sql
dim DownloadURL
dim Email
dim LinkID
dim URL
dim Title
dim LinkType
dim Description
dim DateAdded
dim Priority
dim AvgRating
dim ClickThrus
dim Impressions
dim DownloadFee
dim view_links_sql
dim RelatedCat
dim RelatedCatId
dim view_relatedcats_sql
sub request_search
''' request form inputs from this form
keywords = request("keywords")
end sub
sub request_title
''' request form inputs from this form
Cat = request("Cat")
Cat1 = request("Cat1")
Cat2 = request("Cat2")
Cat3 = request("Cat3")
CatID = request("CatID")
CatId1 = request("CatId1")
CatId2 = request("CatId2")
CatId3 = request("CatId3")
ParentId = request("ParentId")
CatsList = request("CatsList")
end sub
sub request_view_rootcats
''' request form inputs from this form
SubCatId = request("SubCatId")
SubCat = request("SubCat")
Cat = request("Cat")
CatID = request("CatID")
end sub
sub request_view_subcats
''' request form inputs from this form
SubCatId = request("SubCatId")
SubCat = request("SubCat")
Cat = request("Cat")
CatID = request("CatID")
end sub
sub request_view_links
''' request form inputs from this form
DownloadURL = request("DownloadURL")
Email = request("Email")
LinkID = request("LinkID")
URL = request("URL")
Title = request("Title")
Cat = request("Cat")
LinkType = request("LinkType")
Description = request("Description")
DateAdded = request("DateAdded")
Priority = request("Priority")
AvgRating = request("AvgRating")
ClickThrus = request("ClickThrus")
Impressions = request("Impressions")
CatID = request("CatID")
DownloadFee = request("DownloadFee")
end sub
sub request_view_relatedcats
''' request form inputs from this form
Cat = request("Cat")
CatID = request("CatID")
RelatedCat = request("RelatedCat")
RelatedCatId = request("RelatedCatId")
end sub
sub validate_search
''' request and validate data entered from this form
keywords = trim(request("keywords"))
end sub
sub validate_title
''' request and validate data entered from this form
Cat = trim(request("Cat"))
Cat1 = trim(request("Cat1"))
Cat2 = trim(request("Cat2"))
Cat3 = trim(request("Cat3"))
CatID = trim(request("CatID"))
CatId1 = trim(request("CatId1"))
CatId2 = trim(request("CatId2"))
CatId3 = trim(request("CatId3"))
ParentId = trim(request("ParentId"))
CatsList = trim(request("CatsList"))
end sub
sub validate_view_rootcats
''' request and validate data entered from this form
SubCatId = trim(request("SubCatId"))
SubCat = trim(request("SubCat"))
Cat = trim(request("Cat"))
CatID = trim(request("CatID"))
end sub
sub validate_view_subcats
''' request and validate data entered from this form
SubCatId = trim(request("SubCatId"))
SubCat = trim(request("SubCat"))
Cat = trim(request("Cat"))
CatID = trim(request("CatID"))
end sub
sub validate_view_links
''' request and validate data entered from this form
DownloadURL = trim(request("DownloadURL"))
Email = trim(request("Email"))
LinkID = trim(request("LinkID"))
URL = trim(request("URL"))
Title = trim(request("Title"))
Cat = trim(request("Cat"))
LinkType = trim(request("LinkType"))
Description = trim(request("Description"))
DateAdded = trim(request("DateAdded"))
if DateAdded <> "" AND (not isdate(DateAdded)) then
error_list.add "587105date","Added must be a valid date (MM/DD/YY)."
b_error = true
end if
Priority = trim(request("Priority"))
AvgRating = trim(request("AvgRating"))
ClickThrus = trim(request("ClickThrus"))
Impressions = trim(request("Impressions"))
CatID = trim(request("CatID"))
DownloadFee = trim(request("DownloadFee"))
end sub
sub validate_view_relatedcats
''' request and validate data entered from this form
Cat = trim(request("Cat"))
CatID = trim(request("CatID"))
RelatedCat = trim(request("RelatedCat"))
RelatedCatId = trim(request("RelatedCatId"))
end sub
sub db_select_Title
Title_sql = "SELECT Cats.CatId, Cats.Cat As Cat, Cats1.Cat As Cat1, Cats1.CatId AS CatId1, Cats2.Cat AS Cat2, Cats2.CatId AS CatId2, Cats3.Cat AS Cat3, Cats3.CatId AS CatId3 FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) left JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats3.CatId = " & to_sql(CatID,"number") & ""
end sub
sub db_delete_Title
sql = "DELETE FROM " & _
""
'response.write sql
on error resume next
cn.Execute(sql)
if err.number <> 0 then
b_error = true
end if
on error goto 0
end sub
sub db_select_view_RootCats
view_RootCats_sql = "SELECT " & _
"Cats.Cat AS Cat, " & _
"Cats.CatId AS CatId," & _
"SubCats.Cat AS SubCat," & _
"SubCats.CatId AS SubCatId " & _
"FROM (Cats LEFT JOIN Cats AS SubCats ON SubCats.ParentId = Cats.CatId) " & _
"WHERE Cats.CatTypeId = 2 AND Cats.ParentId IS NULL ORDER BY Cats.Cat"
end sub
sub db_delete_view_RootCats
sql = "DELETE FROM " & _
""
'response.write sql
on error resume next
cn.Execute(sql)
if err.number <> 0 then
b_error = true
end if
on error goto 0
end sub
sub db_select_view_SubCats
view_SubCats_sql = "SELECT " & _
"Cats.Cat AS Cat, " & _
"Cats.CatId AS CatId," & _
"SubCats.Cat AS SubCat," & _
"SubCats.CatId AS SubCatId " & _
"FROM Cats LEFT JOIN Cats AS SubCats ON SubCats.ParentId = Cats.CatId " & _
"WHERE Cats.ParentId = " & to_sql(CatID,"number") & " " & _
"ORDER BY Cats.Cat"
end sub
sub db_delete_view_SubCats
sql = "DELETE FROM " & _
""
'response.write sql
on error resume next
cn.Execute(sql)
if err.number <> 0 then
b_error = true
end if
on error goto 0
end sub
sub db_select_view_Links
if do_search = "1" then
request_view_Links
view_Links_sql = "SELECT " & _
"AvgRating, " & _
"Links.CatId," & _
"Cat, " & _
"ClickThrus, " & _
"DownloadFee, " & _
"Links.Description AS Description, " & _
"DownloadURL, " & _
"Email, " & _
"DateAdded, " & _
"Impressions, " & _
"LinkID, " & _
"LinkType, " & _
"Priority, " & _
"Ratings, " & _
"Title, " & _
"URL FROM Cats, Links, LinkTypes " & _
" WHERE Cats.CatID=Links.CatID AND Display=1 AND Links.LinkTypeID=LinkTypes.LinkTypeID AND (Links.Title LIKE '%" & keywords & "%' OR Links.Description LIKE '%" & keywords & "%') ORDER BY Priority, AvgRating DESC, Title"
else
view_Links_sql = "SELECT " & _
"AvgRating, " & _
"Links.CatId," & _
"Cat, " & _
"ClickThrus, " & _
"DownloadFee, " & _
"Links.Description AS Description, " & _
"DownloadURL, " & _
"Email, " & _
"DateAdded, " & _
"Impressions, " & _
"LinkID, " & _
"LinkType, " & _
"Priority, " & _
"Ratings, " & _
"Title, " & _
"URL FROM Cats, Links, LinkTypes " & _
"WHERE Cats.CatID=Links.CatID AND " & _
"Links.LinkTypeID=LinkTypes.LinkTypeID AND " & _
"Display=1 AND " & _
"Links.CatID = " & to_sql(CatID,"number") & " " & _
"ORDER BY Priority, AvgRating DESC, Title"
end if
if request("sortby") <> "" AND inStr(lcase(view_Links_sql),"order by") = 0 then view_Links_sql = view_Links_sql + " ORDER BY " & request("sortby")
end sub
sub db_delete_view_Links
sql = "DELETE FROM Links" & _
" WHERE " & _
"CatID = " & to_sql(CatID,"number") & ""
'response.write sql
on error resume next
cn.Execute(sql)
if err.number <> 0 then
b_error = true
end if
on error goto 0
end sub
sub db_select_view_RelatedCats
view_RelatedCats_sql = "SELECT Cat AS RelatedCat, CatID AS RelatedCatId FROM Cats WHERE RelatedId = " & to_sql(CatID,"number") & ""
end sub
sub db_delete_view_RelatedCats
sql = "DELETE FROM " & _
""
'response.write sql
on error resume next
cn.Execute(sql)
if err.number <> 0 then
b_error = true
end if
on error goto 0
end sub
do_search = request("do_search")
''' request form keys and inputs
keywords = request("keywords")
CatID = request("CatID")
LinkID = request("LinkID")
':: request action
action = lcase(request("action"))
':: handle the action
select case action
case "select_title"
' select the requested key record from database
db_select_Title
case "select_view_rootcats"
' select the requested key record from database
db_select_view_RootCats
case "select_view_subcats"
' select the requested key record from database
db_select_view_SubCats
case "select_view_links"
' select the requested key record from database
if CatID <> "" then
db_select_view_Links
else
b_error = true
error_list.add "edit_view_Links", "Specify record to select."
end if
case "select_view_relatedcats"
' select the requested key record from database
db_select_view_RelatedCats
case "new"
view_Links_sql = "SELECT " & _
"AvgRating, " & _
"Links.CatId," & _
"Cat, " & _
"ClickThrus, " & _
"DownloadFee, " & _
"Links.Description AS Description, " & _
"DownloadURL, " & _
"Email, " & _
"DateAdded, " & _
"Impressions, " & _
"LinkID, " & _
"LinkType, " & _
"Priority, " & _
"Ratings, " & _
"Title, " & _
"URL FROM Cats,Links, LinkTypes " &_
"WHERE Cats.CatID=Links.CatID AND Links.LinkTypeID=LinkTypes.LinkTypeID AND Display=1 " & _
"AND (" & to_sql(date,"date") & " - DateAdded) < 5 ORDER BY DateAdded DESC"
case "hot"
view_Links_sql = "SELECT " & _
"AvgRating, " & _
"Links.CatId," & _
"Cat, " & _
"ClickThrus, " & _
"DownloadFee, " & _
"Links.Description AS Description, " & _
"DownloadURL, " & _
"Email, " & _
"DateAdded, " & _
"Impressions, " & _
"LinkID, " & _
"LinkType, " & _
"Priority, " & _
"Ratings, " & _
"Title, " & _
"URL FROM Cats,Links, LinkTypes " &_
"WHERE Cats.CatID=Links.CatID AND Links.LinkTypeID=LinkTypes.LinkTypeID AND Display=1 AND ClickThrus>1 " & _
"ORDER BY ClickThrus DESC"
end select
':: handle the default case(s) (ignores value of action parameter)
dim report_errors_email
report_errors_email = "mgraham@seakingwdc.org" 'Application("from_address") '"mgraham@seakingwdc.org"
if Keywords <> "" then
db_select_Title
db_select_view_SubCats
db_select_view_RelatedCats
db_select_view_Links
elseif CatID <> "" then
db_select_Title
db_select_view_SubCats
db_select_view_RelatedCats
db_select_view_Links
else
db_select_view_RootCats
end if
%>
<%
display_errs
display_msg
%>
<% if catid = "" then %>
<% else %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if Title_sql <> "" then
cmd.CommandText = Title_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
max_count = cInt(rs.PageCount)
num_recs = rs.RecordCount
rs.AbsolutePage = page_no
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0
%>
<%
if results = true then
%>
<%
else
%>
<%
end if
%>
<% end if %>
|
<% ctr = 0 %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if view_RootCats_sql <> "" then
cmd.CommandText = view_RootCats_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
max_count = cInt(rs.PageCount)
num_recs = rs.RecordCount
rs.AbsolutePage = page_no
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0
%>
<%
if results = true then
%>
<%
else
%>
<%
end if
%>
|
|
<% ctr = 1 %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if view_SubCats_sql <> "" then
cmd.CommandText = view_SubCats_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
max_count = cInt(rs.PageCount)
num_recs = rs.RecordCount
rs.AbsolutePage = page_no
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0
%>
<%
if results = true then
%>
<%
else
%>
<%
end if
%>
|
<% num_recs = 0 %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if view_Links_sql <> "" then
cmd.CommandText = view_Links_sql
rs.Filter = ""
if LinkID <> "" then rs.Filter = "LinkID = " & to_sql(LinkID,"number")
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
max_count = cInt(rs.PageCount)
num_recs = rs.RecordCount
rs.AbsolutePage = page_no
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0
%>
<%
if results = true then
%>
<%
else
%>
<%
end if
%>
<% if action = "" then %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if view_RelatedCats_sql <> "" then
cmd.CommandText = view_RelatedCats_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
max_count = cInt(rs.PageCount)
num_recs = rs.RecordCount
rs.AbsolutePage = page_no
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0
%>
<%
if results = true then
%>
F
<%
else
%>
<%
end if
%>
<% end if %>
<%
':: assure that any db resources are freed
on error resume next
rs.Close
set rs = NOTHING
cn.Close
set cn = NOTHING
user_cn.Close
set user_cn = NOTHING
on error goto 0
%>