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

patrick-canterino.de