+ } // END - if
+}
+
+// Undelete rows by given id numbers
+function adminUndeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $undeleteNow=false, $idColumn='id', $userIdColumn='userid') {
+ // All valid entries? (We hope so here!)
+ if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (($undeleteNow === false) || (count($statusArray) == 1))) {
+ // Shall we un-/lock here or list for locking?
+ if ($undeleteNow === true) {
+ // Undelete entries
+ adminBuilderStatusHandler('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
+ } else {
+ // List for editing
+ adminListBuilder('undelete', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+ } // END - if
+}
+
+// Checks proxy settins by fetching check-updates3.php from www.mxchange.org
+function adminTestProxySettings ($settingsArray) {
+ // Set temporary the new settings
+ mergeConfig($settingsArray);
+
+ // Now get the test URL
+ $content = sendGetRequest('check-updates3.php');
+
+ // Is the first line with "200 OK"?
+ $valid = (strpos($content[0], '200 OK') !== false);
+
+ // Return result
+ return $valid;
+}
+
+// Sends out a link to the given email adress so the admin can reset his/her password
+function sendAdminPasswordResetLink ($email) {
+ // Init output
+ $OUT = '';
+
+ // Look up administator login
+ $result = SQL_QUERY_ESC("SELECT `id`, `login`, `password` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `email`='%s' LIMIT 1",
+ array($email), __FUNCTION__, __LINE__);
+
+ // Is there an account?
+ if (SQL_HASZERONUMS($result)) {
+ // No account found!
+ return getMessage('ADMIN_NO_LOGIN_WITH_EMAIL');
+ } // END - if
+
+ // Load all data
+ $content = SQL_FETCHARRAY($result);
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Generate hash for reset link
+ $content['hash'] = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10));
+
+ // Remove some data
+ unset($content['id']);
+ unset($content['password']);
+
+ // Prepare email
+ $mailText = loadEmailTemplate('admin_reset_password', $content);
+
+ // Send it out
+ sendEmail($email, getMessage('ADMIN_RESET_PASS_LINK_SUBJ'), $mailText);
+
+ // Prepare output
+ return getMessage('ADMIN_RESET_LINK_SENT');
+}
+
+// Validate hash and login for password reset
+function adminResetValidateHashLogin ($hash, $login) {
+ // By default nothing validates... ;)
+ $valid = false;
+
+ // Then try to find that user
+ $result = SQL_QUERY_ESC("SELECT `id`, `password`, `email` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `login`='%s' LIMIT 1",
+ array($login), __FUNCTION__, __LINE__);
+
+ // Is an account here?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load all data
+ $content = SQL_FETCHARRAY($result);
+
+ // Generate hash again
+ $hashFromData = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10));
+
+ // Does both match?
+ $valid = ($hash == $hashFromData);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return result
+ return $valid;
+}
+
+// Reset the password for the login. Do NOT call this function without calling above function first!
+function doResetAdminPassword ($login, $password) {
+ // Generate hash (we already check for sql_patches in generateHash())
+ $passHash = generateHash($password);
+
+ // Update database
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `password`='%s' WHERE `login`='%s' LIMIT 1",
+ array($passHash, $login), __FUNCTION__, __LINE__);
+
+ // Run filters
+ runFilterChain('post_admin_reset_pass', array('login' => $login, 'hash' => $passHash));
+
+ // Return output
+ return getMessage('ADMIN_PASSWORD_RESET_DONE');
+}
+
+// Solves a task by given id number
+function adminSolveTask ($id) {
+ // Update the task data
+ adminUpdateTaskData($id, 'status', 'SOLVED');
+}
+
+// Marks a given task as deleted
+function adminDeleteTask ($id) {
+ // Update the task data
+ adminUpdateTaskData($id, 'status', 'DELETED');
+}
+
+// Function to update task data
+function adminUpdateTaskData ($id, $row, $data) {
+ // Should be admin!
+ if (!isAdmin()) {
+ // Not an admin so redirect better
+ redirectToUrl('modules.php?module=index');
+ } // END - if
+
+ // Is the id not set, then we need a backtrace here... :(
+ if ($id <= 0) {
+ // Initiate backtrace
+ debug_report_bug(sprintf("id is invalid: %s. row=%s, data=%s",
+ $id,
+ $row,
+ $data
+ ));
+ } // END - if
+
+ // Update the task
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_task_system` SET `%s`='%s' WHERE `id`=%s LIMIT 1",
+ array(
+ $row,
+ $data,
+ bigintval($id)
+ ), __FUNCTION__, __LINE__);
+}
+
+// Checks wether if the admin menu has entries
+function ifAdminMenuHasEntries ($action) {
+ return (
+ ((
+ // Is the entry set?
+ isset($GLOBALS['admin_menu_has_entries'][$action])
+ ) && (
+ // And do we have a menu for this action?
+ $GLOBALS['admin_menu_has_entries'][$action] === true
+ )) || (
+ // Login has always a menu
+ $action == 'login'
+ )
+ );
+}
+
+// Setter for 'admin_menu_has_entries'
+function setAdminMenuHasEntries ($action, $hasEntries) {
+ $GLOBALS['admin_menu_has_entries'][$action] = (bool) $hasEntries;
+}
+
+// Creates a link to the user's admin-profile
+function adminCreateUserLink ($userid) {
+ // Is the userid set correctly?
+ if ($userid > 0) {
+ // Create a link to that profile
+ return '{%url=modules.php?module=admin&what=list_user&userid=' . bigintval($userid) . '%}';
+ } // END - if
+
+ // Return a link to the user list
+ return '{%url=modules.php?module=admin&what=list_user%}';
+}
+
+// Generate a "link" for the given admin id (admin_id)
+function generateAdminLink ($adminId) {
+ // No assigned admin is default
+ $adminLink = '<span class="admin_note">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
+
+ // Zero? = Not assigned
+ if (bigintval($adminId) > 0) {
+ // Load admin's login
+ $login = getAdminLogin($adminId);
+
+ // Is the login valid?
+ if ($login != '***') {
+ // Is the extension there?
+ if (isExtensionActive('admins')) {
+ // Admin found
+ $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
+ } else {
+ // Extension not found
+ $adminLink = getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'admins');
+ }
+ } else {
+ // Maybe deleted?
+ $adminLink = '<div class="admin_note">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
+ }
+ } // END - if
+
+ // Return result
+ return $adminLink;