yns_upsave.asp
上传用户:yjkj1008
上传日期:2020-10-17
资源大小:1496k
文件大小:6k
源码类别:

电子政务应用

开发平台:

HTML/CSS

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <!--#include file="Connections/conn_news.asp" --> <% '请尊重作者劳动成果不要删除以上信息 '业一新闻系统3.0正式版 '主页:http://yeyi.net '论坛:http://bbs.yeyi.net '业一网络 承接各种网站制作 '程序开发 软件开发业务 '业务联系 '电话: 13007310512 '联系人:郝亚平 'QQ:24344842 (只谈业务,技术问题请访问论坛) '请尊重作者劳动成果不要删除以上信息 %>
  3. <%
  4. ' *** Restrict Access To Page: Grant or deny access to this page
  5. MM_authorizedUsers="2,3"
  6. MM_authFailedURL="default.asp"
  7. MM_grantAccess=false
  8. If Session("MM_Username") <> "" Then
  9.   If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
  10.          (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
  11.     MM_grantAccess = true
  12.   End If
  13. End If
  14. If Not MM_grantAccess Then
  15.   MM_qsChar = "?"
  16.   If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  17.   MM_referrer = Request.ServerVariables("URL")
  18.   if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  19.   MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  20.   Response.Redirect(MM_authFailedURL)
  21. End If
  22. %>
  23. <%
  24. Dim rs__MMColParam
  25. rs__MMColParam = "1"
  26. If (Request.Form("n_mid") <> "") Then 
  27.   rs__MMColParam = Request.Form("n_mid")
  28. End If
  29. %>
  30. <%
  31. Dim rs
  32. Dim rs_numRows
  33. Set rs = Server.CreateObject("ADODB.Recordset")
  34. rs.ActiveConnection = MM_conn_news_STRING
  35. rs.Source = "SELECT * FROM t_mob WHERE m_id = " + Replace(rs__MMColParam, "'", "''") + ""
  36. rs.CursorType = 0
  37. rs.CursorLocation = 2
  38. rs.LockType = 1
  39. rs.Open()
  40. rs_numRows = 0
  41. %>
  42. <%
  43. Dim n_title
  44. Dim n_content
  45. Dim n_date
  46. Dim fname
  47. Dim fpath
  48. Dim postpath
  49. Dim author
  50. dim mpic
  51. author=Request.Form("n_author")
  52. fname = Request.Form("n_fname")
  53. N_Title=Request.Form("n_title")
  54. n_content=Request.Form("n_content")
  55. n_date=Request.Form("n_date")
  56. fpath=Request.Form("n_tid")
  57. author=Request.Form("n_author")
  58. mpic=Request.Form("n_mpic")
  59. rpic=Request.Form("n_rpic")
  60. pencat=rs.Fields.Item("m_content").Value 
  61. pencat=replace(pencat,"t_title",n_title)
  62. pencat=replace(pencat,"t_author",author)
  63. pencat=replace(pencat,"t_content",n_content)
  64. pencat=replace(pencat,"t_date",n_date)
  65. pencat=replace(pencat,"t_mimg",mpic)
  66. pencat=replace(pencat,"t_rimg",rpic)
  67. Set fso = Server.CreateObject("Scripting.FileSystemObject")
  68. Set fout = fso.CreateTextFile(server.mappath(fpath& "" & fname))
  69. fout.WriteLine pencat
  70. fout.close
  71. %>
  72. <%
  73. ' *** Edit Operations: declare variables
  74. Dim MM_editAction
  75. Dim MM_abortEdit
  76. Dim MM_editQuery
  77. Dim MM_editCmd
  78. Dim MM_editConnection
  79. Dim MM_editTable
  80. Dim MM_editRedirectUrl
  81. Dim MM_editColumn
  82. Dim MM_recordId
  83. Dim MM_fieldsStr
  84. Dim MM_columnsStr
  85. Dim MM_fields
  86. Dim MM_columns
  87. Dim MM_typeArray
  88. Dim MM_formVal
  89. Dim MM_delim
  90. Dim MM_altVal
  91. Dim MM_emptyVal
  92. Dim MM_i
  93. MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
  94. If (Request.QueryString <> "") Then
  95.   MM_editAction = MM_editAction & "?" & Request.QueryString
  96. End If
  97. ' boolean to abort record edit
  98. MM_abortEdit = false
  99. ' query string to execute
  100. MM_editQuery = ""
  101. %>
  102. <%
  103. ' *** Update Record: set variables
  104. If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
  105.   MM_editConnection = MM_conn_news_STRING
  106.   MM_editTable = "t_news"
  107.   MM_editColumn = "n_id"
  108.   MM_recordId = "" + Request.Form("MM_recordId") + ""
  109.   MM_editRedirectUrl = "yns_ok.htm"
  110.   MM_fieldsStr  = "n_tid|value|n_sid|value|n_mid|value|n_commend|value|n_index|value|n_title|value|n_author|value|n_mpic|value|n_rpic|value|n_fname|value|n_date|value|n_content|value"
  111.   MM_columnsStr = "n_tid|none,none,NULL|n_sid|none,none,NULL|n_mid|none,none,NULL|n_commend|none,1,0|n_index|none,1,0|n_title|',none,''|n_author|',none,''|n_mpic|',none,''|n_rpic|',none,''|n_fname|',none,''|n_date|',none,NULL|n_content|',none,''"
  112.   ' create the MM_fields and MM_columns arrays
  113.   MM_fields = Split(MM_fieldsStr, "|")
  114.   MM_columns = Split(MM_columnsStr, "|")
  115.   
  116.   ' set the form values
  117.   For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
  118.     MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  119.   Next
  120.   ' append the query string to the redirect URL
  121.   If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
  122.     If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
  123.       MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
  124.     Else
  125.       MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
  126.     End If
  127.   End If
  128. End If
  129. %>
  130. <%
  131. ' *** Update Record: construct a sql update statement and execute it
  132. If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
  133.   ' create the sql update statement
  134.   MM_editQuery = "update " & MM_editTable & " set "
  135.   For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
  136.     MM_formVal = MM_fields(MM_i+1)
  137.     MM_typeArray = Split(MM_columns(MM_i+1),",")
  138.     MM_delim = MM_typeArray(0)
  139.     If (MM_delim = "none") Then MM_delim = ""
  140.     MM_altVal = MM_typeArray(1)
  141.     If (MM_altVal = "none") Then MM_altVal = ""
  142.     MM_emptyVal = MM_typeArray(2)
  143.     If (MM_emptyVal = "none") Then MM_emptyVal = ""
  144.     If (MM_formVal = "") Then
  145.       MM_formVal = MM_emptyVal
  146.     Else
  147.       If (MM_altVal <> "") Then
  148.         MM_formVal = MM_altVal
  149.       ElseIf (MM_delim = "'") Then  ' escape quotes
  150.         MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
  151.       Else
  152.         MM_formVal = MM_delim + MM_formVal + MM_delim
  153.       End If
  154.     End If
  155.     If (MM_i <> LBound(MM_fields)) Then
  156.       MM_editQuery = MM_editQuery & ","
  157.     End If
  158.     MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  159.   Next
  160.   MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
  161.   If (Not MM_abortEdit) Then
  162.     ' execute the update
  163.     Set MM_editCmd = Server.CreateObject("ADODB.Command")
  164.     MM_editCmd.ActiveConnection = MM_editConnection
  165.     MM_editCmd.CommandText = MM_editQuery
  166.     MM_editCmd.Execute
  167.     MM_editCmd.ActiveConnection.Close
  168.     If (MM_editRedirectUrl <> "") Then
  169.       Response.Redirect(MM_editRedirectUrl)
  170.     End If
  171.   End If
  172. End If
  173. %>
  174. <%
  175. rs.Close()
  176. Set rs = Nothing
  177. %>