<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="websetinfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="aspfn7.asp"-->
<!--#include file="userfn7.asp"-->
<% Session.Timeout = 900 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Define page object
Dim webset_view
Set webset_view = New cwebset_view
Set Page = webset_view

' Page init processing
Call webset_view.Page_Init()

' Page main processing
Call webset_view.Page_Main()
%>
<!--#include file="header.asp"-->
<% If webset.Export = "" Then %>
<script type="text/javascript">
<!--
// Create page object
var webset_view = new ew_Page("webset_view");
// page properties
webset_view.PageID = "view"; // page ID
var EW_PAGE_ID = webset_view.PageID; // for backward compatibility
// extend page with Form_CustomValidate function
webset_view.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
webset_view.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
webset_view.ValidateRequired = true; // uses JavaScript validation
<% Else %>
webset_view.ValidateRequired = false; // no JavaScript validation
<% End If %>
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<% End If %>
<p><span class="aspmaker">查看 表: 站点信息
<br><br>
<% If webset.Export = "" Then %>
<a href="websetlist.asp">返回列表</a>&nbsp;
<% If Security.CanAdd Then %>
<a href="<%= webset.AddUrl %>">增加</a>&nbsp;
<% End If %>
<% If Security.CanEdit Then %>
<a href="<%= webset.EditUrl %>">编辑</a>&nbsp;
<% End If %>
<% If Security.CanAdd Then %>
<a href="<%= webset.CopyUrl %>">复制</a>&nbsp;
<% End If %>
<% If Security.CanDelete Then %>
<a href="<%= webset.DeleteUrl %>">删除</a>&nbsp;
<% End If %>
<% End If %>
</span></p>
<% webset_view.ShowMessage %>
<p>
<% If webset.Export = "" Then %>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<%= ew_CurrentPage %>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td>
<% If Not IsObject(webset_view.Pager) Then Set webset_view.Pager = ew_NewPrevNextPager(webset_view.lStartRec, webset_view.lDisplayRecs, webset_view.lTotalRecs) %>
<% If webset_view.Pager.RecordCount > 0 Then %>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="aspmaker">页&nbsp;</span></td>
<!--first page button-->
	<% If webset_view.Pager.FirstButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.FirstButton.Start %>"><img src="images/first.gif" alt="首页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/firstdisab.gif" alt="首页" width="16" height="16" border="0"></td>
	<% End If %>
<!--previous page button-->
	<% If webset_view.Pager.PrevButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.PrevButton.Start %>"><img src="images/prev.gif" alt="上一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/prevdisab.gif" alt="上一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--current page number-->
	<td><input type="text" name="<%= EW_TABLE_PAGE_NO %>" id="<%= EW_TABLE_PAGE_NO %>" value="<%= webset_view.Pager.CurrentPage %>" size="4"></td>
<!--next page button-->
	<% If webset_view.Pager.NextButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.NextButton.Start %>"><img src="images/next.gif" alt="下一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/nextdisab.gif" alt="下一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--last page button-->
	<% If webset_view.Pager.LastButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.LastButton.Start %>"><img src="images/last.gif" alt="尾页" width="16" height="16" border="0"></a></td>	
	<% Else %>
	<td><img src="images/lastdisab.gif" alt="尾页" width="16" height="16" border="0"></td>
	<% End If %>
	<td><span class="aspmaker">&nbsp;的 <%= webset_view.Pager.PageCount %></span></td>
	</tr></table>
<% Else %>
	<% If Security.CanList Then %>
	<% If webset_view.sSrchWhere = "0=101" Then %>
	<span class="aspmaker">请输入查询条件</span>
	<% Else %>
	<span class="aspmaker">没有找到记录</span>
	<% End If %>
	<% Else %>
	<span class="aspmaker">你无权查看</span>
	<% End If %>
<% End If %>
		</td>
	</tr>
</table>
</form>
<br>
<% End If %>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<% If webset.id.Visible Then ' id %>
	<tr<%= webset.id.RowAttributes %>>
		<td class="ewTableHeader">编号</td>
		<td<%= webset.id.CellAttributes %>>
<div<%= webset.id.ViewAttributes %>><%= webset.id.ViewValue %></div>
</td>
	</tr>
<% End If %>
<% If webset.webname.Visible Then ' webname %>
	<tr<%= webset.webname.RowAttributes %>>
		<td class="ewTableHeader">站点名称</td>
		<td<%= webset.webname.CellAttributes %>>
<div<%= webset.webname.ViewAttributes %>><%= webset.webname.ViewValue %></div>
</td>
	</tr>
<% End If %>
<% If webset.icp.Visible Then ' icp %>
	<tr<%= webset.icp.RowAttributes %>>
		<td class="ewTableHeader">备案号</td>
		<td<%= webset.icp.CellAttributes %>>
<div<%= webset.icp.ViewAttributes %>><%= webset.icp.ViewValue %></div>
</td>
	</tr>
<% End If %>
<% If webset.tongji.Visible Then ' tongji %>
	<tr<%= webset.tongji.RowAttributes %>>
		<td class="ewTableHeader">第三方统计代码</td>
		<td<%= webset.tongji.CellAttributes %>>
<div<%= webset.tongji.ViewAttributes %>><%= webset.tongji.ViewValue %></div>
</td>
	</tr>
<% End If %>
</table>
</div>
</td></tr></table>
<% If webset.Export = "" Then %>
<br>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<%= ew_CurrentPage %>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td>
<% If Not IsObject(webset_view.Pager) Then Set webset_view.Pager = ew_NewPrevNextPager(webset_view.lStartRec, webset_view.lDisplayRecs, webset_view.lTotalRecs) %>
<% If webset_view.Pager.RecordCount > 0 Then %>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="aspmaker">页&nbsp;</span></td>
<!--first page button-->
	<% If webset_view.Pager.FirstButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.FirstButton.Start %>"><img src="images/first.gif" alt="首页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/firstdisab.gif" alt="首页" width="16" height="16" border="0"></td>
	<% End If %>
<!--previous page button-->
	<% If webset_view.Pager.PrevButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.PrevButton.Start %>"><img src="images/prev.gif" alt="上一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/prevdisab.gif" alt="上一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--current page number-->
	<td><input type="text" name="<%= EW_TABLE_PAGE_NO %>" id="<%= EW_TABLE_PAGE_NO %>" value="<%= webset_view.Pager.CurrentPage %>" size="4"></td>
<!--next page button-->
	<% If webset_view.Pager.NextButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.NextButton.Start %>"><img src="images/next.gif" alt="下一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/nextdisab.gif" alt="下一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--last page button-->
	<% If webset_view.Pager.LastButton.Enabled Then %>
	<td><a href="<%= webset_view.PageUrl %>start=<%= webset_view.Pager.LastButton.Start %>"><img src="images/last.gif" alt="尾页" width="16" height="16" border="0"></a></td>	
	<% Else %>
	<td><img src="images/lastdisab.gif" alt="尾页" width="16" height="16" border="0"></td>
	<% End If %>
	<td><span class="aspmaker">&nbsp;的 <%= webset_view.Pager.PageCount %></span></td>
	</tr></table>
<% Else %>
	<% If Security.CanList Then %>
	<% If webset_view.sSrchWhere = "0=101" Then %>
	<span class="aspmaker">请输入查询条件</span>
	<% Else %>
	<span class="aspmaker">没有找到记录</span>
	<% End If %>
	<% Else %>
	<span class="aspmaker">你无权查看</span>
	<% End If %>
<% End If %>
		</td>
	</tr>
</table>
</form>
<% End If %>
<p>
<% If webset.Export = "" Then %>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<% End If %>
<!--#include file="footer.asp"-->
<%

' Drop page object
Set webset_view = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cwebset_view

	' Page ID
	Public Property Get PageID()
		PageID = "view"
	End Property

	' Table Name
	Public Property Get TableName()
		TableName = "webset"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "webset_view"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If webset.UseTokenInUrl Then PageUrl = PageUrl & "t=" & webset.TableVar & "&" ' add page token
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
			Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
		Else
			Session(EW_SESSION_MESSAGE) = v
		End If
	End Property

	' Show Message
	Public Sub ShowMessage()
		If Message <> "" Then ' Message in Session, display
			Response.Write "<p><span class=""ewMessage"">" & Message & "</span></p>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If webset.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (webset.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (webset.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()

		' Initialize table object
		Set webset = New cwebset

		' Initialize other table object
		Set zlogin = New czlogin

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "view"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "webset"

		' Open connection to the database
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open EW_DB_CONNECTION_STRING
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If

		' Table Permission loading event
		Call Security.TablePermission_Loading()
		Call Security.LoadCurrentUserLevel(TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.CanView Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("websetlist.asp")
		End If

		' Global page loading event (in userfn7.asp)
		Call Page_Loading()

		' Page load event, used in current page
		Call Page_Load()
	End Sub

	' -----------------------------------------------------------------
	'  Class terminate
	'  - clean up page object
	'
	Private Sub Class_Terminate()
		Call Page_Terminate("")
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Terminate
	'  - called when exit page
	'  - clean up ADO connection and objects
	'  - if url specified, redirect to url
	'
	Sub Page_Terminate(url)

		' Page unload event, used in current page
		Call Page_Unload()

		' Global page unloaded event (in userfn60.asp)
		Call Page_Unloaded()
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set webset = Nothing

		' Go to url if specified
		If url <> "" Then
			Response.Clear
			Response.Redirect url
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------

	Dim lDisplayRecs ' Number of display records
	Dim lStartRec, lStopRec, lTotalRecs, lRecRange
	Dim lRecCnt

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Paging variables
		lDisplayRecs = 1
		lRecRange = 10

		' Load current record
		Dim bLoadCurrentRecord
		bLoadCurrentRecord = False
		Dim sReturnUrl
		sReturnUrl = ""
		Dim bMatchRecord
		bMatchRecord = False
		If IsPageRequest Then ' Validate request
			If Request.QueryString("id").Count > 0 Then
				webset.id.QueryStringValue = Request.QueryString("id")
			Else
				bLoadCurrentRecord = True
			End If

			' Get action
			webset.CurrentAction = "I" ' Display form
			Select Case webset.CurrentAction
				Case "I" ' Get a record to display
					lStartRec = 1 ' Initialize start position
					Set Rs = LoadRecordset() ' Load records
					lTotalRecs = Rs.RecordCount ' Get record count
					If lTotalRecs <= 0 Then ' No record found
						Message = "没有找到记录" ' Set no record message
						sReturnUrl = "websetlist.asp"
					ElseIf bLoadCurrentRecord Then ' Load current record position
						SetUpStartRec() ' Set up start record position

						' Point to current record
						If CLng(lStartRec) <= CLng(lTotalRecs) Then
							bMatchRecord = True
							Rs.Move lStartRec-1
						End If
					Else ' Match key values
						Do While Not Rs.Eof
							If CStr(webset.id.CurrentValue) = CStr(Rs("id")) Then
								webset.StartRecordNumber = lStartRec ' Save record position
								bMatchRecord = True
								Exit Do
							Else
								lStartRec = lStartRec + 1
								Rs.MoveNext
							End If
						Loop
					End If
					If Not bMatchRecord Then
						Message = "没有找到记录" ' Set no record message
						sReturnUrl = "websetlist.asp" ' No matching record, return to list
					Else
						Call LoadRowValues(Rs) ' Load row values
					End If
			End Select
		Else
			sReturnUrl = "websetlist.asp" ' Not page request, return to list
		End If
		If sReturnUrl <> "" Then Call Page_Terminate(sReturnUrl)

		' Render row
		webset.RowType = EW_ROWTYPE_VIEW
		Call RenderRow()
	End Sub
	Dim Pager

	' -----------------------------------------------------------------
	' Set up Starting Record parameters based on Pager Navigation
	'
	Sub SetUpStartRec()
		Dim nPageNo

		' Exit if lDisplayRecs = 0
		If lDisplayRecs = 0 Then Exit Sub
		If IsPageRequest Then ' Validate request

			' Check for a START parameter
			If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then
				lStartRec = Request.QueryString(EW_TABLE_START_REC)
				webset.StartRecordNumber = lStartRec
			ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then
				nPageNo = Request.QueryString(EW_TABLE_PAGE_NO)
				If IsNumeric(nPageNo) Then
					lStartRec = (nPageNo-1)*lDisplayRecs+1
					If lStartRec <= 0 Then
						lStartRec = 1
					ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then
						lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1
					End If
					webset.StartRecordNumber = lStartRec
				End If
			End If
		End If
		lStartRec = webset.StartRecordNumber

		' Check if correct start record counter
		If Not IsNumeric(lStartRec) Or lStartRec = "" Then ' Avoid invalid start record counter
			lStartRec = 1 ' Reset start record counter
			webset.StartRecordNumber = lStartRec
		ElseIf CLng(lStartRec) > CLng(lTotalRecs) Then ' Avoid starting record > total records
			lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record
			webset.StartRecordNumber = lStartRec
		ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
			lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
			webset.StartRecordNumber = lStartRec
		End If
	End Sub

	' -----------------------------------------------------------------
	' Load recordset
	'
	Function LoadRecordset()

		' Call Recordset Selecting event
		Call webset.Recordset_Selecting(webset.CurrentFilter)

		' Load list page sql
		Dim sSql
		sSql = webset.ListSQL
		If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging

		' Load recordset
		Dim RsRecordset
		Set RsRecordset = Server.CreateObject("ADODB.Recordset")
		RsRecordset.CursorLocation = EW_CURSORLOCATION
		RsRecordset.Open sSql, Conn, 1, 2

		' Call Recordset Selected event
		Call webset.Recordset_Selected(RsRecordset)
		Set LoadRecordset = RsRecordset
	End Function

	' -----------------------------------------------------------------
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = webset.KeyFilter

		' Call Row Selecting event
		Call webset.Row_Selecting(sFilter)

		' Load sql based on filter
		webset.CurrentFilter = sFilter
		sSql = webset.SQL
		If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging
		Set RsRow = Server.CreateObject("ADODB.Recordset")
		RsRow.Open sSql, Conn
		If RsRow.Eof Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values

			' Call Row Selected event
			Call webset.Row_Selected(RsRow)
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		webset.id.DbValue = RsRow("id")
		webset.webname.DbValue = RsRow("webname")
		webset.icp.DbValue = RsRow("icp")
		webset.tongji.DbValue = RsRow("tongji")
	End Sub

	' -----------------------------------------------------------------
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Call Row Rendering event
		Call webset.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id

		webset.id.CellCssStyle = ""
		webset.id.CellCssClass = ""

		' webname
		webset.webname.CellCssStyle = ""
		webset.webname.CellCssClass = ""

		' icp
		webset.icp.CellCssStyle = ""
		webset.icp.CellCssClass = ""

		' tongji
		webset.tongji.CellCssStyle = ""
		webset.tongji.CellCssClass = ""

		' -----------
		'  View  Row
		' -----------

		If webset.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			webset.id.ViewValue = webset.id.CurrentValue
			webset.id.CssStyle = ""
			webset.id.CssClass = ""
			webset.id.ViewCustomAttributes = ""

			' webname
			webset.webname.ViewValue = webset.webname.CurrentValue
			webset.webname.CssStyle = ""
			webset.webname.CssClass = ""
			webset.webname.ViewCustomAttributes = ""

			' icp
			webset.icp.ViewValue = webset.icp.CurrentValue
			webset.icp.CssStyle = ""
			webset.icp.CssClass = ""
			webset.icp.ViewCustomAttributes = ""

			' tongji
			webset.tongji.ViewValue = webset.tongji.CurrentValue
			webset.tongji.CssStyle = ""
			webset.tongji.CssClass = ""
			webset.tongji.ViewCustomAttributes = ""

			' View refer script
			' id

			webset.id.HrefValue = ""

			' webname
			webset.webname.HrefValue = ""

			' icp
			webset.icp.HrefValue = ""

			' tongji
			webset.tongji.HrefValue = ""
		End If

		' Call Row Rendered event
		Call webset.Row_Rendered()
	End Sub

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub
End Class
%>
