$adminId, 'login' => $adminLogin, 'plain_pass' => $adminPassword, 'pass_hash' => $adminHash ); // Run a special filter runFilterChain('do_admin_login_' . $ret, $data); // Return status return $ret; } // Only be executed on cookie checking function ifAdminCookiesAreValid ($adminLogin, $passHash) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLogin=' . $adminLogin . ',passHash=' . $passHash . ' - CALLED!'); // First of all, no admin login is found $ret = '404'; // Then we need to lookup the login name by getting the admin hash $adminHash = getAdminHash($adminLogin); // If this is fine, we can continue if ($adminHash != '-1') { // Now, we need to encode the password in the same way the one is encoded in database $testHash = encodeHashForCookie($adminHash); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash); // If they both match, the login data is valid if ($testHash != $passHash) { // Passwords don't match $ret = 'password'; } elseif (!isAdmin()) { // Is not valid session $ret = 'session'; } else { // All fine $ret = 'done'; } } // END - if // Return status //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ret=' . $ret . ' - EXIT!'); return $ret; } // Do an admin action function doAdminAction () { // Determine correct 'what' value $what = determineWhat(); // Get action value $action = getActionFromModuleWhat(getModule(), $what); // 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()); } else { $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['menu'] = addAdminMenu($action, $what); // Load main template loadTemplate('admin_main', FALSE, $content); // Check if action/what pair is valid $result_action = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND ( ( `what`='%s' AND `what` != 'welcome' ) OR ( ( `what`='' OR `what` IS NULL ) AND ( '%s'='welcome' ) ) ) LIMIT 1", array( $action, $what, $what ), __FUNCTION__, __LINE__); // Is there an entry? if (sqlNumRows($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)) { // Ok, we finally load the admin action module loadInclude($inc); } elseif ($GLOBALS['acl_allow'] === FALSE) { // Access denied 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 . '%}'); } } else { // Invalid action/what pair found loadTemplate('admin_menu_failed', FALSE, '{%message,ADMIN_ACTION_INVALID=' . $action . '/' . $what . '%}'); } // Free memory sqlFreeResult($result_action); // Tableset footer loadTemplate('admin_main_footer', FALSE, $content); } /** * Checks whether current admin is allowed to access given action/what * combination (only one is allowed to be null!). */ function isAdminAllowedAccessMenu ($action, $what = NULL) { // Is there cache? if (!isset($GLOBALS[__FUNCTION__][$action][$what])) { // ACL is always 'allow' when no ext-admins is installed // @TODO This can be rewritten into a filter $GLOBALS[__FUNCTION__][$action][$what] = ((!isExtensionInstalledAndNewer('admins', '0.2.0')) || ((isExtensionActive('admins')) && (isAdminsAllowedByAcl($action, $what)))); } // END - if // Return the cached value return $GLOBALS[__FUNCTION__][$action][$what]; } // Adds an admin menu function addAdminMenu ($action, $what) { // Init variables $SUB = FALSE; $OUT = ''; // Menu descriptions $GLOBALS['menu']['description'] = array(); $GLOBALS['menu']['title'] = array(); // Build main menu $result_main = sqlQuery("SELECT `action` AS `main_action`, `title` AS `main_title`, `descr` AS `main_descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE (`what`='' OR `what` IS NULL) ORDER BY `sort` ASC, `id` DESC", __FUNCTION__, __LINE__); // Are there entries? if (!ifSqlHasZeroNumRows($result_main)) { $OUT .= ''; // Free memory sqlFreeResult($result_main); } // END - if // Return content return $OUT; } // Add admin sub menu function addAdminSubMenu ($mainContent, $action, $what) { // Init content $OUT = ''; // Check for menu entries $result_what = sqlQueryEscaped("SELECT `what` AS `sub_what`, `title` AS `sub_title`, `descr` AS `sub_descr` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE `action`='%s' AND `what` != '' AND `what` IS NOT NULL ORDER BY `sort` ASC, `id` DESC", array($mainContent['main_action']), __FUNCTION__, __LINE__); // Remember the count for later checks setAdminMenuHasEntries($mainContent['main_action'], ((!ifSqlHasZeroNumRows($result_what)) && (($action == $mainContent['main_action']) || (isAdminMenuJavascriptEnabled())))); // Start li-tag for sub menu content $OUT .= '
  • '; // Are there entries? if (ifAdminMenuHasEntries($mainContent['main_action'])) { // Sub menu has been called $SUB = TRUE; // Are there entries? if (!ifSqlHasZeroNumRows($result_what)) { // Start HTML code $OUT .= ''; } // END - if // Free memory sqlFreeResult($result_what); } // END - if // Close li-tag $OUT .= '
  • '; // Return content return $OUT; } // Create an admin selection box form function addAdminSelectionBox ($adminId = NULL, $special = '') { // Default is email as "special column" $ADD = ',`email` AS `special`'; // Is a special column given? if (!empty($special)) { // Additional column for SQL query $ADD = ',`' . $special . '` AS `special`'; } // END - if // Query all entries $result = sqlQuery('SELECT `id`, `login` ' . $ADD . ' FROM `{?_MYSQL_PREFIX?}_admins` ORDER BY `login` ASC', __FUNCTION__, __LINE__); // Init output $OUT = ''; // Load all entries while ($content = sqlFetchArray($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); } // END - if // Free memory sqlFreeResult($result); // Add form to content $content['form_selection'] = $OUT; // Output form 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?}%'") { // Output selection form with all confirmed user accounts listed $result = sqlQuery('SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ' . $whereStatement . ' ORDER BY `userid` ASC', __FUNCTION__, __LINE__); // Default output $OUT = ''; // USe this only for adding points (e.g. adding refs really makes no sence ;-) ) if ($add_all === TRUE) { $OUT = ' '; } elseif ($none === TRUE) { $OUT = ' '; } // Load all entries while ($content = sqlFetchArray($result)) { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . intval($userid) . '/' . $content['userid']); $OUT .= '