]>
git.p6c8.net - jirafeau_project.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>' . t('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>' . t('Sorry, the requested file is not found') .
49 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
52 $p = s2p ($link['md5']);
53 if (!file_exists (VAR_FILES
. $p . $link['md5']))
55 jirafeau_delete_link ($link_name);
56 require (JIRAFEAU_ROOT
.'lib/template/header.php');
57 echo '<div class="error"><p>'.t('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 ($link_name);
66 require (JIRAFEAU_ROOT
.'lib/template/header.php');
67 echo '<div class="message"><p>'.t('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 ($link_name);
76 require (JIRAFEAU_ROOT
.'lib/template/header.php');
77 echo '<div class="error"><p>'.
78 t('The time limit of this file has expired.') . ' ' .
79 t('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 t('Password protection');
96 ?
></legend
> <table
> <tr
>
97 <td
><?php
echo t('Give the password of this file') . ' : ';
98 ?
><input type
= "password" name
=
99 "key" /></td
> </tr
> <tr
> <td
><input type
=
101 "<?php echo t('Download'); ?>"
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");
111 require (JIRAFEAU_ROOT
.'lib/template/header.php');
112 echo '<div class="error"><p>' . t('Access denied') .
114 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
120 header ('Content-Length: ' . $link['file_size']);
121 header ('Content-Type: ' . $link['mime_type']);
122 if (!jirafeau_is_viewable ($link['mime_type']))
124 header ('Content-Disposition: attachment; filename="' .
125 $link['file_name'] . '"');
127 readfile (VAR_FILES
. $p . $link['md5']);
129 if ($link['onetime'] == 'O')
130 jirafeau_delete_link ($link_name);
135 header ('Location: '.$cfg['web_root']);
patrick-canterino.de