]>
git.p6c8.net - jirafeau.git/blob - file.php
0a6e32cb98cc5cd2955834fe19585099dadfbb26
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 'It has been deleted.') . '</p></div>';
85 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
91 if (!isset ($_POST['key']))
93 require (JIRAFEAU_ROOT
.'lib/template/header.php');
96 "<?php echo $_SERVER['REQUEST_URI']; ?>" method
=
97 "post"> <input type
= "hidden" name
= "jirafeau" value
=
98 "<?php echo JIRAFEAU_VERSION; ?>" /><fieldset
>
99 <legend
><?php
echo _('Key protection');
100 ?
></legend
> <table
> <tr
>
101 <td
><?php
echo _('Give the key of this file:');
102 ?
><input type
= "password" name
=
103 "key" /></td
> </tr
> <tr
> <td
><input type
=
105 "<?php echo _('I have the right to download this file'); ?>"
106 /></td
> </tr
> </table
> </fieldset
> </form
> </div
>
107 <?php
require (JIRAFEAU_ROOT
.'lib/template/footer.php');
112 if ($key != md5 ($_POST['key']))
114 header ("HTTP/1.0 403 Forbidden");
116 require (JIRAFEAU_ROOT
.'lib/template/header.php');
117 echo '<div class="error"><p>Error 403: Forbidden</p></div>';
118 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
124 header ('Content-Length: ' . $file_size);
125 header ('Content-Type: ' . $mime_type);
126 if (!jirafeau_is_viewable ($mime_type))
128 header ('Content-Disposition: attachment; filename="' .
131 readfile (VAR_FILES
.$md5);
134 jirafeau_delete ($link_name);
139 header ("HTTP/1.0 404 Not Found");
141 require (JIRAFEAU_ROOT
.'lib/template/header.php');
142 echo '<div class="error"><p>Error 404: Not Found</p></div>';
143 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
149 header ('Location: '.$cfg['web_root']);
patrick-canterino.de