Fixed logfile writing in installation phase, .revision is now ignored
[mailer.git] / inc / modules / admin.php
index 7261d1cddcad84f4bd02cf169f6f6aa612991b77..84c86d8c028c89a9271f1e876938ed9558085309 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Administrationsmodul                             *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision:: 856                                                    $ *
+ * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author:: stelzi                                                   $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
@@ -37,12 +42,6 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
-// Login is default
-if ((empty($GLOBALS['action'])) && ($check == "admin_only")) {
-       // Redirect to right URL
-       LOAD_URL("modules.php?module=admin&action=login");
-} // END - if
-
 // Load include file
 LOAD_INC_ONCE("inc/modules/admin/admin-inc.php");
 
@@ -53,7 +52,7 @@ FIX_DELETED_COOKIES(array('admin_login', 'admin_md5', 'admin_last', 'admin_to'))
 $ret = "init";
 
 // Is no admin registered?
-if (!isBooleanConstantAndTrue('admin_registered')) {
+if (!isAdminRegistered()) {
        // 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', "***");
@@ -67,14 +66,14 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                destroyAdminSession(false);
 
                // Do registration
-               $ret = REGISTER_ADMIN(REQUEST_POST('login'), $hashedPass);
+               $ret = REGISTER_ADMIN(REQUEST_POST('login'), $hashedPass, constant('WEBMASTER'));
                switch ($ret)
                {
                case "done":
-                       changeDataInFile(constant('PATH')."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
-                       if (!constant('_FATAL')) {
+                       $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&amp;action=login&register=done");
+                               LOAD_URL("modules.php?module=admin&amp;register=done");
                        } else {
                                $ret = getMessage('ADMIN_CANNOT_COMPLETE');
                        }
@@ -91,18 +90,18 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                                $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));
+                               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 (!isBooleanConstantAndTrue('admin_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&amp;action=login");
+                               LOAD_URL("modules.php?module=admin");
                        } // END - if
                        break;
                }
@@ -195,7 +194,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
        // At leat one administrator account was created
        if ((isSessionVariableSet('admin_login')) && (isSessionVariableSet('admin_md5')) && (isSessionVariableSet('admin_last')) && (isSessionVariableSet('admin_to'))) {
                // Timeout for last login, we have to logout first!
-               LOAD_URL("modules.php?module=admin&amp;action=login&amp;logout=1");
+               LOAD_URL("modules.php?module=admin&amp;logout=1");
        } // END - if
 
        if (REQUEST_ISSET_GET(('register'))) {
@@ -319,13 +318,13 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                // Load logout template
                if (REQUEST_ISSET_GET(('register'))) {
                        // Secure input
-                       $register = SQL_ESCAPE(REQUEST_GET('register'));
+                       $register = REQUEST_GET(('register'));
 
                        // Special logout redirect for installation of given extension
                        LOAD_TEMPLATE(sprintf("admin_logout_%s_install", $register));
                } elseif (REQUEST_ISSET_GET(('remove'))) {
                        // Secure input
-                       $remove = SQL_ESCAPE(REQUEST_GET('remove'));
+                       $remove = REQUEST_GET(('remove'));
 
                        // Special logout redirect for removal of given extension
                        LOAD_TEMPLATE(sprintf("admin_logout_%s_remove", $remove));
@@ -338,7 +337,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                LOAD_TEMPLATE("admin_settings_saved", false, "<div class=\"admin_fatal\">{--ADMIN_LOGOUT_FAILED--}</div>");
 
                // Add fatal message
-               addFatalMessage(getMessage('CANNOT_UNREG_SESS'));
+               addFatalMessage(__FILE__, __LINE__, getMessage('CANNOT_UNREG_SESS'));
        }
 } else {
        // Maybe an Admin want's to login?
@@ -347,7 +346,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
        {
        case "done":
                // Check for access control line of current menu entry
-               define('__ACL_ALLOW', RUN_FILTER('check_admin_acl'));
+               $GLOBALS['acl_allow'] = runFilterChain('check_admin_acl');
 
                // When type of admin menu is not set fallback to old menu system
                if (!isConfigEntrySet('admin_menu')) setConfigEntry('admin_menu', "OLD");
@@ -358,7 +357,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                        $area = "entrance";
 
                        // Check for similar URL variable
-                       if (REQUEST_ISSET_GET(('area'))) $area = SQL_ESCAPE(REQUEST_GET('area'));
+                       if (REQUEST_ISSET_GET(('area'))) $area = REQUEST_GET(('area'));
 
                        // Load "logical-area menu-system" file
                        LOAD_INC_ONCE("inc/modules/admin/lasys-inc.php");
@@ -375,13 +374,13 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
        case "404": // Administrator login not found
                REQUEST_SET_POST('ok', $ret);
                destroyAdminSession();
-               addFatalMessage(getMessage('ADMIN_NOT_FOUND'));
+               addFatalMessage(__FILE__, __LINE__, getMessage('ADMIN_NOT_FOUND'));
                break;
 
        case "pass": // Wrong password
                REQUEST_SET_POST('ok', $ret);
                destroyAdminSession();
-               addFatalMessage(getMessage('WRONG_PASS'));
+               addFatalMessage(__FILE__, __LINE__, getMessage('WRONG_PASS'));
                break;
 
        default: // Others will be logged