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.

366 lines
13 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' changelang.asp: property page to set language
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 15-Jan-2001 Moved to new framework
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp" -->
  14. <%
  15. '
  16. ' Name of this source file
  17. Const SOURCE_FILE = "ChangeLang.asp"
  18. '
  19. ' Flag to toggle optional tracing output
  20. Const ENABLE_TRACING = TRUE
  21. Const ID_LANG_CHANGE_INPROGRESS = "40010006"
  22. Const ID_LANG_CHANGE_INPROGRESS_DSCP= "40010007"
  23. Dim page
  24. Dim rc
  25. Dim strSelectedLangID 'Contains the Language ID (LANGID) of the selected language.
  26. Dim strOldLangID
  27. '================================================================
  28. 'Start of localization Content
  29. '================================================================
  30. Dim L_TASKTITLE_TEXT
  31. Dim L_SELECTLANGUAGE_LEFT_TEXT
  32. Dim L_LANG_SET_FAILED_ERRORMESSAGE
  33. '================================================================
  34. 'Values are hardcoded instead Fetching from Resource.dll
  35. '================================================================
  36. L_TASKTITLE_TEXT =GetLocString("changelangmsg.dll","&H40010003", varReplacementStrings)
  37. L_SELECTLANGUAGE_LEFT_TEXT =GetLocString("changelangmsg.dll","&H40010004", varReplacementStrings)
  38. L_LANG_SET_FAILED_ERRORMESSAGE =GetLocString("changelangmsg.dll","&H40010005", varReplacementStrings)
  39. Call SA_CreatePage( L_TASKTITLE_TEXT, "", PT_PROPERTY, page )
  40. Call SA_ShowPage( page )
  41. '---------------------------------------------------------------------
  42. ' Function name: OnInitPage
  43. ' Description: Called to signal first time processing for this page.
  44. ' Input Variables: PageIn and EventArg
  45. ' Output Variables: None
  46. ' Return Values: TRUE to indicate initialization was successful. FALSE to indicate
  47. ' errors. Returning FALSE will cause the page to be abandoned.
  48. ' Global Variables: None
  49. ' Called to signal first time processing for this page. Use this method
  50. ' to do first time initialization tasks.
  51. '---------------------------------------------------------------------
  52. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  53. If ( ENABLE_TRACING ) Then
  54. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  55. End If
  56. OnInitPage = TRUE
  57. End Function
  58. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  59. If ( ENABLE_TRACING ) Then
  60. Call SA_TraceOut(SOURCE_FILE, "OnServePropertyPage")
  61. End If
  62. Err.Clear
  63. on Error Resume Next
  64. Dim ICurLang 'Contains the Currently set serverappliance language
  65. Dim obj 'Used as object variable
  66. Dim arrLangDisplayImages 'Contains array of language name images supported by serverappliance
  67. Dim arrLangISONames 'Contains ISO names for Server Appliance supported Languages
  68. Dim arrLangCharSets 'Contains char set names for Server Appliance supported Languages
  69. Dim arrLangCodePages 'Contains code page ids for Server Appliance supported Languages
  70. Dim arrLangIDs 'Contains language IDs for Server Appliance supported Languages
  71. Dim i,k,intColoumns,intTotalNumberofLanguages
  72. Dim strLangID
  73. Dim strLangGIF
  74. Dim sChecked
  75. 'Setting for no of coloumns for display purpose
  76. intColoumns=3
  77. set obj = CreateObject("ServerAppliance.LocalizationManager")
  78. ICurLang = obj.GetLanguages(arrLangDisplayImages, arrLangISONames, arrLangCharSets, arrLangCodePages, arrLangIDs)
  79. intTotalNumberofLanguages = Ubound(arrLangDisplayImages)
  80. strSelectedLangID = Hex(arrLangIDs(iCurLang))
  81. strOldLangID = strSelectedLangID
  82. Call ServeCommonJavaScript()
  83. %>
  84. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 xclass="TasksBody">
  85. <TR>
  86. <TD Nowrap colspan=6 class="TasksBody"><% =L_SELECTLANGUAGE_LEFT_TEXT %></TD>
  87. </TR>
  88. <%
  89. For i=0 to intTotalNumberofLanguages
  90. ' work with images or text
  91. If InStr(arrLangDisplayImages(i), ".gif") Then
  92. strLangGIF = arrLangDisplayImages(i)
  93. 'This is because Loc Manager doesn't pay attention to the registry value
  94. If ("images/english.gif" = strLangGIF) Then
  95. strLangGif = ""
  96. arrLangDisplayImages(i) = "English"
  97. End If
  98. Else
  99. strLangGIF = ""
  100. End If
  101. strLangID = Hex(arrLangIDs(i))
  102. If ( strLangID = strSelectedLangID ) Then
  103. sChecked = "CHECKED"
  104. Else
  105. sChecked = ""
  106. End If
  107. If intTotalNumberofLanguages <= 6 Then
  108. Response.Write "<TR>"
  109. Response.Write "<TD class='TasksBody'>"
  110. If (Trim(Len(strLangGIF)) > 0) Then
  111. Response.Write "<INPUT TYPE=Radio " & sChecked & " NAME='curlang'" & " value=" & "'" & strLangID & "'" & "></td>" & "<td class='TasksBody' width='100%'><IMG border=0 src='" &strLangGIF& "'>"
  112. Else
  113. Response.Write "<INPUT TYPE=Radio " & sChecked & " NAME='curlang'" & " value=" & "'" & strLangID & "'" & "></td>" & "<td class='TasksBody' width='100%'>" & Server.HTMLEncode(arrLangDisplayImages(i))
  114. End If
  115. Response.Write "</TD>"
  116. Response.Write "</TR>"+vbCrLf
  117. Else
  118. If (k mod intColoumns =0 ) Then
  119. Response.Write "<TR>"
  120. k=0
  121. End If
  122. Response.Write "<TD class='TasksBody'>"
  123. If (Trim(Len(strLangGIF)) > 0) Then
  124. Response.Write "<INPUT TYPE=Radio " & sChecked & " NAME='curlang'" & " value=" & "'" & strLangID & "'" & "></td>" & "<td class='TasksBody' width='25%'><IMG border=0 src='" &strLangGIF& "'>"
  125. Else
  126. Response.Write "<INPUT TYPE=Radio " & sChecked & " NAME='curlang'" & " value=" & "'" & strLangID & "'" & "></td>" & "<td class='TasksBody' width='25%'>" & Server.HTMLEncode(arrLangDisplayImages(i))
  127. End If
  128. Response.Write "</TD>"+vbCrLf
  129. If (k =intColoumns-1)Then
  130. Response.Write "</TR>"
  131. End If
  132. k = k+1
  133. End If
  134. Next
  135. %>
  136. </TABLE>
  137. <INPUT TYPE=HIDDEN NAME="OldLanguageID" VALUE="<%=strOldLangID %>" >
  138. <%
  139. OnServePropertyPage = TRUE
  140. End Function
  141. '-------------------------------------------------------------------------
  142. 'Function: OnSubmitPage()
  143. 'Description: Called when the page has been submitted for processing.
  144. ' Use this method to process the submit request.
  145. 'Input Variables: PageIn,EventArg
  146. 'Output Variables: None
  147. 'Returns: True/False
  148. 'Global Variables: None
  149. '-------------------------------------------------------------------------
  150. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  151. On Error Resume Next
  152. Err.Clear
  153. Dim objSAHelper
  154. Dim bModifiedPrivilege
  155. Const CONST_SHUTDOWNPRIVILEGE = "SeShutdownPrivilege"
  156. bModifiedPrivilege = FALSE
  157. 'Create SAHelper object
  158. Set objSAHelper = Server.CreateObject("ServerAppliance.SAHelper")
  159. if err.number <> 0 Then
  160. SA_TraceOut "Create object failed for SAHelper object", err.description
  161. else
  162. 'enable shutdown privilege
  163. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, TRUE)
  164. if err.number <> 0 Then
  165. SA_TraceOut "Enable privilege failed", err.description
  166. exit function
  167. end if
  168. end if
  169. Dim sReturnURL
  170. Dim sURL
  171. If ( ENABLE_TRACING ) Then
  172. Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  173. End If
  174. strSelectedLangID = Request.Form("curlang")
  175. strOldLangID = Request.Form("OldLanguageID")
  176. Call SA_TraceOut(SOURCE_FILE, "Selected Language ID is " & strSelectedLangID )
  177. If (strSelectedLangID = strOldLangID) Then
  178. OnSubmitPage = TRUE
  179. if ( bModifiedPrivilege ) then
  180. 'revert back to disabled state
  181. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, FALSE)
  182. if err.number <> 0 Then
  183. SA_TraceOut "Disable privilege failed", err.description
  184. exit function
  185. end if
  186. end if
  187. set objSAHelper = Nothing
  188. Exit Function
  189. End If
  190. If ChangeLanguage() Then
  191. sReturnURL = Request.Form("ReturnURL")
  192. sURL = getVirtualDirectory() + "network/RebootSys.asp"
  193. Call SA_MungeURL( sURL, "ReturnURL", sReturnURL)
  194. Call SA_MungeURL( sURL, SAI_FLD_PAGEKEY, SAI_GetPageKey())
  195. Response.Redirect(sURL)
  196. OnSubmitPage = TRUE
  197. Else
  198. Call SA_ServeFailurePage(L_LANG_SET_FAILED_ERRORMESSAGE)
  199. End If
  200. if ( bModifiedPrivilege ) then
  201. 'revert back to disabled state
  202. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, FALSE)
  203. if err.number <> 0 Then
  204. SA_TraceOut "Disable privilege failed", err.description
  205. exit function
  206. end if
  207. end if
  208. set objSAHelper = Nothing
  209. End Function
  210. '-------------------------------------------------------------------------
  211. 'Function: OnClosePage()
  212. 'Description: Called when the page is about closed.Use this method
  213. ' to perform clean-up processing
  214. 'Input Variables: PageIn,EventArg
  215. 'Output Variables: PageIn,EventArg
  216. 'Returns: True/False
  217. 'Global Variables: None
  218. '-------------------------------------------------------------------------
  219. Public Function OnClosePage(ByRef PageIn, ByRef EventArgIn)
  220. OnClosePage = TRUE
  221. End Function
  222. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArgIn)
  223. OnPostBackPage = TRUE
  224. End Function
  225. '-------------------------------------------------------------------------
  226. 'Function: ServeCommonJavaScript
  227. 'Description: Serves in initialiging the values,setting the form
  228. ' data and validating the form values
  229. 'Input Variables: None
  230. 'Output Variables: None
  231. 'Returns: None
  232. 'Global Variables: L_PASSWORDNOTMATCH_ERRORMESSAGE
  233. '-------------------------------------------------------------------------
  234. Function ServeCommonJavaScript()
  235. %>
  236. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  237. </script>
  238. <script language="JavaScript">
  239. // Init Function
  240. function Init()
  241. {
  242. EnableOK();
  243. EnableCancel();
  244. }
  245. function ValidatePage()
  246. {
  247. return true;
  248. }
  249. //sets the value of LangID of the selected language into the hidden variable.
  250. function SetData()
  251. {
  252. }
  253. </script>
  254. <%
  255. End Function
  256. '=====================================================================
  257. ' Function name : ChangeLanguage
  258. ' Description : It executes the function Executetask() and sets the current
  259. ' language of serverappliance to the userselected language
  260. ' Input Values : None.
  261. ' Return Values : True on sucessfull change of language, False on error (and error msg
  262. ' will be set by SetErrMsg)
  263. ' L_* (in) Localized strings
  264. '=====================================================================
  265. Function ChangeLanguage
  266. On Error Resume Next
  267. Err.Clear
  268. DIM objTaskContext
  269. DIM objSL
  270. DIM rc
  271. ChangeLanguage = FALSE
  272. Set objTaskContext = Server.CreateObject("Taskctx.TaskContext")
  273. If Err.Number <> 0 Then
  274. SA_TraceOut SOURCE_FILE, "Create Taskctx.TaskContext failed: " + CStr(Hex(Err.Number))
  275. Exit Function
  276. End If
  277. Set objSL = Server.CreateObject("SetSystemLocale.SetSystemLocale")
  278. If Err.Number <> 0 Then
  279. SA_TraceOut SOURCE_FILE, "Create SetSystemLocal.SetSystemLocal failed: " + CStr(Hex(Err.Number))
  280. Exit Function
  281. End If
  282. objTaskContext.SetParameter "LanguageID", strSelectedLangID
  283. Err.Clear
  284. rc = SA_ExecuteTask("ChangeLanguage", FALSE, objTaskContext)
  285. If ( rc <> SA_NO_ERROR ) Then
  286. SA_TraceOut SOURCE_FILE, "objAS.ExecuteTask failed"
  287. Exit Function
  288. End If
  289. Err.Clear
  290. objSL.SetLocale strSelectedLangID
  291. If ( Err.Number <> 0 ) Then
  292. SA_TraceOut SOURCE_FILE, "objSL.SetLocal failed" + CStr(Hex(Err.Number))
  293. Exit Function
  294. End If
  295. ChangeLanguage = TRUE
  296. Err.Clear
  297. Set objTaskContext = Nothing
  298. Set objSL = Nothing
  299. End Function
  300. %>