X-Git-Url: https://git.p6c8.net/jirafeau.git/blobdiff_plain/2dc4984ad57dfcb0ded829bfc9d45493484fe6e3..871a40df8b73ce50251e2827c1e193902756ddac:/admin.php?ds=inline diff --git a/admin.php b/admin.php index 4500a19..4a3d25f 100644 --- a/admin.php +++ b/admin.php @@ -53,72 +53,58 @@ if (php_sapi_name() == "cli") { } /* Unlog if asked. */ - if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { - $_SESSION['admin_auth'] = false; + if (jirafeau_admin_session_logged() && isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { + jirafeau_admin_session_end(); } - /* Check classic admin password authentification. */ - if (isset($_POST['admin_password']) && empty($cfg['admin_http_auth_user'])) { - if ($cfg['admin_password'] === $_POST['admin_password'] || - $cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) { - $_SESSION['admin_auth'] = true; - } else { - $_SESSION['admin_auth'] = false; - require(JIRAFEAU_ROOT . 'lib/template/header.php'); - echo '

'. - t('BAD_PSW') . '

'; + 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'] === 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'); ?> +
+
+ + + + + + + + + + +
+
+
+
+
+ -
-
- - - - - - - - - -
- -
-
-
-

'. - t('NO_ADMIN_AUTH') . - '

'; - require(JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; - } /* Operations may take a long time. * Be sure PHP's safe mode is off. @@ -138,6 +124,7 @@ if (php_sapi_name() == "cli") {
+ @@ -150,6 +137,7 @@ if (php_sapi_name() == "cli") { + @@ -162,6 +150,7 @@ if (php_sapi_name() == "cli") { + @@ -174,6 +163,7 @@ if (php_sapi_name() == "cli") { + @@ -188,6 +178,7 @@ if (php_sapi_name() == "cli") { + @@ -202,8 +193,9 @@ if (php_sapi_name() == "cli") { + - + @@ -216,10 +208,10 @@ if (php_sapi_name() == "cli") { +