]> git.p6c8.net - jirafeau.git/blob - index.php
[FEATURE] Docs: Revice upgrade instructions
[jirafeau.git] / index.php
1 <?php
2 /*
3 * Jirafeau, your web file repository
4 * Copyright (C) 2013
5 * Jerome Jutteau <j.jutteau@gmail.com>
6 * Jimmy Beauvois <jimmy.beauvois@gmail.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as
10 * published by the Free Software Foundation, either version 3 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21 define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
22
23 require (JIRAFEAU_ROOT . 'lib/settings.php');
24 require (JIRAFEAU_ROOT . 'lib/functions.php');
25 require (JIRAFEAU_ROOT . 'lib/lang.php');
26
27 check_errors ($cfg);
28 if (has_error ())
29 {
30 show_errors ();
31 require (JIRAFEAU_ROOT . 'lib/template/footer.php');
32 exit;
33 }
34
35 require (JIRAFEAU_ROOT . 'lib/template/header.php');
36
37 /* Check if user is allowed to upload. */
38 if (!jirafeau_challenge_upload_ip ($cfg, get_ip_address($cfg)))
39 {
40 echo '<div class="error"><p>' . t('Access denied') . '</p></div>';
41 require (JIRAFEAU_ROOT.'lib/template/footer.php');
42 exit;
43 }
44
45 /* Ask password if upload password is set. */
46 if (jirafeau_has_upload_password ($cfg))
47 {
48 session_start();
49
50 /* Unlog if asked. */
51 if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
52 session_unset ();
53
54 /* Auth. */
55 if (isset ($_POST['upload_password']))
56 {
57 if (jirafeau_challenge_upload_password ($cfg, $_POST['upload_password']))
58 {
59 $_SESSION['upload_auth'] = true;
60 $_SESSION['user_upload_password'] = $_POST['upload_password'];
61 }
62 else
63 {
64 $_SESSION['admin_auth'] = false;
65 echo '<div class="error"><p>' . t('Wrong password.') . '</p></div>';
66 require (JIRAFEAU_ROOT.'lib/template/footer.php');
67 exit;
68 }
69 }
70
71 /* Show auth page. */
72 if (!isset ($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true)
73 {
74 ?>
75 <form action = "<?php echo basename(__FILE__); ?>" method = "post">
76 <fieldset>
77 <table>
78 <tr>
79 <td class = "label"><label for = "enter_password">
80 <?php echo t('Upload password') . ':';?></label>
81 </td>
82 <td class = "field"><input type = "password"
83 name = "upload_password" id = "upload_password"
84 size = "40" />
85 </td>
86 </tr>
87 <tr class = "nav">
88 <td></td>
89 <td class = "nav next">
90 <input type = "submit" name = "key" value =
91 "<?php echo t('Login'); ?>" />
92 </td>
93 </tr>
94 </table>
95 </fieldset>
96 </form>
97 <?php
98 require (JIRAFEAU_ROOT.'lib/template/footer.php');
99 exit;
100 }
101 }
102
103 ?>
104 <div id="upload_finished">
105 <p><?php echo t('File uploaded !') ?></p>
106
107 <div id="upload_finished_download_page">
108 <p>
109 <?php echo t('Download page') ?>
110 <a id="upload_link_email" href=""><img id="upload_image_email"/></a>
111 </p>
112 <p><a id="upload_link" href=""></a></p>
113 </div>
114
115 <?php if ($cfg['preview'] == true) { ?>
116 <div id="upload_finished_preview">
117 <p><?php echo t('View link') ?>:</p>
118 <p><a id="preview_link" href=""></a></p>
119 </div>
120 <?php } ?>
121
122 <div id="upload_direct_download">
123 <p><?php echo t('Direct download link') ?>:</p>
124 <p><a id="direct_link" href=""></a></p>
125 </div>
126
127 <div>
128 <p><?php echo t('Delete link') ?>:</p>
129 <p><a id="delete_link" href=""></a></p>
130 </div>
131
132 <div id="validity">
133 <p><?php echo t('This file is valid until the following date'); ?>:</p>
134 <p id="date"></p>
135 </div>
136 </div>
137
138 <div id="uploading">
139 <p>
140 <?php echo t ('Uploading ...'); ?>
141 <div id="uploaded_percentage"></div>
142 <div id="uploaded_speed"></div>
143 <div id="uploaded_time"></div>
144 </p>
145 </div>
146
147 <div id="error_pop" class="error">
148 </div>
149
150 <div id="upload">
151 <fieldset>
152 <legend>
153 <?php echo t('Select a file'); ?>
154 </legend>
155 <p>
156 <input type="file" id="file_select" size="30"
157 onchange="control_selected_file_size(<?php echo $cfg['maximal_upload_size'] ?>, '<?php echo t ('File is too big') . ', ' . t ('File size is limited to') . " " . $cfg['maximal_upload_size'] . " MB"; ?>')"/>
158 </p>
159
160 <div id="options">
161 <table id="option_table">
162 <tr>
163 <td><?php echo t('One time download'); ?>:</td>
164 <td><input type="checkbox" id="one_time_download" /></td>
165 </tr>
166 <tr>
167 <td><label for="input_key"><?php echo t('Password') . ':'; ?></label></td>
168 <td><input type="text" name="key" id="input_key" /></td>
169 </tr>
170 <tr>
171 <td><label for="select_time"><?php echo t('Time limit') . ':'; ?></label></td>
172 <td><select name="time" id="select_time">
173 <?php
174 $expirationTimeOptions = array(
175 array(
176 'value' => 'minute',
177 'label' => 'One minute'
178 ),
179 array(
180 'value' => 'hour',
181 'label' => 'One hour'
182 ),
183 array(
184 'value' => 'day',
185 'label' => 'One day'
186 ),
187 array(
188 'value' => 'week',
189 'label' => 'One week'
190 ),
191 array(
192 'value' => 'month',
193 'label' => 'One month'
194 ),
195 array(
196 'value' => 'quarter',
197 'label' => 'One quarter'
198 ),
199 array(
200 'value' => 'year',
201 'label' => 'One year'
202 ),
203 array(
204 'value' => 'none',
205 'label' => 'None'
206 )
207 );
208 foreach ($expirationTimeOptions as $expirationTimeOption) {
209 $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : '';
210 if(true === $cfg['availabilities'][$expirationTimeOption['value']]) {
211 echo '<option value="' . $expirationTimeOption['value'] . '" ' .
212 $selected . '>' . t($expirationTimeOption['label']) . '</option>';
213 }
214 }
215 ?>
216 </select></td>
217 </tr>
218
219 <?php
220 if ($cfg['maximal_upload_size'] > 0)
221 {
222 echo '<p class="config">' . t ('File size is limited to');
223 echo " " . $cfg['maximal_upload_size'] . " MB</p>";
224 }
225 ?>
226
227 <p id="max_file_size" class="config"></p>
228 <p>
229 <?php
230 if (jirafeau_has_upload_password ($cfg) && $_SESSION['upload_auth'])
231 {
232 ?>
233 <input type="hidden" id="upload_password" name="upload_password" value="<?php echo $_SESSION['user_upload_password'] ?>"/>
234 <?php
235 }
236 else
237 {
238 ?>
239 <input type="hidden" id="upload_password" name="upload_password" value=""/>
240 <?php
241 }
242 ?>
243 <input type="submit" id="send" value="<?php echo t('Send'); ?>"
244 onclick="
245 document.getElementById('upload').style.display = 'none';
246 document.getElementById('uploading').style.display = '';
247 upload ('<?php echo $cfg['web_root']; ?>', <?php echo jirafeau_get_max_upload_size_bytes (); ?>);
248 "/>
249 </p>
250 </table>
251 </div> </fieldset>
252
253 <?php
254 if (jirafeau_has_upload_password ($cfg))
255 {
256 ?>
257 <form action = "<?php echo basename(__FILE__); ?>" method = "post">
258 <input type = "hidden" name = "action" value = "logout"/>
259 <input type = "submit" value = "<?php echo t('Logout'); ?>" />
260 </form>
261 <?php
262 }
263 ?>
264
265 </div>
266
267 <script type="text/javascript" lang="Javascript">
268 document.getElementById('error_pop').style.display = 'none';
269 document.getElementById('uploading').style.display = 'none';
270 document.getElementById('upload_finished').style.display = 'none';
271 document.getElementById('options').style.display = 'none';
272 document.getElementById('send').style.display = 'none';
273 if (!check_html5_file_api ())
274 document.getElementById('max_file_size').innerHTML = '<?php
275 echo t('You browser may not support HTML5 so the maximum file size is ') . jirafeau_get_max_upload_size ();
276 ?>';
277 </script>
278 <?php require (JIRAFEAU_ROOT . 'lib/template/footer.php'); ?>

patrick-canterino.de