PageRenderTime 54ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 1ms

/members_only/news/index.asp

https://github.com/evizitei/bcfpd_asp
ASP | 303 lines | 263 code | 38 blank | 2 comment | 28 complexity | 12e020a7505849a4a267454a5b9a84d5 MD5 | raw file
  1. <!-- #include virtual="/members_only/include/functions.asa"-->
  2. <!-- #include virtual="/members_only/news/fileupload/upload.asa" -->
  3. <%
  4. If Not Session("Authorized")(7) Then
  5. Response.Redirect "/members_only/index.asp"
  6. End If
  7. Dim Uploader, File
  8. Set Uploader = New FileUploader
  9. ' This starts the upload process
  10. 'Uploader.Upload()
  11. dim rsNews
  12. Dim News_Category_ID
  13. Dim Category_Name
  14. dim imgLoc
  15. Dim FileNames(1)
  16. Set rsNews = Server.CreateObject("ADODB.Recordset")
  17. if Request.QueryString("News_Category_ID") <> "" then
  18. News_Category_ID = killChars(Request.QueryString("News_Category_ID"))
  19. end if
  20. Set fs = CreateObject("Scripting.FileSystemObject")
  21. imgPath = "c:\WebSites\bcfdmo\images\news\"
  22. ImgVirtualPath = "/images/news/"
  23. if Request.ServerVariables("REQUEST_METHOD") = "POST" then
  24. Uploader.Upload()
  25. If Uploader.Files.Count > 0 Then
  26. Dim FileCounter
  27. FileCounter = 0
  28. For Each File In Uploader.Files.Items
  29. File.SaveToDisk server.MapPath(ImgVirtualPath)
  30. FileNames(FileCounter) = File.FileName
  31. FileCounter = FileCounter + 1
  32. Next
  33. else
  34. FileNames(0) = ""
  35. FileNames(1) = ""
  36. end if
  37. If Uploader.Form("Submit") = "Update Story" Then
  38. strSQL = "spInsertNews " & Uploader.Form("News_Category_ID") & ",'" & killChars(Uploader.Form("Headline")) & "','" & killChars(Uploader.Form("Story")) & "','" & killChars(Uploader.Form("Author")) & "','" & killChars(Uploader.Form("PubDate")) & "','" & killChars(Uploader.Form("ExpDate")) & "','" & FileNames(0) & "', '" & killChars(Uploader.Form("Image1_Caption")) & "','" & FileNames(1) & "', '" & killChars(Uploader.Form("Image2_Caption")) & "'"
  39. cnnBCFPD.execute(strSQL)
  40. End If
  41. If Uploader.Form("Submit") = "Update Existing Story" Then
  42. strSQL = "spGetNewsImages " & Uploader.Form("Record_ID")
  43. set rsBCFPD = cnnBCFPD.execute(strSQL)
  44. if rsBCFPD("Image1") <> "" then
  45. FileNames(0) = rsBCFPD("Image1")
  46. end if
  47. if rsBCFPD("Image2") <> "" then
  48. FileNames(1) = rsBCFPD("Image2")
  49. end if
  50. strSQL = "spUpdateNews " & Uploader.Form("News_Category_ID") & ",'" & killChars(Uploader.Form("Headline")) & "','" & killChars(Uploader.Form("Story")) & "','" & killChars(Uploader.Form("Author")) & "','" & killChars(Uploader.Form("PubDate")) & "','" & killChars(Uploader.Form("ExpDate")) & "','" & FileNames(0) & "', '" & killChars(Uploader.Form("Image1_Caption")) & "','" & FileNames(1) & "', '" & killChars(Uploader.Form("Image2_Caption")) & "'," & Uploader.Form("Record_ID")
  51. cnnBCFPD.execute(strSQL)
  52. End If
  53. end if
  54. if Request.QueryString("Delete") <> "" then
  55. strSQL = "spGetNewsImages " & Request.QueryString("Delete")
  56. set rsBCFPD = cnnBCFPD.execute(strSQL)
  57. if rsBCFPD("Image1") <> "" then
  58. fs.DeleteFile(ImgPath & rsBCFPD("Image1"))
  59. end if
  60. if rsBCFPD("Image2") <> "" then
  61. fs.DeleteFile(ImgPath & rsBCFPD("Image2"))
  62. end if
  63. strSQL = "spDeleteNewsArticle " & Request.QueryString("Delete")
  64. set rsBCFPD = cnnBCFPD.execute(strSQL)
  65. end if
  66. if Request.QueryString("DeleteImage") = "Image1" then
  67. strSQL = "SELECT Image1, Image1_Caption FROM News WHERE News_ID = " & killChars(Request.QueryString("News_Id"))
  68. rsNews.Open strSQL, cnnBCFPD, 3, 3
  69. if rsNews("Image1") <> "" then
  70. fs.DeleteFile(ImgPath & rsNews("Image1"))
  71. end if
  72. rsNews("Image1") = ""
  73. rsNews("Image1_Caption") = ""
  74. rsNews.Update
  75. rsNews.Close
  76. end if
  77. if Request.QueryString("DeleteImage") = "Image2" then
  78. strSQL = "SELECT Image2, Image2_Caption FROM News WHERE News_ID = " & killChars(Request.QueryString("News_Id"))
  79. rsNews.Open strSQL, cnnBCFPD, 3, 3
  80. if rsNews("Image2") <> "" then
  81. fs.DeleteFile(ImgPath & rsNews("Image2"))
  82. end if
  83. rsNews("Image2") = ""
  84. rsNews("Image2_Caption") = ""
  85. rsNews.Update
  86. rsNews.Close
  87. end if
  88. If Request.QueryString("Feature") <> "" then
  89. rsNews.OPEN "Select * from News where News_Category_ID = " & killChars(News_Category_ID), cnnBCFPD, 3, 3
  90. Do While Not rsNews.EOF
  91. if rsNews("Feature") = true then
  92. rsNews("Feature") = false
  93. rsNews.Update
  94. end if
  95. rsNews.MoveNext
  96. loop
  97. rsNews.Close
  98. rsNews.Open "Select * from News where News_ID = " & killChars(Request.QueryString("Feature")) & " AND News_Category_ID = " & News_Category_ID, cnnBCFPD, 3, 3
  99. rsNews("Feature") = true
  100. rsNews.Update
  101. rsNews.Close
  102. End If
  103. strSQL = "bcfpdwebuser.spGetNewsCategories"
  104. set rsBCFPD = cnnBCFPD.execute(strSQL)
  105. Category_Name = rsBCFPD("Name")
  106. %>
  107. <!--#include virtual="/members_only/include/templates/top.asa"-->
  108. <!--#include virtual="/members_only/include/templates/members.asa"-->
  109. <table width="98%" border="0" cellspacing="0" cellpadding="5" bordercolor="orange">
  110. <tr>
  111. <td class="PageTitle"><%=Category_Name%> Update</td>
  112. </tr>
  113. <tr>
  114. <td valign="bottom">
  115. <%
  116. If Uploader.Form("Submit") = "Add Story" OR Request.QueryString("News_Id") <> "" Then
  117. If Uploader.Form("Submit") = "Add Story" Then
  118. rsNews.Open "News", cnnBCFPD, 3, 3
  119. rsNews.AddNew
  120. End If
  121. If Request.QueryString("News_Id") <> "" Then
  122. rsNews.Open "SELECT * FROM News WHERE News_Id = " & killChars(Request.QueryString("News_Id")), cnnBCFPD, 3, 3
  123. End If
  124. if rsNews("PubDate") = "" then
  125. DefaultPubDate = formatdatetime(now(),2)
  126. else
  127. DefaultPubDate = rsNews("PubDate")
  128. end if
  129. if rsNews("ExpDate") = "" then
  130. DefaultExpDate = formatdatetime(dateadd("yyyy", 1, now()),2)
  131. else
  132. DefaultExpDate = rsNews("ExpDate")
  133. end if
  134. %>
  135. <!-- 8. A form is created that contains a table with update fields.-->
  136. <form method="POST" id="form1" name="form1" action="<%=Request.ServerVariables("SCRIPT_NAME")%>?News_Category_ID=<%=News_Category_ID%>" ENCTYPE="multipart/form-data">
  137. <!-- 8a. A table is created that contains the requested information.-->
  138. <table border="0" cellpadding="3" cellspacing="3">
  139. <tr>
  140. <td class="ContactInfo">Category:</td>
  141. <td>
  142. <SELECT id=News_Category_ID name=News_Category_ID> <OPTION value=1 <%if rsNews("News_Category_ID") = 1 then %> selected <%end if %>>BCFPD News</OPTION>
  143. <OPTION value=6 <%if rsNews("News_Category_ID") = 6 then %> selected <%end if %> >Emergency Preparedness</OPTION>
  144. <OPTION value=5 <%if rsNews("News_Category_ID") = 5 then %> selected <%end if %>>Hot Topic</OPTION>
  145. <OPTION value=2 <%if rsNews("News_Category_ID") = 2 then %> selected <%end if %>>MO-TF1 News</OPTION>
  146. <OPTION value=3 <%if rsNews("News_Category_ID") = 3 then %> selected <%end if %>>Wildland News</OPTION>
  147. </SELECT>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td class="ContactInfo">Headline:</td>
  152. <td><input maxlength=255 type="text" name="Headline" size="40" value="<%=rsNews("Headline")%>"></td>
  153. </tr>
  154. <tr>
  155. <td class="ContactInfo">Story:</td>
  156. <td><textarea cols="60" rows="20" name="Story"><%=rsNews("Story")%></textarea></td>
  157. </tr>
  158. <tr>
  159. <td class="ContactInfo">Author:</td>
  160. <td><input maxlength=255 type="text" name="Author" value="<%=rsNews("Author")%>"></td>
  161. </tr>
  162. <tr>
  163. <td class="ContactInfo">Publication Date:</td>
  164. <td><input maxlength=10 type="text" name="PubDate" value="<%=DefaultPubDate%>"></td>
  165. </tr>
  166. <tr>
  167. <td class="ContactInfo">Expiration Date:</td>
  168. <td><input maxlength=10 type="text" name="ExpDate" value="<%=DefaultExpDate%>"></td>
  169. </tr>
  170. <tr>
  171. <td class="ContactInfo">Image 1:</td>
  172. <% if rsNews("Image1") <> "" then %>
  173. <td><img width=100 src="/images/news/<%=rsNews("Image1")%>">&nbsp;<a href="index.asp?DeleteImage=Image1&News_Id=<%=Request.QueryString("News_Id")%>&News_Category_ID=<%=News_Category_ID%>">Delete Image</a></td>
  174. <% else %>
  175. <td><input type="file" id="Image1" name="Image1"></td>
  176. <% end if %>
  177. </tr>
  178. <tr>
  179. <td class="ContactInfo">Image 1 Caption:</td>
  180. <td><input maxlength=500 type="text" size="40" name="Image1_Caption" value="<%=rsNews("Image1_Caption")%>" maxlength="500"></td>
  181. </tr>
  182. <tr>
  183. <td class="ContactInfo">Image 2:</td>
  184. <% if rsNews("Image2") <> "" then %>
  185. <td><img width=100 src="/images/news/<%=rsNews("Image2")%>">&nbsp;<a href="index.asp?DeleteImage=Image2&News_Id=<%=Request.QueryString("News_Id")%>&News_Category_ID=<%=News_Category_ID%>">Delete Image</a></td>
  186. <% else %>
  187. <td><input type="file" id="Image2" name="Image2"></td>
  188. <% end if %>
  189. </tr>
  190. <tr>
  191. <td class="ContactInfo">Image 2 Caption:</td>
  192. <td><input maxlength=500 type="text" size="40" name="Image2_Caption" value="<%=rsNews("Image2_Caption")%>" maxlength="500"></td>
  193. </tr>
  194. <tr>
  195. <td align="right" colspan="2">
  196. <!-- 8b. If Then Else statement to check if updating new record or existing.-->
  197. <% If Request.QueryString("News_Id") <> "" Then %>
  198. <a href="javascript:submit(document.form1, 'Update Existing Story');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  199. <input type="Hidden" name="Submit">
  200. <input type="hidden" name="Record_ID" value="<%=rsNews("News_Id")%>">
  201. <img src="/images/spacer.gif" border="0" height="1" width="35">
  202. <a style="cursor: hand" href="/members_only/news/index.asp"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  203. <% Else %>
  204. <a href="javascript:submit(document.form1, 'Update Story');"><img SRC="/images/members/buttons/Save.gif" border="0"></a>
  205. <img src="/images/spacer.gif" border="0" height="1" width="35">
  206. <a style="cursor: hand" href="/members_only/news/index.asp"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  207. <input type="Hidden" name="Submit">
  208. <% End If %>
  209. </td>
  210. </tr>
  211. </table>
  212. </form>
  213. <% Else
  214. strSQL = "bcfpdwebuser.spGetNews"
  215. set rsNews = cnnBCFPD.execute(strSQL)
  216. %>
  217. <form method="post" action="index.asp?News_Category_ID=<%=Request.QueryString("News_Category_ID")%>" id="form2" name="form2" ENCTYPE="multipart/form-data">
  218. <!-- 10. A table is created that will contain a delete check box, Headline links, and date info.-->
  219. <table border="0" cellpadding="4" cellspacing="0">
  220. <tr>
  221. <td class="subheadercenter">&nbsp;</td>
  222. <td class="subheadercenter">Featured</td>
  223. <td class="subheadercenter">Category</td>
  224. <td class="subheadercenter">Headline</td>
  225. <td class="subheadercenter">Publication Date</td>
  226. <td class="subheadercenter">Expiration Date</td>
  227. <!-- <td>Change Order</td> -->
  228. </tr>
  229. <!-- 11. Do While Loop to populate the table with database information.-->
  230. <% if rsNews.RecordCount = 1 then
  231. rsNews("Feature") = true
  232. end if
  233. Do while not rsNews.EOF %>
  234. <tr>
  235. <td align="center"><a href="index.asp?Delete=<%=rsNews("News_ID")%>">delete</a></td>
  236. <td align="center"><%if rsNews("Feature") then%><img SRC="/images/members/buttons/checkmarkRED.gif"><%else%><a href="index.asp?Feature=<%=rsNews("News_ID")%>&amp;News_Category_ID=<%=rsNews("News_Category_ID")%>"><img SRC="/images/members/buttons/checkmarkBlack.gif" border="0"></a><%end if%></td>
  237. <td class="AppLabel" align="center"><%=rsNews("Name")%></td>
  238. <td><a href="index.asp?News_Id=<%=rsNews("News_Id")%>&amp;News_Category_ID=<%=rsNews("News_Category_ID")%>"><%=rsNews("Headline")%></a></td>
  239. <td class="AppLabel" align="center"><%=rsNews("PubDate")%></td>
  240. <td class="AppLabel" align="center"><%=rsNews("ExpDate")%></td>
  241. </tr>
  242. <% rsNews.MoveNext
  243. Loop
  244. %>
  245. <tr>
  246. <td align="right" colspan="6">
  247. <a href="javascript:submit(document.form2, 'Add Story');"><img SRC="/images/members/buttons/add.gif" border="0"></a>
  248. <img src="/images/spacer.gif" border="0" height="1" width="35">
  249. <a href="javascript:Delete();"><img SRC="/images/members/buttons/Delete.gif" border="0"></a>
  250. <img src="/images/spacer.gif" border="0" height="1" width="35">
  251. <a style="cursor: hand" OnClick="window.location.href='/members_only/';"><img src="/images/members/buttons/cancel.gif" border="0" width="45" height="34"></a>
  252. <input type="hidden" name="Submit">
  253. </td>
  254. </tr>
  255. </table>
  256. </form>
  257. <% End If
  258. rsBCFPD.Close
  259. set rsNews = Nothing
  260. set rsBCFPD = nothing
  261. %>
  262. </td>
  263. </tr>
  264. </table>
  265. <!--#include virtual="/members_only/include/templates/bottom.asa"-->