+ } // END - if
+}
+
+// Un-/lock rows by given id numbers
+function adminLockEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $statusArray=array(), $lockNow=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)) && (($lockNow === false) || (count($statusArray) == 1))) {
+ // Shall we un-/lock here or list for locking?
+ if ($lockNow === true) {
+ // Un-/lock entries
+ adminBuilderStatusHandler("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
+ } else {
+ // List for editing
+ adminListBuilder("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+ } // 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_NUMROWS($result) == 0) {
+ // 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) {
+ // Init hash
+ $passHash = '';
+
+ // Now check if we have sql_patches installed
+ if (isExtensionInstalledAndNewer('sql_patches', '0.3.6')) {
+ // Use new way of hashing
+ $passHash = generateHash($password);
+ } else {
+ // Old MD5 method
+ $passHash = md5($password);