]>
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 require (JIRAFEAU_ROOT
.'lib/template/header.php');
38 echo '<div class="error"><p>' . _('Sorry, the requested file is not found') . '</p></div>';
39 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
43 $link = jirafeau_get_link ($link_name);
44 if (count ($link) == 0)
46 require (JIRAFEAU_ROOT
.'lib/template/header.php');
47 echo '<div class="error"><p>' . _('Sorry, the requested file is not found') .
49 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
53 if (!file_exists (VAR_FILES
. $link['md5']))
55 jirafeau_delete ($link_name);
56 require (JIRAFEAU_ROOT
.'lib/template/header.php');
57 echo '<div class="error"><p>'._('File not available.').
59 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
63 if (!empty ($delete_code) && $delete_code == $link['link_code'])
65 jirafeau_delete ($link_name);
66 require (JIRAFEAU_ROOT
.'lib/template/header.php');
67 echo '<div class="message"><p>'._('File has been deleted.').
69 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
73 if ($link['time'] != JIRAFEAU_INFINITY
&& time ()> $link['time'])
75 jirafeau_delete ($link_name);
76 require (JIRAFEAU_ROOT
.'lib/template/header.php');
77 echo '<div class="error"><p>'.
78 _('The time limit of this file has expired.') . ' ' .
79 _('File has been deleted.') .
81 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
85 if (!empty ($link['key']))
87 if (!isset ($_POST['key']))
89 require (JIRAFEAU_ROOT
.'lib/template/header.php');
92 "<?php echo $_SERVER['REQUEST_URI']; ?>" method
=
93 "post"> <input type
= "hidden" name
= "jirafeau" value
=
94 "<?php echo JIRAFEAU_VERSION; ?>" /><fieldset
>
95 <legend
><?php
echo _('Password protection');
96 ?
></legend
> <table
> <tr
>
97 <td
><?php
echo _('Give the password of this file:');
98 ?
><input type
= "password" name
=
99 "key" /></td
> </tr
> <tr
> <td
><input type
=
101 "<?php echo _('I have the right to download this file'); ?>"
102 /></td
> </tr
> </table
> </fieldset
> </form
> </div
>
103 <?php
require (JIRAFEAU_ROOT
.'lib/template/footer.php');
108 if ($link['key'] != md5 ($_POST['key']))
110 header ("Access denied");
112 require (JIRAFEAU_ROOT
.'lib/template/header.php');
113 echo '<div class="error"><p>' . _('Access denied') .
115 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
121 header ('Content-Length: ' . $link['file_size']);
122 header ('Content-Type: ' . $link['mime_type']);
123 if (!jirafeau_is_viewable ($link['mime_type']))
125 header ('Content-Disposition: attachment; filename="' .
126 $link['file_name'] . '"');
128 readfile (VAR_FILES
. $link['md5']);
130 if ($link['onetime'] == 'O')
131 jirafeau_delete ($link_name);
136 header ('Location: '.$cfg['web_root']);
patrick-canterino.de