]>
git.p6c8.net - jirafeau_mojo42.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/>.
20 define ('JIRAFEAU_ROOT', dirname (__FILE__
) . '/');
22 require (JIRAFEAU_ROOT
. 'lib/lang.php');
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']))
29 $link_name = $_GET['h'];
32 if (isset ($_GET['d']) && !empty ($_GET['d']))
33 $delete_code = $_GET['d'];
35 if (!preg_match ('/[0-9a-f]{32}$/', $link_name))
37 header ("HTTP/1.0 404 Not Found");
39 require (JIRAFEAU_ROOT
.'lib/template/header.php');
40 echo '<div class="error"><p>' . _('Error 404: Not Found') . '</p></div>';
41 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
45 $link_file = VAR_LINKS
.$link_name;
46 if (file_exists ($link_file))
48 $content = file ($link_file);
49 $file_name = trim ($content[0]);
50 $mime_type = trim ($content[1]);
51 $file_size = trim ($content[2]);
52 $key = trim ($content[3], NL
);
53 $time = trim ($content[4]);
54 $md5 = trim ($content[5]);
55 $onetime = trim ($content[6]);
56 $link_code = trim ($content[9]);
58 if (!file_exists (VAR_FILES
.$md5))
60 jirafeau_delete ($link_name);
61 require (JIRAFEAU_ROOT
.'lib/template/header.php');
62 echo '<div class="error"><p>'._('File not available.').
64 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
68 if (!empty ($delete_code) && $delete_code == $link_code)
70 jirafeau_delete ($link_name);
71 require (JIRAFEAU_ROOT
.'lib/template/header.php');
72 echo '<div class="message"><p>'._('File has been deleted.').
74 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
78 if ($time != JIRAFEAU_INFINITY
&& time ()> $time)
80 jirafeau_delete ($link_name);
81 require (JIRAFEAU_ROOT
.'lib/template/header.php');
82 echo '<div class="error"><p>'.
83 _('The time limit of this file has expired.') . ' ' .
84 _('File has been deleted.') .
86 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
92 if (!isset ($_POST['key']))
94 require (JIRAFEAU_ROOT
.'lib/template/header.php');
97 "<?php echo $_SERVER['REQUEST_URI']; ?>" method
=
98 "post"> <input type
= "hidden" name
= "jirafeau" value
=
99 "<?php echo JIRAFEAU_VERSION; ?>" /><fieldset
>
100 <legend
><?php
echo _('Password protection');
101 ?
></legend
> <table
> <tr
>
102 <td
><?php
echo _('Give the password of this file:');
103 ?
><input type
= "password" name
=
104 "key" /></td
> </tr
> <tr
> <td
><input type
=
106 "<?php echo _('I have the right to download this file'); ?>"
107 /></td
> </tr
> </table
> </fieldset
> </form
> </div
>
108 <?php
require (JIRAFEAU_ROOT
.'lib/template/footer.php');
113 if ($key != md5 ($_POST['key']))
115 header ("HTTP/1.0 403 Forbidden");
117 require (JIRAFEAU_ROOT
.'lib/template/header.php');
118 echo '<div class="error"><p>' . _('Error 403: Forbidden') .
120 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
126 header ('Content-Length: ' . $file_size);
127 header ('Content-Type: ' . $mime_type);
128 if (!jirafeau_is_viewable ($mime_type))
130 header ('Content-Disposition: attachment; filename="' .
133 readfile (VAR_FILES
.$md5);
136 jirafeau_delete ($link_name);
141 header ("HTTP/1.0 404 Not Found");
143 require (JIRAFEAU_ROOT
.'lib/template/header.php');
144 echo '<div class="error"><p>' . _('Error 404: Not Found') .
146 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
152 header ('Location: '.$cfg['web_root']);
patrick-canterino.de