showinframes.php 5.4 KB

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