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.

565 lines
18 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' Ftp_WelcomeMsg.asp: Set the messages to the FTP Sites/Service
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 25-10-2000 Created date
  11. ' 15-01-2000 Modified for new Framework
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp"--->
  15. <!-- #include virtual="/admin/wsa/inc_wsa.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Form Variables
  19. '-------------------------------------------------------------------------
  20. Dim F_strWelcomeMsg 'holds Welcome message
  21. Dim F_strExitMsg 'holds Exit message
  22. Dim F_strMaxConMsg 'holds Max connections message
  23. 'Dim F_AllSites 'holds value for the selected option button
  24. Dim FTPInstalled 'holds boolean whether FTP service is installed or not
  25. '-------------------------------------------------------------------------
  26. ' Global Variables
  27. '-------------------------------------------------------------------------
  28. Dim G_objService 'holds the object locator
  29. Dim G_objSites 'holds the site/service object
  30. '-------------------------------------------------------------------------
  31. ' Start of localization content
  32. '-------------------------------------------------------------------------
  33. Dim L_MESSAGETASKTITLETEXT
  34. Dim L_WELCOMEMSG
  35. Dim L_EXITMSG
  36. Dim L_MAXCONMSG
  37. Dim L_APPLYTOALLFTPTEXT
  38. Dim L_APPLYTOINHERITEDFTPTEXT
  39. Dim L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE
  40. Dim L_INFORMATION_ERRORMESSAGE
  41. Dim L_FTPNOTINSTALLED_ERRORMESSAGE
  42. 'Dim L_FTPWELCOMEPAGEDISCRIPTION
  43. L_MESSAGETASKTITLETEXT = GetLocString("GeneralSettings.dll", "40420025", "")
  44. L_WELCOMEMSG = GetLocString("GeneralSettings.dll", "40420026", "")
  45. L_EXITMSG = GetLocString("GeneralSettings.dll", "40420027", "")
  46. L_MAXCONMSG = GetLocString("GeneralSettings.dll", "40420028", "")
  47. L_APPLYTOALLFTPTEXT = GetLocString("GeneralSettings.dll", "4042002B", "")
  48. L_APPLYTOINHERITEDFTPTEXT = GetLocString("GeneralSettings.dll", "4042002C", "")
  49. L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE = GetLocString("GeneralSettings.dll", "C042002D", "")
  50. L_INFORMATION_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042000F", "")
  51. L_FTPNOTINSTALLED_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420058", "")
  52. 'L_FTPWELCOMEPAGEDISCRIPTION = GetLocString("GeneralSettings.dll", "40420059", "")
  53. '-------------------------------------------------------------------------
  54. 'END of localization content
  55. '-------------------------------------------------------------------------
  56. 'Create property page
  57. Dim rc
  58. Dim page
  59. rc=SA_CreatePage(L_MESSAGETASKTITLETEXT,"",PT_PROPERTY,page)
  60. 'Serve the page
  61. If(rc=0) then
  62. SA_ShowPage(Page)
  63. End if
  64. '-------------------------------------------------------------------------
  65. 'Function: OnInitPage()
  66. 'Description: Called to signal first time processing for this page.
  67. ' Use this method to do first time initialization tasks
  68. 'Input Variables: PageIn,EventArg
  69. 'Output Variables: None
  70. 'Returns: True/False
  71. 'Global Variables: None
  72. '-------------------------------------------------------------------------
  73. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  74. InitObjects()
  75. if FTPInstalled = false then
  76. ServeFailurePage L_FTPNOTINSTALLED_ERRORMESSAGE ,sReturnURL
  77. end if
  78. SetVariablesFromSystem()
  79. OnInitPage = True
  80. End Function
  81. '-------------------------------------------------------------------------
  82. 'Function: OnServePropertyPage()
  83. 'Description: Called when the page needs to be served.Use this
  84. ' method to serve content
  85. 'Input Variables: PageIn,EventArg
  86. 'Output Variables: None
  87. 'Returns: True/False
  88. 'Global Variables: None
  89. '-------------------------------------------------------------------------
  90. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  91. Call ServeCommonJavaScript()
  92. Call ServePage()
  93. OnServePropertyPage = True
  94. End Function
  95. '-------------------------------------------------------------------------
  96. 'Function: OnPostBackPage()
  97. 'Description: Called to signal that the page has been posted-back.
  98. 'Input Variables: PageIn,EventArg
  99. 'Output Variables: None
  100. 'Returns: True/False
  101. 'Global Variables: None
  102. '-------------------------------------------------------------------------
  103. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  104. OnPostBackPage = True
  105. End Function
  106. '-------------------------------------------------------------------------
  107. 'Function: OnSubmitPage()
  108. 'Description: Called when the page has been submitted for processing.
  109. ' Use this method to process the submit request.
  110. 'Input Variables: PageIn,EventArg
  111. 'Output Variables: None
  112. 'Returns: True/False
  113. 'Global Variables: None
  114. '-------------------------------------------------------------------------
  115. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  116. OnSubmitPage = ServeVariablesFromForm()
  117. End Function
  118. '-------------------------------------------------------------------------
  119. 'Function: OnClosePage()
  120. 'Description: Called when the page is about closed.Use this method
  121. ' to perform clean-up processing
  122. 'Input Variables: PageIn,EventArg
  123. 'Output Variables: None
  124. 'Returns: True/False
  125. 'Global Variables: None
  126. '-------------------------------------------------------------------------
  127. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  128. OnClosePage = TRUE
  129. End Function
  130. '-------------------------------------------------------------------------
  131. 'Function: ServeCommonJavaScript
  132. 'Description: Serves in initialiging the values,setting the form
  133. ' data and validating the form values
  134. 'Input Variables: None
  135. 'Output Variables: None
  136. 'Returns: True/False
  137. 'Global Variables: None
  138. '-------------------------------------------------------------------------
  139. Function ServeCommonJavaScript()
  140. %>
  141. <!-- #include file="inc_MasterWeb.js" -->
  142. <script language="JavaScript">
  143. //Validates input
  144. function ValidatePage()
  145. {
  146. // validate functions
  147. return true;
  148. }
  149. //init function
  150. function Init()
  151. {
  152. var FTPinst = "<%=Server.HTMLEncode(FTPInstalled)%>";
  153. if (FTPinst == "False")
  154. {
  155. document.frmTask.txtWelcomeMsg.disabled = true;
  156. document.frmTask.txtExitMsg.disabled = true;
  157. document.frmTask.txtMaxConMsg.disabled = true;
  158. //document.frmTask.optAllSites[0].disabled = true;
  159. //document.frmTask.optAllSites[1].disabled = true;
  160. return false;
  161. }
  162. return true;
  163. }
  164. function SetData()
  165. {
  166. return true;
  167. }
  168. function HandleKey(input)
  169. {
  170. if(input == "DISABLE")
  171. document.onkeypress = "";
  172. else
  173. document.onkeypress = HandleKeyPress;
  174. }
  175. </script>
  176. <% End Function
  177. '-------------------------------------------------------------------------
  178. 'Function: ServePage()
  179. 'Description: For displaying outputs HTML to the user
  180. 'Input Variables: None
  181. 'Output Variables: None
  182. 'Returns: None
  183. 'Global Variables: L_DELETE_CONFIRM_TEXT
  184. '-------------------------------------------------------------------------
  185. Function ServePage
  186. %>
  187. <TABLE WIDTH=518 VALIGN="middle" ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  188. <tr><td>
  189. <table width=100% border=0 CELLSPACING=0 CELLPADDING=2 align=left class="TasksBody">
  190. <TR>
  191. <TD width="30%" align=left>
  192. </TD>
  193. </TR>
  194. <TR>
  195. <TD >
  196. <%=L_WELCOMEMSG%>
  197. </TD>
  198. <td colspan=2>
  199. <textarea style="HEIGHT: 100px; WIDTH: 400px" tabIndex=1 class="formField" name=txtWelcomeMsg onfocus=HandleKey("DISABLE") onblur=HandleKey("ENABLE")><%=Server.HTMLEncode(F_strWelcomeMsg)%></textarea>
  200. </td>
  201. </TR>
  202. <TR>
  203. <TD>
  204. <%=L_EXITMSG%>
  205. </td>
  206. <td colspan=2>
  207. <input type=text name=txtExitMsg size=73 class="formField" tabIndex=2 value="<%=Server.HTMLEncode(F_strExitMsg)%>">
  208. </TD>
  209. </TR>
  210. <TR>
  211. <TD>
  212. <%=L_MAXCONMSG%>
  213. </td>
  214. <td>
  215. <input type=text name=txtMaxConMsg class="formField" size=73 tabIndex=3 value="<%=Server.HTMLEncode(F_strMaxConMsg)%>">
  216. </TD>
  217. </TR>
  218. </table>
  219. </tr></td>
  220. </TABLE>
  221. <%
  222. End Function
  223. '-------------------------------------------------------------------------
  224. 'Function name: ServeVariablesFromForm()
  225. 'Description: Serves in getting the data from Client
  226. 'Input Variables: None
  227. 'Output Variables: None
  228. 'Returns: True/False
  229. 'Global Variables: None
  230. '-------------------------------------------------------------------------
  231. Function ServeVariablesFromForm
  232. 'setting the form variables
  233. F_strWelcomeMsg = Request.Form("txtWelcomeMsg")
  234. F_strExitMsg = Request.Form("txtExitMsg")
  235. F_strMaxConMsg = Request.Form("txtMaxConMsg")
  236. 'F_AllSites = Request.Form("optAllSites")
  237. 'set the welcome message settings
  238. If setWelcomeMsg()then
  239. ServeVariablesFromForm = true
  240. else
  241. ServeVariablesFromForm = false
  242. end if
  243. End Function
  244. '-------------------------------------------------------------------------
  245. 'Function name: SetVariablesFromSystem
  246. 'Description: Serves in Getting the data from Client
  247. 'Input Variables: None
  248. 'Output Variables: None
  249. 'Returns: None
  250. 'Global Variables: None
  251. '-------------------------------------------------------------------------
  252. Function SetVariablesFromSystem
  253. 'Getting values from system
  254. Err.Clear
  255. on error Resume next
  256. Dim objSetting
  257. Dim count
  258. Dim strObjPath
  259. if FTPInstalled = true then
  260. strObjPath = GetIISWMIProviderClassName("IIs_FtpServiceSetting") & ".Name='MSFTPSVC'"
  261. Set objSetting =G_objService.Get(strObjPath)
  262. if Err.number <> 0 then
  263. SetErrMsg L_INFORMATION_ERRORMESSAGE
  264. exit function
  265. end if
  266. if trim(objSetting.GreetingMessage(0)) ="" and trim(objSetting.ExitMessage)="" and trim(objSetting.MaxClientsMessage)="" then
  267. exit function
  268. end if
  269. F_strWelcomeMsg = objSetting.GreetingMessage(0)
  270. if UBound(objSetting.GreetingMessage) <> -1 then
  271. for count=1 to ubound(objSetting.GreetingMessage)
  272. F_strWelcomeMsg = F_strWelcomeMsg & vbNewLine & objSetting.GreetingMessage(count)
  273. next
  274. end if
  275. F_strExitMsg = objSetting.ExitMessage
  276. F_strMaxConMsg = objSetting.MaxClientsMessage
  277. 'Release the object
  278. set objSetting = nothing
  279. end if
  280. End Function
  281. '-------------------------------------------------------------------------
  282. 'Function name: InitObjects
  283. 'Description: Initialization of global variables is done
  284. 'Input Variables: None
  285. 'Returns: true/false
  286. '--------------------------------------------------------------------------
  287. Function InitObjects()
  288. Err.Clear
  289. on error resume next
  290. ' Get instances of IIS_FTPServiceSetting that are visible throughout
  291. Set G_objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  292. set G_objSites = G_objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPServiceSetting"))
  293. if Err.number <> 0 or G_objSites.count = 0 then
  294. FTPInstalled = false
  295. Err.Clear
  296. else
  297. FTPInstalled = true
  298. end if
  299. end function
  300. '------------------------------------------------------------------------------------------------------
  301. 'Function name: setWelcomeMsg
  302. 'Description: Serves in setting the messages for welcome,exit and maxcon to FTP service/sites
  303. 'Input Variables: None
  304. 'Output Variables: Boolean
  305. 'Global Variables: G_objService
  306. ' G_objSites
  307. '------------------------------------------------------------------------------------------------------
  308. Function setWelcomeMsg()
  309. Err.Clear
  310. on error resume next
  311. 'Check whether FTPService is installed
  312. InitObjects()
  313. if FTPInstalled = true then
  314. if NOT SetMessageForAllSites(G_objService) then
  315. ServeFailurePage L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE, sReturnURL
  316. end if
  317. end if
  318. setWelcomeMsg = true
  319. 'Release the objects
  320. set G_objSites = nothing
  321. set G_objService = nothing
  322. end function
  323. '------------------------------------------------------------------------------------------------------
  324. 'Function name: SetMessageForAllSites
  325. 'Description: Serves in setting the messages for welcome,exit and maxcon to the all FTP sites
  326. 'Input Variables: G_objService
  327. 'Output Variables: boolean
  328. 'Returns: None
  329. 'Global Variables: G_objService
  330. 'Other function used: SetMessageForNewSites
  331. '------------------------------------------------------------------------------------------------------
  332. Function SetMessageForAllSites(G_objService)
  333. Err.Clear
  334. on error resume next
  335. Dim objSetting
  336. Dim inst
  337. Dim arrProp(1)
  338. SetMessageForAllSites = false
  339. 'Set Master FTP settings
  340. SetMessageForNewSites G_objService
  341. 'arrProp(0) = "GreetingMessage"
  342. arrProp(0) = "ExitMessage"
  343. arrProp(1) = "MaxClientsMessage"
  344. Set objSetting = getMessageForNoninheritedSites(G_objService)
  345. for each inst in objSetting
  346. if not SetMessages(inst) then
  347. SA_TraceOut "Ftp_WelcomeMsg", L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE
  348. end if
  349. Next
  350. SetMessageForAllSites = true
  351. 'release the object
  352. set objSetting = nothing
  353. End Function
  354. '------------------------------------------------------------------------------------------------------
  355. 'Function name: SetMessageForNewSites
  356. 'Description: Serves in setting the messages for welcome,exit and maxcon to the new FTP sites
  357. 'Input Variables: G_objService
  358. 'Output Variables: boolean
  359. 'Returns: None
  360. 'Global variables: G_objService
  361. '-------------------------------------------------------------------------------------------------------
  362. Function SetMessageForNewSites(G_objService)
  363. Err.Clear
  364. on error resume next
  365. Dim objSetting
  366. Dim strObjPath
  367. SetMessageForNewSites = false
  368. strObjPath = GetIISWMIProviderClassName("IIs_FtpServiceSetting") & ".Name='MSFTPSVC'"
  369. Set objSetting =G_objService.Get(strObjPath)
  370. if Err.number <> 0 then
  371. SetErrMsg L_INFORMATION_ERRORMESSAGE
  372. exit function
  373. end if
  374. if not SetMessages(objSetting) then
  375. SA_TraceOut "Ftp_WelcomeMsg", L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE
  376. exit function
  377. end if
  378. SetMessageForNewSites = true
  379. 'release the object
  380. set objSetting = nothing
  381. End Function
  382. '-----------------------------------------------------------------------------------------------------------
  383. 'Function name: SetMessages
  384. 'Description: Serves in setting the messages for welcome,exit and maxcon.
  385. 'Input Variables: inst
  386. 'Returns: boolean 'true if no error occurs else false
  387. 'Global variables: None
  388. '-----------------------------------------------------------------------------------------------------------
  389. Function SetMessages(inst)
  390. Err.Clear
  391. on error resume next
  392. inst.GreetingMessage = array(F_strWelcomeMsg)
  393. inst.ExitMessage=F_strExitMsg
  394. inst.MaxClientsMessage=F_strMaxConMsg
  395. inst.Put_(WBEMFLAG)
  396. if Err.number <> 0 then
  397. SA_TraceOut "Ftp_WelcomeMsg", L_FAIL_TO_SET_WELCOME_ERROR_MESSAGE
  398. SetMessages = false
  399. exit function
  400. end if
  401. SetMessages = true
  402. End function
  403. '---------------------------------------------------------------------------------
  404. 'Function name: getMessageForNoninheritedSites
  405. 'Description: gets the sites which are non inherited from master service
  406. 'Input Variables: Service
  407. 'Returns: Instances
  408. 'Global variables: None
  409. '----------------------------------------------------------------------------------
  410. Function getMessageForNoninheritedSites(G_objService)
  411. Err.Clear
  412. on error resume next
  413. Dim strQuery
  414. Dim objInstances
  415. Dim objChild
  416. Dim objMaster
  417. Dim count
  418. Dim strTemp
  419. Dim instMaster
  420. Dim instChild
  421. Dim strWelcomeMsg
  422. Dim strExitMsg
  423. Dim strMaxConMsg
  424. Dim strChildWelcomeMsg
  425. set objMaster = G_objService.InstancesOf(GetIISWMIProviderClassName("IIs_Ftpservicesetting"))
  426. for each instMaster in objMaster
  427. strWelcomeMsg = instMaster.GreetingMessage(0)
  428. for count=1 to ubound(instMaster.GreetingMessage)
  429. strWelcomeMsg = strWelcomeMsg & vbNewLine & instMaster.GreetingMessage(count)
  430. next
  431. strExitMsg = instMaster.ExitMessage
  432. strMaxConMsg = instMaster.MaxClientsMessage
  433. next
  434. 'release the object
  435. set objMaster = nothing
  436. set objChild = G_objService.InstancesOf(GetIISWMIProviderClassName("IIs_FtpServerSetting"))
  437. strQuery = "select * from " & GetIISWMIProviderClassName("IIS_FtpServerSetting") & " where "
  438. for each instChild in objChild
  439. strChildWelcomeMsg = instChild.GreetingMessage(0)
  440. for count=1 to ubound(instChild.GreetingMessage)
  441. strChildWelcomeMsg = strChildWelcomeMsg & vbNewLine & instChild.GreetingMessage(count)
  442. next
  443. if (strChildWelcomeMsg <> strWelcomeMsg) or (strExitMsg <> instChild.ExitMessage) or (strMaxConMsg <> instChild.MaxClientsMessage) then
  444. strTemp = strTemp & "Name ='" & instChild.Name & "' or "
  445. end if
  446. next
  447. 'release the object
  448. set objChild = nothing
  449. strTemp = left(strTemp,len(strTemp)-3)
  450. strQuery = strQuery & strTemp
  451. set objInstances = G_objService.ExecQuery(strQuery)
  452. set getMessageForNoninheritedSites = objInstances
  453. End function
  454. %>