]>
git.p6c8.net - jirafeau_project.git/blob - admin.php
3 * Jirafeau, your web file repository
4 * Copyright (C) 2012 Jerome Jutteau <j.jutteau@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 define ('JIRAFEAU_ROOT', dirname (__FILE__
) . '/');
22 require (JIRAFEAU_ROOT
. 'lib/config.original.php');
23 require (JIRAFEAU_ROOT
. 'lib/settings.php');
24 require (JIRAFEAU_ROOT
. 'lib/functions.php');
25 require (JIRAFEAU_ROOT
. 'lib/lang.php');
27 /* Check if installation is OK. */
28 if (file_exists (JIRAFEAU_ROOT
. 'install.php')
29 && !file_exists (JIRAFEAU_ROOT
. 'lib/config.local.php'))
31 header('Location: install.php');
35 /* Disable admin interface if we have a empty admin password. */
36 if (empty($cfg['admin_password']))
38 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
39 echo '<div class="error"><p>'.
40 t('Sorry, the admin interface is not enabled.') .
42 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
50 if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
51 $_SESSION['admin_auth'] = false;
54 if (isset ($_POST['admin_password']))
56 if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0)
57 $_SESSION['admin_auth'] = true;
60 $_SESSION['admin_auth'] = false;
61 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
62 echo '<div class="error"><p>'.
63 t('Wrong password.') . '</p></div>';
64 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
68 /* Ask for password. */
69 elseif (!isset ($_SESSION['admin_auth']) ||
$_SESSION['admin_auth'] != true)
71 require (JIRAFEAU_ROOT
. 'lib/template/header.php'); ?
>
72 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
76 <td
class = "label"><label
for = "enter_password">
77 <?php
echo t('Administration password') . ':';?
></label
>
79 <td
class = "field"><input type
= "password"
80 name
= "admin_password" id
= "admin_password"
86 <td
class = "nav next">
87 <input type
= "submit" name
= "key" value
=
88 "<?php echo t('Login'); ?>" />
95 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
99 /* Operations may take a long time.
100 * Be sure PHP's safe mode is off.
106 /* Admin interface. */
107 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
108 ?
><h2
><?php
echo t('Admin interface'); ?
></h2
><?php
110 /* Show admin interface. */
112 ?
><div id
= "install">
113 <fieldset
><legend
><?php
echo t('Actions');?
></legend
>
115 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
117 <input type
= "hidden" name
= "action" value
= "clean"/>
119 <?php
echo t('Clean expired files'); ?
>
123 <input type
= "submit" value
= "<?php echo t('Clean'); ?>" />
127 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
129 <input type
= "hidden" name
= "action" value
= "clean_async"/>
131 <?php
echo t('Clean old unfinished transferts'); ?
>
135 <input type
= "submit" value
= "<?php echo t('Clean'); ?>" />
140 if ($cfg['enable_blocks'])
143 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
145 <input type
= "hidden" name
= "action" value
= "clean_block"/>
147 <?php
echo t('Clean unused blocks'); ?
>
151 <input type
= "submit" value
= "<?php echo t('Clean'); ?>" />
159 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
161 <input type
= "hidden" name
= "action" value
= "list"/>
163 <?php
echo t('List all files'); ?
>
167 <input type
= "submit" value
= "<?php echo t('List'); ?>" />
171 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
173 <input type
= "hidden" name
= "action" value
= "search_by_name"/>
175 <?php
echo t('Search files by name'); ?
>
178 <input type
= "text" name
= "name" id
= "name"/>
181 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
185 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
187 <input type
= "hidden" name
= "action" value
= "search_by_file_hash"/>
189 <?php
echo t('Search files by file hash'); ?
>
192 <input type
= "text" name
= "hash" id
= "hash"/>
195 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
199 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
201 <input type
= "hidden" name
= "action" value
= "search_link"/>
203 <?php
echo t('Search a specific link'); ?
>
206 <input type
= "text" name
= "link" id
= "link"/>
209 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
214 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
215 <input type
= "hidden" name
= "action" value
= "logout"/>
216 <input type
= "submit" value
= "<?php echo t('Logout'); ?>" />
218 </fieldset
></div
><?php
221 /* Check for actions */
222 if (isset ($_POST['action']))
224 if (strcmp ($_POST['action'], 'clean') == 0)
226 $total = jirafeau_admin_clean ();
227 echo '<div class="message">' . NL
;
229 echo t('Number of cleaned files') . ' : ' . $total;
232 elseif (strcmp ($_POST['action'], 'clean_async') == 0)
234 $total = jirafeau_admin_clean_async ();
235 echo '<div class="message">' . NL
;
237 echo t('Number of cleaned files') . ' : ' . $total;
240 elseif (strcmp ($_POST['action'], 'clean_block') == 0)
242 $total = jirafeau_admin_clean_block ();
243 echo '<div class="message">' . NL
;
245 echo t('Number of cleaned files') . ' : ' . $total;
248 elseif (strcmp ($_POST['action'], 'list') == 0)
250 jirafeau_admin_list ("", "", "");
252 elseif (strcmp ($_POST['action'], 'search_by_name') == 0)
254 jirafeau_admin_list ($_POST['name'], "", "");
256 elseif (strcmp ($_POST['action'], 'search_by_file_hash') == 0)
258 jirafeau_admin_list ("", $_POST['hash'], "");
260 elseif (strcmp ($_POST['action'], 'search_link') == 0)
262 jirafeau_admin_list ("", "", $_POST['link']);
264 elseif (strcmp ($_POST['action'], 'delete_link') == 0)
266 jirafeau_delete_link ($_POST['link']);
267 echo '<div class="message">' . NL
;
268 echo '<p>' . t('Link deleted') . '</p></div>';
270 elseif (strcmp ($_POST['action'], 'delete_file') == 0)
272 $count = jirafeau_delete_file ($_POST['md5']);
273 echo '<div class="message">' . NL
;
274 echo '<p>' . t('Deleted links') . ' : ' . $count . '</p></div>';
276 elseif (strcmp ($_POST['action'], 'download') == 0)
278 $l = jirafeau_get_link ($_POST['link']);
281 $p = s2p ($l['md5']);
282 header ('Content-Length: ' . $l['file_size']);
283 header ('Content-Type: ' . $l['mime_type']);
284 header ('Content-Disposition: attachment; filename="' .
285 $l['file_name'] . '"');
286 if (file_exists(VAR_FILES
. $p . $l['md5']))
287 readfile (VAR_FILES
. $p . $l['md5']);
291 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
patrick-canterino.de