]> git.p6c8.net - jirafeau.git/blob - index.php
adding courgette as default style
[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 <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 (strlen ($cfg['upload_password']) > 0)
39 {
40 session_start();
41
42 /* Unlog if asked. */
43 if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
44 $_SESSION['upload_auth'] = false;
45
46 /* Auth. */
47 if (isset ($_POST['upload_password']))
48 {
49 if (strcmp ($cfg['upload_password'], $_POST['upload_password']) == 0)
50 $_SESSION['upload_auth'] = true;
51 else
52 {
53 $_SESSION['admin_auth'] = false;
54 echo '<div class="error"><p>' . t('Wrong password.') . '</p></div>';
55 require (JIRAFEAU_ROOT.'lib/template/footer.php');
56 exit;
57 }
58 }
59
60 /* Show auth page. */
61 if (!isset ($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true)
62 {
63 ?>
64 <form action = "<?php echo basename(__FILE__); ?>" 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 <div id="upload_finished">
94 <p>
95 <?php echo t('File uploaded! Copy the following URL to get it') ?>:
96 <br />
97 <a id="upload_link" href=""></a>
98 <br />
99 </p>
100
101 <p>
102 <?php echo t('Keep the following URL to delete it at any moment'); ?>:
103 <br />
104 <a id="delete_link" href=""></a>
105 </p>
106
107 <p id="validity">
108 <?php echo t('This file is valid until the following date'); ?>:
109 <br /><strong><div id="date"></div></strong>
110 </p>
111 </div>
112
113 <div id="uploading">
114 <p>
115 <?php echo t ('Uploading ...'); ?><div id="uploaded_percentage"></div>
116 </p>
117 </div>
118
119 <div id="upload">
120 <fieldset>
121 <legend>
122 <?php echo t('Select a file'); ?>
123 </legend>
124 <p>
125 <input type="file" id="file_select" size="30"
126 onchange="
127 document.getElementById('options').style.display = '';
128 document.getElementById('send').style.display = '';
129 "/>
130 </p>
131
132 <div id="options">
133 <table id="option_table">
134 <tr>
135 <td><?php echo t('One time download'); ?>:</td>
136 <td><input type="checkbox" id="one_time_download" /></td>
137 </tr>
138 <tr>
139 <td><label for="input_key"><?php echo t('Password') . ':'; ?></label></td>
140 <td><input type="text" name="key" id="input_key" /></td>
141 </tr>
142 <tr>
143 <td><label for="select_time"><?php echo t('Time limit') . ':'; ?></label></td>
144 <td><select name="time" id="select_time">
145 <option value="none"><?php echo t('None'); ?></option>
146 <option value = "minute"><?php echo t('One minute'); ?></option>
147 <option value = "hour"><?php echo t('One hour'); ?></option>
148 <option value = "day"><?php echo t('One day'); ?></option>
149 <option value = "week"><?php echo t('One week'); ?></option>
150 <option value = "month"><?php echo t('One month');?></option>
151 </select></td>
152 </tr>
153 <p id="max_file_size" class="config"></p>
154 <p>
155
156 <input type="hidden" id="upload_password" name="upload_password" value="<?php echo $cfg['upload_password']?>"/>
157 <input type="submit" id="send" value="<?php echo t('Send'); ?>"
158 onclick="
159 document.getElementById('upload').style.display = 'none';
160 document.getElementById('uploading').style.display = '';
161 upload ('<?php echo $cfg['web_root']; ?>', <?php echo jirafeau_get_max_upload_size_bytes (); ?>);
162 "/>
163 </p>
164 </table>
165 </div> </fieldset>
166
167 <?php
168 if (strlen ($cfg['upload_password']) > 0)
169 {
170 ?>
171 <form action = "<?php echo basename(__FILE__); ?>" method = "post">
172 <input type = "hidden" name = "action" value = "logout"/>
173 <input type = "submit" value = "<?php echo t('Logout'); ?>" />
174 </form>
175 <?php
176 }
177 ?>
178
179 </div>
180
181 <script lang="Javascript">
182 document.getElementById('uploading').style.display = 'none';
183 document.getElementById('upload_finished').style.display = 'none';
184 document.getElementById('options').style.display = 'none';
185 document.getElementById('send').style.display = 'none';
186 if (!check_html5_file_api ())
187 document.getElementById('max_file_size').innerHTML = '<?php
188 echo t('You browser may not support HTML5 so the maximum file size is ') . jirafeau_get_max_upload_size ();
189 ?>';
190 </script>
191 <?php require (JIRAFEAU_ROOT . 'lib/template/footer.php'); ?>

patrick-canterino.de