showinframes.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Code library for HotPotatoes integration.
  5. * @package chamilo.exercise
  6. * @author Istvan Mandak
  7. */
  8. /* Included libraries */
  9. require '../inc/global.inc.php';
  10. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  11. $time = time();
  12. require_once api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php';
  13. header('Content-Type: text/html; charset='.api_get_system_encoding());
  14. // Initialization
  15. $doc_url = str_replace(array('../', '\\', '\\0', '..'), array('', '', '', ''), urldecode($_GET['file']));
  16. $cid = api_get_course_id();
  17. $document_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  18. $document_web_path = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document';
  19. $origin = $_REQUEST['origin'];
  20. $learnpath_id = $_REQUEST['learnpath_id'];
  21. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  22. $time = $_REQUEST['time'];
  23. // Read content
  24. $full_file_path = $document_path.$doc_url;
  25. my_delete($full_file_path.$_user['user_id'].'.t.html');
  26. $content = ReadFileCont($full_file_path.$_user['user_id'].'.t.html');
  27. if ($content == '') {
  28. $content = ReadFileCont($full_file_path);
  29. $mit = "function Finish(){";
  30. $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
  31. "function mySaveScore() // This function included by Dokeos System\n".
  32. "{\n".
  33. " if (SaveScoreVariable==0)\n".
  34. " {\n".
  35. " SaveScoreVariable = 1;\n".
  36. " if (C.ie)\n".
  37. " {\n".
  38. " document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n".
  39. " //window.alert(Score);\n".
  40. " }\n".
  41. " else\n".
  42. " {\n".
  43. " window.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=".Security::remove_XSS($time)."&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n".
  44. " }\n".
  45. " }\n".
  46. "}\n".
  47. "// Must be included \n".
  48. "function Finish(){\n".
  49. " mySaveScore();";
  50. $newcontent = str_replace($mit, $js_content, $content);
  51. $prehref = "<!-- BeginTopNavButtons -->";
  52. $posthref = "<!-- BeginTopNavButtons -->";
  53. $newcontent = str_replace($prehref, $posthref, $newcontent);
  54. if (CheckSubFolder($full_file_path.$_user['user_id'].'.t.html') == 0) {
  55. $newcontent = ReplaceImgTag($newcontent);
  56. }
  57. } else {
  58. //my_delete($full_file_path.$_user['user_id'].'.t.html');
  59. $newcontent = $content;
  60. }
  61. WriteFileCont($full_file_path.$_user['user_id'].'.t.html', $newcontent);
  62. /* $prehref="javascript:void(0);";
  63. $posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
  64. $newcontent = str_replace($prehref,$posthref,$newcontent);
  65. $prehref="class=\"GridNum\" onclick=";
  66. $posthref="class=\"GridNum\" onMouseover=";
  67. $newcontent = str_replace($prehref,$posthref,$newcontent);
  68. */
  69. $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
  70. // echo $document_web_path.$doc_url.$_user['user_id'].'.t.html';
  71. // exit;
  72. // Adjustung the header's height according to the current visual theme.
  73. // This is not the elegant solution, but it helps for the moment.
  74. $header_heights = array(
  75. 'academica' => 105,
  76. 'baby_orange' => 105,
  77. 'blue_lagoon' => 105,
  78. 'chamilo' => 178,
  79. 'chamilo_electric_blue' => 178,
  80. 'chamilo_green' => 178,
  81. 'chamilo_orange' => 178,
  82. 'chamilo_red' => 178,
  83. 'cool_blue' => 105,
  84. 'corporate' => 105,
  85. 'cosmic_campus' => 178,
  86. 'delicious_bordeaux' => 105,
  87. 'dokeos_blue' => 105,
  88. 'dokeos_classic' => 105,
  89. 'dokeos_classic_2D' => 105,
  90. 'empire_green' => 105,
  91. 'fruity_orange' => 105,
  92. 'medical' => 130,
  93. 'public_admin' => 130,
  94. 'royal_purple' => 105,
  95. 'silver_line' => 105,
  96. 'sober_brown' => 130,
  97. 'steel_grey' => 105,
  98. 'tasty_olive' => 105
  99. );
  100. $header_height = $header_heights[api_get_visual_theme()];
  101. if (empty($header_height)) {
  102. $header_height = 178;
  103. }
  104. ?>
  105. <!DOCTYPE html
  106. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  107. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  108. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?>" lang="<?php echo api_get_language_isocode(); ?>">
  109. <head>
  110. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>">
  111. <title><?php echo get_lang('Exercices').' - '.api_get_software_name(); ?></title>
  112. </head>
  113. <?php
  114. if ($origin!='learnpath') {
  115. ?>
  116. <frameset rows="<?php echo $header_height; ?>,*" border="0" frameborder="no">
  117. <frame name="top" scrolling="no" noresize target="contents" src="testheaderpage.php?file=<?php echo Security::remove_XSS(str_replace(array('../','\\','\\0','..'),array('','','',''),urldecode($_GET['file']))); ?>">
  118. <frame name="main" src="<?php echo $document_web_path.$doc_url.$_user['user_id'].'.t.html?time='.Security::remove_XSS($time); ?>">
  119. <noframes>
  120. <body>
  121. <p>This page uses frames, but your browser doesn't support them.
  122. We suggest you try Mozilla, Firebird, Safari, Opera, or other browsers updated this millenium.
  123. </p>
  124. </body>
  125. </noframes>
  126. </frameset>
  127. <?php
  128. } else {
  129. ?>
  130. <script type='text/javascript'>
  131. s='<?php echo $document_web_path.$doc_url.$_user['user_id']; ?>.t.html?time=<?php echo Security::remove_XSS($time); ?>';
  132. //document.write(s);
  133. window.location=s;
  134. </script>
  135. <?php
  136. }
  137. ?>
  138. </html>