sniff.tpl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {% raw %}
  2. <script LANGUAGE="JavaScript">
  3. var nav ="";
  4. var screen_size_w;
  5. var screen_size_h;
  6. var java="";
  7. var type_mimetypes="";
  8. var suffixes_mimetypes="";
  9. var list_plugins="";
  10. var check_some_activex="";
  11. var check_some_plugins="";
  12. var java_sun_ver="";
  13. <!-- check Microsoft Internet Explorer -->
  14. if (navigator.userAgent.indexOf("MSIE") != -1) { var nav="ie";}
  15. <!-- check Screen Size -->
  16. screen_size_w=screen.width;
  17. screen_size_h=screen.height;
  18. <!-- list mimetypes types, suffixes and plugins (no for IE) -->
  19. if (nav!="ie"){
  20. if (navigator.mimeTypes && navigator.mimeTypes.length > 0) {
  21. for (i=0; i < navigator.mimeTypes.length; i++) {
  22. type_mimetypes=type_mimetypes+" "+navigator.mimeTypes[i].type;
  23. suffixes_mimetypes=suffixes_mimetypes+" "+navigator.mimeTypes[i].suffixes;
  24. if (navigator.mimeTypes[i].enabledPlugin!=null) {
  25. list_plugins=list_plugins+" "+navigator.mimeTypes[i].enabledPlugin.name;
  26. }
  27. }
  28. }
  29. }
  30. <!-- check some activex for IE -->
  31. if (nav=="ie"){
  32. //TODO:check wmediaplayer are too aggressive. Then we can assume that if there Windows, there Wmediaplayer?
  33. var check_some_activex =
  34. DetectActiveXObject("ShockwaveFlash.ShockwaveFlash.1", "flash_yes")+
  35. DetectActiveXObject("QuickTime.QTElementBehavior", "quicktime_yes")+
  36. //DetectActiveXObject("MediaPlayer.MediaPlayer.1","wmediaplayer_yes")+
  37. DetectActiveXObject("acroPDF.PDF.1","acrobatreader_yes");
  38. function DetectActiveXObject(ObjectName, name) {
  39. result = false;
  40. document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  41. document.write('on error resume next \n');
  42. document.write('result = IsObject(CreateObject("' + ObjectName + '")) \n');
  43. document.write('</SCRIPT\> \n');
  44. if (result) return name+' , '; else return '';
  45. }
  46. }
  47. <!-- check some plugins for not IE -->
  48. if (nav!="ie"){
  49. if (list_plugins.indexOf("Shockwave Flash")!=-1){
  50. check_some_plugins=check_some_plugins+', flash_yes';
  51. }
  52. if (list_plugins.indexOf("QuickTime")!=-1){
  53. check_some_plugins=check_some_plugins+', quicktime_yes';
  54. }
  55. if (list_plugins.indexOf("Windows Media Player")!=-1){
  56. check_some_plugins=check_some_plugins+', wmediaplayer_yes';
  57. }
  58. if (list_plugins.indexOf("Adobe Acrobat")!=-1){
  59. check_some_plugins=check_some_plugins+',acrobatreader_yes';
  60. }
  61. }
  62. <!-- java -->
  63. if(navigator.javaEnabled()==true){java="java_yes";}else{java="java_no";}
  64. <!-- check java Sun ver -->
  65. //for not IE
  66. if (nav!="ie"){
  67. if (navigator.mimeTypes["application/x-java-applet"]){ java_sun_ver="javasun_yes";}
  68. if (navigator.mimeTypes["application/x-java-applet;jpi-version=1.6.0_24"]){ java_sun_ver=java_sun_ver+" , javasun_ver_1.6_24_yes"; }//This java version 1.6.0_24 is problematic, the user should be updated
  69. }
  70. //for IE
  71. if (nav=="ie"){
  72. //1.5->end nov 2009
  73. //TODO:extract minor version
  74. var java_sun_ver =
  75. DetectActiveXObject("JavaWebStart.isInstalled","javasun_yes")+
  76. DetectActiveXObject("JavaWebStart.isInstalled.1.4.2.0","javasun_ver_1.4_yes")+
  77. DetectActiveXObject("JavaWebStart.isInstalled.1.5.0.0","javasun_ver_1.5_yes")+
  78. DetectActiveXObject("JavaWebStart.isInstalled.1.6.0.0","javasun_ver_1.6_yes")+
  79. DetectActiveXObject("JavaWebStart.isInstalled.1.7.0.0","javasun_ver_1.7_yes");
  80. function DetectActiveXObject(ObjectName, name) {
  81. result = false;
  82. document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  83. document.write('on error resume next \n');
  84. document.write('result = IsObject(CreateObject("' + ObjectName + '")) \n');
  85. document.write('</SCRIPT\> \n');
  86. if (result) return name+' , '; else return '';
  87. }
  88. }
  89. <!-- Send to server -->
  90. function sendSniff(){
  91. document.forms.sniff_nav_form.sniff_navigator.value="checked";
  92. document.forms.sniff_nav_form.sniff_navigator_screen_size_w.value=screen_size_w;
  93. document.forms.sniff_nav_form.sniff_navigator_screen_size_h.value=screen_size_h;
  94. document.forms.sniff_nav_form.sniff_navigator_type_mimetypes.value=type_mimetypes;
  95. document.forms.sniff_nav_form.sniff_navigator_suffixes_mimetypes.value=suffixes_mimetypes;
  96. document.forms.sniff_nav_form.sniff_navigator_list_plugins.value=list_plugins;
  97. document.forms.sniff_nav_form.sniff_navigator_check_some_activex.value=check_some_activex;
  98. document.forms.sniff_nav_form.sniff_navigator_check_some_plugins.value=check_some_plugins;
  99. document.forms.sniff_nav_form.sniff_navigator_java.value=java;
  100. document.forms.sniff_nav_form.sniff_navigator_java_sun_ver.value=java_sun_ver;
  101. document.sniff_nav_form.submit();
  102. }
  103. </script>
  104. {% endraw %}
  105. <form name="sniff_nav_form" method="POST">
  106. <input type="hidden" name="sniff_navigator">
  107. <input type="hidden" name="sniff_navigator_screen_size_w">
  108. <input type="hidden" name="sniff_navigator_screen_size_h">
  109. <input type="hidden" name="sniff_navigator_type_mimetypes">
  110. <input type="hidden" name="sniff_navigator_suffixes_mimetypes">
  111. <input type="hidden" name="sniff_navigator_list_plugins">
  112. <input type="hidden" name="sniff_navigator_check_some_activex">
  113. <input type="hidden" name="sniff_navigator_check_some_plugins">
  114. <input type="hidden" name="sniff_navigator_java">
  115. <input type="hidden" name="sniff_navigator_java_sun_ver">
  116. </form>
  117. {#
  118. <script>
  119. sendSniff();
  120. </script>
  121. #}