######################################################## ## ## Hack Title: Rename Users ## Hack Version: 1.0.1 ## Author: Christoph "Toxic" Hellings (toxic@freenet.de) ## Date Created: 09-03-02 ## Date Updated: 09-12-02 ## Thread Location: http://www.tforumhacks.com/tforum/viewtopic.php?TopicID=1094 ## Working Example: ## Description: The title says all ;) ## ## ## Installation Level: Easy ## Installation Time: 5 Minutes ## Files To Edit: 2 ## Edit Database: no ## Included Files: none ## ######################################################## ## ## Installation/Author Notes: ## ## I think it works but no warranty... ## UPGRADING INSTRUCTIONS 1.0.0 -> 1.0.1: ## replace the RenameUser() function in adminfunctions.php with the new version ## END OF UPGRADING INSTRUCTIONS ## ######################################################## # #-----[ ACTION: BACKUP ]------------------------------------------ # Every time you edit your files, you should always back them up first. Although all of these hacks have been tested on various systems, they may not work with your configuration or you may not like what it does. Backing up protects yourself and your users from downtime. # #-----[ ACTION: OPEN ]------------------------------------------- # admin.php # #-----[ ACTION: FIND ]------------------------------------------- # Mass Delete
# #-----[ ACTION: ADD AFTER ]-------------------------------------- # Rename User
# #-----[ ACTION: OPEN ]------------------------------------------- # adminfunctions.php # #-----[ ACTION: ADD ]-------------------------------------------- # function RenameUser() { global $fSettings,$Submit,$oldname,$newname; if ($Submit == "Rename") { $oldname = addslashes(trim($oldname)); $newname = addslashes(trim($newname)); if ($oldname == "" || $newname == "") die("Nothing specified!"); if ($oldname == $newname) die ("Old name and new name are the same!"); $query = "SELECT UserName FROM t_users WHERE UserName = '$oldname' OR UserName = '$newname'"; $result = mysql_query($query); $row = mysql_fetch_array($result); if ($row[0] != $oldname) die("User $oldname doesn't exist!"); $query = "UPDATE t_users set UserName='$newname' WHERE UserName='$oldname'"; $result = mysql_query($query); if (!$result) die("Rename failed. Reason: ".mysql_error()); $query = "UPDATE t_messages set Poster='$newname' WHERE Poster='$oldname'"; $result = mysql_query($query); if (!$result) die("Rename failed. Reason: ".mysql_error()); $query = "UPDATE t_pm set FromUser='$newname' WHERE FromUser='$oldname'"; $result = mysql_query($query); if (!$result) die("Rename failed. Reason: ".mysql_error()); $query = "UPDATE t_pm set ToUser='$newname' WHERE ToUser='$oldname'"; $result = mysql_query($query); if (!$result) die("Rename failed. Reason: ".mysql_error()); echo "Rename successful!"; } else {?> tForum Administration Area
Old name:
New name: