+ } // END - if
+}
+// Un-/lock rows by given ID numbers
+function ADMIN_LOCK_ENTRIES_CONFIRM ($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) || (count($statusArray) == 1))) {
+ // Shall we un-/lock here or list for locking?
+ if ($lockNow) {
+ // Un-/lock entries
+ ADMIN_BUILD_STATUS_HANDLER("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ } else {
+ // List for editing
+ ADMIN_BUILD_LIST("lock", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+ } // END - if
+}
+// Undelete rows by given ID numbers
+function ADMIN_UNDELETE_ENTRIES_CONFIRM ($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) || (count($statusArray) == 1))) {
+ // Shall we un-/lock here or list for locking?
+ if ($lockNow) {
+ // Undelete entries
+ ADMIN_BUILD_STATUS_HANDLER("undelete", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray);
+ } else {
+ // List for editing
+ ADMIN_BUILD_LIST("undelete", $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+ } // END - if
+}
+// Checks proxy settins by fetching check-updates3.php from www.mxchange.org
+function ADMIN_TEST_PROXY_SETTINGS ($settingsArray) {
+ global $_CONFIG;
+
+ // Set temporary the new settings
+ $_CONFIG = array_merge($_CONFIG, $settingsArray);
+
+ // Now get the test URL
+ $content = GET_URL("check-updates3.php");
+
+ // Is the first line with "200 OK"?
+ $valid = eregi("200 OK", $content[0]);
+
+ // Return result
+ return $valid;
+}
+// Sends out a link to the given email adress so the admin can reset his/her password
+function ADMIN_SEND_PASSWORD_RESET_LINK ($email) {
+ global $_CONFIG;
+ // Init output
+ $OUT = "";
+
+ // Compile out security characters (must be for looking up!)
+ $email = COMPILE_CODE($email);
+
+ // Look up administator login
+ $result = SQL_QUERY_ESC("SELECT id, login, password FROM "._MYSQL_PREFIX."_admins WHERE email='%s' LIMIT 1",
+ array($email), __FILE__, __LINE__);
+
+ // Is there an account?
+ if (SQL_NUMROWS($result) == 0) {
+ // No account found!
+ return 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(URL.":".$content['id'].":".$content['login'].":".$content['password'], substr($content['password'], 10));
+
+ // Remove some data
+ unset($content['id']);
+ unset($content['password']);
+
+ // Prepare email
+ $mailText = LOAD_EMAIL_TEMPLATE("admin_reset_password", $content);
+
+ // Send it out
+ SEND_EMAIL($email, ADMIN_RESET_PASS_LINK_SUBJ, $mailText);
+
+ // Prepare output
+ return ADMIN_RESET_LINK_SENT;
+}
+// Validate hash and login for password reset
+function ADMIN_VALIDATE_RESET_LINK_HASH_LOGIN ($hash, $login) {
+ // By default nothing validates... ;)
+ $valid = false;
+
+ // Compile the login for lookup
+ $login = COMPILE_CODE($login);
+
+ // 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), __FILE__, __LINE__);
+
+ // Is an account here?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load all data
+ $content = SQL_FETCHARRAY($result);
+
+ // Generate hash again
+ $hashFromData = generateHash(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 ADMIN_RESET_PASSWORD ($login, $password) {
+ // Init hash
+ $passHash = "";
+
+ // Now check if we have sql_patches installed
+ if (GET_EXT_VERSION("sql_patches") >= "0.3.6") {
+ // Use new way of hashing
+ $passHash = generateHash($password);
+ } else {
+ // Old MD5 method
+ $passHash = md5($password);