Source for file download.php
Documentation is available at download.php
<?php // $Id: download.php 12218 2007-05-01 18:27:14Z yannoo $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
==============================================================================
==============================================================================
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* @package dokeos.document
==============================================================================
==============================================================================
==============================================================================
include('../inc/global.inc.php');
include(api_get_path(LIBRARY_PATH). 'document.lib.php');
require_once('forumconfig.inc.php');
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
$doc_url = $_GET['file'];
//change the '&' that got rewritten to '///' by mod_rewrite back to '&'
//still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
include(api_get_path(LIBRARY_PATH). 'events.lib.inc.php');
//if the rewrite rule asks for a directory, we redirect to the document explorer
//remove last slash if present
//$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url;
//mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (Ren�)
while ($doc_url{$dul = strlen($doc_url)- 1}== '/') $doc_url = substr($doc_url,0,$dul);
header('Location: '. $document_explorer);
$sql= 'SELECT thread_id, forum_id,filename FROM '. $tbl_forum_post. ' f INNER JOIN '. $tbl_forum_attachment. ' a
ON a.post_id=f.post_id WHERE path LIKE BINARY "'. $doc_url. '"';
if ($forum_thread_visibility== 1 && $forum_forum_visibility== 1)
|