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.

188 lines
4.9 KiB

  1. <%
  2. //these are used for the fnHex function, when converting to a hex digit
  3. var HexChars = { "10" : "a",
  4. "11" : "b",
  5. "12" : "c",
  6. "13" : "d",
  7. "14" : "e",
  8. "15" : "f"
  9. };
  10. // fnVerifyNumber - Checks a number to make sure its within the proper range and
  11. // type
  12. function fnVerifyNumber( nValue, nLow, nHigh )
  13. {
  14. try
  15. {
  16. var pattern = new RegExp( "^[0-9]{" + String(nLow).length + "," + String(nHigh).length + "}$", "g" );
  17. if ( pattern.test ( nValue ) )
  18. {
  19. if ( (nValue < nLow) || (nValue > nHigh) )
  20. return false;
  21. else
  22. return true;
  23. }
  24. else
  25. {
  26. return false;
  27. }
  28. }
  29. catch ( err )
  30. {
  31. return false;
  32. }
  33. }
  34. //Verify that the guid is properly formatted and within the proper range.
  35. function fnVerifyGUID( gGUID )
  36. {
  37. //The assumptions that we make is that the GUID will consist of letters from a-f (lowercase only!!!)
  38. //and the numbers 0-9 in the exact pattern as the sample guid. If the guid does not match, then it fails
  39. // sample guid: bc94ebaa-195f-4dcc-a4c5-6722a7f942ff
  40. gGUID = String(gGUID).toLowerCase();
  41. var pattern = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/g;
  42. if ( pattern.test( gGUID ) )
  43. return true;
  44. else
  45. return false;
  46. }
  47. //This routine will calculate a hex version of the number passed in
  48. // nInt = The number to convert
  49. // useNumLen = the number of bytes to extend to: eg 12 will yield an 12 digit value padded with zeros at front
  50. function fnHex ( nInt, useNumLen )
  51. {
  52. var nHexNum = "";
  53. var nSize = 8;
  54. if ( useNumLen )
  55. nSize = nInt.length;
  56. nInt = Math.abs( nInt );
  57. for ( i=0 ; i < nSize ; i++ )
  58. {
  59. var Remainder = nInt % 16;
  60. //we have to account for roundoff error with javascript. the .5 does it.
  61. nInt = Math.round( ((nInt / 16) - .5 ) );
  62. if ( Remainder > 9 )
  63. nHexNum = HexChars[ String( Remainder )] + nHexNum;
  64. else
  65. nHexNum = String( Remainder ) + nHexNum;
  66. }
  67. return nHexNum;
  68. }
  69. //trims the leading and trailing spaces on a string
  70. //this function has been added to the string object.
  71. function fnTrim ( szString )
  72. {
  73. pattern = /^(\s*)|(\s*)$/g
  74. try
  75. {
  76. if ( String( szString ) != "undefined" )
  77. {
  78. szString = szString.replace( pattern, "" );
  79. }
  80. return szString;
  81. }
  82. catch ( err )
  83. {
  84. return "undefined";
  85. }
  86. }
  87. String.prototype.trim = fnTrim;
  88. function fnEncode ( nNum )
  89. {
  90. var changeSign = Math.round( Math.random() * 7) + 1 ;
  91. if ( nNum < 0 )
  92. {
  93. changeSign = 9;
  94. nNum *= -1;
  95. }
  96. var randNum = Math.round( Math.random() * 99 );
  97. var randFinalNum = Math.round ( Math.random() * 99 );
  98. var randMultiplier = Math.round( Math.random() * 8 ) + 1 ;
  99. var randLen = String( randNum).length;
  100. var nNumLen = String( nNum * randMultiplier ).length;
  101. var done = changeSign + "" + randLen + "" + randNum + "" + randMultiplier + "" + nNumLen + "" + (nNum*randMultiplier) + "" + randFinalNum
  102. done = fnHex ( done, true );
  103. if ( changeSign < 0 )
  104. done = "-" + done;
  105. return ( done )
  106. }
  107. function fnDecode( nNum )
  108. {
  109. var nNum = new String( Number( nNum ) );
  110. var changeSign = nNum.substr( 0, 1 );
  111. if ( changeSign == "9" )
  112. var changeSign = -1;
  113. else
  114. var changeSign = 1;
  115. var randLen = Number ( nNum.substr ( 1, 1 ) ) + 2;
  116. var randMultiplier = Number ( nNum.substr( randLen, 1 ) );
  117. var nNumLen = Number ( nNum.substr( randLen + 1, 1 ) );
  118. var preNum = nNum.substr( Number(randLen) + 2 , nNumLen );
  119. var final = changeSign * (preNum / randMultiplier);
  120. return final;
  121. }
  122. //this functiion assumes that all the localized strings are present in the file
  123. //that is calling this include.
  124. function fnPrintLinks( szCancelURL, szContinueURL )
  125. {
  126. Response.Write("<BR><Table class='clstblLinks'><tbody><tr><td nowrap class='clsTDLinks'>" )
  127. if ( szContinueURL != "" )
  128. {
  129. //Response.Write("<form name='frmContinue' id='frmContinue' method='get' action='" + szContinueURL + "'>" ); //needed for NS 4.0 compatibility
  130. Response.Write("<input name='btnContinue' id='btnContinue' type='button' value='" + L_CONTINUE_TEXT + "' onclick=\"fnFollowLink('" + szContinueURL + "')\">" )
  131. Response.Write("<label for='btnContinue' accesskey='" + L_CONTINUEACCESSKEY_TEXT + "'></label>" )
  132. //Response.Write("</form>");
  133. }
  134. Response.Write("</td><td nowrap class='clsTDLinks'>")
  135. //Response.Write("<form>" ); //needed for NS 4.0 compatibility
  136. Response.Write("<input name='btnCancel' id='btnCancel' type='button' value='" + L_CANCEL_TEXT + "' onclick=\"fnFollowLink('" + szCancelURL + "')\">" )
  137. Response.Write("<label for='btnCancel' accesskey='" + L_CANCELACCESSKEY_TEXT + "'></label>" )
  138. //Response.Write("</form>");
  139. Response.Write("</td></tr></tbody></table>" )
  140. }
  141. %>