dokeos-document
[ class tree: dokeos-document ] [ index: dokeos-document ] [ all elements ]

Source for file download.php

Documentation is available at download.php

  1. <?php // $Id: download.php 12218 2007-05-01 18:27:14Z yannoo $
  2. /*
  3. ==============================================================================
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) Olivier Brouckaert
  10.     Copyright (c) Roan Embrechts
  11.     Copyright (c) Sergio A. Kessler aka "sak"
  12.  
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.  
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.  
  21.     See the GNU General Public License for more details.
  22.  
  23.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  24. ==============================================================================
  25. */
  26. /**
  27. ==============================================================================
  28. *    This file is responsible for  passing requested documents to the browser.
  29. *    Html files are parsed to fix a few problems with URLs,
  30. *    but this code will hopefully be replaced soon by an Apache URL
  31. *    rewrite mechanism.
  32. *
  33. *    @package dokeos.document
  34. ==============================================================================
  35. */
  36.  
  37. /*
  38. ==============================================================================
  39.         FUNCTIONS
  40. ==============================================================================
  41. */
  42. /* file_html_dynamic_parsing removed */
  43. /* other functions updated and moved to lib/document.lib.php */
  44.  
  45. /*
  46. ==============================================================================
  47.         MAIN CODE
  48. ==============================================================================
  49. */
  50.  
  51.  
  52. include('../inc/global.inc.php');
  53. $this_section=SECTION_COURSES;
  54.  
  55. include(api_get_path(LIBRARY_PATH).'document.lib.php');
  56.  
  57. // IMPORTANT to avoid caching of documents
  58. header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
  59. header('Cache-Control: public');
  60. header('Pragma: no-cache');
  61.  
  62. //protection
  63.  
  64. $doc_url $_GET['doc_url'];
  65. //change the '&' that got rewritten to '///' by mod_rewrite back to '&'
  66. $doc_url str_replace('///''&'$doc_url);
  67. //still a space present? it must be a '+' (that got replaced by mod_rewrite)
  68. $doc_url str_replace(' ''+'$doc_url);
  69. $doc_url str_replace('/..'''$doc_url)//echo $doc_url;
  70.  
  71. include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
  72.  
  73. if (isset($_course))
  74. {
  75.     api_not_allowed(true);
  76. }
  77.  
  78.  
  79. //if the rewrite rule asks for a directory, we redirect to the document explorer
  80. if(is_dir(api_get_path(SYS_COURSE_PATH).$_course['path']."/document".$doc_url)) 
  81. {
  82.     //remove last slash if present
  83.     //$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url; 
  84.     //mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
  85.     while ($doc_url{$dul strlen($doc_url)-1}=='/'$doc_url substr($doc_url,0,$dul);
  86.     //group folder?
  87.     $gid_req ($_GET['gidReq'])?'&gidReq='.$_GET['gidReq']:'';
  88.     //create the path
  89.     $document_explorer api_get_path(WEB_CODE_PATH).'document/document.php?curdirpath='.urlencode($doc_url).'&cidReq='.$_GET['cidReq'].$gid_req;
  90.     //redirect
  91.     header('Location: '.$document_explorer);
  92. }
  93.  
  94. // launch event
  95. event_download($doc_url);
  96.  
  97. $sys_course_path api_get_path(SYS_COURSE_PATH);
  98. $full_file_name $sys_course_path.$_course['path'].'/document'.$doc_url;
  99.  
  100. ?>

Documentation generated on Thu, 12 Jun 2008 13:20:25 -0500 by phpDocumentor 1.4.1