-if (!isBooleanConstantAndTrue('admin_registered')) {
- // Admin is not registered so we have to inform the user
- if ((isset($_POST['ok'])) && ((empty($_POST['login'])) || (empty($_POST['pass'])) || (strlen($_POST['pass']) < 4))) $_POST['ok'] = "***";
- if ((isset($_POST['ok'])) && ($_POST['ok'] != "***")) {
- // Hash the password with the old function because we are here in install mode
- $hashedPass = md5($_POST['pass']);
-
- // Kill maybe existing session variables
- DESTROY_ADMIN_SESSION(false);
-
- // Do registration
- $ret = REGISTER_ADMIN($_POST['login'], $hashedPass);
- switch ($ret)
- {
- case "done":
- admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
- if (!_FATAL) {
- // Registering is done
- LOAD_URL("modules.php?module=admin&action=login®ister=done");
- } else {
- $ret = ADMIN_CANNOT_COMPLETE;
- }
- break;
-
- case "failed":
- $ret = ADMIN_REGISTER_FAILED;
- break;
-
- case "already":
- default:
- if ($ret == "already") {
- // Admin does already exists!
- $ret = ADMIN_LOGIN_ALREADY_REG;
- } else {
- // Any other kind will be logged and interpreted as 'done'
- DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown return code %s from CHECK_ADMIN_LOGIN()", $ret));
- // @TODO Why is this set to 'done'?
- $ret = "done";
- }
-
- // Admin still not registered?
- if (!isBooleanConstantAndTrue('admin_registered')) {
- // Write to config that registration is done
- admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
-
- // Load URL for login
- LOAD_URL("modules.php?module=admin&action=login");
- } // END - if
- break;
- }
- }
-
- // Whas that action okay?
- if ($ret != "done") {
- // Fixes another "Notice"
- if (!empty($_POST['login'])) {
- define('__LOGIN_VALUE', $_POST['login']);
- } else {
- define('__LOGIN_VALUE', "");
- }
-
- // Yet-another "Notice" fix
- if ((!empty($_POST['ok'])) && ($_POST['ok'] == "***")) {
- // No login entered?
- if (empty($_POST['login'])) $MSG1 = ADMIN_NO_LOGIN;
-
- // An error comes back from registration?
- if (!empty($ret)) $MSG1 = $ret;
-
- // No password entered?
- if (empty($_POST['pass'])) $MSG2 = ADMIN_NO_PASS;
-
- // Or password too short?
- if (strlen($_POST['pass']) < 4) $MSG2 = ADMIN_SHORT_PASS;
-
- // Output error messages
- define('__MSG_LOGIN', LOAD_TEMPLATE("admin_login_msg", true, $MSG1));
- define('__MSG_PASS', LOAD_TEMPLATE("admin_login_msg", true, $MSG2));
-
- // Reset variables
- $MSG1 = ""; $MSG2 = "";
- } else {
- // Reset values to nothing
- define('__MSG_LOGIN', "");
- define('__MSG_PASS' , "");
- }
-
- // Load register template
- LOAD_TEMPLATE("admin_reg_form");
- }
-} elseif (isset($_GET['reset_pass'])) {