- $ret = REGISTER_ADMIN(REQUEST_POST('login'), $hashedPass);
- switch ($ret)
- {
- case "done":
- changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
- if (!constant('_FATAL')) {
- // Registering is done
- LOAD_URL("modules.php?module=admin&action=login®ister=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()", $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
- changeDataInFile(constant('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;
- }
- }
+ $ret = addAdminAccount(postRequestParameter('login'), $hashedPass, getWebmaster());
+
+ // Check if registration wents fine
+ switch ($ret) {
+ case 'done':
+ // Change ADMIN_REGISTERED entry
+ $done = changeDataInLocalConfigurationFile('ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0);
+
+ // Was it successfull?
+ 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