]> git.p6c8.net - jirafeau_project.git/blob - index.php
lib/lang: add empty template to add new languages for issue #9
[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 <http://www.gnu.org/licenses/>.
20 */
21 define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
22
23 require (JIRAFEAU_ROOT . 'lib/config.original.php');
24 require (JIRAFEAU_ROOT . 'lib/settings.php');
25 require (JIRAFEAU_ROOT . 'lib/functions.php');
26 require (JIRAFEAU_ROOT . 'lib/lang.php');
27 require (JIRAFEAU_ROOT . 'lib/template/header.php');
28
29 check_errors ($cfg);
30 if (has_error ())
31 {
32 show_errors ();
33 require (JIRAFEAU_ROOT . 'lib/template/footer.php');
34 exit;
35 }
36
37 /* Ask password if upload password is set. */
38 if (jirafeau_has_upload_password ($cfg))
39 {
40 session_start();
41
42 /* Unlog if asked. */
43 if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
44 session_unset ();
45
46 /* Auth. */
47 if (isset ($_POST['upload_password']))
48 {
49 if (jirafeau_challenge_upload_password ($cfg, $_POST['upload_password']))
50 {
51 $_SESSION['upload_auth'] = true;
52 $_SESSION['user_upload_password'] = $_POST['upload_password'];
53 }
54 else
55 {
56 $_SESSION['admin_auth'] = false;
57 echo '<div class="error"><p>' . t('Wrong password.') . '</p></div>';
58 require (JIRAFEAU_ROOT.'lib/template/footer.php');
59 exit;
60 }
61 }
62
63 /* Show auth page. */
64 if (!isset ($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true)
65 {
66 ?>
67 <form action = "<?php echo basename(__FILE__); ?>" method = "post">
68 <fieldset>
69 <table>
70 <tr>
71 <td class = "label"><label for = "enter_password">
72 <?php echo t('Upload password') . ':';?></label>
73 </td>
74 <td class = "field"><input type = "password"
75 name = "upload_password" id = "upload_password"
76 size = "40" />
77 </td>
78 </tr>
79 <tr class = "nav">
80 <td></td>
81 <td class = "nav next">
82 <input type = "submit" name = "key" value =
83 "<?php echo t('Login'); ?>" />
84 </td>
85 </tr>
86 </table>
87 </fieldset>
88 </form>
89 <?php
90 require (JIRAFEAU_ROOT.'lib/template/footer.php');
91 exit;
92 }
93 }
94
95 ?>
96 <div id="upload_finished">
97 <p><?php echo t('File uploaded !') ?></p>
98 <br />
99
100 <?php if ($cfg['download_page'] == true) { ?>
101 <div id="upload_finished_download_page">
102 <?php echo t('Download page') ?>
103 <p><a id="upload_link" href=""></a></p>
104 <br />
105 </div>
106 <?php } ?>
107
108 <div id="upload_password_page">
109 <p><?php echo t('Download page') ?>:</p>
110 <p><a id="password_link" href=""></a></p>
111 <br />
112 </div>
113
114 <?php if ($cfg['preview'] == true) { ?>
115 <div id="upload_finished_preview">
116 <p><?php echo t('View link') ?>:</p>
117 <p><a id="preview_link" href=""></a></p>
118 <br />
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 <br />
126 </div>
127
128 <p><?php echo t('Delete link') ?>:</p>
129 <p><a id="delete_link" href=""></a></p>
130 <br />
131
132 <p id="validity">
133 <?php echo t('This file is valid until the following date'); ?>:
134 <br /><strong><div id="date"></div></strong>
135 </p>
136 </div>
137
138 <div id="uploading">
139 <p>
140 <?php echo t ('Uploading ...'); ?><div id="uploaded_percentage"></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 if ($cfg['availabilities']['none']) { ?>
171 <option value="none"><?php echo t('None'); ?></option>
172 <?php } ?>
173 <?php if ($cfg['availabilities']['year']) { ?>
174 <option value = "year"><?php echo t('One year');?></option>
175 <?php } ?>
176 <?php if ($cfg['availabilities']['month']) { ?>
177 <option value = "month"><?php echo t('One month');?></option>
178 <?php } ?>
179 <?php if ($cfg['availabilities']['week']) { ?>
180 <option value = "week"><?php echo t('One week'); ?></option>
181 <?php } ?>
182 <?php if ($cfg['availabilities']['day']) { ?>
183 <option value = "day"><?php echo t('One day'); ?></option>
184 <?php } ?>
185 <?php if ($cfg['availabilities']['hour']) { ?>
186 <option value = "hour"><?php echo t('One hour'); ?></option>
187 <?php } ?>
188 <?php if ($cfg['availabilities']['minute']) { ?>
189 <option value = "minute"><?php echo t('One minute'); ?></option>
190 <?php } ?>
191 </select></td>
192 </tr>
193
194 <?php
195 if ($cfg['maximal_upload_size'] > 0)
196 {
197 echo '<p class="config">' . t ('File size is limited to');
198 echo " " . $cfg['maximal_upload_size'] . " MB</p>";
199 }
200 ?>
201
202 <p id="max_file_size" class="config"></p>
203 <p>
204 <?php
205 if (jirafeau_has_upload_password ($cfg) && $_SESSION['upload_auth'])
206 {
207 ?>
208 <input type="hidden" id="upload_password" name="upload_password" value="<?php echo $_SESSION['user_upload_password'] ?>"/>
209 <?php
210 }
211 else
212 {
213 ?>
214 <input type="hidden" id="upload_password" name="upload_password" value=""/>
215 <?php
216 }
217 ?>
218 <input type="submit" id="send" value="<?php echo t('Send'); ?>"
219 onclick="
220 document.getElementById('upload').style.display = 'none';
221 document.getElementById('uploading').style.display = '';
222 upload ('<?php echo $cfg['web_root']; ?>', <?php echo jirafeau_get_max_upload_size_bytes (); ?>);
223 "/>
224 </p>
225 </table>
226 </div> </fieldset>
227
228 <?php
229 if (jirafeau_has_upload_password ($cfg))
230 {
231 ?>
232 <form action = "<?php echo basename(__FILE__); ?>" method = "post">
233 <input type = "hidden" name = "action" value = "logout"/>
234 <input type = "submit" value = "<?php echo t('Logout'); ?>" />
235 </form>
236 <?php
237 }
238 ?>
239
240 </div>
241
242 <script lang="Javascript">
243 document.getElementById('error_pop').style.display = 'none';
244 document.getElementById('uploading').style.display = 'none';
245 document.getElementById('upload_finished').style.display = 'none';
246 document.getElementById('options').style.display = 'none';
247 document.getElementById('send').style.display = 'none';
248 if (!check_html5_file_api ())
249 document.getElementById('max_file_size').innerHTML = '<?php
250 echo t('You browser may not support HTML5 so the maximum file size is ') . jirafeau_get_max_upload_size ();
251 ?>';
252 </script>
253 <?php require (JIRAFEAU_ROOT . 'lib/template/footer.php'); ?>

patrick-canterino.de