%
check_security(1)
dim whos_online
dim ctr
dim CatID
dim LinkID
dim Title
dim check_ctr
dim whats_hot_sql
dim whats_cool_sql
dim survey_id
dim survey
dim feature
dim question_id
dim question
dim view_results
dim survey_sql
dim default_section
dim text
dim ContentID
dim ContentTitle
dim Author
dim ShortDesc
dim weekly_feature_sql
dim content_field
dim TopicId
dim ForumId
dim user_id
dim Subject
dim DateLast
dim Replies
dim user_name
dim disc_topics_sql
sub request_whats_hot
''' request form inputs from this form
ctr = request("ctr")
CatID = request("CatID")
LinkID = request("LinkID")
Title = request("Title")
check_ctr = request("check_ctr")
end sub
sub request_whats_cool
''' request form inputs from this form
CatID = request("CatID")
LinkID = request("LinkID")
Title = request("Title")
end sub
sub request_survey
''' request form inputs from this form
survey_id = request("survey_id")
survey = request("survey")
feature = request("feature")
question_id = request("question_id")
question = request("question")
view_results = request("view_results")
end sub
sub request_weekly_feature
''' request form inputs from this form
ContentID = request("ContentID")
ContentTitle = request("ContentTitle")
Author = request("Author")
ShortDesc = request("ShortDesc")
end sub
sub request_disc_topics
''' request form inputs from this form
TopicId = request("TopicId")
ForumId = request("ForumId")
user_id = request("user_id")
Subject = request("Subject")
DateLast = request("DateLast")
Replies = request("Replies")
user_name = request("user_name")
end sub
sub validate_whats_hot
''' request and validate data entered from this form
ctr = trim(request("ctr"))
CatID = trim(request("CatID"))
LinkID = trim(request("LinkID"))
Title = trim(request("Title"))
check_ctr = trim(request("check_ctr"))
end sub
sub validate_whats_cool
''' request and validate data entered from this form
CatID = trim(request("CatID"))
LinkID = trim(request("LinkID"))
Title = trim(request("Title"))
end sub
sub validate_survey
''' request and validate data entered from this form
survey_id = trim(request("survey_id"))
survey = trim(request("survey"))
feature = trim(request("feature"))
question_id = trim(request("question_id"))
question = trim(request("question"))
view_results = trim(request("view_results"))
end sub
sub validate_weekly_feature
''' request and validate data entered from this form
ContentID = trim(request("ContentID"))
ContentTitle = trim(request("ContentTitle"))
Author = trim(request("Author"))
ShortDesc = trim(request("ShortDesc"))
end sub
sub validate_disc_topics
''' request and validate data entered from this form
TopicId = trim(request("TopicId"))
ForumId = trim(request("ForumId"))
user_id = trim(request("user_id"))
Subject = trim(request("Subject"))
DateLast = trim(request("DateLast"))
Replies = trim(request("Replies"))
user_name = trim(request("user_name"))
end sub
sub db_select_whats_hot
whats_hot_sql = "SELECT TOP 10 " & _
"CatID, " & _
"DateAdded, " & _
"LinkID, " & _
"Title FROM Links " & _
"WHERE Display=1 " & _
"ORDER BY ClickThrus DESC "
end sub
sub db_delete_whats_hot
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_whats_cool
whats_cool_sql = "SELECT TOP 10 " & _
"CatID, " & _
"DateAdded, " & _
"LinkID, " & _
"Title FROM Links " & _
"WHERE Display=1 " & _
"ORDER BY AvgRating DESC"
end sub
sub db_delete_whats_cool
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_survey
survey_sql = "SELECT " & _
"SurveyQuestions.survey_id, " & _
"Surveys.survey, " & _
"Surveys.feature, " & _
"SurveyQuestions.question_id, " & _
"SurveyQuestions.question FROM (Surveys LEFT JOIN SurveyQuestions ON Surveys.survey_id = SurveyQuestions.survey_id) " & _
"WHERE Surveys.feature = 1"
end sub
sub db_delete_survey
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_weekly_feature
sql = "SELECT " & _
"Author, " & _
"ContentID, " & _
"ShortDesc, Title AS ContentTitle " & _
"FROM Content WHERE Feature = 1"
on error resume next
set rs = cn.Execute(sql)
if err.number <> 0 then
b_error = true
elseif rs.EOF then
b_results = false
else
ContentID = rs("ContentID")
ContentTitle = rs("ContentTitle")
Author = rs("Author")
ShortDesc = rs("ShortDesc")
end if
rs.Close
on error goto 0
end sub
sub db_insert_weekly_feature
sql = "INSERT INTO Content" & _
"(" & _
"Author," & _
"ShortDesc" & _
") VALUES (" & to_sql(Author,"text") & "," & _
"" & to_sql(ShortDesc,"text") & ")" & _
""
'response.write sql
on error resume next
cn.Execute(sql)
if err.Number <> 0 then
b_error = true
else
set rs = cn.Execute("SELECT @@IDENTITY")
ContentID = rs(0)
rs.Close
end if
on error goto 0
end sub
sub db_update_weekly_feature
sql = "UPDATE Content SET " & _
"Author = " & to_sql(Author,"text") & ", " & _
"ShortDesc = " & to_sql(ShortDesc,"text") & " WHERE " & _
"ContentID = " & to_sql(ContentID,"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_delete_weekly_feature
sql = "DELETE FROM Content" & _
" WHERE " & _
"ContentID = " & to_sql(ContentID,"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_disc_topics
disc_topics_sql = "SELECT TOP 5 " & _
"Disc_Topics.TopicId, " & _
"Disc_Topics.ForumId, " & _
"Users.user_id, " & _
"Disc_Topics.Subject, " & _
"Disc_Topics.Message, " & _
"Disc_Topics.DateLast, " & _
"Disc_Topics.Replies, " & _
"Users.user_name FROM (Users RIGHT JOIN Disc_Topics ON Users.user_id = Disc_Topics.user_id) " & _
"ORDER BY Replies DESC, DateLast DESC" & _
""
end sub
sub db_delete_disc_topics
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
ContentID = request("ContentID")
''' request action
action = lcase(request("action"))
''' action case handler
select case action
case "select_whats_hot"
' select the requested key record from database
db_select_whats_hot
case "select_whats_cool"
' select the requested key record from database
db_select_whats_cool
case "select_survey"
' select the requested key record from database
db_select_survey
case "select_weekly_feature"
' select the requested key record from database
if ContentID <> "" then
db_select_weekly_feature
else
b_error = true
error_list.add "edit_weekly_feature", "Specify record to select."
end if
case "insert_weekly_feature"
' request form data and insert a new record into database
validate_weekly_feature
if not b_error then
db_insert_weekly_feature
end if
case "update_weekly_feature"
' request form data and update an existing database record
validate_weekly_feature
if not b_error then
if ContentID <> "" then
db_update_weekly_feature
else
b_error = true
error_list.add "update_weekly_feature", "Specify record to update."
end if
end if
case "delete_weekly_feature"
' delete the requested key database record
if ContentID <> "" then
db_delete_weekly_feature
response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted."
else
b_error = true
error_list.add "delete_weekly_feature", "Specify record to delete."
end if
case "select_disc_topics"
' select the requested key record from database
db_select_disc_topics
end select
':: handle the default case(s) for each form (separate from action= parameter)
title = ""
db_select_whats_cool
db_select_whats_hot
db_select_survey
db_select_disc_topics
%>
<%
display_errs
display_msg
%>
<%
'' the online_users dictionary obj is defined via the app events in global.asa
'' users are added when they login via i_utils.asp
if isObject(online_users) then
%>
<%
a_sessions = online_users.keys
for iUser = 0 to online_users.Count - 1
sKey = a_sessions(iUser)
aTmp = split(online_users.Item(sKey),",")
if uBound(aTmp) = 1 then
sUserId = aTmp(0)
sUserName = aTmp(1)
else
sUserName = aTmp(0)
end if
response.write " " & sUserName & "
|
"
next
'end if
%>
<% end if %>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if survey_sql <> "" then
cmd.CommandText = survey_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
%>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if whats_hot_sql <> "" then
cmd.CommandText = whats_hot_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
%>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if whats_cool_sql <> "" then
cmd.CommandText = whats_cool_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
%>

|
|
<% if request("section") = "" then %><% end if %>
|
|
|
<% db_select_weekly_feature %>
<%
':: check if hide form var was set
if not b_hide_weekly_feature then
%>
<%
':: end hide form if
end if
%>
<%
page_no = request("page_no")
if page_no = "" then page_no = 1
if disc_topics_sql <> "" then
cmd.CommandText = disc_topics_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
%>
|
<%
':: 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
%>