www.gusucode.com > 站长俱乐部新闻发布系统精简版 1.01源码程序 > admin/admin_item_edit_link.asp

    <!--#include file="admin_scripts.asp" -->
<!--#include file="admin_top.asp" -->
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<%
' *** Edit Operations: declare variables

' set the form action variable
dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
        MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
dim MM_abortEdit
MM_abortEdit = false

' query string to execute
dim MM_editQuery
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

'get date variables
Dim myStartDate, myEndDate
myStartDate = request.form("startYear") & "-" & request.form("startMonth") & "-" & request.form("startDay") & " " & request.form("startHour") & ":" & request.form("startMinute") & ":" & request.form("startSecond")
myEndDate = request.form("endYear") & "-" & request.form("endMonth") & "-" & request.form("endDay") & " " & request.form("endHour") & ":" & request.form("endMinute") & ":" & request.form("endSecond")

  dim MM_editConnection, MM_editTable, MM_editColumn, MM_recordId, MM_editRedirectUrl, MM_fieldsStr, MM_columnsStr
  MM_editConnection = MM_oConn_STRING
  MM_editTable  = "ac_item"
  MM_editColumn = "ID"
  MM_recordId = "" & Request.Form("MM_recordId") & ""
  MM_editRedirectUrl = "default.asp"
  MM_fieldsStr = "Title|value|Category_ID|value|Content|value|Updated|value|VerticalPosition|value|User_ID|value|Type|value|VisibleMenu|value|SiteHome|value"
  MM_columnsStr = "Title|',none,''|Category_ID|none,none,Null|Content|',none,''|Updated|',none,''|VerticalPosition|none,none,NULL|User_ID|none,none,NULL|Type|',none,''|VisibleMenu|',none,''|SiteHome|',none,''"

  ' create the MM_fields and MM_columns arrays
  dim MM_fields, MM_columns
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  if CStr(request.form("Type"))="Iframe" then

      ' set the form values for Iframe
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        	if MM_i = 4 then
                        MM_fields(MM_i+1) = CStr(request.form("Width")) & "--" & CStr(request.form("Height")) & "--" & CStr(Request.Form(MM_fields(MM_i)))
        	else
        		MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
    	end if
      Next

  else

      ' set the form values for other link types
      dim MM_i
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
      Next

  end if

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If 

End If
%>

<%
' *** Update Record: construct a sql update statement and execute it

If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  dim MM_formVal, MM_typeArray, MM_delim, MM_altVal, MM_emptyVal, MM_editCmd
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
    MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next

  'alter sql to add in date information
  MM_editQuery = MM_editQuery & ",StartPub='" & myStartDate & "'"
  MM_editQuery = MM_editQuery & ",EndPub='" & myEndDate & "'"
  
  MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
  
  If (Not MM_abortEdit) Then
    ' execute the update
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Session("currentPage") = Request.Form("ID")
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If  
  
End If
%>

<%
dim myParam
myParam = "1"
if (Request.Form("ID") <> "") then
  myParam = Request.Form("ID")
end if
%>
<%
'dim Item, Item_numRows
set Item = Server.CreateObject("ADODB.Recordset")
Item.ActiveConnection = MM_oConn_STRING
Item.Source = "SELECT * FROM ac_item WHERE ID = "& myParam &""
Item.CursorType = 0
Item.CursorLocation = 2
Item.LockType = 1
Item.Open()
Item_numRows = 0

'check that the user is allowed to edit this page
if (Session("MM_UserAuthorization") = 3) AND (Item.Fields.Item("User_ID").Value) <> (Session("MM_UserID")) then 
	Response.Redirect(MM_authFailedURL)
end if

dim myItemPos
myItemPos = Item.Fields.Item("VerticalPosition").Value
%>
<%
dim currentYear, currentMonth, currentDay
dim currentHour, currentMinute, currentSecond
dim endYear, endMonth, endDay
dim endHour, endMinute, endSecond
dim dbStartPub, dbEndPub
dim myDateArray1, myDateArray2, myDateArray3

'get start date from database and set form variables
dbStartPub = Item.Fields.Item("StartPub").Value
myDateArray1 = Split(dbStartPub, "-")
myDateArray2 = Split(myDateArray1(2)," ")
myDateArray3 = Split(myDateArray2(1), ":")
currentYear = CInt(myDateArray1(0))
currentMonth = CInt(myDateArray1(1))
currentDay = CInt(myDateArray2(0))
currentHour = CInt(myDateArray3(0))
currentMinute = CInt(myDateArray3(1))
currentSecond = CInt(myDateArray3(2))

'get end date from database and set form variables
dbEndPub = CStr(Item.Fields.Item("EndPub").Value)
myDateArray1 = Split(dbEndPub, "-")
myDateArray2 = Split(myDateArray1(2)," ")
myDateArray3 = Split(myDateArray2(1), ":")
endYear = CInt(myDateArray1(0))
endMonth = CInt(myDateArray1(1))
endDay = CInt(myDateArray2(0))
endHour = CInt(myDateArray3(0))
endMinute = CInt(myDateArray3(1))
endSecond = CInt(myDateArray3(2))

dim strCurrentTime
strCurrentTime = Year(now) & "/" & Month(now)  & "/" & Day(now) & " " & Hour(now) & ":" & Minute(now) & ":" & Second(now)

'get visible in menu and site home variables from db
dim strVisibleMenu, strSiteHome
strVisibleMenu = Item.Fields.Item("VisibleMenu").Value
strSiteHome = Item.Fields.Item("SiteHome").Value
%>
<%
dim CategoryEdit, CategoryEdit_numRows
set CategoryEdit = Server.CreateObject("ADODB.Recordset")
CategoryEdit.ActiveConnection = MM_oConn_STRING
CategoryEdit.Source = "SELECT * FROM ac_category"
CategoryEdit.CursorType = 0
CategoryEdit.CursorLocation = 2
CategoryEdit.LockType = 1
CategoryEdit.Open()
CategoryEdit_numRows = 0
%>
<table border="0" cellpadding="5" cellspacing="0" class="ac_admin_main">
        <tr><tr><td><img src="../images/blank.gif" width="18" height="6" alt="" /></td></tr> 
	<tr valign="baseline"><td><%= adminHeading(2,lang_admin_default_001,"icons/document_edit_24.gif",lang_admin_item_edit_001,"#") %></td></tr> 
        	<td class="contentarea" colspan=4>
        		<form method="post" action="<%=MM_editAction%>" name="form1">
			<table width="100%" align="center" border="0">
			<tr valign="baseline"> 
				<td align="right" nowrap class="content_titles4" width="20%"><%= lang_admin_cat_add_001 %></td>
				<td class="content_right" width="20%"> <input type="text" id="<%= lang_admin_cat_add_001 %>" name="Title" value="<%=(Item.Fields.Item("Title").Value)%>" size="32"> </td>
				<td nowrap align="right" class="content_titles4"  width="15%"><%= lang_admin_item_add_003 %></td>
				<td class="content_right"> <select name="Category_ID" id="select2">
				<% 
				while (not CategoryEdit.EOF) 
				%>
				                <option value="<%=(CategoryEdit.Fields.Item("ID").Value)%>" <% if (CategoryEdit.Fields.Item("ID").Value = Item.Fields.Item("Category_ID").Value) then Response.Write("SELECTED") : Response.Write("") %> ><%=(CategoryEdit.Fields.Item("Name").Value)%></option>
				<%
				CategoryEdit.MoveNext()
				wend
				
				if (CategoryEdit.CursorType > 0) then
				  if (not CategoryEdit.BOF) then CategoryEdit.MoveFirst()
				else 
				  CategoryEdit.Requery
				end if
				%>
				</select></td>
			</tr>
			<tr>
				<td align="right" class="content_titles4"><%= lang_admin_cat_add_003 %></td>
				<td  class="content_right">
                                <select name="VerticalPosition">
                                    <option value="1" <% if myItemPos="1" then response.write("SELECTED") %>>1</option>
                                    <option value="2" <% if myItemPos="2" then response.write("SELECTED") %>>2</option>
                                    <option value="3" <% if myItemPos="3" then response.write("SELECTED") %>>3</option>
                                    <option value="4" <% if myItemPos="4" then response.write("SELECTED") %>>4</option>
                                    <option value="5" <% if myItemPos="5" then response.write("SELECTED") %>>5</option>
                                    <option value="6" <% if myItemPos="6" then response.write("SELECTED") %>>6</option>
                                    <option value="7" <% if myItemPos="7" then response.write("SELECTED") %>>7</option>
                                    <option value="8" <% if myItemPos="8" then response.write("SELECTED") %>>8</option>
                                    <option value="9" <% if myItemPos="9" then response.write("SELECTED") %>>9</option>
                                    <option value="10" <% if myItemPos="10" then response.write("SELECTED") %>>10</option>
                                    <option value="11" <% if myItemPos="11" then response.write("SELECTED") %>>11</option>
                                    <option value="12" <% if myItemPos="12" then response.write("SELECTED") %>>12</option>
                                    <option value="13" <% if myItemPos="13" then response.write("SELECTED") %>>13</option>
                                    <option value="14" <% if myItemPos="14" then response.write("SELECTED") %>>14</option>
                                    <option value="15" <% if myItemPos="15" then response.write("SELECTED") %>>15</option>
                                    <option value="16" <% if myItemPos="16" then response.write("SELECTED") %>>16</option>
                                    <option value="17" <% if myItemPos="17" then response.write("SELECTED") %>>17</option>
                                    <option value="18" <% if myItemPos="18" then response.write("SELECTED") %>>18</option>
                                    <option value="19" <% if myItemPos="19" then response.write("SELECTED") %>>19</option>
                                    <option value="20" <% if myItemPos="20" then response.write("SELECTED") %>>20</option>
                                    <option value="21" <% if myItemPos="21" then response.write("SELECTED") %>>21</option>
                                    <option value="22" <% if myItemPos="22" then response.write("SELECTED") %>>22</option>
                                    <option value="23" <% if myItemPos="23" then response.write("SELECTED") %>>23</option>
                                    <option value="24" <% if myItemPos="24" then response.write("SELECTED") %>>24</option>
                                    <option value="25" <% if myItemPos="25" then response.write("SELECTED") %>>25</option>
                                    <option value="26" <% if myItemPos="26" then response.write("SELECTED") %>>26</option>
                                    <option value="27" <% if myItemPos="27" then response.write("SELECTED") %>>27</option>
                                    <option value="28" <% if myItemPos="28" then response.write("SELECTED") %>>28</option>
                                    <option value="29" <% if myItemPos="29" then response.write("SELECTED") %>>29</option>
                                    <option value="30" <% if myItemPos="30" then response.write("SELECTED") %>>30</option>
                                </select>
                                </td>
				<td align="right" class="content_titles4"><%= lang_admin_item_edit_002 %></td>
				<td class="content_right2"> <input type="text" name="" value="<%=(Item.Fields.Item("Updated").Value)%>" size="32"></td>
			</tr>
                        <% if Item.Fields.Item("Type").Value="Iframe" then 
                                dim IframeStr, IframeStrArray
		                IframeStr = Item.Fields.Item("Content").Value
		                IframeStrArray = split(IframeStr,"--")
                        %>
                        <tr>
                                <td align="right" class="content_titles4"><%= lang_admin_cat_add_link_001 %></td>
                                <td class="content_right"><input type="text" id="<%= lang_admin_cat_add_link_001 %>" name="content" value="<%= IframeStrArray(2) %>" size="32">
                                <td class="content_right"><%= lang_admin_item_add_028 %> &nbsp;<input type="text" id="width" name="width" size="10" value="<%= IframeStrArray(0) %>"><br><%= lang_admin_item_add_029 %> <input type="text" id="height" name="height" size="10" value="<%= IframeStrArray(1) %>"></td><td></td>
              	                </td>
                        </tr>                         
                        <% else %>
		        <tr>
			        <td align="right" class="content_titles4"><%= lang_admin_cat_add_link_001 %></td>
			        <td class="content_right"><input type="text" id="<%= lang_admin_cat_add_link_001 %>" name="content" value="<%=(Item.Fields.Item("Content").Value)%>" size="32">
			        <td></td><td></td>
				</td>
		        </tr>
		        <% end if %>
		        <!--#include file="admin_item_time_form_edit.asp" -->  
			<input type="hidden" name="ID" value="<%= Item.Fields.Item("ID").Value %>">
			<input type="hidden" name="Type" value="<%= Item.Fields.Item("Type").Value %>">
			<input type="hidden" name="User_ID" value="<%= Item.Fields.Item("User_ID").Value %>">
			<input type="hidden" name="MM_update" value="form1">
			<input type="hidden" name="MM_recordId" value="<%= Item.Fields.Item("ID").Value %>">
			<input type="hidden" name="Updated" value="<%= Now %>"> 
			<tr>
				<td align="right" class="content_apply"><%= lang_admin_config_008 %></td>
				<td class="savebg" colspan=3><INPUT TYPE="image" src="images/save_out.gif" HEIGHT="39" WIDTH="39" BORDER="0" ALT="<%= lang_admin_config_009 %>" value="Update" name="Submit" id="Image1" onMouseOver="MM_swapImage('Image1','','images/save_over.gif',1)" onMouseOut="MM_swapImgRestore()" onClick="MM_validateForm('Title','','R','content','','R');return document.MM_returnValue"></td>
			</tr>
      			</form>
			</table>
		</td>
	</tr>
</table>
<%
Item.Close()
CategoryEdit.Close()
%>

<!--#include file="admin_bottom.asp" -->