PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/members_only/photo_gallery/images/index.asp

http://github.com/evizitei/bcfpd_asp
ASP | 192 lines | 164 code | 24 blank | 4 comment | 7 complexity | 1101a6e39c02aab2827b1e9aac94ef88 MD5 | raw file
  1. <!-- #include virtual="/members_only/include/functions.asa"-->
  2. <%
  3. If Not Session("Authorized")(5) Then
  4. Response.Redirect "/members_only/index.asp"
  5. End If
  6. ImgPath = "c:\websites\bcfdmo\images\photo_gallery\images\"
  7. Set fs = CreateObject("Scripting.FileSystemObject")
  8. Set f = fs.GetFolder(ImgPath & "\")
  9. Set fc = f.Files
  10. set rsCategory = Server.CreateObject("ADODB.Recordset")
  11. strNode = "SELECT * FROM Image_Category"
  12. for each item in Request.Form("Delete")
  13. rsCategory.Open "SELECT ThumbnailName FROM Image WHERE Image_Category_ID = " & item, cnnMain,3,3
  14. if not rsCategory.EOF then
  15. do while not rsCategory.EOF
  16. if fs.FileExists(ImgPath & "thumbnail\" & rsCategory("ThumbnailName")) then
  17. fs.DeleteFile(ImgPath & "thumbnail\" & rsCategory("ThumbnailName"))
  18. end if
  19. rsCategory.MoveNext
  20. loop
  21. end if
  22. rsCategory.Close
  23. rsCategory.Open "SELECT ThumbnailName FROM Image WHERE FilmStrip = 1 AND Image_Category_ID = " & item, cnnMain,3,3
  24. if not rsCategory.EOF then
  25. do while not rsCategory.EOF
  26. fs.DeleteFile(ImgPath & "filmstrip\" & rsCategory("ThumbnailName"))
  27. rsCategory.MoveNext
  28. loop
  29. end if
  30. rsCategory.Close
  31. strSQL = "DELETE FROM Image_Category WHERE Category_ID = " & item
  32. cnnMain.execute(strSQL)
  33. next
  34. ' If there is a request to update the new record, update the new record.
  35. If Request.Form("Submit") = "Update Category" Then
  36. rsCategory.Open "Image_Category", cnnMain,3,3
  37. rsCategory.AddNew
  38. For Each Item in Request.Form
  39. If Item <> "Submit" Then
  40. rsCategory(Item) = Request.Form(Item)
  41. End If
  42. Next
  43. rsCategory.Update
  44. rsCategory.Close
  45. End If
  46. ' If there is a request to update an existing record, update the existing record.
  47. If Request.Form("Submit") = "Update Existing Category" Then
  48. rsCategory.Open "SELECT * FROM Image_Category WHERE Category_ID =" & Request.Form("Category_ID"), cnnMain,3,3
  49. For Each Item in Request.Form
  50. If Item <> "Submit" AND Item <> "Category_ID" Then
  51. rsCategory(Item) = Request.Form(Item)
  52. End If
  53. Next
  54. rsCategory.Update
  55. rsCategory.Close
  56. End If
  57. %>
  58. <!--#include virtual="/members_only/include/templates/top.asa"-->
  59. <!--#include virtual="/members_only/include/templates/members.asa"-->
  60. <table border="0" width="95%" cellspacing="0" cellpadding="5">
  61. <tr>
  62. <td class="PageTitle">Image Categories For Photo Gallery</td>
  63. </tr>
  64. <tr>
  65. <td valign="bottom">
  66. <% If Request.Form("Submit") = "Add New Category" OR Request.QueryString("Category_ID") <> "" Then
  67. ' If there is a request to add new record, add new record.
  68. If Request.Form("Submit") = "Add New Category" Then
  69. rsCategory.Open strNode, cnnMain, 3, 3
  70. rsCategory.AddNew
  71. End If
  72. ' If there is a request by clicking a hyper link, open the recordset and grab the selected record.
  73. If Request.QueryString("Category_ID") <> "" Then
  74. rsCategory.Open "SELECT * FROM Image_Category WHERE Category_ID = " & Request.QueryString("Category_ID"), cnnMain, 3, 3
  75. End If
  76. %>
  77. <!--' 9. A form is created that contains a table with update fields.-->
  78. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" id="form1" name="form1">
  79. <!-- 9a. A table is created that contains the requested information.-->
  80. <table border="0" cellpadding="3" cellspacing="3">
  81. <tr>
  82. <td></td>
  83. <td>
  84. <table border="0" cellpadding="3" cellspacing="0" bordercolor="#f2f2f2">
  85. <tr>
  86. <td class="ContactInfo" bordercolor="#f2f2f2">Name:</td>
  87. <td bordercolor="#f2f2f2"><input type="text" name="Name" size="50" maxlength="200" value="<%=rsCategory("Name")%>"></td>
  88. </tr>
  89. <tr>
  90. <td class="ContactInfo" bordercolor="#f2f2f2">Description:</td>
  91. <td bordercolor="#f2f2f2"><textarea name="Description" maxlength="8000" cols="50" rows="10"><%=rsCategory("Description")%></textarea></td>
  92. </tr>
  93. <tr>
  94. <td align="right" colspan="2">
  95. <% If Request.QueryString("Category_ID") <> "" Then %>
  96. <a href="javascript:submit(document.form1, 'Update Existing Category');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  97. <img src="/images/spacer.gif" border="0" height="1" width="35">
  98. <a style="cursor: hand" OnClick="window.location='/members_only/photo_gallery/images/index.asp';"><img src="/images/members/buttons/cancel.gif" border="0"></a></td>
  99. <input type="hidden" name="Submit">
  100. <input type="hidden" name="Category_ID" value="<%=rsCategory("Category_ID")%>">
  101. <% Else %>
  102. <a href="javascript:submit(document.form1, 'Update Category');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  103. <img src="/images/spacer.gif" border="0" height="1" width="35">
  104. <a style="cursor: hand" OnClick="window.location='/members_only/photo_gallery/images/index.asp';"><img src="/images/members/buttons/cancel.gif" border="0"></a></td>
  105. <input type="hidden" name="Submit">
  106. <% End If %>
  107. </td>
  108. </tr>
  109. </table>
  110. </td>
  111. </tr>
  112. </table>
  113. </form>
  114. <% Else %>
  115. <%
  116. rsCategory.Open "SELECT * FROM Image_Category ORDER BY Name ASC" , cnnMain, 3, 3
  117. %>
  118. <form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" id="form2" name="form2">
  119. <!-- 11. A table is created that will contain a delete check box, Make Feature/Headline links, and date info.-->
  120. <table border="0" cellpadding="3" cellspacing="3">
  121. <tr>
  122. <td></td>
  123. <td>
  124. <table border="0" cellpadding="3" cellspacing="3" bordercolor="#f2f2f2">
  125. <tr>
  126. <td class="subheadercenter">Delete</td>
  127. <td class="subheadercenter">Category Name</td>
  128. <td class="subheadercenter" colspan="3">Edit</td>
  129. </tr>
  130. <!-- 12. Do While Loop to populate the table with database information.-->
  131. <% Do while not rsCategory.EOF %>
  132. <tr>
  133. <td align="center" bordercolor="#f2f2f2"><input type="checkbox" name="Delete" value="<%=rsCategory("Category_ID")%>"></td>
  134. <td class="ContactInfo" bordercolor="#f2f2f2"><%=rsCategory("Name")%></td>
  135. <td align="center" class="ContactInfo"><a class="Update" href="index.asp?Category_ID=<%=rsCategory("Category_ID")%>">Category</a></td>
  136. <td align="center" class="ContactInfo"><a class="Update" href="image_list.asp?Category_ID=<%=rsCategory("Category_ID")%>">Category Images</a></td>
  137. <td align="center" class="ContactInfo"><a class="Update" href="filmstrip.asp?Category_ID=<%=rsCategory("Category_ID")%>">Film Strip Images</a></td>
  138. </tr>
  139. <% rsCategory.MoveNext
  140. Loop
  141. %>
  142. <tr>
  143. <td colspan="5">
  144. <table>
  145. <tr>
  146. <td align="right">
  147. <a href="javascript:submit(document.form2, 'Add New Category');"><img SRC="/images/members/buttons/add.gif" border="0"></a>
  148. <img src="/images/spacer.gif" border="0" height="1" width="35">
  149. <a href="javascript:Delete();"><img SRC="/images/members/buttons/Delete.gif" border="0"></a>
  150. <img src="/images/spacer.gif" border="0" height="1" width="35">
  151. <a style="cursor: hand" OnClick="window.location='/members_only/index.asp';"><img src="/images/members/buttons/cancel.gif" border="0"></a></td>
  152. <input type="hidden" name="Submit">
  153. </td>
  154. </tr>
  155. </table>
  156. </td>
  157. </tr>
  158. </table>
  159. </td>
  160. </tr>
  161. </table>
  162. </form>
  163. <%rsCategory.Close%>
  164. <% End If %>
  165. </td>
  166. </tr>
  167. </table>
  168. <!--#include virtual="/members_only/include/templates/bottom.asa"-->