showinframes.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. * Code library for HotPotatoes integration.
  5. * @package dokeos.exercise
  6. * @author Istvan Mandak
  7. */
  8. /*
  9. -----------------------------------------------------------
  10. Included libraries
  11. -----------------------------------------------------------
  12. */
  13. require '../inc/global.inc.php';
  14. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  15. $time=time();
  16. require_once api_get_path(SYS_PATH).'main/exercice/hotpotatoes.lib.php';
  17. // init
  18. $doc_url=str_replace(array('../','\\','\\0','..'),array('','','',''),urldecode($_GET['file']));
  19. $cid = api_get_course_id();
  20. $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document";
  21. $documentWebPath= api_get_path(WEB_COURSE_PATH).$_course['path']."/document";
  22. $origin = $_REQUEST['origin'];
  23. $learnpath_id = $_REQUEST['learnpath_id'];
  24. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  25. $time = $_REQUEST['time'];
  26. // read content
  27. $full_file_path = $documentPath.$doc_url;
  28. my_delete($full_file_path.$_user['user_id'].".t.html");
  29. $content = ReadFileCont($full_file_path.$_user['user_id'].".t.html");
  30. if ($content=="")
  31. {
  32. $content = ReadFileCont($full_file_path);
  33. $mit = "function Finish(){";
  34. $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
  35. "function mySaveScore() // This function included by Dokeos System\n".
  36. "{\n".
  37. " if (SaveScoreVariable==0)\n".
  38. " {\n".
  39. " SaveScoreVariable = 1;\n".
  40. " if (C.ie)\n".
  41. " {\n".
  42. " 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".
  43. " //window.alert(Score);\n".
  44. " }\n".
  45. " else\n".
  46. " {\n".
  47. " 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".
  48. " }\n".
  49. " }\n".
  50. "}\n".
  51. "// Must be included \n".
  52. "function Finish(){\n".
  53. " mySaveScore();";
  54. $newcontent = str_replace($mit,$js_content,$content);
  55. $prehref="<!-- BeginTopNavButtons -->";
  56. $posthref="<!-- BeginTopNavButtons --><!-- edited by Dokeos -->";
  57. $newcontent = str_replace($prehref,$posthref,$newcontent);
  58. if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0)
  59. { $newcontent = ReplaceImgTag($newcontent); }
  60. }
  61. else
  62. {
  63. //my_delete($full_file_path.$_user['user_id'].".t.html");
  64. $newcontent = $content;
  65. }
  66. WriteFileCont($full_file_path.$_user['user_id'].".t.html",$newcontent);
  67. /* $prehref="javascript:void(0);";
  68. $posthref=$_configuration['root_web']."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
  69. $newcontent = str_replace($prehref,$posthref,$newcontent);
  70. $prehref="class=\"GridNum\" onclick=";
  71. $posthref="class=\"GridNum\" onMouseover=";
  72. $newcontent = str_replace($prehref,$posthref,$newcontent);
  73. */
  74. $doc_url = GetFolderPath($doc_url).urlencode(basename($doc_url));
  75. // echo $documentWebPath.$doc_url.$_user['user_id'].".t.html";
  76. // exit;
  77. ?>
  78. <html>
  79. <head>
  80. <title>Tests - Dokeos</title>
  81. </head>
  82. <?php
  83. if ($origin!='learnpath') {
  84. ?>
  85. <frameset rows="130,*" border="0" frameborder="no">
  86. <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']))); ?>">
  87. <frame name="main" src="<?php echo $documentWebPath.$doc_url.$_user['user_id'].".t.html?time=".Security::remove_XSS($time); ?>">
  88. <noframes>
  89. <body>
  90. <p>This page uses frames, but your browser doesn't support them.
  91. We suggest you try Mozilla, Firebird, Safari, Opera, or other browsers updated this millenium.
  92. </p>
  93. </body>
  94. </noframes>
  95. </frameset>
  96. <?php
  97. } else {
  98. ?>
  99. <script language='Javascript' type='text/javascript'>
  100. s='<?php echo $documentWebPath.$doc_url.$_user['user_id']; ?>.t.html?time=<?php echo Security::remove_XSS($time); ?>';
  101. //document.write(s);
  102. window.location=s;
  103. </script>
  104. <?php
  105. }
  106. ?>
  107. </html>