]>
git.p6c8.net - jirafeau.git/blob - file.php
3 * Jirafeau, your web file repository
4 * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
5 * Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 define('JIRAFEAU_ROOT', dirname(__FILE__
) . '/');
23 require(JIRAFEAU_ROOT
. 'lib/config.php');
24 require(JIRAFEAU_ROOT
. 'lib/settings.php');
25 require(JIRAFEAU_ROOT
. 'lib/functions.php');
27 if(isset($_GET['h']) && !empty($_GET['h'])) {
28 $link_name = $_GET['h'];
30 if(!ereg('[0-9a-f]{32}$', $link_name)) {
31 header("HTTP/1.0 404 Not Found");
33 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
34 echo '<div class="error"><p>Error 404: Not Found</p></div>';
35 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
39 $link_file = VAR_LINKS
. $link_name;
40 if(file_exists($link_file)) {
41 $content = file($link_file);
42 $file_name = trim($content[0]);
43 $mime_type = trim($content[1]);
44 $file_size = trim($content[2]);
45 $key = trim($content[3], NL
);
46 $time = trim($content[4]);
47 $md5 = trim($content[5]);
48 $onetime = trim($content[6]);
50 if(!file_exists(VAR_FILES
. $md5)) {
51 jirafeau_delete($link_name);
53 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
54 echo '<div class="error"><p>' . _('File not available.') . '</p></div>';
55 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
59 if($time != JIRAFEAU_INFINITY
) {
61 jirafeau_delete($link_name);
63 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
64 echo '<div class="error"><p>' . _('The time limit of this file has expired. It has been deleted.') . '</p></div>';
65 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
71 if(!isset($_POST['key'])) {
72 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
75 <form action
="<?php echo $_SERVER['REQUEST_URI']; ?>" method
="post">
76 <input type
="hidden" name
="jirafeau" value
="<?php echo JIRAFEAU_VERSION; ?>" />
78 <legend
><?php
echo _('Key protection'); ?
></legend
>
81 <td
><?php
echo _('Give the key of this file:'); ?
> <input type
="password" name
="key" /></td
>
84 <td
><input type
="submit" value
="<?php echo _('I have the right to download this file'); ?>" /></td
>
91 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
94 if($key != $_POST['key']) {
95 header("HTTP/1.0 403 Forbidden");
97 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
98 echo '<div class="error"><p>Error 403: Forbidden</p></div>';
99 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
105 header('Content-Length: ' . $file_size);
106 header('Content-Type: ' . $mime_type);
107 if(!jirafeau_is_viewable($mime_type)) {
108 header('Content-Disposition: attachment; filename="' . $file_name . '"');
110 readfile(VAR_FILES
. $md5);
112 if($onetime == 'O') {
113 jirafeau_delete($link_name);
117 header("HTTP/1.0 404 Not Found");
119 require(JIRAFEAU_ROOT
. 'lib/template/header.php');
120 echo '<div class="error"><p>Error 404: Not Found</p></div>';
121 require(JIRAFEAU_ROOT
. 'lib/template/footer.php');
125 header('Location: ' . $cfg['web_root']);
patrick-canterino.de