]>
git.p6c8.net - jirafeau_mojo42.git/blob - admin.php
2fd8d2920349050c2b36242b8df1130cc06eb51d
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.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 /* Check if the install.php script is still in the directory. */
36 if (file_exists (JIRAFEAU_ROOT
. 'install.php'))
38 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
39 echo '<div class="error"><p>'.
40 t('Installer script still present') .
42 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
46 /* Disable admin interface if we have a empty admin password. */
47 if (!$cfg['admin_password'])
49 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
50 echo '<div class="error"><p>'.
51 t('Sorry, the admin interface is not enabled.') .
53 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
61 if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0))
62 $_SESSION['admin_auth'] = false;
65 if (isset ($_POST['admin_password']))
67 if (strcmp ($cfg['admin_password'], $_POST['admin_password']) == 0)
68 $_SESSION['admin_auth'] = true;
71 $_SESSION['admin_auth'] = false;
72 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
73 echo '<div class="error"><p>'.
74 t('Wrong password.') . '</p></div>';
75 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
79 /* Ask for password. */
80 elseif (!isset ($_SESSION['admin_auth']) ||
$_SESSION['admin_auth'] != true)
82 require (JIRAFEAU_ROOT
. 'lib/template/header.php'); ?
>
83 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
87 <td
class = "label"><label
for = "enter_password">
88 <?php
echo t('Administration password') . ':';?
></label
>
90 <td
class = "field"><input type
= "password"
91 name
= "admin_password" id
= "admin_password"
97 <td
class = "nav next">
98 <input type
= "submit" name
= "key" value
=
99 "<?php echo t('Login'); ?>" />
106 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
110 /* Operations may take a long time.
111 * Be sure PHP's safe mode is off.
115 /* Admin interface. */
116 require (JIRAFEAU_ROOT
. 'lib/template/header.php');
117 ?
><h2
><?php
echo t('Admin interface'); ?
></h2
><?php
119 /* Show admin interface. */
121 ?
><div id
= "install">
122 <fieldset
><legend
><?php
echo t('Actions');?
></legend
>
124 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
126 <input type
= "hidden" name
= "action" value
= "clean"/>
128 <?php
echo t('Clean expired files'); ?
>
132 <input type
= "submit" value
= "<?php echo t('Clean'); ?>" />
136 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
138 <input type
= "hidden" name
= "action" value
= "clean_async"/>
140 <?php
echo t('Clean old unfinished transferts'); ?
>
144 <input type
= "submit" value
= "<?php echo t('Clean'); ?>" />
148 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
150 <input type
= "hidden" name
= "action" value
= "list"/>
152 <?php
echo t('List all files'); ?
>
156 <input type
= "submit" value
= "<?php echo t('List'); ?>" />
160 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
162 <input type
= "hidden" name
= "action" value
= "search_by_name"/>
164 <?php
echo t('Search files by name'); ?
>
167 <input type
= "text" name
= "name" id
= "name"/>
170 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
174 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
176 <input type
= "hidden" name
= "action" value
= "search_by_file_hash"/>
178 <?php
echo t('Search files by file hash'); ?
>
181 <input type
= "text" name
= "hash" id
= "hash"/>
184 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
188 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
190 <input type
= "hidden" name
= "action" value
= "search_link"/>
192 <?php
echo t('Search a specific link'); ?
>
195 <input type
= "text" name
= "link" id
= "link"/>
198 <input type
= "submit" value
= "<?php echo t('Search'); ?>" />
203 <form action
= "<?php echo basename(__FILE__); ?>" method
= "post">
204 <input type
= "hidden" name
= "action" value
= "logout"/>
205 <input type
= "submit" value
= "<?php echo t('Logout'); ?>" />
207 </fieldset
></div
><?php
210 /* Check for actions */
211 if (isset ($_POST['action']))
213 if (strcmp ($_POST['action'], 'clean') == 0)
215 $total = jirafeau_admin_clean ();
216 echo '<div class="message">' . NL
;
218 echo t('Number of cleaned files') . ' : ' . $total;
221 elseif (strcmp ($_POST['action'], 'clean_async') == 0)
223 $total = jirafeau_admin_clean_async ();
224 echo '<div class="message">' . NL
;
226 echo t('Number of cleaned files') . ' : ' . $total;
229 elseif (strcmp ($_POST['action'], 'list') == 0)
231 jirafeau_admin_list ("", "", "");
233 elseif (strcmp ($_POST['action'], 'search_by_name') == 0)
235 jirafeau_admin_list ($_POST['name'], "", "");
237 elseif (strcmp ($_POST['action'], 'search_by_file_hash') == 0)
239 jirafeau_admin_list ("", $_POST['hash'], "");
241 elseif (strcmp ($_POST['action'], 'search_link') == 0)
243 jirafeau_admin_list ("", "", $_POST['link']);
245 elseif (strcmp ($_POST['action'], 'delete_link') == 0)
247 jirafeau_delete_link ($_POST['link']);
248 echo '<div class="message">' . NL
;
249 echo '<p>' . t('Link deleted') . '</p></div>';
251 elseif (strcmp ($_POST['action'], 'delete_file') == 0)
253 $count = jirafeau_delete_file ($_POST['md5']);
254 echo '<div class="message">' . NL
;
255 echo '<p>' . t('Deleted links') . ' : ' . $count . '</p></div>';
257 elseif (strcmp ($_POST['action'], 'download') == 0)
259 $l = jirafeau_get_link ($_POST['link']);
262 $p = s2p ($l['md5']);
263 header ('Content-Length: ' . $l['file_size']);
264 header ('Content-Type: ' . $l['mime_type']);
265 header ('Content-Disposition: attachment; filename="' .
266 $l['file_name'] . '"');
267 if (file_exists(VAR_FILES
. $p . $l['md5']))
268 readfile (VAR_FILES
. $p . $l['md5']);
272 require (JIRAFEAU_ROOT
.'lib/template/footer.php');
patrick-canterino.de