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

    <!--#include file="admin_scripts.asp" -->
<!--#include file="admin_top.asp" -->
<link href="css/screen.css" rel="stylesheet" type="text/css" />
<%
'get a list of items from the database for linking purposes
dim ItemList, ItemList_numRows, ListHasCategory
set ItemList = Server.CreateObject("ADODB.Recordset")
ItemList.ActiveConnection = MM_oConn_STRING
ItemList.Source = "SELECT * FROM ac_item ORDER BY Title ASC"
ItemList.CursorType = 0
ItemList.CursorLocation = 2
ItemList.LockType = 1
ItemList.Open()
ItemList_numRows = 0
LeftHasCategory = 0
dim myLinks, myID, myTitle, myLastID, myNewID

While (not ItemList.EOF)
         myID = ItemList.Fields.Item("ID").Value
         myTitle =  ItemList.Fields.Item("Title").Value
         myLinks = myLinks & "<option value="& myID &">" & myTitle & "</option>"

         'get the highest ID number so that we know what the ID of the new will be
         if (ItemList.Fields.Item("ID").Value > myLastID) then
              myLastID = ItemList.Fields.Item("ID").Value
         end if
         'response.write(myLastID & " " & ItemList.Fields.Item("ID").Value & "<br>")
   	 ItemList.MoveNext()
Wend
ItemList.Close()
Set ItemList = Nothing
myNewID = myLastID + 1
%>
<%
dim myParam
myParam = "1"
if (Request.Form("ID") <> "") then
  myParam = Request.Form("ID")
end if
%>
<%
dim currentYear, currentMonth, currentDay
dim currentHour, currentMinute, currentSecond
currentYear = Year(now)
currentMonth = Month(now)
currentDay = Day(now)
currentHour = Hour(now)
currentMinute = Minute(now)
currentSecond = Second(now)

dim strCurrentTime
strCurrentTime = currentYear & "/" & currentMonth  & "/" & currentDay & " " & currentHour & ":" & currentMinute & ":" & currentSecond
%>
<%
' *** Edit Operations: declare variables

Dim MM_editAction, MM_abortEdit, MM_editQuery, MM_editCmd

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>

<%
' *** Insert Record: set variables
Dim MM_editConnection, MM_editTable, MM_editRedirectUrl, MM_editColumn, MM_recordId
Dim MM_fieldsStr, MM_columnsStr, MM_fields, MM_columns, MM_typeArray, MM_formVal
Dim MM_delim, MM_altVal, MM_emptyVal, MM_i
Dim myStartDate, myEndDate

If (CStr(Request("MM_insert")) = "form1") Then
  'get date variables
  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")
  
  'get other form variables
  MM_editConnection = MM_oConn_STRING
  MM_editTable  = "ac_item"
  MM_editRedirectUrl = "default.asp"
  MM_fieldsStr = "ID|value|Title|value|Category_ID|value|Content|value|Updated|value|VerticalPosition|value|User_ID|value|Type|value|VisibleMenu|value|SiteHome|value"
  MM_columnsStr = "ID|none,none,NULL|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
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  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

  ' 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
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) = "form1") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  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_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  'alter sql to add in date information
  MM_tableValues = MM_tableValues & ",StartPub,EndPub"
  MM_dbValues = MM_dbValues & ",'"& myStartDate &"','" & myEndDate & "'"
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

  If (Not MM_abortEdit) Then
    ' execute the insert
    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") = getLatestItem()
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If

function getLatestItem()
	'get the ID of the item that has just been added
	dim ItemLatest
	set ItemLatest = Server.CreateObject("ADODB.Recordset")
	ItemLatest.ActiveConnection = MM_oConn_STRING
	ItemLatest.Source = "SELECT * FROM ac_item ORDER BY ID DESC"
	ItemLatest.CursorType = 0
	ItemLatest.CursorLocation = 2
	ItemLatest.LockType = 1
	ItemLatest.Open()
	dim lastID
	getLatestItem = ItemLatest.Fields.Item("ID").Value
	ItemLatest.Close()
	Set ItemLatest = Nothing
end function

%>
<%
'dim Item, Item_numRows
set Item = Server.CreateObject("ADODB.Recordset")
Item.ActiveConnection = MM_oConn_STRING
Item.Source = "SELECT ID, Title, Category_ID, Content, Updated, VerticalPosition FROM ac_item"
Item.CursorType = 0
Item.CursorLocation = 2
Item.LockType = 1
Item.Open()
Item_numRows = 0
%>
<%
'dim Category, Category_numRows
dim CatID
set Category = Server.CreateObject("ADODB.Recordset")
Category.ActiveConnection = MM_oConn_STRING
Category.Source = "SELECT * FROM ac_category WHERE ID = "& myParam & ""
Category.CursorType = 0
Category.CursorLocation = 2
Category.LockType = 1
Category.Open()
Category_numRows = 0
CatID = Category.Fields.Item("ID").Value
%>

<table border="0" cellpadding="5" cellspacing="0" class="ac_admin_main">
  <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_add_24.gif",lang_admin_item_add_001,"#") %></td></tr> 
    <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="<%= lang_admin_item_add_002 %>" size="32">
            </td>
            <td align="right" class="content_titles4" width="15%"><%= lang_admin_item_add_003 %></td>
            <td class="content_right2"><input type="text" value="<%=(Category.Fields.Item("Name").Value)%>" size="32"</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">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                      <option value="5">5</option>
                      <option value="6">6</option>
                      <option value="7">7</option>
                      <option value="8">8</option>
                      <option value="9">9</option>
                      <option value="10">10</option>
                      <option value="11">11</option>
                      <option value="12">12</option>
                      <option value="13">13</option>
                      <option value="14">14</option>
                      <option value="15">15</option>
                      <option value="16">16</option>
                      <option value="17">17</option>
                      <option value="18">18</option>
                      <option value="19">19</option>
                      <option value="20">20</option>
                      <option value="21">21</option>
                      <option value="22">22</option>
                      <option value="23">23</option>
                      <option value="24">24</option>
                      <option value="25">25</option>
                      <option value="26">26</option>
                      <option value="27">27</option>
                      <option value="28">28</option>
                      <option value="29">29</option>
                      <option value="30">30</option>
                  </select>
            <td></td><td></td>
	  </td>
          </tr>
          
          <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" size="32">
            <td></td><td></td>
	  </td>
          </tr>          
	  <!--#include file="admin_item_time_form.asp" -->
          <tr><td align="right" class="content_apply"><%= lang_admin_config_008 %></td><td bgcolor="#6E7B83" class="contentarea2" colspan="3"><INPUT TYPE="image" src="images/save_out.gif" HEIGHT="39" WIDTH="39" BORDER="0" ALT="<%= lang_admin_config_009 %>" value="Add" 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>
        </table>
  <input type="hidden" name="Updated" value="<%=Now %>">
  <input type="hidden" name="Category_ID" value="<%=(Category.Fields.Item("ID").Value)%>">
  <input type="hidden" name="User_ID" value="<%= Session("MM_UserID") %>">
  <input type="hidden" name="Type" value="rss">
  <input type="hidden" name="ID" value="<%= myNewID %>">
  <input type="hidden" name="MM_insert" value="form1">
</form>
</td></tr></table>
<%
Item.Close()
Set Item = Nothing
%>

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