- // Admin is not registered so we have to inform the user
- if ((isFormSent()) && ((!REQUEST_ISSET_POST(('login'))) || (!REQUEST_ISSET_POST(('pass'))) || (strlen(REQUEST_POST('pass')) < 4))) {
- REQUEST_SET_POST('ok', '***');
- }
-
- if ((isFormSent()) && (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/cache/config-local.php', "ADMIN-SETUP", "setConfigEntry('ADMIN_REGISTERED', \"", "\");", 'Y', 0);
- if ($done === true) {
- // Registering is done
- redirectToUrl('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/cache/config-local.php', "ADMIN-SETUP", "setConfigEntry('ADMIN_REGISTERED', \"", "\");", 'Y', 0);
-
- // Load URL for login
- redirectToUrl('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 ((isFormSent()) && (REQUEST_POST('ok') == '***')) {
- // No login entered?
- if (!REQUEST_ISSET_POST(('login'))) $loginMessage = getMessage('ADMIN_NO_LOGIN');
-
- // An error comes back from registration?
- if (!empty($ret)) $loginMessage = $ret;
-
- // No password entered?
- if (!REQUEST_ISSET_POST(('pass'))) $passwdMessage = getMessage('ADMIN_NO_PASS');
-
- // Or password too short?
- if (strlen(REQUEST_POST('pass')) < 4) $passwdMessage = getMessage('ADMIN_SHORT_PASS');
-
- // Output error messages
- define('__MSG_LOGIN', LOAD_TEMPLATE('admin_login_msg', true, $loginMessage));
- define('__MSG_PASS', LOAD_TEMPLATE('admin_login_msg', true, $passwdMessage));
-
- // Reset variables
- $loginMessage = ''; $passwdMessage = '';
- } else {
- // Reset values to nothing
- define('__MSG_LOGIN', '');
- define('__MSG_PASS' , '');
- }
-
- // Output message in seperate template
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NOT_REGISTERED'));
-
- // Load register template
- LOAD_TEMPLATE('admin_reg_form');
- }
-} elseif (REQUEST_ISSET_GET(('reset_pass'))) {