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.

283 lines
7.8 KiB

  1. <%
  2. var g_objPassportManager = ""; //a global passport manager object, not instantiated until called
  3. if ( typeof( L_SITELANG_TEXT ) == "undefined" )
  4. var L_SITELANG_TEXT = "en"
  5. if ( typeof( g_ThisServer ) == "undefined" )
  6. {
  7. var g_ThisServer = new String( Request.ServerVariables( "SERVER_NAME" ) );
  8. var g_ThisScript = Request.ServerVariables( "SCRIPT_NAME" );
  9. if ( Request.ServerVariables("SERVER_PORT_SECURE") == "1" )
  10. var g_ThisURL = "https://" + g_ThisServer + "/" + g_ThisScript;
  11. else
  12. var g_ThisURL = "http://" + g_ThisServer + "/" + g_ThisScript;
  13. //g_ThisServer = g_ThisServer + "/" + fnGetBrowserLang();
  14. g_ThisServer = g_ThisServer + "/" + L_SITELANG_TEXT;
  15. }
  16. // This function will clear all the cookies that are set on this page.
  17. // We clear them out first just in case there are any lingering items.
  18. function fnClearCookies()
  19. {
  20. //fnWriteCookie( "SID", "", "OCAV3" );
  21. fnWriteCookie( "SID", "" );
  22. fnWriteCookie( "GUID", "" );
  23. fnWriteCookie( "State", "" );
  24. fnWriteCookie( "CID", "" );
  25. fnWriteCookie( "PID", "" );
  26. fnWriteCookie( "UID", "" );
  27. fnWriteCookie( "LCID", "" );
  28. //fnWriteCookies "", "", "PPIN" );
  29. }
  30. //Using a write cookie function in case we decide to change the attributes of the cookie
  31. //EG: add an expires value, or change the domain etc. . .
  32. function fnWriteCookie( ID, Value, Key )
  33. {
  34. try
  35. {
  36. if ( String(Key) == "undefined" )
  37. {
  38. Response.Cookies("OCAV3")( ID ) = Value;
  39. //Response.Cookies("OCAV3").Secure = true; //don't really need secure nothing that secure to send!
  40. Response.Cookies("OCAV3").Path = "/"
  41. //Response.Cookies("OCAV3").Expires = "jan 1, 2004 12:00:00"
  42. }
  43. else
  44. {
  45. Response.Cookies( Key ) = String(Value);
  46. Response.Cookies( Key ).Path = "/"
  47. }
  48. }
  49. catch( err )
  50. {
  51. Response.Write("Could not set cookie: " + ID + " Value: " + Value + " err: " + err.description )
  52. }
  53. }
  54. //very basic, just get one of the cookies in our collection
  55. //you can't use this to get non-keyed cookies. Probably should add that
  56. //but I don't use anything that is not in the key
  57. function fnGetCookie( ID )
  58. {
  59. return ( Request.Cookies( "OCAV3" )( ID ) );
  60. }
  61. function DumpCookies()
  62. {
  63. //todo: Remove this test code before shipping
  64. Response.Write("<BR><B>Cookie dump</B><BR>" );
  65. Response.Write(" SID: " + fnGetCookie( "SID" ) + "<BR>" );
  66. Response.Write(" GUID: " + fnGetCookie( "GUID" ) + "<BR>" );
  67. Response.Write(" State: " + fnGetCookie( "State" ) + "<BR>" );
  68. Response.Write(" CID : " + fnGetCookie( "CID" ) + "<BR>" );
  69. Response.Write(" PPIN : " + Request.Cookies( "PPIN" ) );
  70. Response.Write("<BR><BR>All OCAV3: " + Request.Cookies( "OCAV3" ) + "<BR>" )
  71. Response.Write("<BR><BR>All Root: " + Request.Cookies() + "<BR><BR>" )
  72. }
  73. function fnGetBrowserLCID()
  74. {
  75. var lcid = { "en" : "1033",
  76. "ja" : "1041",
  77. "fr" : "1036",
  78. "de" : "1031"
  79. }
  80. var lang = new String ( Request.ServerVariables( "HTTP_ACCEPT_LANGUAGE" ) )
  81. lang = lang.substr( 0, 2 )
  82. switch ( String( lang ) )
  83. {
  84. case "en":
  85. case "ja":
  86. case "fr":
  87. case "de":
  88. return lcid[ lang ] ;
  89. default:
  90. return lcid[ "en" ];
  91. }
  92. }
  93. function fnGetBrowserLang()
  94. {
  95. var lang = new String ( Request.ServerVariables( "HTTP_ACCEPT_LANGUAGE" ) )
  96. lang = lang.substr( 0, 2 );
  97. switch( String( lang ) )
  98. {
  99. case "en":
  100. case "ja":
  101. case "fr":
  102. case "de":
  103. return ( lang );
  104. default:
  105. return "en";
  106. }
  107. }
  108. function fnGetPassportObject()
  109. {
  110. if ( !g_objPassportManager )
  111. {
  112. //TODO:remove Response.Write("Getting passport object: <BR>" );
  113. g_objPassportManager = Server.CreateObject("Passport.Manager");
  114. }
  115. }
  116. function fnDisplayPassportPrompt( bGetCustomerID )
  117. {
  118. fnGetPassportObject();
  119. if ( g_objPassportManager.FromNetworkServer )
  120. {
  121. fnWriteCookie( "PPIN", "1" );
  122. Response.Redirect( g_ThisURL );
  123. }
  124. if ( g_objPassportManager.IsAuthenticated() || g_objPassportManager.HasTicket )
  125. {
  126. var LogOutURL = g_objPassportManager.LogoTag2(Server.URLEncode("http://" + g_ThisServer + "/Welcome.asp"),3600, true, false, fnGetBrowserLCID(), true )
  127. var ppMemberHighID = new String( g_objPassportManager.Profile("MemberIDHigh" ));
  128. var ppMemberLowID = new String ( g_objPassportManager.Profile("MemberIDLow" ) );
  129. var ppMemberID = "0x" + fnHex( ppMemberHighID ) + fnHex( ppMemberLowID );
  130. Response.Write( "\n\n<SCRIPT LANGUAGE=JAVASCRIPT>idICPMenuPane.insertAdjacentHTML(\"beforeEnd\", \"" + "<Span style='position:absolute;top:0;right:5;height:20;width:100;'><center><span style='background-color:white'>" + LogOutURL.replace( /\"/g, "'") + "</span></center></span>" + "\")</SCRIPT>\n\n" )
  131. return ppMemberID;
  132. }
  133. else
  134. {
  135. Response.Write("<p class='clsPTitle'>" + L_PASSPORTSIGNIN_TEXT + "</p>" )
  136. Response.Write("<p class='clsPBody'>" + L_PASSPORTLOGIN_TEXT + "<BR><BR>" )
  137. Response.Write( g_objPassportManager.LogoTag2(Server.URLEncode( g_ThisURL ),3600, false, false, fnGetBrowserLCID(), true, "passport.com", 0, 10))
  138. fnWriteCookie( "PPIN", "" );
  139. return false;
  140. }
  141. }
  142. function fnGetCustomerName()
  143. {
  144. try
  145. {
  146. //Response.Write("User Name: " + g_objPassportManager.Profile("FirstName") + "<BR>" )
  147. //Response.Write("User Name: " + g_objPassportManager.Profile("LastName") + "<BR>" )
  148. //Response.Write("Nickname: " + g_objPassportManager.Profile("Nickname") + "<BR>" )
  149. //Response.Write("Nickname: " + g_objPassportManager.Profile("MemberIDHigh") + "<BR>" )
  150. var NickName = new String( g_objPassportManager.Profile("Nickname") )
  151. var FirstName = new String( g_objPassportManager.Profile("FirstName") )
  152. if ( NickName == "" || NickName == "undefined" )
  153. {
  154. if ( FirstName == "" || FirstName == "undefined" )
  155. return ""
  156. else
  157. return " " + g_objPassportManager.Profile("FirstName");
  158. }
  159. else
  160. return ( " " + g_objPassportManager.Profile("Nickname") )
  161. return ""
  162. }
  163. catch( err )
  164. {
  165. return "";
  166. }
  167. }
  168. function fnIsBrowserIE()
  169. {
  170. var IETest = /MSIE/ig;
  171. var OperaTest = /Opera/ig;
  172. var szBrowser = new String( Request.ServerVariables( "HTTP_USER_AGENT" ) )
  173. if ( OperaTest.test( szBrowser ) )
  174. {
  175. return false;
  176. }
  177. else
  178. {
  179. if( IETest.test( szBrowser ) )
  180. {
  181. var szVersion =szBrowser.indexOf( "MSIE", 0 )
  182. var szVersion = new Number( szBrowser.substr( szVersion + 5, 3 ) )
  183. if ( szVersion >= 5 )
  184. return true;
  185. else
  186. return false;
  187. }
  188. else
  189. {
  190. return false;
  191. }
  192. }
  193. }
  194. function fnIsBrowserValid()
  195. {
  196. var szBrowser = Request.ServerVariables( "HTTP_USER_AGENT" );
  197. //Response.Write("Useragent: " + Request.ServerVariables("HTTP_USER_AGENT") + "<BR>" )
  198. //first thing todo is to reject anything that is Opera
  199. OperaTest = /Opera/ig;
  200. NetscapeTest = /Netscape/ig;
  201. if ( OperaTest.test ( szBrowser ) )
  202. {
  203. //Response.Write("<BR>Opera, thanks for playing<BR>" )
  204. return false;
  205. }
  206. //Next test IE, we already have the IE code written, lets just call it
  207. //it already has all the version information and stuff
  208. if ( fnIsBrowserIE() )
  209. {
  210. return true;
  211. } else if ( NetscapeTest.test ( szBrowser ) )
  212. {
  213. //Response.Write( "<BR><h1>Netscape browser</H1></BR>" )
  214. //Verify that were on the right platform
  215. if ( fnVerifyPlatform( szBrowser ) )
  216. return true;
  217. else
  218. return false;
  219. }
  220. //if we fall through to here, then we don't know what kind of browser were
  221. //running on.
  222. return false;
  223. }
  224. function fnVerifyPlatform( szUserAgent )
  225. {
  226. regPlatformTest = /Windows NT 5/gi;
  227. if( regPlatformTest.test( szUserAgent ) )
  228. return true
  229. else
  230. return false
  231. }
  232. %>