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

patrick-canterino.de