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.

1562 lines
48 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' folders.asp: Displays the drives and folders
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 16-Jan-2001 Creation date
  11. ' 26-Mar-2001 Modified date
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp" -->
  15. <!-- #include virtual="/admin/ots_main.asp" -->
  16. <!-- #include file="loc_folder.asp"-->
  17. <!-- #include file="inc_folders.asp"-->
  18. <%
  19. '-------------------------------------------------------------------------
  20. ' Global Variables
  21. '-------------------------------------------------------------------------
  22. Dim rc
  23. Dim page
  24. Dim tableIcon
  25. 'OTS page Search variables
  26. Dim g_iSearchCol
  27. Dim g_sSearchColValue
  28. 'OTS page paging variables
  29. Dim g_bPagingInitialized
  30. Dim g_bPageChangeRequested
  31. Dim g_sPageAction
  32. Dim g_iPageMin
  33. Dim g_iPageMax
  34. Dim g_iPageCurrent
  35. 'OTS page Sort variables
  36. Dim g_bSortRequested
  37. Dim g_iSortCol
  38. Dim g_sSortSequence
  39. Dim g_bSearchChanged
  40. Dim g_strFirstColText 'Heading for first Column
  41. Dim g_strSecondColText 'Heading for second colum
  42. Dim g_strThirdColText 'Heading for third column
  43. Dim g_strFourthColText 'Heading for fourth column
  44. Dim g_strFifthColText 'name for fifth column
  45. 'SA_Traceout
  46. Dim SOURCE_FILE
  47. SOURCE_FILE = SA_GetScriptFileName()
  48. Const CONST_GOUP = "GOUP"
  49. Const CONST_FOLDERS_PER_PAGE = 100
  50. Const CONST_WMI_PERFORMANCE_FLAG = 48
  51. Const CONST_SHARE_MULTIPLE = "M"
  52. Const CONST_SHARE_SINGLE = "S"
  53. 'Holds shares web site name
  54. CONST CONST_SHARES ="Shares"
  55. '-------------------------------------------------------------------------
  56. ' Form Variables
  57. '-------------------------------------------------------------------------
  58. Dim F_parent_Folder 'Getting the Parent Folder name
  59. Dim F_strTaskType 'Task type(Goup or open)
  60. Dim F_strNavigation 'Navigation variable
  61. Dim F_strParent 'Parent key for goup function
  62. '======================================================
  63. ' Entry point
  64. '======================================================
  65. F_strNavigation = Request.QueryString("navigation")
  66. g_strSecondColText = L_COLUMN_MODIFIED_TEXT
  67. g_strThirdColText = L_COLUMN_ATTRIBUTES_TEXT
  68. g_strFourthColText = L_COLUMN_SHARED_TEXT
  69. g_strFifthColText = "SHARE FORMAT"
  70. 'Displays the heading for the Drives
  71. If F_strNavigation = "" Then
  72. L_VOLUMESON_APPLIANCE_TEXT = L_VOLUMES_ON_APPLIANCE_TEXT
  73. g_strSecondColText = L_TOTAL_SIZE_TEXT
  74. g_strThirdColText = L_FREE_SPACE_TEXT
  75. 'tableIcon = "images/disks_32x32.gif"
  76. g_strFirstColText = L_COLUMN_NAME_TEXT
  77. Else
  78. Dim arrVarReplacementStringsFolder(1)
  79. arrVarReplacementStringsFolder(0) = GetParentDirectory()
  80. L_FOLDERSPATH_TEXT = SA_GetLocString("foldermsg.dll", "40430066", arrVarReplacementStringsFolder)
  81. L_VOLUMESON_APPLIANCE_TEXT = L_FOLDERSPATH_TEXT
  82. 'tableIcon = "images/folder_32x32.gif"
  83. g_strFirstColText = L_COLUMN_FOLDERNAME
  84. End if
  85. tableIcon = "images/OpenFolderX16.gif"
  86. ' Create Page
  87. rc = SA_CreatePage( L_VOLUMESON_APPLIANCE_TEXT, tableIcon, PT_AREA, page )
  88. ' Show page
  89. rc = SA_ShowPage( page )
  90. '-------------------------------------------------------------------------
  91. 'Function name: OnInitPage
  92. 'Description: Called to signal first time processing for this page. Use this method
  93. ' to do first time initialization tasks.
  94. 'Input Variables: PageIn,EventArg
  95. 'Output Variables: PageIn,EventArg
  96. 'Returns: TRUE to indicate initialization was successful. FALSE to indicate
  97. ' errors. Returning FALSE will cause the page to be abandoned.
  98. 'Global Variables: Out:None
  99. ' In:None
  100. '-------------------------------------------------------------------------
  101. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  102. Dim strHost 'hold host name
  103. Call SA_TraceOut("SOURCE_FILE", "OnInitPage")
  104. ' Initialize variables
  105. Call InitializeVariables()
  106. ' Disable automatic output back button for Folders page
  107. Call SA_SetPageAttribute(pageIn, AUTO_BACKBUTTON, PAGEATTR_DISABLE)
  108. strHost = GetComputerName() 'Get the system name
  109. 'Function call to update the text file for shares default page
  110. Call GenSharesPage(strHost , GetWebSiteID(CONST_SHARES))
  111. End Function
  112. '-------------------------------------------------------------------------
  113. 'Function name: OnServeAreaPage
  114. 'Description: Called when the page needs to be served. Use this method to
  115. ' serve content.
  116. 'Input Variables: PageIn,EventArg
  117. 'Output Variables: PageIn,EventArg
  118. 'Returns: TRUE to indicate not problems occured. FALSE to indicate errors.
  119. ' Returning FALSE will cause the page to be abandoned.
  120. 'Global Variables: Out:None
  121. ' In:g_bSearchChanged, g_bPagingInitialized,g_iPageCurrent,
  122. ' g_strFirstColText,g_strSecondColText,g_strThirdColText,g_strFourthColText,
  123. ' g_sSearchColValue,g_iSearchCol, g_iPageMin, g_iPageMax,
  124. ' g_iSortCol,and g_sSortSequence
  125. '-------------------------------------------------------------------------
  126. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  127. Dim table
  128. Dim iColumnName
  129. Dim iColumnSize
  130. Dim iColumnSpace
  131. Dim iColumnShare
  132. Dim strDrivesFolders
  133. Dim arrDrives
  134. Dim nidx
  135. Dim nCount
  136. Dim arrPath
  137. Dim strTempFolder
  138. Dim strGOUPURL
  139. Dim strUrlBase
  140. Dim nReturnValue
  141. Dim arrFolders
  142. Dim strFolderName
  143. Dim arrFolderName
  144. 'Variables for the display of Share Type
  145. Dim strkey
  146. Dim sharetype
  147. Dim strShr
  148. Dim arrDicItems
  149. Dim strShrTypes
  150. Dim strShrPath
  151. Dim objDict 'Dictionary Object
  152. Dim arrShareTypes
  153. Dim strParentFolder
  154. Dim strShareFormat ' Format of the shares of a folder (Single, or multiple or none)
  155. Dim strShareName '
  156. Dim arrShareNames
  157. Dim strReturnToFolders
  158. ' Initialize variables
  159. nCount = 0
  160. iColumnName = 1
  161. iColumnSize = 2
  162. iColumnSpace = 3
  163. iColumnShare = 4
  164. Call SA_TraceOut("SOURCE_FILE", "OnServeAreaPage")
  165. If F_parent_Folder <> "" then
  166. table = OTS_CreateTable("", L_DESCRIPTION_HEADING2_TEXT)
  167. Else
  168. table = OTS_CreateTable("", L_DESCRIPTION_HEADING1_TEXT)
  169. End If
  170. If ( TRUE = g_bSearchChanged ) Then
  171. ' Need to recalculate the paging range
  172. g_bPagingInitialized = FALSE
  173. ' Restarting on page #1
  174. g_iPageCurrent = 1
  175. End If
  176. ' Add columns to table
  177. nReturnValue = AddColumnsToTable(table)
  178. if nReturnValue = false then
  179. Call SA_ServeFailurepage(L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE)
  180. OnServeAreaPage = false
  181. Exit function
  182. end if
  183. ' Get rows of data for the table
  184. 'If F_parent_Folder is Null getting Drives
  185. if F_parent_Folder = "" Then
  186. strDrivesFolders=GetDrives
  187. Else
  188. 'Else Geeting the Folders
  189. strDrivesFolders=GetFolders
  190. End If
  191. '----------------------------------------------------------------------
  192. 'Start displaying the Shared Type
  193. ' Taking the instance of Dictionary Object to place all shares
  194. ' in Dictionay object.
  195. set objDict=server.CreateObject("scripting.dictionary")
  196. ' Setting the property of Dictionary object to compare the shares in
  197. ' incase sensitive
  198. objDict.CompareMode= vbTextCompare
  199. ' Add all shares to shares table
  200. ' Gets all windows shares with name,path and description and type
  201. call GetCifsShares(objDict)
  202. ' Gets all unix shares with name,path and type
  203. call GetNfsshares(objDict)
  204. ' Gets all Ftp shares with name,path and type
  205. call GetFtpShares(objDict)
  206. ' Gets all Http shares with name,path and type
  207. call GetHttpShares(objDict)
  208. ' Gets all netware shares with name,path and type
  209. call GetNetWareShares(objDict)
  210. ' Gets all AppleTalk shares with name,path and type
  211. call GetAppleTalkShares(objDict)
  212. ' Displaying all shares In Object Picker Control
  213. arrDrives = split(strDrivesFolders,chr(1))
  214. For nidx = 0 to ubound(arrDrives) - 1
  215. 'nCount = nCount + 1
  216. arrPath= split(arrDrives(nidx),chr(2))
  217. strShareName = ""
  218. if F_parent_Folder = "" Then
  219. arrPath(1) =arrpath(1)&"\"
  220. End If
  221. sharetype=""
  222. For each strkey in objDict.Keys
  223. strShrTypes=""
  224. strShr=split(strKey,chr(1))
  225. arrDicItems = split(objDict.Item(strKey),chr(1))
  226. strShrTypes = arrDicItems(1)
  227. 'Checking for isarray or not
  228. If Isarray(strShr) Then
  229. 'checking for the existence
  230. If Ubound(strShr)=1 Then
  231. strShrPath = strShr(1)
  232. End If ' end of If Ubound(strShr)=1 Then
  233. End If ' end of If Isarray(strShr) Then
  234. if lcase(TRIM(arrPath(1))) = lcase(TRIM(strShrPath)) then
  235. ' Build list of all share names separated by "~"
  236. If Isarray(strShr) and UBound(strShr) >= 0 Then
  237. strShareName = strShareName & strShr(0) & chr(126)
  238. End if
  239. arrShareTypes = split(strShrTypes," ")
  240. If Isarray(arrShareTypes) Then
  241. If Ubound(arrShareTypes) >= 0 Then
  242. For nCount=0 to UBound(arrShareTypes)
  243. If Instr(sharetype,arrShareTypes(nCount)) = 0 then
  244. sharetype = sharetype & " " & arrShareTypes(nCount)
  245. End If
  246. Next
  247. End If
  248. End If
  249. end if
  250. Next
  251. ' Retrieve the share names from the list
  252. arrShareNames = split(strShareName, chr(126))
  253. If IsArray(arrShareNames) and UBound(arrShareNames) > 1 then
  254. ' The selected folder entry has multiple share names
  255. strShareFormat = CONST_SHARE_MULTIPLE
  256. Else
  257. ' The selected folder entry either has a single share name or
  258. ' The selected folder entry does not have any share names
  259. strShareFormat = CONST_SHARE_SINGLE
  260. End If
  261. arrFolderName = replace(arrPath(1),"\","/") & chr(1)& arrPath(3)& chr(1) & sharetype
  262. ' Add rows to the table
  263. If ( Len( g_sSearchColValue ) <= 0 ) Then
  264. nCount=nCount+1
  265. ' Verify that the current user part of the current page
  266. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  267. Call OTS_AddTableRow( table,Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  268. End If
  269. ' Search criteria blank, select all rows
  270. Else
  271. Select Case (g_iSearchCol)
  272. Case iColumnName
  273. If ( InStr(1, arrPath(0), g_sSearchColValue, 1) ) Then
  274. nCount=nCount+1
  275. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  276. Call OTS_AddTableRow( table, Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  277. End If
  278. End If
  279. Case iColumnSize
  280. If ( InStr(1,arrPath(2), g_sSearchColValue, 1) ) Then
  281. nCount=nCount+1
  282. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  283. Call OTS_AddTableRow( table, Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  284. End If
  285. End If
  286. Case iColumnSpace
  287. If ( InStr(1, arrPath(3), g_sSearchColValue, 1) ) Then
  288. nCount=nCount+1
  289. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  290. Call OTS_AddTableRow( table, Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  291. End If
  292. End If
  293. Case iColumnShare
  294. If ( InStr(1, sharetype, g_sSearchColValue, 1) ) Then
  295. nCount=nCount+1
  296. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  297. Call OTS_AddTableRow( table, Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  298. End If
  299. End If
  300. Case Else
  301. nCount=nCount+1
  302. If ( IsItemOnPage(nCount, g_iPageCurrent, CONST_FOLDERS_PER_PAGE) ) Then
  303. Call OTS_AddTableRow( table, Array(arrFolderName,arrPath(0),arrPath(2),arrPath(3), sharetype, strShareFormat))
  304. End If
  305. End Select
  306. End If
  307. Next
  308. ' Add Tasks to the table
  309. nReturnValue= OTS_SetTableTasksTitle(table, L_SHARETASKTITLE_TEXT)
  310. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  311. Call SA_ServeFailurepage(L_FAILEDTOADDTASKTITLE_ERRORMESSAGE)
  312. OnServeAreaPage = false
  313. Exit Function
  314. End IF
  315. If F_parent_Folder <> "" Then
  316. strTempFolder = UnescapeChars(F_parent_Folder)
  317. strTempFolder = replace(strTempFolder,"\","/")
  318. arrFolders = split(strTempFolder, "/")
  319. If IsArray(arrFolders) then
  320. If Ubound(arrFolders) >= 0 then
  321. strFolderName = arrFolders(1)
  322. End if
  323. End if
  324. if strFolderName = "" or strFolderName = NULL then
  325. ' Drives OTS
  326. strGOUPURL = "folders/folders.asp?mytasks=CONST_GOUP"
  327. else
  328. ' Folders OTS
  329. strGOUPURL = "folders/folders.asp?mytasks=CONST_GOUP&navigation=next"
  330. end if
  331. call SA_MungeURL(strGOUPURL,"parent",strTempFolder)
  332. call SA_MungeURL(strGOUPURL,"Tab1",GetTab1())
  333. call SA_MungeURL(strGOUPURL,"Tab2",GetTab2())
  334. 'If not top level, add task for going one level up
  335. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_COLUMN_GOUP_TEXT, _
  336. L_UP_ROLLOVER_TEXT, _
  337. strGOUPURL,_
  338. OTS_PT_AREA, _
  339. "OTS_TaskAlways" ) )
  340. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  341. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  342. OnServeAreaPage = false
  343. Exit Function
  344. End IF
  345. 'New task
  346. strUrlBase = "folders/folder_new.asp"
  347. call SA_MungeURL(strUrlBase,"parent", strTempFolder)
  348. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  349. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  350. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SERVEAREABUTTON_NEW_TEXT, _
  351. L_CREATE_ROLLOVER_TEXT, _
  352. strUrlBase,_
  353. OTS_PT_PROPERTY, _
  354. "OTS_TaskAlways" ) )
  355. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  356. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  357. OnServeAreaPage = false
  358. Exit Function
  359. End IF
  360. 'Delete task
  361. strUrlBase = "folders/folder_delete.asp"
  362. call SA_MungeURL(strUrlBase,"parent", strTempFolder)
  363. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  364. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  365. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SERVEAREABUTTON_DELETE_TEXT, _
  366. L_DELETE_ROLLOVER_TEXT, _
  367. strUrlBase,_
  368. OTS_PT_PROPERTY, _
  369. "OTS_TaskAny") )
  370. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  371. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  372. OnServeAreaPage = false
  373. Exit Function
  374. End IF
  375. 'Open task
  376. strReturnToFolders = "folders/folders.asp"
  377. Call SA_MungeURL(strReturnToFolders, "Tab1", GetTab1())
  378. Call SA_MungeURL(strReturnToFolders, "Tab2", GetTab2())
  379. Call SA_MungeURL(strReturnToFolders,"parent", strTempFolder)
  380. strUrlBase = "folders/folders.asp?navigation=next"
  381. call SA_MungeURL(strGOUPURL,"parent", strTempFolder)
  382. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  383. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  384. call SA_MungeURL(strUrlBase, "ReturnURL", strReturnToFolders)
  385. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SERVEAREABUTTON_OPEN_TEXT, _
  386. L_OPEN_ROLLOVER_TEXT, _
  387. strUrlBase,_
  388. OTS_PT_AREA, _
  389. "OTS_TaskOne") )
  390. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  391. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  392. OnServeAreaPage = false
  393. Exit Function
  394. End IF
  395. 'Properties task
  396. strUrlBase = "folders/folder_prop.asp"
  397. call SA_MungeURL(strUrlBase,"parent", strTempFolder)
  398. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  399. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  400. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SERVEAREABUTTON_PROPERTIES_TEXT, _
  401. L_PROPERTIES_ROLLOVER_TEXT, _
  402. strUrlBase,_
  403. OTS_PT_PROPERTY, _
  404. "OTS_TaskAny") )
  405. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  406. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  407. OnServeAreaPage = false
  408. Exit Function
  409. End IF
  410. 'Share task
  411. strUrlBase = "folders/folder_dispatch.asp?ParentPlugin=Folders"
  412. call SA_MungeURL(strUrlBase,"parent", strTempFolder)
  413. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  414. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  415. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SHARELINK_TEXT, _
  416. L_SHARE_ROLLOVER_TEXT, _
  417. strUrlBase,_
  418. OTS_PT_AREA, _
  419. "ShareTask") )
  420. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  421. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  422. OnServeAreaPage = false
  423. Exit Function
  424. End IF
  425. 'Mulitple Share task
  426. strUrlBase = "Shares/shares.asp?ParentPlugin=Folders"
  427. Call SA_MungeURL(strUrlBase,"parent",strTempFolder)
  428. Call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  429. Call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  430. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_MANAGESHARES_TEXT, _
  431. L_MANAGE_SHARES_ROLLOVER_TXT, _
  432. strUrlBase,_
  433. OTS_PT_AREA, _
  434. "OTS_TaskAlways") )
  435. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  436. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  437. OnServeAreaPage = false
  438. Exit Function
  439. End IF
  440. else
  441. 'Open task
  442. strReturnToFolders = "folders/folders.asp"
  443. Call SA_MungeURL(strReturnToFolders, "Tab1", GetTab1())
  444. Call SA_MungeURL(strReturnToFolders, "Tab2", GetTab2())
  445. Call SA_MungeURL(strReturnToFolders,"parent", strTempFolder)
  446. strUrlBase = "folders/folders.asp?navigation=next"
  447. call SA_MungeURL(strGOUPURL,"parent", strTempFolder)
  448. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  449. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  450. call SA_MungeURL(strUrlBase, "ReturnURL", strReturnToFolders)
  451. nReturnValue = OTS_AddTableTask(table, OTS_CreateTaskEx(L_SERVEAREABUTTON_OPEN_TEXT, _
  452. L_VOLUME_OPEN_ROLLOVERTEXT_TEXT, _
  453. strUrlBase,_
  454. OTS_PT_AREA, _
  455. "OTS_TaskOne") )
  456. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  457. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  458. OnServeAreaPage = false
  459. Exit Function
  460. End IF
  461. 'Share task
  462. strUrlBase = "folders/folder_dispatch.asp?ParentPlugin=Folders"
  463. call SA_MungeURL(strUrlBase,"parent", strTempFolder)
  464. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  465. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  466. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_SHARELINK_TEXT, _
  467. L_SHARELINK_ROLLOVER_TEXT, _
  468. strUrlBase,_
  469. OTS_PT_AREA, _
  470. "ShareTask") )
  471. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  472. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  473. OnServeAreaPage = false
  474. Exit Function
  475. End IF
  476. 'Mulitple Share task
  477. strUrlBase = "Shares/shares.asp?ParentPlugin=Folders"
  478. Call SA_MungeURL(strUrlBase,"parent",strTempFolder)
  479. Call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  480. Call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  481. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_MANAGESHARES_TEXT, _
  482. L_MANAGE_SHARES_ROLLOVER_TXT, _
  483. strUrlBase,_
  484. OTS_PT_AREA, _
  485. "OTS_TaskAlways") )
  486. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  487. Call SA_ServeFailurepage(L_FAILEDTOADDTASK_ERRORMESSAGE)
  488. OnServeAreaPage = false
  489. Exit Function
  490. End IF
  491. End If
  492. ' Enable sorting
  493. Call OTS_EnablePaging(table, TRUE)
  494. If ( FALSE = g_bPagingInitialized ) Then
  495. g_iPageMin = 1
  496. g_iPageMax = Int(nCount / CONST_FOLDERS_PER_PAGE )
  497. If ( (nCount MOD CONST_FOLDERS_PER_PAGE) > 0 ) Then
  498. g_iPageMax = g_iPageMax + 1
  499. End If
  500. g_iPageCurrent = 1
  501. Call OTS_SetPagingRange(table, g_iPageMin, g_iPageMax, g_iPageCurrent)
  502. End If
  503. Call OTS_SortTable(table, g_iSortCol, g_sSortSequence, SA_RESERVED)
  504. Call OTS_SetTableMultiSelection(table, true)
  505. ' Send table to the response stream
  506. '
  507. Call OTS_ServeTable(table)
  508. ' Required to retain the share format of the folder selected in the OTS
  509. Response.Write("<input type=hidden name=shareformat id=shareformat value=''>")
  510. 'custom task function to decide whether to disable the share task or not
  511. Dim rows
  512. Dim tasks
  513. rows = ""
  514. Call OTS_GetTableRows(Table, rows)
  515. Call OTS_GetTableTasks(Table, tasks)
  516. Call ServeCustomTaskFunction(tasks, rows)
  517. Set objDict = Nothing
  518. OnServeAreaPage = TRUE
  519. End Function
  520. '-------------------------------------------------------------------------
  521. 'Function name: OnSearchNotify()
  522. 'Description: Search notification event handler. When one or more columns are
  523. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  524. ' this event in the following scenarios:
  525. ' 1) The user presses the search Go button.
  526. ' 2) The user requests a table column sort
  527. ' 3) The user presses either the page next or page previous buttons
  528. '
  529. ' The EventArg indicates the source of this notification event which can
  530. ' be either a search change event (scenario 1) or a post back event
  531. ' (scenarios 2 or 3)
  532. '
  533. 'Input Variables: PageIn,EventArg,sItem,sValue
  534. 'Output Variables: PageIn,EventArg,sItem,sValue
  535. 'Returns: Always returns TRUE
  536. 'Global Variables: Out:g_bSearchChanged,g_iSearchCol,g_sSearchColValue
  537. ' In:None
  538. '-------------------------------------------------------------------------
  539. Public Function OnSearchNotify(ByRef PageIn, _
  540. ByRef EventArg, _
  541. ByRef sItem, _
  542. ByRef sValue )
  543. OnSearchNotify = TRUE
  544. Call SA_TraceOut("SOURCE_FILE", "OnSearchNotify() Change Event Fired sItem :" & sItem)
  545. ' User pressed the search GO button
  546. '
  547. If SA_IsChangeEvent(EventArg) Then
  548. Call SA_TraceOut("SOURCE_FILE", "OnSearchNotify() Change Event Fired")
  549. g_bSearchChanged = TRUE
  550. g_iSearchCol = Int(sItem)
  551. g_sSearchColValue = CStr(sValue)
  552. '
  553. ' User clicked a column sort, OR clicked either the page next or page prev button
  554. ElseIf SA_IsPostBackEvent(EventArg) Then
  555. Call SA_TraceOut("SOURCE_FILE", "OnSearchNotify() Postback Event Fired")
  556. g_bSearchChanged = FALSE
  557. g_iSearchCol = Int(sItem)
  558. g_sSearchColValue = CStr(sValue)
  559. '
  560. ' Unknown event source
  561. Else
  562. Call SA_TraceOut("SOURCE_FILE", "Unrecognized Event in OnSearchNotify()")
  563. End IF
  564. End Function
  565. '-------------------------------------------------------------------------
  566. 'Function name: OnPagingNotify()
  567. 'Description: Paging notification event handler. This event is triggered in one of
  568. ' the following scenarios:
  569. '
  570. ' 1) The user presses either the page next or page previous buttons
  571. ' 2) The user presses the search Go button.
  572. ' 3) The user requests a table column sort
  573. '
  574. ' The EventArg indicates the source of this notification event which can
  575. ' be either a paging change event (scenario 1) or a post back event
  576. ' (scenarios 2 or 3)
  577. '
  578. ' The iPageCurrent argument indicates which page the user has requested.
  579. ' This is an integer value between iPageMin and iPageMax.
  580. '
  581. '
  582. 'Input Variables: PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  583. 'Output Variables: PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  584. 'Returns: Always returns TRUE
  585. 'Global Variables: Out:g_bPageChangeRequested,g_sPageAction,g_iPageMin,g_iPageMax
  586. ' g_iPageCurrent
  587. ' In:None
  588. '-------------------------------------------------------------------------
  589. Public Function OnPagingNotify(ByRef PageIn, _
  590. ByRef EventArg, _
  591. ByVal sPageAction, _
  592. ByVal iPageMin, _
  593. ByVal iPageMax, _
  594. ByVal iPageCurrent )
  595. OnPagingNotify = TRUE
  596. g_bPagingInitialized = TRUE
  597. Call SA_TraceOut("SOURCE_FILE:", "OnPagingNotify() Change Event FiredCurrentPage:" & iPageCurrent)
  598. ' User pressed either page next or page previous
  599. If SA_IsChangeEvent(EventArg) Then
  600. Call SA_TraceOut("SOURCE_FILE", "OnPagingNotify() Change Event Fired")
  601. g_bPageChangeRequested = TRUE
  602. g_sPageAction = CStr(sPageAction)
  603. g_iPageMin = iPageMin
  604. g_iPageMax = iPageMax
  605. g_iPageCurrent = iPageCurrent
  606. ' User clicked a column sort OR the search GO button
  607. ElseIf SA_IsPostBackEvent(EventArg) Then
  608. Call SA_TraceOut("SOURCE_FILE", "OnPagingNotify() Postback Event Fired")
  609. g_bPageChangeRequested = FALSE
  610. g_sPageAction = CStr(sPageAction)
  611. g_iPageMin = iPageMin
  612. g_iPageMax = iPageMax
  613. g_iPageCurrent = iPageCurrent
  614. ' Unknown event source
  615. Else
  616. Call SA_TraceOut("SOURCE_FILE", "Unrecognized Event in OnPagingNotify()")
  617. End IF
  618. End Function
  619. '-------------------------------------------------------------------------
  620. 'Function name: OnSortNotify()
  621. 'Description: Sorting notification event handler. This event is triggered in one of
  622. ' the following scenarios:
  623. '
  624. ' 1) The user presses the search Go button.
  625. ' 2) The user presses either the page next or page previous buttons
  626. ' 3) The user requests a table column sort
  627. '
  628. ' The EventArg indicates the source of this notification event which can
  629. ' be either a sorting change event (scenario 1) or a post back event
  630. ' (scenarios 2 or 3)
  631. '
  632. ' The sortCol argument indicated which column the user would like to sort
  633. ' and the sortSeq argument indicates the desired sort sequence which can
  634. ' be either ascending or descending.
  635. 'Input Variables: PageIn,EventArg,sortCol,sortSeq
  636. 'Output Variables: PageIn,EventArg,sortCol,sortSeq
  637. 'Returns: Always returns TRUE
  638. 'Global Variables: Out:g_bSearchChanged,g_iSortCol,g_sSortSequence
  639. ' In:None
  640. '-------------------------------------------------------------------------
  641. Public Function OnSortNotify(ByRef PageIn, _
  642. ByRef EventArg, _
  643. ByVal sortCol, _
  644. ByVal sortSeq )
  645. OnSortNotify = TRUE
  646. ' User pressed column sort
  647. If SA_IsChangeEvent(EventArg) Then
  648. Call SA_TraceOut("SOURCE_FILE", "OnSortNotify() Change Event Fired")
  649. g_bSearchChanged=TRUE
  650. g_iSortCol = Int(sortCol)
  651. g_sSortSequence = sortSeq
  652. ' User presed the search GO button OR clicked either the page next or page prev button
  653. ElseIf SA_IsPostBackEvent(EventArg) Then
  654. Call SA_TraceOut("SOURCE_FILE", "OnSortNotify() Postback Event Fired")
  655. g_iSortCol = sortCol
  656. g_sSortSequence = sortSeq
  657. g_bSortRequested = TRUE
  658. ' Unknown event source
  659. Else
  660. Call SA_TraceOut("SOURCE_FILE", "Unrecognized Event in OnSearchNotify()")
  661. End IF
  662. Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + " sequence: " + sortSeq)
  663. End Function
  664. '-------------------------------------------------------------------------
  665. ' Function name: AddColumnsToTable()
  666. ' Description: Add columns to table
  667. ' Input Variables: table object
  668. ' Output Variables: None
  669. ' Return Values: True/False
  670. ' Global Variables: g_(*), L_(*)
  671. '-------------------------------------------------------------------------
  672. Function AddColumnsToTable(table)
  673. on error resume next
  674. Err.Clear
  675. Dim colFlags
  676. Dim nReturnValue
  677. AddColumnsToTable = false
  678. colFlags = (OTS_COL_HIDDEN OR OTS_COL_KEY)
  679. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumn( L_COLUMN_NAME_TEXT, "left", colFlags ))
  680. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  681. Exit Function
  682. End IF
  683. 'Name column
  684. colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH)
  685. nReturnValue= OTS_AddTableColumn(table, OTS_CreateColumnEx( g_strFirstColText, "left", colFlags, 22 ))
  686. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  687. Exit Function
  688. End IF
  689. 'Size/Modified column
  690. iColumnSize = 2
  691. colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH)
  692. nReturnValue= OTS_AddTableColumn(table, OTS_CreateColumnEx(g_strSecondColText, "left", colFlags, 16 ))
  693. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  694. Exit Function
  695. End IF
  696. 'Space/Attribute column
  697. iColumnSpace = 3
  698. colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH)
  699. nReturnValue= OTS_AddTableColumn(table, OTS_CreateColumnEx(g_strThirdColText, "left", colFlags, 12 ))
  700. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  701. Exit Function
  702. End IF
  703. 'Shared column
  704. iColumnShare = 4
  705. colFlags = (OTS_COL_SEARCH)
  706. nReturnValue= OTS_AddTableColumn(table, OTS_CreateColumnEx(g_strFourthColText, "left", colFlags, 12))
  707. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  708. Exit Function
  709. End IF
  710. 'Shared column format
  711. colFlags = OTS_COL_HIDDEN
  712. nReturnValue= OTS_AddTableColumn(table, OTS_CreateColumnEx(g_strFifthColText, "left", colFlags, 6))
  713. If nReturnValue <> OTS_ERR_SUCCESS or Err.number <> 0 Then
  714. Exit Function
  715. End IF
  716. AddColumnsToTable = true
  717. End Function
  718. '-------------------------------------------------------------------------
  719. ' Function name: GoUpInit()
  720. ' Description: Initializes the F_parent_Folder
  721. ' Input Variables: None
  722. ' Output Variables: None
  723. ' Return Values: None
  724. ' Global Variables: Out:F_parent_Folder
  725. ' In: L_FILESYSTEMOBJECTNOTCREATED_ERRORMESSAGE
  726. '-------------------------------------------------------------------------
  727. Function GoUpInit()
  728. On Error Resume Next
  729. Err.Clear
  730. Dim objFolder
  731. Set objFolder = Server.CreateObject("Scripting.FileSystemObject")
  732. If Err.number <> 0 Then
  733. Call SA_ServeFailurepage(L_FILESYSTEMOBJECTNOTCREATED_ERRORMESSAGE & "(" & Hex(Err.Number) & ")" )
  734. End If
  735. F_strParent = UnescapeChars(F_strParent)
  736. F_strParent=replace(F_strParent,"/","\")
  737. F_parent_Folder = F_strParent
  738. 'If the drive with ":" then add "\"
  739. If Right(Trim(F_parent_Folder),1) = ":" Then
  740. F_parent_Folder = F_parent_Folder & "\"
  741. End if
  742. 'Getting the parent folder
  743. F_parent_Folder = objFolder.GetParentFolderName(F_parent_Folder)
  744. Set objFolder=Nothing
  745. End Function
  746. '-------------------------------------------------------------------------
  747. ' Function name: GetDrives
  748. ' Description: Gets All Drives from input the system
  749. ' Input Variables: WMI Folder ClassName
  750. ' Output Variables: None
  751. ' Return Values: Returns string with all Drives
  752. ' Global Variables: Out:None
  753. ' In: L_WMICONNECTIONFAILED_ERRORMESSAGE
  754. ' L_DISKCOLLECTION_ERRORMESSAGE
  755. '-------------------------------------------------------------------------
  756. Function GetDrives
  757. On Error Resume Next
  758. Err.Clear
  759. Dim objService 'Service object
  760. Dim objDriveCollection 'Drives collection
  761. Dim objInstance 'Instances
  762. Dim strLogicalDisks 'String holding all Drive letters
  763. Dim strVolName 'Volume name
  764. Dim L_LOCAL_DISK_TEXT
  765. Dim arrVolname(1)
  766. Dim strVol(1)
  767. Dim strQuery
  768. strLogicalDisks = ""
  769. Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  770. Set objDriveCollection = objService.InstancesOf("Win32_LogicalDisk", CONST_WMI_PERFORMANCE_FLAG)
  771. If Err.Number <> 0 then
  772. Call SA_ServeFailurepage(L_DISKCOLLECTION_ERRORMESSAGE & " (" & Hex(Err.Number) & ")")
  773. End if
  774. For Each objInstance in objDriveCollection
  775. If objInstance.DriveType = 3 then
  776. strVolName = objInstance.VolumeName
  777. strVol(0) = Cstr(objInstance.DeviceId)
  778. if strVolName = "" then
  779. L_LOCAL_DISK_TEXT = SA_GetLocString("foldermsg.dll", "40430049", strVol)
  780. strVolName = L_LOCAL_DISK_TEXT
  781. else
  782. strVolName = strVolName & " (" & objInstance.DeviceId & ")"
  783. end if
  784. strLogicalDisks = strLogicalDisks & strVolName & chr(2) & objInstance.DeviceId & chr(2) & _
  785. GEtUNITS(objInstance.size,ConvertToUNITS(objInstance.size)) & chr(2) & _
  786. GEtUNITS(objInstance.freespace,ConvertToUNITS(objInstance.freespace)) & chr(1)
  787. End if
  788. Next
  789. GetDrives = strLogicalDisks
  790. Set objService = Nothing
  791. Set objDriveCollection = Nothing
  792. Set objInstance = Nothing
  793. End Function
  794. '-------------------------------------------------------------------------
  795. ' Function name: GetFolders
  796. ' Description: Gets the Folders
  797. ' Input Variables: None
  798. ' Output Variables: None
  799. ' Return Values: Returns string with all Folders
  800. ' Global Variables: Out: F_parent_Folder
  801. ' In:L_FILESYSTEMOBJECTNOTCREATED_ERRORMESSAGE
  802. ' Out:F_parent_Folder
  803. '-------------------------------------------------------------------------
  804. Function GetFolders
  805. On Error Resume Next
  806. Err.Clear
  807. Dim objFolder
  808. Set objFolder = Server.CreateObject("Scripting.FileSystemObject")
  809. If Err.number <> 0 Then
  810. Call SA_ServeFailurepage( L_FILESYSTEMOBJECTNOTCREATED_ERRORMESSAGE & "(" & Hex(Err.Number) & ")" )
  811. Exit Function
  812. End If
  813. If Right(Trim(F_parent_Folder),1) = ":" Then 'If the drive with ":" then add "\"
  814. F_parent_Folder = F_parent_Folder & "\"
  815. End if
  816. GetFolders = SubFolds(objFolder) 'Getting the Subfolders
  817. Set objFolder = Nothing
  818. End Function
  819. '-------------------------------------------------------------------------
  820. ' Function name: SubFolds
  821. ' Description: Gets the Folders and Sub Folders
  822. ' Input Variables: None
  823. ' Output Variables: None
  824. ' Return Values: Returns string with all sub Folders
  825. ' Global Variables: Out: F_parent_Folder
  826. ' In:L_FAILEDTOGETTHEFOLDER_ERRORMESSAGE
  827. ' In:L_FAILEDTOGETTHESUBFOLDER_ERRORMESSAGE
  828. '-------------------------------------------------------------------------
  829. Function SubFolds(objFolder)
  830. On Error Resume Next
  831. Err.Clear
  832. Dim objSubFolder 'Object Sub Folder
  833. Dim objFolders
  834. Dim objSubFold 'Sub Folders
  835. Dim strFolder 'Folders string
  836. Dim strFoldType
  837. strFolder = ""
  838. Set objFolders = objFolder.GetFolder(F_parent_Folder) 'Getting the Folder
  839. If Err.number <> 0 Then
  840. SetErrMsg L_FAILEDTOGETTHEFOLDER_ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
  841. SubFolds = ""
  842. Exit Function
  843. End If
  844. Set objSubFolder=objFolders.SubFolders 'Getting the Sub Folders
  845. For Each objSubFold in objSubFolder
  846. strFoldType=""
  847. 'Read only
  848. If (objSubFold.Attributes and 1)=1 Then
  849. strFoldType="R" & strFoldType
  850. End If
  851. 'Hidden
  852. If (objSubFold.Attributes and 2)=2 Then
  853. strFoldType="H" & strFoldType
  854. End If
  855. 'System folder
  856. If (objSubFold.Attributes and 4)=4 Then
  857. strFoldType="S" & strFoldType
  858. End If
  859. 'Compressed
  860. If (objSubFold.Attributes and 2048)=2048 Then
  861. strFoldType="C" & strFoldType
  862. End If
  863. If (objSubFold.Attributes and 32)=32 Then
  864. strFoldType="A" & strFoldType
  865. End If
  866. strFolder=strFolder&objSubFold.Name&chr(2)&objSubFold.path&chr(2)&objSubFold.DateLastModified&chr(2)&strFoldType&chr(1)
  867. Next
  868. SubFolds=strFolder
  869. Set objSubFolder = Nothing
  870. Set objFolders = Nothing
  871. Set objSubFold = Nothing
  872. End Function
  873. '-------------------------------------------------------------------------
  874. ' Function name: ConvertToUNITS
  875. ' Description: serves in Converting the bytes in to KBs
  876. ' Input Variables: nSize
  877. ' Output Variables: None
  878. ' Return Values: ConvertToUNITS
  879. ' Global Variables: Out: None
  880. ' In:none
  881. '-------------------------------------------------------------------------
  882. Function ConvertToUNITS(nSize)
  883. On Error Resume Next
  884. Err.Clear
  885. Dim nCount
  886. Dim nTmp
  887. 'checking for the null or string value
  888. If nSize="" OR Not Isnumeric(nSize) Then
  889. nSize=0 'Initialize the value
  890. End If
  891. nTmp = nSize/1024
  892. if clng(nTmp) > 1024 then
  893. nCount = 1 + ConvertToUNITS(nTmp)
  894. end if
  895. ConvertToUNITS = nCount
  896. End Function
  897. '-------------------------------------------------------------------------
  898. ' Function name: GetUNITS
  899. ' Description: serves in Converting the bytes in to KB,MB,GB..
  900. ' Input Variables: None
  901. ' Output Variables: nSize,nCount
  902. ' Return Values: GetUNITS
  903. ' Global Variables: Out:None
  904. ' In:none
  905. '-------------------------------------------------------------------------
  906. Function GetUNITS(nSize,nCount)
  907. On Error Resume Next
  908. Err.Clear
  909. Dim nTmp
  910. Select case nCount
  911. case 1:
  912. nTmp = nSize/1024
  913. if nTmp > 999 then
  914. GetUNITS = formatNumber1(nTmp/1024) & " "+L_MB_TEXT
  915. else
  916. GetUNITS = formatNumber1(nTmp) & " "+L_KB_TEXT
  917. end if
  918. case 2:
  919. nTmp = nSize/(1024*1024)
  920. if nTmp > 999 then
  921. GetUNITS = formatNumber1(nTmp/1024) & " " + L_GB_TEXT
  922. else
  923. GetUNITS = formatNumber1(nTmp) & " "+L_MB_TEXT
  924. end if
  925. case 3:
  926. nTmp = nSize/(1024*1024*1024)
  927. if nTmp > 999 then
  928. GetUNITS = formatNumber1(nTmp/1024) & " "+L_TB_TEXT
  929. else
  930. GetUNITS = formatNumber1(nTmp) & " "+L_GB_TEXT
  931. end if
  932. case 4:
  933. nTmp = nSize/(1024*1024*1024*1024)
  934. GetUNITS = formatNumber1(nTmp) &" "+L_TB_TEXT
  935. case else
  936. Call SA_TraceOut(SA_GetScriptFileName(), "ISSUE: Folders.asp::GetUNITS() called with unexpected nCount parameter: " + CStr(nCount))
  937. End select
  938. end Function
  939. '-------------------------------------------------------------------------
  940. ' Function name: formatNumber1
  941. ' Description: serves in formating the numbers
  942. ' Input Variables: nTmp
  943. ' Output Variables: none
  944. ' Return Values: formatNumber1
  945. ' Global Variables: Out: none
  946. ' In:none
  947. '-------------------------------------------------------------------------
  948. Function formatNumber1(nTmp)
  949. On Error Resume Next
  950. Err.Clear
  951. Dim strTemp
  952. strTemp = cstr(nTmp)
  953. if instr(strTemp,".") > 3 then
  954. strTemp = Left(strTemp,3)
  955. else
  956. strTemp = Left(strTemp,4)
  957. end if
  958. formatNumber1 = strTemp
  959. End Function
  960. '-------------------------------------------------------------------------
  961. ' Function name: IsItemOnPage
  962. ' Description: Help to determine whether a particular row belongs the particular page or not
  963. ' Input Variables: iCurrentItem,iCurrentPage, iItemsPerPage
  964. ' Output Variables: none
  965. ' Return Values: True/False
  966. ' Global Variables: Out: none
  967. ' In:none
  968. '-------------------------------------------------------------------------
  969. Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  970. Dim iLowerLimit
  971. Dim iUpperLimit
  972. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  973. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  974. If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  975. IsItemOnPage = TRUE
  976. Else
  977. IsItemOnPage = FALSE
  978. End If
  979. End Function
  980. '-------------------------------------------------------------------------
  981. ' Function name: InitializeVariables()
  982. ' Description: This is to initialize the variables
  983. ' Input Variables: None
  984. ' Output Variables: none
  985. ' Return Values: True/False
  986. ' Global Variables: Out: g_iPageCurrent,g_iSortCol,g_sSortSequence,F_parent_Folder
  987. ' F_strTaskType,F_strParent
  988. ' In:none
  989. '-------------------------------------------------------------------------
  990. Sub InitializeVariables()
  991. Err.Clear
  992. On error resume next
  993. Dim intIndex
  994. Dim itemKey
  995. Dim arrPKey
  996. g_iPageCurrent = 1
  997. g_iSortCol = 1
  998. g_sSortSequence = "A"
  999. F_parent_Folder = ""
  1000. F_strTaskType = Request.QueryString("mytasks")
  1001. F_strParent = UnescapeChars(Request.QueryString("parent"))
  1002. If F_strNavigation <> "" then
  1003. If ( OTS_GetTableSelection("SA_DEFAULT", 1, itemKey) ) Then
  1004. arrPKey = split(itemKey, chr(1))
  1005. F_parent_Folder = UnescapeChars(arrPKey(0))
  1006. End If
  1007. End if
  1008. F_parent_Folder = replace(UnescapeChars(F_parent_Folder),"/","\")
  1009. Call SA_TraceOut("FOLDERS", "ParentAfterInit:" + F_parent_Folder)
  1010. IF F_strTaskType = "CONST_GOUP" Then
  1011. 'initializes the correct value to F_parent_Folder
  1012. Call GoUpInit()
  1013. End If
  1014. End Sub
  1015. '-------------------------------------------------------------------------
  1016. ' Function name: GetParentDirectory
  1017. ' Description: Gets the parent dir to show in the title
  1018. ' Input Variables: None
  1019. ' Output Variables: None
  1020. ' Return Values: Parent directory
  1021. ' Global Variables: None
  1022. '-------------------------------------------------------------------------
  1023. Function GetParentDirectory
  1024. Dim strParent
  1025. Dim arrPKEY
  1026. Dim itemKey
  1027. strParent = ""
  1028. Call SA_StoreTableParameters()
  1029. If ( OTS_GetTableSelection("SA_DEFAULT", 1, itemKey) ) Then
  1030. arrPKey = split(itemKey, chr(1))
  1031. strParent = UnescapeChars(arrPKey(0))
  1032. End If
  1033. strParent = replace(UnescapeChars(strParent),"/","\")
  1034. Call SA_TraceOut("FOLDERS", "MyTask:" + Request.QueryString("mytasks"))
  1035. Call SA_TraceOut("FOLDERS", "ParentBeforeInit:" + strParent)
  1036. Call SA_TraceOut("FOLDERS", "Parent2:" + Request.QueryString("parent"))
  1037. if (Request.QueryString("mytasks") = "CONST_GOUP") then
  1038. Dim objFolder
  1039. Set objFolder = Server.CreateObject("Scripting.FileSystemObject")
  1040. If Err.number <> 0 Then
  1041. Call SA_ServeFailurepage(L_FILESYSTEMOBJECTNOTCREATED_ERRORMESSAGE & "(" & Hex(Err.Number) & ")" )
  1042. End If
  1043. strParent = UnescapeChars(Request.QueryString("parent"))
  1044. strParent = UnescapeChars(strParent)
  1045. strParent=replace(strParent,"/","\")
  1046. 'If the drive with ":" then add "\"
  1047. If Right(Trim(strParent),1) = ":" Then
  1048. strParent = strParent & "\"
  1049. End if
  1050. 'Getting the parent folder
  1051. strParent = objFolder.GetParentFolderName(strParent)
  1052. Set objFolder=Nothing
  1053. end if
  1054. GetParentDirectory = strParent
  1055. End Function
  1056. '---------------------------------------------------------------------
  1057. ' Function: ServeCustomTaskFunction()
  1058. '
  1059. ' Synopsis: Demonstrate how to emit client-side javascript code to dynamically
  1060. ' enable OTS tasks.
  1061. '
  1062. ' Arguments: [in] aTasks - Array of tasks added to the OTS table
  1063. ' [in] aItems - Array of items added to the OTS table
  1064. '
  1065. ' Returns: Nothing
  1066. '
  1067. '---------------------------------------------------------------------
  1068. Private Function ServeCustomTaskFunction(ByRef aTasks, ByRef aItems)
  1069. Call SA_TraceOut(SOURCE_FILE, "ServeCustomTaskFunction")
  1070. %>
  1071. <script language='javascript'>
  1072. //----------------------------------------------------------------------
  1073. // Function: ShareObject
  1074. //
  1075. // Synopsis: Pseudo object constructor to create a DiskObject.
  1076. //
  1077. // Arguments: [in] ShareFormat string indicating the format of the disk
  1078. //
  1079. // Returns: Reference to ShareObject
  1080. //
  1081. //----------------------------------------------------------------------
  1082. function ShareObject(ShareFormat)
  1083. {
  1084. this.ShareFormat = ShareFormat;
  1085. }
  1086. <%
  1087. Dim iX
  1088. Dim aItem
  1089. Dim sShareFormat
  1090. Response.Write(""+vbCrLf)
  1091. Response.Write("//"+vbCrLf)
  1092. Response.Write("// Create ShareFormat array, one element for every row in the OTS Table."+vbCrLf)
  1093. Response.Write("//"+vbCrLf)
  1094. Response.Write("var oShareObjects = new Array();"+vbCrLf)
  1095. If ( IsArray(aItems)) Then
  1096. For iX = 0 to (UBound(aItems)-1)
  1097. aItem = aItems(iX)
  1098. If ( IsArray(aItem)) Then
  1099. sShareFormat = aItem(5)
  1100. Response.Write("oShareObjects["+CStr(iX)+"] = new ShareObject('"+sShareFormat+"');"+vbCrLf)
  1101. Else
  1102. Call SA_TraceOut(SA_GetScriptFileName(), "Error: aItem is not an array")
  1103. End If
  1104. Next
  1105. End If
  1106. %>
  1107. //----------------------------------------------------------------------
  1108. // Function: ShareTask
  1109. //
  1110. // Synopsis: Demonstates how to write a TaskFn to handle automatically enabling
  1111. // of tasks. This sample disables the Compress task if any FAT disk
  1112. // has been selected
  1113. //
  1114. // Arguments: [in] sMessage
  1115. // [in] iTaskNo number of task, this will always be the Compress task
  1116. // since we only use it for that task.
  1117. // [in] iItemNo index number of item that has been selected
  1118. //
  1119. // Returns: True to continue processing, False to stop.
  1120. //
  1121. var ShareTaskEnabled = false;
  1122. var iNumSharesSelected = 0;
  1123. function ShareTask(sMessage, iTaskNo, iItemNo)
  1124. {
  1125. var bRc = true;
  1126. try
  1127. {
  1128. if ( sMessage.toLowerCase() == OTS_MESSAGE_BEGIN )
  1129. {
  1130. iNumSharesSelected = 0;
  1131. ShareTaskEnabled = true;
  1132. }
  1133. else if ( sMessage.toLowerCase() == OTS_MESSAGE_ITEM )
  1134. {
  1135. var ShareObject = oShareObjects[iItemNo];
  1136. iNumSharesSelected += 1;
  1137. // Update hidden variable for use in Shares.asp
  1138. document.getElementById("shareformat").value = ShareObject.ShareFormat
  1139. if ( ShareObject.ShareFormat == '<%=CONST_SHARE_MULTIPLE%>' )
  1140. {
  1141. ShareTaskEnabled = false;
  1142. }
  1143. }
  1144. else if ( sMessage.toLowerCase() == OTS_MESSAGE_END )
  1145. {
  1146. if ( iNumSharesSelected == 1 && ShareTaskEnabled == true )
  1147. {
  1148. OTS_SetTaskEnabled(iTaskNo, true);
  1149. }
  1150. else
  1151. {
  1152. OTS_SetTaskEnabled(iTaskNo, false);
  1153. }
  1154. }
  1155. }
  1156. catch(oException)
  1157. {
  1158. if ( SA_IsDebugEnabled() )
  1159. {
  1160. alert("CompressDiskTask function encountered exception\n\nError: " + oException.number + "\nDescription:"+oException.description);
  1161. }
  1162. }
  1163. return bRc;
  1164. }
  1165. </script>
  1166. <%
  1167. End Function
  1168. '-------------------------------------------------------------------------
  1169. ' Function name: GenSharesPage
  1170. ' Description: lists all shares
  1171. ' Input Variables: strHostName -hostname
  1172. ' strSharesSiteID -website ID
  1173. ' Output Variables: None
  1174. ' Returns:
  1175. ' Global Variables:
  1176. '
  1177. '-------------------------------------------------------------------------
  1178. Sub GenSharesPage(strHostName,strSharesSiteID)
  1179. Err.Clear
  1180. On Error Resume Next
  1181. Dim strSharesFolder
  1182. Dim oFileSystemObject
  1183. Dim oSharesListFile
  1184. Set oFileSystemObject = Server.CreateObject("Scripting.FileSystemObject")
  1185. 'strSharesFolder = oFileSystemObject.GetSpecialFolder(0).Drive & "\inetpub\shares"
  1186. strSharesFolder = GetSharesFolder()
  1187. Set oSharesListFile = oFileSystemObject.CreateTextFile( strSharesFolder + "\SharesList.txt", True, True)
  1188. Dim oWebVirtDir
  1189. Dim oWebRoot
  1190. Dim index
  1191. Dim urlAdmin, i, urlHTTPSAdmin
  1192. Dim nNumSites
  1193. nNumSites = 1000
  1194. Dim arrVroots()
  1195. ReDim arrVroots(nNumSites, 1 )
  1196. Set oWebRoot = GetObject( "IIS://" & strHostName & "/" & strSharesSiteID & "/root")
  1197. if (Err.Number) then
  1198. Call SA_TraceOut(SOURCE_FILE, "GenSharesPage:GetObject Failed with Error:"+Hex(Err.Number))
  1199. exit sub
  1200. end if
  1201. index = -1
  1202. For Each oWebVirtDir in oWebRoot
  1203. index = index + 1
  1204. if (index > nNumSites) then
  1205. Call SA_TraceOut(SOURCE_FILE, "GenSharesPage:Num Shares:"+nNumSites)
  1206. nNumSites = nNumSites + 1000
  1207. ReDim Preserve arrVroots(nNumSites, 1 )
  1208. end if
  1209. arrVroots( index, 0 ) = oWebVirtDir.Name
  1210. Next
  1211. Call SAQuickSort( arrVroots, 0, index, 1, 0 )
  1212. For i = 0 To index
  1213. oSharesListFile.Writeline(arrVroots( i, 0 ))
  1214. Next
  1215. oSharesListFile.Close
  1216. End Sub
  1217. '-------------------------------------------------------------------------
  1218. ' Function name: GetWebSiteID
  1219. ' Description: Get web site name
  1220. ' Input Variables: strWebSiteNamee
  1221. ' Output Variables: None
  1222. ' Returns: website name
  1223. ' Global Variables: IN:G_objHTTPService
  1224. '-------------------------------------------------------------------------
  1225. Function GetWebSiteID( strWebSiteName )
  1226. On Error Resume Next
  1227. Err.Clear
  1228. Dim strWMIpath 'hold query string for WMI
  1229. Dim objSiteCollection 'hold Sites collection
  1230. Dim objSite 'hold Site instance
  1231. 'Build the query for WMI
  1232. strWMIpath = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where servercomment =" & chr(34) & strWebSiteName & chr(34)
  1233. Set objSiteCollection = G_objHTTPService.ExecQuery(strWMIpath)
  1234. for each objSite in objSiteCollection
  1235. GetWebSiteID = objSite.Name
  1236. Exit For
  1237. Next
  1238. 'Destroying dynamically created object
  1239. Set objSiteCollection = Nothing
  1240. End Function
  1241. %>