X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fadmin-inc.php;h=505bcc0f82e90b90a9bd1a9ae52b4d4f9834a475;hb=c25f923b9006723f30055e6bd7145d6aaa8cee42;hp=2e47837431641f431c3e483a6c55638377c51bde;hpb=4264b4f73e06a6b957330a9972efe600a8ff4ab5;p=mailer.git diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 2e47837431..505bcc0f82 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -52,7 +52,7 @@ function addAdminAccount ($adminLogin, $passHash, $adminEmail) { // Is the entry there? if (SQL_HASZERONUMS($result)) { // Ok, let's create the admin login - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`,`password`,`email`) VALUES ('%s', '%s', '%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins` (`login`, `password`, `email`) VALUES ('%s', '%s', '%s')", array( $adminLogin, $passHash, @@ -133,12 +133,15 @@ function ifAdminCookiesAreValid ($adminLogin, $passHash) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash); // If they both match, the login data is valid - if ($testHash == $passHash) { + if ($testHash != $passHash) { + // Passwords don't match + $ret = 'password'; + } elseif (!isAdmin()) { + // Is not valid session + $ret = 'session'; + } else { // All fine $ret = 'done'; - } else { - // Set status - $ret = 'password'; } } // END - if @@ -158,18 +161,18 @@ function doAdminAction () { // Load welcome template if (isExtensionActive('admins')) { // @TODO This and the next getCurrentAdminId() call might be moved into the templates? - $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId()); + $content['welcome'] = loadTemplate('admin_welcome_admins', TRUE, getCurrentAdminId()); } else { - $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId()); + $content['welcome'] = loadTemplate('admin_welcome', TRUE, getCurrentAdminId()); } // Load header, footer, render menu - $content['header'] = loadTemplate('admin_header' , true, $content); - $content['footer'] = loadTemplate('admin_footer' , true, $content); + $content['header'] = loadTemplate('admin_header' , TRUE, $content); + $content['footer'] = loadTemplate('admin_footer' , TRUE, $content); $content['menu'] = addAdminMenu($action, $what); // Load main template - loadTemplate('admin_main', false, $content); + loadTemplate('admin_main', FALSE, $content); // Check if action/what pair is valid $result_action = SQL_QUERY_ESC("SELECT @@ -200,26 +203,26 @@ LIMIT 1", if (SQL_NUMROWS($result_action) == 1) { // Is valid but does the inlcude file exists? $inc = sprintf("inc/modules/admin/action-%s.php", $action); - if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === true)) { + if ((isIncludeReadable($inc)) && (isMenuActionValid('admin', $action, $what)) && ($GLOBALS['acl_allow'] === TRUE)) { // Ok, we finally load the admin action module loadInclude($inc); - } elseif ($GLOBALS['acl_allow'] === false) { + } elseif ($GLOBALS['acl_allow'] === FALSE) { // Access denied - loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACCESS_DENIED=' . $what . '%}'); + loadTemplate('admin_menu_failed', FALSE, '{%message,ADMIN_ACCESS_DENIED=' . $what . '%}'); } else { // Include file not found :-( - loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACTION_404=' . $action . '%}'); + loadTemplate('admin_menu_failed', FALSE, '{%message,ADMIN_ACTION_404=' . $action . '%}'); } } else { // Invalid action/what pair found - loadTemplate('admin_menu_failed', false, '{%message,ADMIN_ACTION_INVALID=' . $action . '/' . $what . '%}'); + loadTemplate('admin_menu_failed', FALSE, '{%message,ADMIN_ACTION_INVALID=' . $action . '/' . $what . '%}'); } // Free memory SQL_FREERESULT($result_action); // Tableset footer - loadTemplate('admin_main_footer', false, $content); + loadTemplate('admin_main_footer', FALSE, $content); } /** @@ -241,7 +244,7 @@ function isAdminAllowedAccessMenu ($action, $what = NULL) { // Adds an admin menu function addAdminMenu ($action, $what) { // Init variables - $SUB = false; + $SUB = FALSE; $OUT = ''; // Menu descriptions @@ -272,7 +275,7 @@ ORDER BY // Is the current admin allowed to access this 'action' menu? if (isAdminAllowedAccessMenu($mainContent['main_action'])) { - if ($SUB === false) { + if ($SUB === FALSE) { // Insert compiled menu title and description $GLOBALS['menu']['title'][$mainContent['main_action']] = $mainContent['main_title']; $GLOBALS['menu']['description'][$mainContent['main_action']] = $mainContent['main_descr']; @@ -353,7 +356,7 @@ ORDER BY // Are there entries? if (ifAdminMenuHasEntries($mainContent['main_action'])) { // Sub menu has been called - $SUB = true; + $SUB = TRUE; // Are there entries? if (!SQL_HASZERONUMS($result_what)) { @@ -442,8 +445,17 @@ ORDER BY // Load all entries while ($content = SQL_FETCHARRAY($result)) { + // Default is none + $content['default'] = ''; + + // Is the id the same? + if ($content['id'] == $adminId) { + // Set this as default + $content['default'] = ' selected="selected"'; + } // END - if + // Add the entry - $OUT .= loadTemplate('select_admins_option', true, $content); + $OUT .= loadTemplate('select_admins_option', TRUE, $content); } // END - if // Free memory @@ -453,11 +465,11 @@ ORDER BY $content['form_selection'] = $OUT; // Output form - loadTemplate('select_admins_box', false, $content); + loadTemplate('select_admins_box', FALSE, $content); } // Create a member selection box -function addMemberSelectionBox ($userid = NULL, $add_all = false, $return = false, $none = false, $field = 'userid', $whereStatement = " WHERE `surname` NOT LIKE '{?tester_user_surname_prefix?}%'") { +function addMemberSelectionBox ($userid = NULL, $add_all = FALSE, $return = FALSE, $none = FALSE, $field = 'userid', $whereStatement = " WHERE `surname` NOT LIKE '{?tester_user_surname_prefix?}%'") { // Output selection form with all confirmed user accounts listed $result = SQL_QUERY('SELECT `userid`, @@ -473,9 +485,9 @@ ORDER BY $OUT = ''; // USe this only for adding points (e.g. adding refs really makes no sence ;-) ) - if ($add_all === true) { + if ($add_all === TRUE) { $OUT = ' '; - } elseif ($none === true) { + } elseif ($none === TRUE) { $OUT = ' '; } @@ -483,7 +495,7 @@ ORDER BY while ($content = SQL_FETCHARRAY($result)) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . intval($userid) . '/' . $content['userid']); $OUT .= '