]> git.p6c8.net - jirafeau_mojo42.git/blob - index.php
Translated using Weblate (Italian)
[jirafeau_mojo42.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 show_errors();
30 require(JIRAFEAU_ROOT . 'lib/template/footer.php');
31 exit;
32 }
33
34 require(JIRAFEAU_ROOT . 'lib/template/header.php');
35
36 /* Check if user is allowed to upload. */
37 if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) {
38
39 /* Ask password if upload password is set. */
40 if (jirafeau_has_upload_password($cfg)) {
41 session_start();
42
43 /* Unlog if asked. */
44 if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) {
45 session_unset();
46 }
47
48 /* Auth. */
49 if (isset($_POST['upload_password'])) {
50 if (jirafeau_challenge_upload_password($cfg, $_POST['upload_password'])) {
51 $_SESSION['upload_auth'] = true;
52 $_SESSION['user_upload_password'] = $_POST['upload_password'];
53 } else {
54 $_SESSION['admin_auth'] = false;
55 echo '<div class="error"><p>' . t('Wrong password.') . '</p></div>';
56 require(JIRAFEAU_ROOT.'lib/template/footer.php');
57 exit;
58 }
59 }
60
61 /* Show auth page. */
62 if (!isset($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true) {
63 ?>
64 <form method="post">
65 <fieldset>
66 <table>
67 <tr>
68 <td class = "label"><label for = "enter_password">
69 <?php echo t('Upload password') . ':'; ?></label>
70 </td>
71 <td class = "field"><input type = "password"
72 name = "upload_password" id = "upload_password"
73 size = "40" />
74 </td>
75 </tr>
76 <tr class = "nav">
77 <td></td>
78 <td class = "nav next">
79 <input type = "submit" name = "key" value =
80 "<?php echo t('Login'); ?>" />
81 </td>
82 </tr>
83 </table>
84 </fieldset>
85 </form>
86 <?php
87 require(JIRAFEAU_ROOT.'lib/template/footer.php');
88 exit;
89 }
90 }
91 }
92
93 ?>
94 <div id="upload_finished">
95 <p><?php echo t('File uploaded !') ?></p>
96
97 <div id="upload_finished_download_page">
98 <p>
99 <?php echo t('Download page') ?>
100 <a id="upload_link_email" href=""><img id="upload_image_email"/></a>
101 </p>
102 <p><a id="upload_link" href=""></a></p>
103 </div>
104
105 <?php if ($cfg['preview'] == true) {
106 ?>
107 <div id="upload_finished_preview">
108 <p><?php echo t('View link') ?>:</p>
109 <p><a id="preview_link" href=""></a></p>
110 </div>
111 <?php
112 } ?>
113
114 <div id="upload_direct_download">
115 <p><?php echo t('Direct download link') ?>:</p>
116 <p><a id="direct_link" href=""></a></p>
117 </div>
118
119 <div>
120 <p><?php echo t('Delete link') ?>:</p>
121 <p><a id="delete_link" href=""></a></p>
122 </div>
123
124 <div id="validity">
125 <p><?php echo t('This file is valid until the following date'); ?>:</p>
126 <p id="date"></p>
127 </div>
128 </div>
129
130 <div id="uploading">
131 <p>
132 <?php echo t('Uploading ...'); ?>
133 <div id="uploaded_percentage"></div>
134 <div id="uploaded_speed"></div>
135 <div id="uploaded_time"></div>
136 </p>
137 </div>
138
139 <div id="error_pop" class="error">
140 </div>
141
142 <div id="upload">
143 <fieldset>
144 <legend>
145 <?php echo t('Select a file'); ?>
146 </legend>
147 <p>
148 <input type="file" id="file_select" size="30"
149 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"; ?>')"/>
150 </p>
151
152 <div id="options">
153 <table id="option_table">
154 <tr>
155 <td><?php echo t('One time download'); ?>:</td>
156 <td><input type="checkbox" id="one_time_download" /></td>
157 </tr>
158 <tr>
159 <td><label for="input_key"><?php echo t('Password') . ':'; ?></label></td>
160 <td><input type="text" name="key" id="input_key" /></td>
161 </tr>
162 <tr>
163 <td><label for="select_time"><?php echo t('Time limit') . ':'; ?></label></td>
164 <td><select name="time" id="select_time">
165 <?php
166 $expirationTimeOptions = array(
167 array(
168 'value' => 'minute',
169 'label' => 'One minute'
170 ),
171 array(
172 'value' => 'hour',
173 'label' => 'One hour'
174 ),
175 array(
176 'value' => 'day',
177 'label' => 'One day'
178 ),
179 array(
180 'value' => 'week',
181 'label' => 'One week'
182 ),
183 array(
184 'value' => 'month',
185 'label' => 'One month'
186 ),
187 array(
188 'value' => 'quarter',
189 'label' => 'One quarter'
190 ),
191 array(
192 'value' => 'year',
193 'label' => 'One year'
194 ),
195 array(
196 'value' => 'none',
197 'label' => 'None'
198 )
199 );
200 foreach ($expirationTimeOptions as $expirationTimeOption) {
201 $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : '';
202 if (true === $cfg['availabilities'][$expirationTimeOption['value']]) {
203 echo '<option value="' . $expirationTimeOption['value'] . '" ' .
204 $selected . '>' . t($expirationTimeOption['label']) . '</option>';
205 }
206 }
207 ?>
208 </select></td>
209 </tr>
210
211 <?php
212 if ($cfg['maximal_upload_size'] > 0) {
213 echo '<p class="config">' . t('File size is limited to');
214 echo " " . $cfg['maximal_upload_size'] . " MB</p>";
215 }
216 ?>
217
218 <p id="max_file_size" class="config"></p>
219 <p>
220 <?php
221 if (jirafeau_has_upload_password($cfg) && $_SESSION['upload_auth']) {
222 ?>
223 <input type="hidden" id="upload_password" name="upload_password" value="<?php echo $_SESSION['user_upload_password'] ?>"/>
224 <?php
225
226 } else {
227 ?>
228 <input type="hidden" id="upload_password" name="upload_password" value=""/>
229 <?php
230
231 }
232 ?>
233 <input type="submit" id="send" value="<?php echo t('Send'); ?>"
234 onclick="
235 document.getElementById('upload').style.display = 'none';
236 document.getElementById('uploading').style.display = '';
237 upload ('<?php echo $cfg['web_root']; ?>', <?php echo jirafeau_get_max_upload_size_bytes(); ?>);
238 "/>
239 </p>
240 </table>
241 </div> </fieldset>
242
243 <?php
244 if (jirafeau_has_upload_password($cfg)) {
245 ?>
246 <form method="post">
247 <input type = "hidden" name = "action" value = "logout"/>
248 <input type = "submit" value = "<?php echo t('Logout'); ?>" />
249 </form>
250 <?php
251
252 }
253 ?>
254
255 </div>
256
257 <script type="text/javascript" lang="Javascript">
258 document.getElementById('error_pop').style.display = 'none';
259 document.getElementById('uploading').style.display = 'none';
260 document.getElementById('upload_finished').style.display = 'none';
261 document.getElementById('options').style.display = 'none';
262 document.getElementById('send').style.display = 'none';
263 if (!check_html5_file_api ())
264 document.getElementById('max_file_size').innerHTML = '<?php
265 echo t('You browser may not support HTML5 so the maximum file size is ') . jirafeau_get_max_upload_size();
266 ?>';
267 </script>
268 <?php require(JIRAFEAU_ROOT . 'lib/template/footer.php'); ?>

patrick-canterino.de