]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin.php
Commented out for testing... opps
[mailer.git] / inc / modules / admin.php
index e7aabd542decdb44844cb008233164661fd5712f..cb73fecea022525744d1f1f26211dd5dd1e4eb67 100644 (file)
@@ -49,25 +49,25 @@ require_once(PATH."inc/modules/admin/admin-inc.php");
 // Fix "deleted" cookies in PHP4 (PHP5 does remove them, PHP4 sets them to deleted!)
 FIX_DELETED_COOKIES(array('admin_login', 'admin_md5', 'admin_last', 'admin_to'));
 
-// Is the logout empty?
-if (empty($_GET['logout'])) $_GET['logout'] = "";
-
 if (!isBooleanConstantAndTrue('admin_registered')) {
        // Admin is not registered so we have to inform the user
        if ((isset($_POST['ok'])) && ((empty($_POST['login'])) || (empty($_POST['pass'])) || (strlen($_POST['pass']) < 4))) $_POST['ok'] = "***";
        if ((isset($_POST['ok'])) && ($_POST['ok'] != "***")) {
-               // Hash the password with our new generateHash() function
-               $hashedPass = generateHash($_POST['pass']);
+               // Hash the password with the old function because we are here in install mode
+               $hashedPass = md5($_POST['pass']);
 
-               // If the password has not been hashed we have to fall-back to md5()
-               if ($hashedPass == $_POST['pass']) $hashedPass = md5($hashedPass);
+               // Kill maybe existing session variables
+               set_session('admin_login'       , "");
+               set_session('admin_md5'         , "");
+               set_session('admin_last'        , "");
+               set_session('admin_to'          , "");
 
                // Do registration
                $ret = REGISTER_ADMIN($_POST['login'], $hashedPass);
                switch ($ret)
                {
                case "done":
-                       admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define ('admin_registered', ", ");", "true", 0);
+                       admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
                        if (!_FATAL) {
                                // Registering is done
                                LOAD_URL(URL."/modules.php?module=admin&amp;action=login&register=done");
@@ -89,9 +89,10 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                                // Any other kind
                                $ret = "done";
                        }
+
                        if (!isBooleanConstantAndTrue('admin_registered')) {
                                // Write to config that registration is done
-                               admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define ('admin_registered', ", ");", "true", 0);
+                               admin_WriteData(PATH."inc/config.php", "ADMIN-SETUP", "define('admin_registered', ", ");", "true", 0);
 
                                // Load URL for login
                                $URL = URL."/modules.php?module=admin&amp;action=login";
@@ -100,6 +101,8 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                        break;
                }
        }
+
+       // Whas that action okay?
        if ($ret != "done") {
                // Fixes another "Notice"
                if (!empty($_POST['login'])) {
@@ -158,27 +161,21 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                switch ($ret)
                {
                case "done": // Admin and password are okay, so we log in now
-                       // Try to register the session variables
-                       if ((set_session("admin_md5", generatePassString(generateHash($_POST['pass'], __SALT)))) && (set_session("admin_login", $_POST['login'])) && (set_session("admin_last", time())) && (set_session("admin_to", $_POST['timeout']))) {
-                               // Construct URL and redirect
-                               $URL = URL."/modules.php?module=admin&amp;";
-
-                               // Rewrite overview module
-                               if ($GLOBALS['what'] == "overview") {
-                                       $GLOBALS['action'] = GET_ACTION($GLOBALS['module'], $GLOBALS['what']);
-                               }
+                       // Construct URL and redirect
+                       $URL = URL."/modules.php?module=admin&amp;";
 
-                               // Add data to URL
-                               if (!empty($GLOBALS['what'])) $URL .= "what=".$GLOBALS['what'];
-                                elseif (!empty($GLOBALS['action'])) $URL .= "action=".$GLOBALS['action'];
-                                elseif (!empty($_GET['area'])) $URL .= "area=".$_GET['area'];
-
-                               // Load URL
-                               LOAD_URL($URL);
-                       } else {
-                               OUTPUT_HTML("<STRONG class=\"admin_fatal\">".ADMIN_LOGIN_FAILED."</STRONG>");
-                               ADD_FATAL(CANNOT_REGISTER_SESS);
+                       // Rewrite overview module
+                       if ($GLOBALS['what'] == "overview") {
+                               $GLOBALS['action'] = GET_ACTION($GLOBALS['module'], $GLOBALS['what']);
                        }
+
+                       // Add data to URL
+                       if (!empty($GLOBALS['what'])) $URL .= "what=".$GLOBALS['what'];
+                        elseif (!empty($GLOBALS['action'])) $URL .= "action=".$GLOBALS['action'];
+                        elseif (!empty($_GET['area'])) $URL .= "area=".$_GET['area'];
+
+                       // Load URL
+                       LOAD_URL($URL);
                        break;
 
                case "404": // Administrator login not found
@@ -253,7 +250,7 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                // Load login form template
                LOAD_TEMPLATE("admin_login_form", false, $content);
        }
-} elseif ($_GET['logout'] == "1") {
+} elseif (isset($_GET['logout'])) {
        // Only try to remove cookies
        if (set_session("admin_login", "") && set_session("admin_md5", "") && set_session("admin_last", "") && set_session("admin_to", "")) {
                // Also remove array elements
@@ -266,7 +263,13 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
                @session_destroy();
 
                // Load logout template
-               LOAD_TEMPLATE("admin_logout");
+               if (isset($_GET['sql_patches'])) {
+                       // Special logout redirect for sql_patchrs
+                       LOAD_TEMPLATE("admin_logout_sql_patches");
+               } else {
+                       // Logged out normally
+                       LOAD_TEMPLATE("admin_logout");
+               }
        } else {
                // Something went wrong here...
                OUTPUT_HTML("<STRONG class=\"admin_fatal\">".ADMIN_LOGOUT_FAILED."</STRONG>");
@@ -277,7 +280,8 @@ if (!isBooleanConstantAndTrue('admin_registered')) {
 } else {
        // Maybe an Admin want's to login?
        $ret = CHECK_ADMIN_COOKIES(SQL_ESCAPE(get_session('admin_login')), SQL_ESCAPE(get_session('admin_md5')));
-       switch ($ret) {
+       switch ($ret)
+       {
        case "done":
                // Cookie-Data accepted
                if ((set_session("admin_md5", SQL_ESCAPE(get_session('admin_md5')))) && (set_session("admin_login", SQL_ESCAPE(get_session('admin_login')))) && (set_session("admin_last", time())) && (set_session("admin_to", bigintval(get_session('admin_to'))))) {