source for sakino.kelbie.scot
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.

172 lines
5.9 KiB

7 months ago
  1. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  2. var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
  3. var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
  4. function ControlVersion()
  5. {
  6. var version;
  7. var axo;
  8. var e;
  9. // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
  10. try {
  11. // version will be set for 7.X or greater players
  12. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  13. version = axo.GetVariable("$version");
  14. } catch (e) {
  15. }
  16. if (!version)
  17. {
  18. try {
  19. // version will be set for 6.X players only
  20. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  21. // installed player is some revision of 6.0
  22. // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
  23. // so we have to be careful.
  24. // default to the first public version
  25. version = "WIN 6,0,21,0";
  26. // throws if AllowScripAccess does not exist (introduced in 6.0r47)
  27. axo.AllowScriptAccess = "always";
  28. // safe to call for 6.0r47 or greater
  29. version = axo.GetVariable("$version");
  30. } catch (e) {
  31. }
  32. }
  33. if (!version)
  34. {
  35. try {
  36. // version will be set for 4.X or 5.X player
  37. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
  38. version = axo.GetVariable("$version");
  39. } catch (e) {
  40. }
  41. }
  42. if (!version)
  43. {
  44. try {
  45. // version will be set for 3.X player
  46. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
  47. version = "WIN 3,0,18,0";
  48. } catch (e) {
  49. }
  50. }
  51. if (!version)
  52. {
  53. try {
  54. // version will be set for 2.X player
  55. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  56. version = "WIN 2,0,0,11";
  57. } catch (e) {
  58. version = -1;
  59. }
  60. }
  61. return version;
  62. }
  63. // JavaScript helper required to detect Flash Player PlugIn version information
  64. function GetSwfVer(){
  65. // NS/Opera version >= 3 check for Flash plugin in plugin array
  66. var flashVer = -1;
  67. if (navigator.plugins != null && navigator.plugins.length > 0) {
  68. if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
  69. var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
  70. var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
  71. var descArray = flashDescription.split(" ");
  72. var tempArrayMajor = descArray[2].split(".");
  73. var versionMajor = tempArrayMajor[0];
  74. var versionMinor = tempArrayMajor[1];
  75. var versionRevision = descArray[3];
  76. if (versionRevision == "") {
  77. versionRevision = descArray[4];
  78. }
  79. if (versionRevision[0] == "d") {
  80. versionRevision = versionRevision.substring(1);
  81. } else if (versionRevision[0] == "r") {
  82. versionRevision = versionRevision.substring(1);
  83. if (versionRevision.indexOf("d") > 0) {
  84. versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
  85. }
  86. }
  87. var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
  88. }
  89. }
  90. // MSN/WebTV 2.6 supports Flash 4
  91. else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
  92. // WebTV 2.5 supports Flash 3
  93. else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
  94. // older WebTV supports Flash 2
  95. else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
  96. else if ( isIE && isWin && !isOpera ) {
  97. flashVer = ControlVersion();
  98. }
  99. return flashVer;
  100. }
  101. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  102. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  103. {
  104. versionStr = GetSwfVer();
  105. if (versionStr == -1 ) {
  106. return false;
  107. } else if (versionStr != 0) {
  108. if(isIE && isWin && !isOpera) {
  109. // Given "WIN 2,0,0,11"
  110. tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
  111. tempString = tempArray[1]; // "2,0,0,11"
  112. versionArray = tempString.split(","); // ['2', '0', '0', '11']
  113. } else {
  114. versionArray = versionStr.split(".");
  115. }
  116. var versionMajor = versionArray[0];
  117. var versionMinor = versionArray[1];
  118. var versionRevision = versionArray[2];
  119. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  120. if (versionMajor > parseFloat(reqMajorVer)) {
  121. return true;
  122. } else if (versionMajor == parseFloat(reqMajorVer)) {
  123. if (versionMinor > parseFloat(reqMinorVer))
  124. return true;
  125. else if (versionMinor == parseFloat(reqMinorVer)) {
  126. if (versionRevision >= parseFloat(reqRevision))
  127. return true;
  128. }
  129. }
  130. return false;
  131. }
  132. }
  133. function doProtect()
  134. {
  135. if(isIE){
  136. if(DetectFlashVer(10, 0, 0)){
  137. document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="0" height="0" id="protector" align="middle">');
  138. document.write('<param name="allowScriptAccess" value="sameDomain" />');
  139. document.write('<param name="allowFullScreen" value="false" />');
  140. document.write('<param name="movie" value="protector.swf" />');
  141. document.write('<param name="quality" value="high" />');
  142. document.write('<param name="bgcolor" value="#ffffff" />');
  143. document.write('</object>');
  144. }
  145. }else{
  146. if(DetectFlashVer(10, 0, 0)){
  147. document.write('<embed id="protector"');
  148. document.write(' pluginspage="http://www.macromedia.com/go/getflashplayer"');
  149. document.write(' allowScriptAccess="sameDomain"');
  150. document.write(' width="0"');
  151. document.write(' height="0"');
  152. document.write(' align="middle"');
  153. document.write(' type="application/x-shockwave-flash"');
  154. document.write(' src="protector.swf"');
  155. document.write(' bgcolor="#E1E1E1"');
  156. document.write(' scale="exactfit"');
  157. document.write(' wmode="Window"');
  158. document.write('></embed>');
  159. }
  160. }
  161. }
  162. doProtect();