- // Admin is not registered so we have to inform the user
- if ((IS_FORM_SENT()) && ((!REQUEST_ISSET_POST(('login'))) || (!REQUEST_ISSET_POST(('pass'))) || (strlen(REQUEST_POST('pass')) < 4))) {
- REQUEST_SET_POST('ok', "***");
- }
-
- if ((IS_FORM_SENT()) && (REQUEST_POST('ok') != "***")) {
- // Hash the password with the old function because we are here in install mode
- $hashedPass = md5(REQUEST_POST('pass'));
-
- // Kill maybe existing session variables
- destroyAdminSession(false);
-
- // Do registration
- $ret = REGISTER_ADMIN(REQUEST_POST('login'), $hashedPass, constant('WEBMASTER'));
- switch ($ret)
- {
- case "done":
- $done = changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
- if ($done === true) {
- // Registering is done
- LOAD_URL("modules.php?module=admin&register=done");
- } else {
- $ret = getMessage('ADMIN_CANNOT_COMPLETE');
- }
- break;
-
- case "failed":
- $ret = getMessage('ADMIN_REGISTER_FAILED');
- break;
-
- case "already":
- default:
- if ($ret == "already") {
- // Admin does already exists!
- $ret = getMessage('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() and interpreted as 'done'!", $ret));
- // @TODO Why is this set to 'done'?
- $ret = "done";
- }
-
- // Admin still not registered?
- if (!isAdminRegistered()) {
- // Write to config that registration is done
- changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
-
- // Load URL for login
- LOAD_URL("modules.php?module=admin");
- } // END - if
- break;
- }
- }
-
- // Whas that action okay?
- if ($ret != "done") {
- // Fixes another "Notice"
- if (REQUEST_ISSET_POST(('login'))) {
- define('__LOGIN_VALUE', REQUEST_POST('login'));
- } else {
- define('__LOGIN_VALUE', "");
- }
-
- // Yet-another "Notice" fix
- if ((IS_FORM_SENT()) && (REQUEST_POST('ok') == "***")) {
- // No login entered?
- if (!REQUEST_ISSET_POST(('login'))) $MSG1 = getMessage('ADMIN_NO_LOGIN');
-
- // An error comes back from registration?
- if (!empty($ret)) $MSG1 = $ret;
-
- // No password entered?
- if (!REQUEST_ISSET_POST(('pass'))) $MSG2 = getMessage('ADMIN_NO_PASS');
-
- // Or password too short?
- if (strlen(REQUEST_POST('pass')) < 4) $MSG2 = getMessage('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 (REQUEST_ISSET_GET(('reset_pass'))) {