link_goto.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This page is used to launch an event when a user clicks
  5. * on a page linked in a course.
  6. * - It gets name of URL
  7. * - It calls the event function
  8. * - It redirects the user to the linked page
  9. *
  10. * Need the liens.id, user.user_id et cours.code when called
  11. * ?link_id=$myrow[0]&link_url=$myrow[1]
  12. * url is given to avoid a new select
  13. *
  14. * @author Thomas Depraetere, Hugues Peeters, Christophe Gesch� - original versions
  15. * @package chamilo.link
  16. */
  17. /* INIT SECTION */
  18. //require_once '../inc/global.inc.php';
  19. require_once api_get_path(LIBRARY_PATH).'link.lib.php';
  20. $this_section = SECTION_COURSES;
  21. $linkId = intval($_GET['link_id']);
  22. $linkInfo = get_link_info($linkId);
  23. if ($linkInfo['target'] == '_in_header') {
  24. $tpl = $app['template'];
  25. $url = $linkInfo['url'];
  26. $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links'));
  27. $frame = '<iframe name="page" onload="javascript:resizeIframe(this);" style="width:100%;height:500px" frameBorder=0px; src="'.$url.'">
  28. </iframe>';
  29. $js = "<script>
  30. function resizeIframe(obj) {
  31. /*var body = obj.contentWindow.document.body;
  32. var height =$(obj, top.document).height();
  33. console.log(height);
  34. console.log(jQuery('iframe',top.document).height());
  35. obj.style.height = height;*/
  36. }
  37. </script>";
  38. $tpl->assign('content', $js.$frame);
  39. $tpl->display_one_col_template();
  40. } else {
  41. $link_url = html_entity_decode(Security::remove_XSS($_GET['link_url']));
  42. // Launch event
  43. event_link($linkId);
  44. header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
  45. header("Cache-Control: post-check=0, pre-check=0", false);
  46. header("Pragma: no-cache"); // HTTP/1.0
  47. header("Location: $link_url");
  48. // To be sure that the script stops running after the redirection
  49. exit;
  50. }