Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1009 lines
31 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' Site_area.asp: site area page - lists all the sites,and provides
  6. ' links for creating new site, modifying site settings and
  7. ' deleting site
  8. '
  9. ' Copyright (c) Microsoft Corporation. All rights reserved.
  10. '
  11. ' Date Description
  12. '12-Sep-00 Creation date
  13. '25-Jan-01 Modified for new framework
  14. '-------------------------------------------------------------------------
  15. %>
  16. <!-- #include virtual="/admin/inc_framework.asp" -->
  17. <!-- #include virtual="/admin/ots_main.asp" -->
  18. <!-- #include file="resources.asp" -->
  19. <!-- #include file="inc_wsa.asp" -->
  20. <%
  21. '-------------------------------------------------------------------------
  22. ' Global Variables
  23. '-------------------------------------------------------------------------
  24. Dim rc ' to hold return code for page
  25. Dim page ' to hold page object
  26. Dim g_Table ' to hold table object
  27. Dim g_nCount ' to hold sites number
  28. Dim g_bSearchRequested
  29. Dim g_iSearchCol
  30. Dim g_sSearchColValue
  31. Dim g_bPagingInitialized
  32. Dim g_bPageChangeRequested
  33. Dim g_sPageAction
  34. Dim g_iPageMin
  35. Dim g_iPageMax
  36. Dim g_iPageCurrent
  37. Dim g_bSortRequested
  38. Dim g_iSortCol
  39. Dim g_sSortSequence
  40. Const SITES_PER_PAGE = 100
  41. '=========================================================================
  42. ' Entry point
  43. '=========================================================================
  44. ' Create Page
  45. rc = SA_CreatePage( L_APPLIANCE_SITES_TEXT, "", PT_AREA, page )
  46. ' Show page
  47. rc = SA_ShowPage( page )
  48. '=========================================================================
  49. ' Web Framework Event Handlers
  50. '=========================================================================
  51. '-------------------------------------------------------------------------
  52. ' Function name: OnInitPage
  53. ' Description: Called to signal first time processing for this page.
  54. ' Input Variables: PageIn and EventArg
  55. ' Output Variables: None
  56. ' Return Values: TRUE to indicate initialization was successful. FALSE
  57. ' to indicate errors. Returning FALSE will cause the
  58. ' page to be abandoned.
  59. ' Global Variables: None
  60. ' Called to signal first time processing for this page. Use this method
  61. ' to do first time initialization tasks.
  62. '----------------------------------------------------------------------------
  63. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  64. 'Check for site
  65. Call AlterRuningState()
  66. OnInitPage = TRUE
  67. g_iSortCol = 1
  68. g_sSortSequence = "A"
  69. g_bPagingInitialized = FALSE
  70. g_iPageCurrent = 1
  71. ' Disable automatic output back button for Folders page
  72. Call SA_SetPageAttribute(pageIn, AUTO_BACKBUTTON, PAGEATTR_DISABLE)
  73. End Function
  74. '----------------------------------------------------------------------------
  75. ' Function name: OnServeAreaPage
  76. ' Description: Called when the page needs to be served.
  77. ' Input Variables: PageIn, EventArg
  78. ' Output Variables: None
  79. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate
  80. ' errors. Returning FALSE will cause the page to be
  81. ' abandoned.
  82. ' Global Variables: In:g_bPageChangeRequested,g_sPageAction,
  83. ' g_bSearchRequested,g_iSearchCol,g_sSearchColValue
  84. ' In:L_(*)-Localization Strings
  85. ' Called when the page needs to be served. Use this method to serve
  86. ' content.
  87. '----------------------------------------------------------------------------
  88. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  89. Dim iSiteName 'to hold index of sitename
  90. Dim iSiteIdentifier 'to hold index of siteidentifier
  91. Dim iSiteDescription 'to hold index of site description
  92. Dim iSiteIPAddress 'to hold index of IPAddress
  93. Dim iPort 'to hold index of port
  94. Dim iStatus 'to hold index of status of site
  95. Dim iHostHeader 'to hold index of Hostheader
  96. Dim strReturnTo
  97. Dim sTaskURL
  98. Dim colFlags 'to hold flag value
  99. ' Create the table
  100. g_Table = OTS_CreateTable("", "")
  101. ' Create columns and add them to the table
  102. ' Add hidden column for SiteName
  103. iSiteName = 0
  104. colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_FLAG_KEY)
  105. If ( g_iSortCol = iSiteName ) Then
  106. colFlags = colFlags OR OTS_COL_SORT
  107. End If
  108. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_COLUMN_ID_TEXT, _
  109. "left",colFlags))
  110. 'Add hidden columns for SiteIdentifier
  111. iSiteIdentifier = 1
  112. colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_FLAG_KEY)
  113. If ( g_iSortCol = iSiteIdentifier ) Then
  114. colFlags = colFlags OR OTS_COL_SORT
  115. End If
  116. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_COLUMN_ID_TEXT, _
  117. "left",colFlags))
  118. 'Add column for Site Description
  119. iSiteDescription = 2
  120. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  121. If ( g_iSortCol = iSiteDescription ) Then
  122. colFlags = colFlags OR OTS_COL_SORT
  123. End If
  124. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_COLUMN_DESCRIPTION_TEXT, _
  125. "left",colFlags))
  126. 'Column containing IPAddress value for each site
  127. iSiteIPAddress = 3
  128. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  129. If ( g_iSortCol = iSiteIPAddress ) Then
  130. colFlags = colFlags OR OTS_COL_SORT
  131. End If
  132. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_COLUMN_FULLNAME_TEXT, _
  133. "left",colFlags))
  134. 'Column containing Port value for each site
  135. iPort = 4
  136. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  137. If ( g_iSortCol = iPort ) Then
  138. colFlags = colFlags OR OTS_COL_SORT
  139. End If
  140. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_COLUMN_PORT_TEXT, _
  141. "left", colFlags))
  142. 'Column containing status of each site
  143. iStatus = 5
  144. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  145. If ( g_iSortCol = iStatus ) Then
  146. colFlags = colFlags OR OTS_COL_SORT
  147. End If
  148. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_SITE_STATUS, _
  149. "left", colFlags))
  150. 'Column containing HostHeader of each site
  151. iHostHeader = 6
  152. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  153. If ( g_iSortCol = iHostHeader ) Then
  154. colFlags = colFlags OR OTS_COL_SORT
  155. End If
  156. rc = OTS_AddTableColumn(g_Table, OTS_CreateColumn( L_HOST_HEADER, _
  157. "left", colFlags))
  158. 'add site instances
  159. Call EnumSiteInstances()
  160. '
  161. ' Add tasks to the OTS table
  162. '
  163. 'Add Task title
  164. Call OTS_SetTableTasksTitle(g_Table, L_TASKS_TEXT)
  165. 'Add NEW Task
  166. Call OTS_AddTableTask( g_Table, _
  167. OTS_CreateTaskEx(L_SERVEAREABUTTON_NEW_TEXT, _
  168. L_NEW_ROLLOVERTEXT, _
  169. "WSA/site_new.asp",_
  170. OTS_PAGE_TYPE_TABBED_PROPERTY, _
  171. "OTS_TaskAlways"))
  172. 'If no of sites more than one then show Modify, delete and reset tasks
  173. 'Add modify task
  174. Call OTS_AddTableTask( g_Table, _
  175. OTS_CreateTaskEx(L_SERVEAREABUTTON_MODIFY_TEXT, _
  176. L_MODIFY_ROLLOVERTEXT, _
  177. "WSA/site_modify.asp",_
  178. OTS_PAGE_TYPE_TABBED_PROPERTY,"ImportWebsiteCustomTask"))
  179. 'Add delete task
  180. Call OTS_AddTableTask( g_Table, _
  181. OTS_CreateTaskEx(L_SERVEAREABUTTON_DELETE_TEXT, _
  182. L_DELETE_ROLLOVERTEXT, _
  183. "WSA/site_delete.asp",_
  184. OTS_PAGE_TYPE_SIMPLE_PROPERTY,"ImportWebsiteCustomTask") )
  185. 'Add pause task
  186. sTaskURL = "WSA/site_area.asp?site=pause"
  187. strReturnTo = "tasks.asp"
  188. Call SA_MungeURL(strReturnTo, "Tab1", GetTab1())
  189. Call SA_MungeURL(sTaskURL, "ReturnURL", strReturnTo)
  190. Call OTS_AddTableTask( g_Table, _
  191. OTS_CreateTaskEx(L_PAUSETASK_TEXT, _
  192. L_PAUSE_ROLLOVERTEXT, _
  193. sTaskURL,_
  194. OTS_PAGE_TYPE_STANDARD_PAGE,"AdminWebsiteCustomTask") )
  195. 'Add stop task
  196. sTaskURL = "WSA/site_area.asp?site=stop"
  197. strReturnTo = "tasks.asp"
  198. Call SA_MungeURL(strReturnTo, "Tab1", GetTab1())
  199. Call SA_MungeURL(sTaskURL, "ReturnURL", strReturnTo)
  200. Call OTS_AddTableTask( g_Table, _
  201. OTS_CreateTaskEx(L_STOPTASK_TEXT, _
  202. L_STOP_ROLLOVERTEXT, _
  203. sTaskURL,_
  204. OTS_PAGE_TYPE_STANDARD_PAGE,"AdminWebsiteCustomTask") )
  205. 'Add start task
  206. sTaskURL = "WSA/site_area.asp?site=start"
  207. strReturnTo = "tasks.asp"
  208. Call SA_MungeURL(strReturnTo, "Tab1", GetTab1())
  209. Call SA_MungeURL(sTaskURL, "ReturnURL", strReturnTo)
  210. Call OTS_AddTableTask( g_Table, _
  211. OTS_CreateTaskEx(L_STARTTASK_TEXT, _
  212. L_START_ROLLOVERTEXT, _
  213. sTaskURL,_
  214. OTS_PAGE_TYPE_STANDARD_PAGE,"AdminWebsiteCustomTask") )
  215. ' Enable paging feature
  216. Call OTS_EnablePaging(g_Table, TRUE)
  217. ' If paging range needs to be initialised then
  218. ' we need to figure out how many pages we are going to display
  219. If ( g_bPagingInitialized = FALSE) Then
  220. g_iPageMin = 1
  221. g_iPageMax = Int(g_nCount / SITES_PER_PAGE )
  222. If ( (g_nCount MOD SITES_PER_PAGE) > 0 ) Then
  223. g_iPageMax = g_iPageMax + 1
  224. End If
  225. If (g_iPageMax = 0) Then
  226. g_iPageMax = 1
  227. End If
  228. g_iPageCurrent = 1
  229. Call OTS_SetPagingRange(g_Table, _
  230. g_iPageMin, _
  231. g_iPageMax, _
  232. g_iPageCurrent)
  233. End If
  234. ' Enable sorting
  235. Call OTS_EnableTableSort(g_Table, true)
  236. ' sort table
  237. Call OTS_SortTable(g_Table, g_iSortCol, g_sSortSequence, SA_RESERVED)
  238. ' Send table to the response stream
  239. Call OTS_ServeTaskViewTable(g_Table)
  240. Dim rows
  241. Dim tasks
  242. '
  243. ' Render the custom task functions
  244. '
  245. Call OTS_GetTableRows(g_Table, rows)
  246. Call OTS_GetTableTasks(g_Table, tasks)
  247. Call ServerCustomTaskFunction(tasks, rows)
  248. OnServeAreaPage = TRUE
  249. End Function
  250. '-------------------------------------------------------------------------
  251. ' Function: OnPageChange()
  252. ' Description: Called to signal user selected a page change event
  253. ' (next/previous)
  254. ' Input Variables: PageIn,EventArg,sPageAction
  255. ' Output Variables: None
  256. ' Return Values: Always returns TRUE
  257. ' Global Variables: In:g_bPageChangeRequested,g_sPageAction
  258. '-------------------------------------------------------------------------
  259. Public Function OnPageChange(ByRef PageIn, _
  260. ByRef EventArg, _
  261. ByRef sPageAction )
  262. OnPageChange = TRUE
  263. g_bPageChangeRequested = TRUE
  264. g_sPageAction = CStr(sPageAction)
  265. End Function
  266. '-------------------------------------------------------------------------
  267. ' Function: AlterRuningState()
  268. ' Description: alter the runing state of web site
  269. ' Input Variables: None
  270. ' Output Variables: None
  271. ' Return Values: None
  272. ' Global Variables: In:None
  273. '-------------------------------------------------------------------------
  274. Function AlterRuningState()
  275. Dim strSiteVal ' to hold site name
  276. Dim retVal ' to hold the return value
  277. Dim F_strSiteID
  278. Dim objService
  279. strSiteVal = Request.QueryString("site")
  280. select case strSiteVal
  281. case "pause"
  282. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  283. F_strSiteID = Request.QueryString("PKey")
  284. retVal = PauseWebSite(objService, F_strSiteID )
  285. Set objService = nothing
  286. case "stop"
  287. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  288. F_strSiteID = Request.QueryString("PKey")
  289. retVal = StopWebSite(objService, F_strSiteID )
  290. Set objService = nothing
  291. case "start"
  292. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  293. F_strSiteID = Request.QueryString("PKey")
  294. retVal = StartWebSite(objService, F_strSiteID )
  295. if retVal = false then
  296. Call SA_SetErrMsg(L_ERR_WEBSITE_START)
  297. End If
  298. Set objService = nothing
  299. end select
  300. End Function
  301. '-------------------------------------------------------------------------
  302. ' Function: OnSearchNotify()
  303. '
  304. ' Synopsis: Search notification event handler. When one or more columns are
  305. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  306. ' this event in the following scenarios:
  307. '
  308. ' 1) The user presses the search Go button.
  309. ' 2) The user requests a table column sort
  310. ' 3) The user presses either the page next or page previous
  311. ' buttons
  312. '
  313. ' The EventArg indicates the source of this notification event
  314. ' which can be either a search change event (scenario 1) or a
  315. ' post back event
  316. ' (scenarios 2 or 3)
  317. '
  318. ' Returns: Always returns TRUE
  319. '
  320. '-------------------------------------------------------------------------
  321. Public Function OnSearchNotify(ByRef PageIn, _
  322. ByRef EventArg, _
  323. ByRef sItem, _
  324. ByRef sValue )
  325. OnSearchNotify = TRUE
  326. '
  327. ' User pressed the search GO button
  328. '
  329. If SA_IsChangeEvent(EventArg) Then
  330. g_bSearchRequested = TRUE
  331. g_iSearchCol = Int(sItem)
  332. g_sSearchColValue = CStr(sValue)
  333. '
  334. ' User clicked a column sort, OR clicked either the page next or page
  335. ' prev button
  336. '
  337. ElseIf SA_IsPostBackEvent(EventArg) Then
  338. g_bSearchRequested = FALSE
  339. g_iSearchCol = Int(sItem)
  340. g_sSearchColValue = CStr(sValue)
  341. '
  342. ' Unknown event source
  343. '
  344. Else
  345. Call SA_TraceOut("Site_area.asp", _
  346. "Unrecognized Event in OnSearchNotify()")
  347. End IF
  348. End Function
  349. '-------------------------------------------------------------------------
  350. ' Function: OnPagingNotify()
  351. '
  352. ' Synopsis: Paging notification event handler. This event is triggered in
  353. ' one of the following scenarios:
  354. '
  355. ' 1) The user presses either the page next or page previous buttons
  356. ' 2) The user presses the search Go button.
  357. ' 3) The user requests a table column sort
  358. '
  359. ' The EventArg indicates the source of this notification event
  360. ' which can be either a paging change event (scenario 1) or a
  361. ' post back event(scenarios 2 or 3)
  362. '
  363. ' The iPageCurrent argument indicates which page the user has
  364. ' requested.This is an integer value between iPageMin and iPageMax.
  365. '
  366. ' Returns: Always returns TRUE
  367. '
  368. '-------------------------------------------------------------------------
  369. Public Function OnPagingNotify(ByRef PageIn, _
  370. ByRef EventArg, _
  371. ByVal sPageAction, _
  372. ByVal iPageMin, _
  373. ByVal iPageMax, _
  374. ByVal iPageCurrent )
  375. OnPagingNotify = TRUE
  376. g_bPagingInitialized = TRUE
  377. '
  378. ' User pressed either page next or page previous
  379. '
  380. If SA_IsChangeEvent(EventArg) Then
  381. g_bPageChangeRequested = TRUE
  382. g_sPageAction = CStr(sPageAction)
  383. g_iPageMin = iPageMin
  384. g_iPageMax = iPageMax
  385. g_iPageCurrent = iPageCurrent
  386. '
  387. ' User clicked a column sort OR the search GO button
  388. ElseIf SA_IsPostBackEvent(EventArg) Then
  389. g_bPageChangeRequested = FALSE
  390. g_sPageAction = CStr(sPageAction)
  391. g_iPageMin = iPageMin
  392. g_iPageMax = iPageMax
  393. g_iPageCurrent = iPageCurrent
  394. '
  395. ' Unknown event source
  396. Else
  397. Call SA_TraceOut("Site_area.asp", _
  398. "Unrecognized Event in OnPagingNotify()")
  399. End IF
  400. End Function
  401. '-------------------------------------------------------------------------
  402. ' Function: OnSortNotify()
  403. '
  404. ' Synopsis: Sorting notification event handler. This event is triggered in
  405. ' one ofthe following scenarios:
  406. '
  407. ' 1) The user presses the search Go button.
  408. ' 2) The user presses either the page next or page previous buttons
  409. ' 3) The user requests a table column sort
  410. '
  411. ' The EventArg indicates the source of this notification event
  412. ' which can be either a sorting change event (scenario 1) or a
  413. ' post back event (scenarios 2 or 3)
  414. '
  415. ' The sortCol argument indicated which column the user would like
  416. ' to sort and the sortSeq argument indicates the desired sort
  417. ' sequence which can be either ascending or descending.
  418. '
  419. ' Returns: Always returns TRUE
  420. '
  421. '-------------------------------------------------------------------------
  422. Public Function OnSortNotify(ByRef PageIn, _
  423. ByRef EventArg, _
  424. ByVal sortCol, _
  425. ByVal sortSeq )
  426. OnSortNotify = TRUE
  427. '
  428. ' User pressed column sort
  429. '
  430. If SA_IsChangeEvent(EventArg) Then
  431. g_iSortCol = sortCol
  432. g_sSortSequence = sortSeq
  433. g_bSortRequested = TRUE
  434. '
  435. ' User presed the search GO button OR clicked either the page next
  436. ' or page prev button
  437. ElseIf SA_IsPostBackEvent(EventArg) Then
  438. g_iSortCol = sortCol
  439. g_sSortSequence = sortSeq
  440. g_bSortRequested = TRUE
  441. '
  442. ' Unknown event source
  443. '
  444. Else
  445. Call SA_TraceOut("Site_area.asp", _
  446. "Unrecognized Event in OnSearchNotify()")
  447. End IF
  448. End Function
  449. '-------------------------------------------------------------------------
  450. ' Function: IsItemOnPage()
  451. ' Description: Called to verify whether the current site is
  452. ' displayed or not
  453. ' Input Variables: iCurrentItem, iCurrentPage, iItemsPerPage
  454. ' Output Variables: None
  455. ' Return Values: Boolean
  456. ' Global Variables: None
  457. '-------------------------------------------------------------------------
  458. Private Function IsItemOnPage(ByVal iCurrentItem, _
  459. iCurrentPage, _
  460. iItemsPerPage)
  461. Dim iLowerLimit
  462. Dim iUpperLimit
  463. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  464. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  465. If ( iCurrentItem > iLowerLimit and iCurrentItem < iUpperLimit ) Then
  466. IsItemOnPage = TRUE
  467. Else
  468. IsItemOnPage = FALSE
  469. End If
  470. End Function
  471. '-------------------------------------------------------------------------
  472. ' Function: EnumSiteInstances()
  473. ' Description: Enum site instances and filled the table row
  474. ' Input Variables: None
  475. ' Output Variables: None
  476. ' Return Values: Boolean
  477. ' Global Variables: None
  478. '-------------------------------------------------------------------------
  479. Function EnumSiteInstances()
  480. Dim objService 'to hold WMI Connection object
  481. Dim objSite 'to hold sitecollection value
  482. Dim instSite 'to hold site intsance value
  483. Dim strSID 'to hold site identifier value
  484. Dim strSiteDescription 'to hold site description value
  485. Dim status 'to hold site site status value
  486. Dim strQuery 'to hold Query string
  487. Dim objStatus 'to hold site name
  488. Dim instStatus 'to hold site instance
  489. Dim arrIndx 'to hold array index
  490. Dim strSiteID 'to hold site name
  491. Dim strIPArr 'to hold site IPArray
  492. Dim strPort 'to hold site port value
  493. Dim strSiteDesc 'to hold site description
  494. Dim strHostHeader 'to hold site host header
  495. Dim strIPAddr 'to hold site IP Address
  496. Dim objSiteCol 'to hold the site collection object
  497. Dim rowcount
  498. Err.Clear
  499. On Error Resume Next
  500. g_nCount = 0
  501. strHostHeader = ""
  502. Set objService = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  503. If Err.number <> 0 Then
  504. Call SA_TRACEOUT("Site_area.asp","GetWMIConnection failed")
  505. EnumSiteInstances = FALSE
  506. Exit Function
  507. End If
  508. Set objSiteCol = objService.InstancesOf(GetIISWMIProviderClassName("IIs_WebServerSetting"))
  509. If objSiteCol.count = 0 Then
  510. Set objService = nothing
  511. SA_ServeFailurepageEx L_INFORMATION_ERRORMESSAGE, sReturnURL
  512. End If
  513. 'Release the object
  514. set objSiteCol = nothing
  515. Set objSite = getObjSiteCollection(objService)
  516. If Err.number <> 0 Then
  517. Call SA_TRACEOUT("Site_area.asp","getObjSiteCollection failed")
  518. EnumSiteInstances = FALSE
  519. Set objService = nothing
  520. Exit Function
  521. End If
  522. 'Navigation logic
  523. For Each instSite in objSite
  524. 'get site name
  525. strSiteID = instSite.name
  526. 'get site description
  527. strSiteDescription = instSite.ServerComment
  528. ' Get the SiteIdentifier
  529. strQuery = GetIISWMIProviderClassName("IIs_WebServer") & ".Name='" & instSite.name & "'"
  530. set objStatus = objService.Get(strQuery)
  531. select case objStatus.ServerState
  532. case 2
  533. status = L_START_TEXT
  534. case 4
  535. status = L_STOPPED_TEXT
  536. case 6
  537. status = L_PAUSED_TEXT
  538. end select
  539. 'get serverID property
  540. strSID = instSite.ServerID
  541. 'For site not created from WebUI, the SID is null
  542. 'we set it to "" here to be able to insert it into the OTS row
  543. if isNull( strSID ) then
  544. strSID = ""
  545. end if
  546. If IsIIS60Installed Then
  547. 'Get IP Address
  548. if instSite.ServerBindings(0).IP = "" Then
  549. strIPAddr = L_IP_UNASSIGNED_TEXT
  550. Else
  551. strIPAddr = instSite.ServerBindings(0).IP
  552. End If
  553. 'Get port number
  554. strPort = instSite.ServerBindings(0).Port
  555. 'Get Host Header
  556. strHostHeader = instSite.ServerBindings(0).Hostname
  557. Else
  558. 'get site IPAddress
  559. strIPArr=split(instSite.ServerBindings(0),":")
  560. if strIPArr(0)="" then
  561. strIPAddr= L_IP_UNASSIGNED_TEXT
  562. else
  563. strIPAddr= strIPArr(0)
  564. end if
  565. 'Get port number
  566. strPort=strIPArr(1)
  567. 'Get Host header
  568. if ubound(strIPArr) > 2 then
  569. for arrIndx = 2 to ubound(strIPArr)
  570. strHostHeader = strHostHeader & strIPArr(arrIndx) & ":"
  571. next
  572. strHostHeader = left(strHostHeader,len(strHostHeader)-1)
  573. else
  574. strHostHeader = strIPArr(2)
  575. end if
  576. End If ' end if isiis60installed
  577. ' Increment the count of number of sites
  578. g_nCount = g_nCount + 1
  579. rowcount = rowcount + 1
  580. 'Enable search criteria
  581. If ( g_bSearchRequested ) Then
  582. If ( Len( g_sSearchColValue ) <= 0 ) Then
  583. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  584. SITES_PER_PAGE) ) Then
  585. ' Search criteria blank, select all rows
  586. Call OTS_AddTableRow( g_Table, _
  587. Array(strSiteID, strSID, strSiteDescription, _
  588. strIPAddr,strPort,status, _
  589. strHostHeader))
  590. End if
  591. Else
  592. Select Case (g_iSearchCol)
  593. Case 2 'iSiteDescription
  594. If ( ucase(left(strSiteDescription,len(g_sSearchColValue)))= _
  595. ucase(g_sSearchColValue)) Then
  596. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  597. SITES_PER_PAGE) ) Then
  598. Call OTS_AddTableRow( g_Table, _
  599. Array(strSiteID, strSID, strSiteDescription, _
  600. strIPAddr, strPort,status, _
  601. strHostHeader))
  602. End If
  603. End If
  604. Case 3 'iSiteIPAddress
  605. if ( ucase(left(strIPAddr,len(g_sSearchColValue)))= _
  606. ucase(g_sSearchColValue)) then
  607. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  608. SITES_PER_PAGE) ) Then
  609. Call OTS_AddTableRow( g_Table, _
  610. Array(strSiteID, strSID, strSiteDescription, _
  611. strIPAddr, strPort,status, _
  612. strHostHeader))
  613. End If
  614. End If
  615. Case 4 'iPort
  616. if ( ucase(strPort) = ucase(g_sSearchColValue) ) then
  617. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  618. SITES_PER_PAGE) ) Then
  619. Call OTS_AddTableRow( g_Table, _
  620. Array(strSiteID, strSID, strSiteDescription, strIPAddr, _
  621. strPort,status, strHostHeader))
  622. End If
  623. End If
  624. Case 5 'iStatus
  625. if (ucase(left(status,len(g_sSearchColValue))) = _
  626. ucase(g_sSearchColValue)) then
  627. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  628. SITES_PER_PAGE) ) Then
  629. Call OTS_AddTableRow( g_Table, _
  630. Array(strSiteID, strSID, strSiteDescription, strIPAddr, _
  631. strPort,status, strHostHeader))
  632. End If
  633. End If
  634. Case 6 'iHostHeader
  635. if (ucase(left(strHostHeader,len(g_sSearchColValue)))= _
  636. ucase(g_sSearchColValue) ) then
  637. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  638. SITES_PER_PAGE) ) Then
  639. Call OTS_AddTableRow( g_Table, _
  640. Array(strSiteID, strSID, strSiteDescription, strIPAddr, _
  641. strPort,status, strHostHeader))
  642. End If
  643. End If
  644. Case Else
  645. Call SA_TraceOut("TEMPLATE_AREA", _
  646. "Unrecognized search column: " + CStr(g_iSearchCol))
  647. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  648. SITES_PER_PAGE) ) Then
  649. Call OTS_AddTableRow( g_Table, _
  650. Array(strSiteID, strSID, strSiteDescription, strIPAddr, _
  651. strPort,status, strHostHeader))
  652. End If
  653. End Select
  654. End If
  655. rowcount = rowcount - 1
  656. Else
  657. ' Search not enabled, select all rows
  658. If ( IsItemOnPage( rowcount, g_iPageCurrent, _
  659. SITES_PER_PAGE) ) Then
  660. Call OTS_AddTableRow( g_Table, _
  661. Array(strSiteID, strSID, strSiteDescription, strIPAddr, _
  662. strPort,status, strHostHeader))
  663. End If
  664. End If
  665. Next
  666. 'Release the objects
  667. Set objService = Nothing
  668. set objSite = nothing
  669. Set objStatus = nothing
  670. EnumSiteInstances = True
  671. End Function
  672. '---------------------------------------------------------------------
  673. ' Function: ServeCustomTaskFunction()
  674. '
  675. ' Synopsis: Emit client-side javascript code to dynamically
  676. ' enable OTS tasks.
  677. '
  678. ' Arguments: [in] aTasks - Array of tasks added to the OTS table
  679. ' [in] aItems - Array of items added to the OTS table
  680. '
  681. ' Returns: Nothing
  682. '
  683. '---------------------------------------------------------------------
  684. Private Function ServerCustomTaskFunction(ByRef aTasks, ByRef aItems)
  685. '
  686. ' For different type of sites, we disable/enable different tasks
  687. '
  688. Dim L_IMPORT_SITE ' Sites imported (not created thru webui, and not Admin site)
  689. Dim L_ADMIN_SITE ' Admin site upon which the current asp is running
  690. Dim L_NORMAL_SITE ' Sites created thru webui
  691. L_IMPORT_SITE = "Import"
  692. L_ADMIN_SITE= "Admin"
  693. L_NORMAL_SITE = "Normal"
  694. %>
  695. <script language='javascript'>
  696. //----------------------------------------------------------------------
  697. // Function: WebsiteObject
  698. //
  699. // Synopsis: Pseudo object constructor to create a WebsiteObject.
  700. //
  701. // Arguments: [in] WebsiteType string indicating the type of the website
  702. //
  703. // Returns: Reference to WebsiteType
  704. //
  705. //----------------------------------------------------------------------
  706. function WebsiteObject(WebsiteType)
  707. {
  708. this.WebsiteType = WebsiteType;
  709. }
  710. <%
  711. Dim iX
  712. Dim aItem
  713. Dim sWebsiteType
  714. Response.Write(""+vbCrLf)
  715. Response.Write("//"+vbCrLf)
  716. Response.Write("// Create WebsiteObject array, one element for every row in the OTS Table."+vbCrLf)
  717. Response.Write("//"+vbCrLf)
  718. Response.Write("var oWebsiteObjects = new Array();"+vbCrLf)
  719. If IsArray(aItems) Then
  720. For iX = 0 to (UBound(aItems)-1)
  721. aItem = aItems(iX)
  722. if ( IsArray(aItem)) Then
  723. ' If the Website is the site running the current asp document, it's the admin site
  724. if ucase(GetCurrentWebsiteName()) = ucase(aItem(0)) Then
  725. sWebsiteType = L_ADMIN_SITE
  726. ' If the website is not admin, and don't have a identifier, then it's a import site
  727. ' Notice admin site also has an empty identifier
  728. elseif aItem(1) = "" then
  729. sWebsiteType = L_IMPORT_SITE
  730. ' Otherwise it's a site created thru webui
  731. else
  732. sWebsiteType = L_NORMAL_SITE
  733. end if
  734. Response.Write("oWebsiteObjects["+CStr(iX)+"] = new WebsiteObject('"+sWebsiteType+"');"+vbCrLf)
  735. Else
  736. Call SA_TraceOut(SA_GetScriptFileName(), "Error: aItem is not an array")
  737. End If
  738. Next
  739. End If
  740. %>
  741. //----------------------------------------------------------------------
  742. // Function: ImportWebsiteCustomTask
  743. //
  744. // Synopsis: Disable the tasks when user click a website which is not
  745. // a normal site (created thru webui)
  746. //
  747. // Reference: Refer to sample_ots_dynamic_tasks.asp for complete example for
  748. // how to dynamically enable/disable tasks
  749. //
  750. // Arguments: [in] sMessage
  751. // [in] iTaskNo number of task, this will always be the Compress task
  752. // since we only use it for that task.
  753. // [in] iItemNo index number of item that has been selected
  754. //
  755. // Returns: True to continue processing, False to stop.
  756. //
  757. var ImportWebsiteCustomTaskEnabled = false;
  758. function ImportWebsiteCustomTask(sMessage, iTaskNo, iItemNo)
  759. {
  760. var bRc = true;
  761. try
  762. {
  763. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  764. {
  765. ImportWebsiteCustomTaskEnabled = true;
  766. }
  767. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  768. {
  769. var websiteObject = oWebsiteObjects[iItemNo];
  770. if ( websiteObject.WebsiteType == '<%=L_IMPORT_SITE%>'
  771. || websiteObject.WebsiteType == '<%=L_ADMIN_SITE%>' )
  772. {
  773. ImportWebsiteCustomTaskEnabled = false;
  774. }
  775. }
  776. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  777. {
  778. if ( ImportWebsiteCustomTaskEnabled == true )
  779. {
  780. OTS_SetTaskEnabled(iTaskNo, true);
  781. }
  782. else
  783. {
  784. OTS_SetTaskEnabled(iTaskNo, false);
  785. }
  786. }
  787. }
  788. catch(oException)
  789. {
  790. if ( SA_IsDebugEnabled() )
  791. {
  792. alert("ImportWebsiteCustomTask function encountered exception\n\nError: " + oException.number + "\nDescription:"+oException.description);
  793. }
  794. }
  795. return bRc;
  796. }
  797. //----------------------------------------------------------------------
  798. // Function: AdminWebsiteCustomTask
  799. //
  800. // Synopsis: Disable the tasks when user click the admin website
  801. //
  802. // Reference: Refer to sample_ots_dynamic_tasks.asp for complete example for
  803. // how to dynamically enable/disable tasks
  804. //
  805. // Arguments: [in] sMessage
  806. // [in] iTaskNo number of task, this will always be the Compress task
  807. // since we only use it for that task.
  808. // [in] iItemNo index number of item that has been selected
  809. //
  810. // Returns: True to continue processing, False to stop.
  811. //
  812. var AdminWebsiteCustomTaskEnabled = false;
  813. function AdminWebsiteCustomTask(sMessage, iTaskNo, iItemNo)
  814. {
  815. var bRc = true;
  816. try
  817. {
  818. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  819. {
  820. AdminWebsiteCustomTaskEnabled = true;
  821. }
  822. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  823. {
  824. var websiteObject = oWebsiteObjects[iItemNo];
  825. if ( websiteObject.WebsiteType == '<%=L_ADMIN_SITE%>' )
  826. {
  827. AdminWebsiteCustomTaskEnabled = false;
  828. }
  829. }
  830. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  831. {
  832. if ( AdminWebsiteCustomTaskEnabled == true )
  833. {
  834. OTS_SetTaskEnabled(iTaskNo, true);
  835. }
  836. else
  837. {
  838. OTS_SetTaskEnabled(iTaskNo, false);
  839. }
  840. }
  841. }
  842. catch(oException)
  843. {
  844. if ( SA_IsDebugEnabled() )
  845. {
  846. alert("AdminWebsiteCustomTask function encountered exception\n\nError: " + oException.number + "\nDescription:"+oException.description);
  847. }
  848. }
  849. return bRc;
  850. }
  851. </script>
  852. <%
  853. End Function
  854. %>