- case "already":
- default:
- if ($ret == "already")
- {
- // Admin does already exists!
- $ret = ADMIN_LOGIN_ALREADY_REG;
- }
- else
- {
- // Any other kind
- $ret = "done";
- }
- if (!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
- $URL = URL."/modules.php?module=admin&action=login";
- LOAD_URL($URL);
- }
- break;
- }
- }
- if ($ret != "done")
- {
- // Fixes another "Notice"
- if (!empty($_POST['login'])) {
- define('__LOGIN_VALUE', $_POST['login']);
- } else {
- define('__LOGIN_VALUE', "");
- }
+ // Do registration
+ $ret = addAdminAccount(postRequestParameter('login'), $hashedPass, getConfig('WEBMASTER'));
+
+ // Check if registration wents fine
+ switch ($ret) {
+ case 'done':
+ $done = changeDataInFile(getCachePath() . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0);
+ if ($done === true) {
+ // Registering is done
+ redirectToUrl('modules.php?module=admin&register=done');
+ } else {
+ // Registration incomplete
+ $errorMessage = '{--ADMIN_CANNOT_COMPLETE--}';
+
+ // Set this to have our error message displayed
+ setPostRequestParameter('ok', '***');
+ }
+ break;
+
+ case 'failed': // Registration has failed
+ $errorMessage = '{--ADMIN_REGISTER_FAILED--}';
+
+ // Set this to have our error message displayed
+ setPostRequestParameter('ok', '***');
+ break;
+
+ case 'already': // Admin does already exists!
+ $errorMessage = '{--ADMIN_LOGIN_ALREADY_REG--}';
+
+ // Set this to have our error message displayed
+ setPostRequestParameter('ok', '***');
+ break;
+
+ default:
+ // Any other kind will be logged
+ $errorMessage = sprintf("Unknown return code %s from ifAdminLoginDataIsValid().", $ret);
+ logDebugMessage(__FILE__, __LINE__, $errorMessage);
+
+ // Set this to have our error message displayed
+ setPostRequestParameter('ok', '***');
+ break;
+ } // END - switch
+ } // END - if
+
+ // Whas that action okay?
+ if ($ret != 'done') {
+ // Init login name
+ $content['login'] = '';
+ if (isPostRequestParameterSet('login')) {
+ $content['login'] = postRequestParameter('login');
+ } // END - if
+
+ // Init array elements
+ $content['login_message'] = '';
+ $content['pass1_message'] = '';
+ $content['pass2_message'] = '';
+
+ // Yet-another notice-fix
+ if ((isFormSent()) && (postRequestParameter('ok') == '***')) {
+ // Init variables
+ $loginMessage = '';
+ $pass1Message = '';
+ $pass2Message = '';