- $ret = REGISTER_ADMIN($_POST['login'], $hashedPass);
- switch ($ret)
- {
- case "done":
- admin_WriteData(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
- admin_WriteData(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(postRequestElement('login'), $hashedPass, getConfig('WEBMASTER'));
+
+ // Check if registration wents fine
+ switch ($ret) {
+ case 'done':
+ $done = changeDataInFile(getConfig('CACHE_PATH') . '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'
+ logDebugMessage(__FILE__, __LINE__, sprintf("Unknown return code %s from ifAdminLoginDataIsValid() 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(getConfig('CACHE_PATH') . 'config-local.php', 'ADMIN-SETUP', "setConfigEntry('ADMIN_REGISTERED', '", "');", 'Y', 0);
+
+ // Load URL for login
+ redirectToUrl('admin.php');
+ } // END - if
+ break;
+ } // END - switch