yns_save.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="1,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. ' *** Insert Record: set variables
  104. If (CStr(Request("MM_insert")) = "form1") Then
  105.   MM_editConnection = MM_conn_news_STRING
  106.   MM_editTable = "t_news"
  107.   MM_editRedirectUrl = "yns_ok.htm"
  108.   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"
  109.   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,''"
  110.   ' create the MM_fields and MM_columns arrays
  111.   MM_fields = Split(MM_fieldsStr, "|")
  112.   MM_columns = Split(MM_columnsStr, "|")
  113.   
  114.   ' set the form values
  115.   For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
  116.     MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  117.   Next
  118.   ' append the query string to the redirect URL
  119.   If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
  120.     If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
  121.       MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
  122.     Else
  123.       MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
  124.     End If
  125.   End If
  126. End If
  127. %>
  128. <%
  129. ' *** Insert Record: construct a sql insert statement and execute it
  130. Dim MM_tableValues
  131. Dim MM_dbValues
  132. If (CStr(Request("MM_insert")) <> "") Then
  133.   ' create the sql insert statement
  134.   MM_tableValues = ""
  135.   MM_dbValues = ""
  136.   For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
  137.     MM_formVal = MM_fields(MM_i+1)
  138.     MM_typeArray = Split(MM_columns(MM_i+1),",")
  139.     MM_delim = MM_typeArray(0)
  140.     If (MM_delim = "none") Then MM_delim = ""
  141.     MM_altVal = MM_typeArray(1)
  142.     If (MM_altVal = "none") Then MM_altVal = ""
  143.     MM_emptyVal = MM_typeArray(2)
  144.     If (MM_emptyVal = "none") Then MM_emptyVal = ""
  145.     If (MM_formVal = "") Then
  146.       MM_formVal = MM_emptyVal
  147.     Else
  148.       If (MM_altVal <> "") Then
  149.         MM_formVal = MM_altVal
  150.       ElseIf (MM_delim = "'") Then  ' escape quotes
  151.         MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
  152.       Else
  153.         MM_formVal = MM_delim + MM_formVal + MM_delim
  154.       End If
  155.     End If
  156.     If (MM_i <> LBound(MM_fields)) Then
  157.       MM_tableValues = MM_tableValues & ","
  158.       MM_dbValues = MM_dbValues & ","
  159.     End If
  160.     MM_tableValues = MM_tableValues & MM_columns(MM_i)
  161.     MM_dbValues = MM_dbValues & MM_formVal
  162.   Next
  163.   MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
  164.   If (Not MM_abortEdit) Then
  165.     ' execute the insert
  166.     Set MM_editCmd = Server.CreateObject("ADODB.Command")
  167.     MM_editCmd.ActiveConnection = MM_editConnection
  168.     MM_editCmd.CommandText = MM_editQuery
  169.     MM_editCmd.Execute
  170.     MM_editCmd.ActiveConnection.Close
  171.     If (MM_editRedirectUrl <> "") Then
  172.       Response.Redirect(MM_editRedirectUrl)
  173.     End If
  174.   End If
  175. End If
  176. %>
  177. <%
  178. rs.Close()
  179. Set rs = Nothing
  180. %>