]>
git.p6c8.net - jirafeau_mojo42.git/blob - pub/file.php
1abbec5994ce7a3598d8c2c746e60a8af5b2c443
3 * Jyraphe, your web file repository
4 * Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 define('JYRAPHE_ROOT', dirname(__FILE__
) . '/');
22 require(JYRAPHE_ROOT
. 'lib/config.php');
23 require(JYRAPHE_ROOT
. 'lib/settings.php');
24 require(JYRAPHE_ROOT
. 'lib/functions.php');
26 if(isset($_GET['h']) && !empty($_GET['h'])) {
27 $link_name = $_GET['h'];
29 if(!ereg('^[OR][0-9a-f]{32}$', $link_name)) {
30 header("HTTP/1.0 404 Not Found");
32 require(JYRAPHE_ROOT
. 'lib/template/header.php');
33 echo '<div class="error"><p>Error 404: Not Found</p></div>';
34 require(JYRAPHE_ROOT
. 'lib/template/footer.php');
38 $link_file = VAR_LINKS
. $link_name;
39 if(file_exists($link_file)) {
40 $content = file($link_file);
41 $file_name = trim($content[0]);
42 $mime_type = trim($content[1]);
43 $file_size = trim($content[2]);
44 $key = trim($content[3], NL
);
45 $time = trim($content[4]);
47 if($time != JYRAPHE_INFINITY
) {
50 $new_name = jyraphe_detect_collision($file_name, VAR_TRASH
);
51 rename(VAR_FILES
. $file_name, VAR_TRASH
. $new_name);
53 require(JYRAPHE_ROOT
. 'lib/template/header.php');
54 echo '<div class="error"><p>' . _('The time limit of this file has expired. It has been deleted.') . '</p></div>';
55 require(JYRAPHE_ROOT
. 'lib/template/footer.php');
62 if(!isset($_POST['key'])) {
63 require(JYRAPHE_ROOT
. 'lib/template/header.php');
66 <form action
="<?php echo $_SERVER['REQUEST_URI']; ?>" method
="post">
67 <input type
="hidden" name
="jyraphe" value
="<?php echo JYRAPHE_VERSION; ?>" />
69 <legend
><?php
echo _('Key protection'); ?
></legend
>
72 <td
><?php
echo _('Give the key of this file:'); ?
> <input type
="password" name
="key" /></td
>
75 <td
><input type
="submit" value
="<?php echo _('I have the right to download this file'); ?>" /></td
>
82 require(JYRAPHE_ROOT
. 'lib/template/footer.php');
85 if($key != $_POST['key']) {
86 header("HTTP/1.0 403 Forbidden");
88 require(JYRAPHE_ROOT
. 'lib/template/header.php');
89 echo '<div class="error"><p>Error 403: Forbidden</p></div>';
90 require(JYRAPHE_ROOT
. 'lib/template/footer.php');
96 header('Content-Length: ' . $file_size);
97 header('Content-Type: ' . $mime_type);
98 if(!jyraphe_is_viewable($mime_type)) {
99 header('Content-Disposition: attachment; filename="' . $file_name . '"');
101 readfile(VAR_FILES
. $file_name);
103 if($link_name[0] == 'O') {
105 $new_name = jyraphe_detect_collision($file_name, VAR_TRASH
);
106 rename(VAR_FILES
. $file_name, VAR_TRASH
. $new_name);
110 header("HTTP/1.0 404 Not Found");
112 require(JYRAPHE_ROOT
. 'lib/template/header.php');
113 echo '<div class="error"><p>Error 404: Not Found</p></div>';
114 require(JYRAPHE_ROOT
. 'lib/template/footer.php');
118 header('Location: ' . $cfg['web_root']);
patrick-canterino.de