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.

276 lines
7.5 KiB

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