X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/507c6d855f2a15a6d5509b27517ee60732006a3c..a050a0d51152ae3f8eaf77017cfd07e6c6a64c6b:/admin.php diff --git a/admin.php b/admin.php index 6560f10..93b7d35 100644 --- a/admin.php +++ b/admin.php @@ -1,7 +1,7 @@ + * Copyright (C) 2015 Jerome Jutteau * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -32,52 +32,54 @@ if (file_exists(JIRAFEAU_ROOT . 'install.php') /* If called from CLI, no password or graphical interface */ if (php_sapi_name() == "cli") { + if ($cfg['installation_done'] == false) { + die("Installation not completed yet.\n"); + } if ((count($argv)>1) && $argv[1]=="clean_expired") { $total = jirafeau_admin_clean(); - echo "$total expired files deleted."; + echo "$total expired files deleted.\n"; } elseif ((count($argv)>1) && $argv[1]=="clean_async") { $total = jirafeau_admin_clean_async(); - echo "$total old unfinished transfers deleted."; + echo "$total old unfinished transfers deleted.\n"; } else { - die("No command found. Should be admin.php ."); + die("No command found. Should be admin.php .\n"); } } else { /* Disable admin interface if we have a empty admin password. */ - if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) { - require(JIRAFEAU_ROOT . 'lib/template/header.php'); - echo '

'. + if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) { + require(JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. t('NO_ADMIN') . '

'; - require(JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; - } + require(JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } - /* Unlog if asked. */ - if (jirafeau_admin_session_logged() && isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { - jirafeau_admin_session_end(); - } + /* Unlog if asked. */ + if (jirafeau_admin_session_logged() && isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { + jirafeau_admin_session_end(); + } - if (!jirafeau_admin_session_logged()) { - /* Test HTTP authentification. */ - if (!empty($cfg['admin_http_auth_user']) && + if (!jirafeau_admin_session_logged()) { + /* Test HTTP authentification. */ + if (!empty($cfg['admin_http_auth_user']) && $cfg['admin_http_auth_user'] == $_SERVER['PHP_AUTH_USER']) { - jirafeau_admin_session_start(); - } - /* Test web password authentification. */ - else if (!empty($cfg['admin_password']) && isset($_POST['admin_password'])) { - if ($cfg['admin_password'] === $_POST['admin_password'] || - $cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) { - jirafeau_admin_session_start(); - } else { - require(JIRAFEAU_ROOT . 'lib/template/header.php'); - echo '

'. t('BAD_PSW') . '

'; - require(JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; - } - } - /* Admin password prompt form. */ - else { - require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?> + jirafeau_admin_session_start(); + } + /* Test web password authentification. */ + elseif (!empty($cfg['admin_password']) && isset($_POST['admin_password'])) { + if ($cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) { + jirafeau_admin_session_start(); + } else { + require(JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. t('BAD_PSW') . '

'; + require(JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; + } + } + /* Admin password prompt form. */ + else { + require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?>