% dim keywords dim search_sql dim articles dim LongDesc dim Title dim ShortDesc dim Author dim DateAdded dim CatID dim ContentID dim Cat dim FileName dim DownloadURL dim RelatedURL dim AvgRating dim user_id dim detail_content_sql dim ContentTypeID dim ContentType dim view_content_sql sub request_search ''' request form inputs from this form keywords = request("keywords") end sub sub request_detail_content ''' request form inputs from this form LongDesc = request("LongDesc") Title = request("Title") ShortDesc = request("ShortDesc") Author = request("Author") DateAdded = request("DateAdded") CatID = request("CatID") ContentID = request("ContentID") Cat = request("Cat") FileName = request("FileName") DownloadURL = request("DownloadURL") RelatedURL = request("RelatedURL") AvgRating = request("AvgRating") user_id = request("user_id") end sub sub request_view_content ''' request form inputs from this form Cat = request("Cat") ContentTypeID = request("ContentTypeID") CatID = request("CatID") ContentID = request("ContentID") Author = request("Author") ContentType = request("ContentType") Title = request("Title") DateAdded = request("DateAdded") ShortDesc = request("ShortDesc") end sub sub validate_search ''' request and validate data entered from this form keywords = trim(request("keywords")) end sub sub validate_detail_content ''' request and validate data entered from this form LongDesc = trim(request("LongDesc")) Title = trim(request("Title")) ShortDesc = trim(request("ShortDesc")) Author = trim(request("Author")) DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "587290date","DateAdded must be a valid date (MM/DD/YY)." b_error = true end if CatID = trim(request("CatID")) ContentID = trim(request("ContentID")) Cat = trim(request("Cat")) FileName = trim(request("FileName")) DownloadURL = trim(request("DownloadURL")) RelatedURL = trim(request("RelatedURL")) AvgRating = trim(request("AvgRating")) user_id = trim(request("user_id")) end sub sub validate_view_content ''' request and validate data entered from this form Cat = trim(request("Cat")) ContentTypeID = trim(request("ContentTypeID")) CatID = trim(request("CatID")) ContentID = trim(request("ContentID")) Author = trim(request("Author")) ContentType = trim(request("ContentType")) Title = trim(request("Title")) DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "587303date","DateAdded must be a valid date (MM/DD/YY)." b_error = true end if ShortDesc = trim(request("ShortDesc")) end sub sub db_select_detail_content detail_content_sql = "SELECT " & _ "LongDesc, " & _ "Author, " & _ "Cats.CatID, " & _ "DateAdded, " & _ "DownloadURL, " & _ "FileName, " & _ "RelatedURL, " & _ "ShortDesc, " & _ "AvgRating," & _ "Title, " & _ "user_id, " & _ "Cat FROM (Content LEFT JOIN Cats ON Content.CatId = Cats.CatId) " & _ "WHERE ContentID = " & to_sql(ContentID,"number") & "" end sub sub db_delete_detail_content 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_view_content if do_search = "1" then request_view_content view_content_sql = "SELECT " & _ "content.ContentID, " & _ "Content.ContentTypeID, " & _ "Content.CatID, " & _ "content.Author, " & _ "ContentTypes.ContentType, " & _ "Cats.Cat, " & _ "content.Title, " & _ "content.DateAdded, " & _ "content.ShortDesc FROM ((Content LEFT JOIN Cats ON cats.catid = content.catid) LEFT JOIN ContentTypes ON content.contenttypeid = ContentTypes.contenttypeid) " & _ " WHERE (Title LIKE '%" & keywords & "%' OR ShortDesc LIKE '%" & keywords & "%') ORDER BY Priority, AvgRating DESC, Title" else view_content_sql = "SELECT " & _ "content.ContentID, " & _ "Content.ContentTypeID, " & _ "Content.CatID, " & _ "content.Author, " & _ "ContentTypes.ContentType, " & _ "Cats.Cat, " & _ "content.Title, " & _ "content.DateAdded, " & _ "content.ShortDesc FROM ((Content LEFT JOIN Cats ON cats.catid = content.catid) LEFT JOIN ContentTypes ON content.contenttypeid = ContentTypes.contenttypeid) " & _ "WHERE (Content.ContentTypeID=2 OR Content.ContentTypeID=5) AND Display=1 ORDER BY Priority, AvgRating DESC, Title" & _ "" end if if request("sortby") <> "" AND inStr(lcase(view_content_sql),"order by") = 0 then view_content_sql = view_content_sql + " ORDER BY " & request("sortby") end sub sub db_delete_view_content 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 do_search = request("do_search") ''' request form keys and inputs keywords = request("keywords") ContentID = request("ContentID") ContentTypeID = request("ContentTypeID") CatID = request("CatID") ''' request action action = lcase(request("action")) ''' action case handler select case action case "select_detail_content" ' select the requested key record from database if ContentID <> "" then db_select_detail_content else b_error = true error_list.add "edit_detail_content", "Specify record to select." end if case "select_view_content" ' select the requested key record from database if ContentID <> "" then db_select_view_content else b_error = true error_list.add "edit_view_content", "Specify record to select." end if case "display_detail_content" display_detail_content = true end select ':: handle the default case(s) for each form (separate from action= parameter) if ContentID <> "" then ''' increment content impressions cn.execute ("UPDATE Content SET impressions = impressions + 1 WHERE ContentId = " & ContentId) db_select_detail_content display_detail_content = TRUE elseif Keywords <> "" then if len(Keywords) < 2 then b_error = true error_list.add "invalidkeywords", "Search terms must be at least 2 characters." end if end if if not b_error then db_select_view_content %> <% display_errs display_msg %>
| <% set rs = cn.execute("SELECT contenttype from contenttypes where contenttypeid = " & contenttypeid & "") %> <% =rs("ContentType") %> <% rs.close %> |
<% end if %> <% if ContentID <> "" OR display_detail_content then %>
<% page_no = request("page_no") if page_no = "" then page_no = 1 if detail_content_sql <> "" then cmd.CommandText = detail_content_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 %>
| <% if page_no > 1 then %> ?<% =request_string %>page_no=<% =page_no-1 %>&sortby=<% =request("sortby") %>">PREV <% else %> <% end if %> | Page <% for i = 1 to max_count %> <% if i = cint(page_no) then %> <%=i%> <% else %> ?<% =request_string %>page_no=<% =i %>&sortby=<% =request("sortby") %>"><%=i%> <% end if %> <%next %> | <% if cInt(page_no) < cInt(max_count) then %> ?<% =request_string %>page_no=<% =page_no+1 %>&sortby=<% =request("sortby") %>">NEXT <% end if %> |