php forum
php mysql forum
php mysql smarty
 
Topic Options
#128107 - 12/19/01 05:51 PM How to change user names but retain everything else?
svr Offline
Member

Registered: 09/28/01
Posts: 189
Hello some users are asking that I change their usernames. However to do that they want to keep the other stuff same that is number of posts, rank etc.

One way I thought was to just change the name in the *.cgi file in the /Members directory.

Any suggestions? Any problems doing it this way? Updating of threads going to cause problems? Thx in advv!

Top
#128108 - 12/19/01 05:54 PM Re: How to change user names but retain everything else?
Lord Dexter Offline
Member

Registered: 05/25/01
Posts: 6503
Loc: Melbourne, Australia
There is a name change hack you can install. I think it's in the database but I'm not sure.

Top
#128109 - 12/19/01 06:40 PM Re: How to change user names but retain everything else?
Metallifukinca Offline
Member

Registered: 08/21/00
Posts: 620
Loc: Toronto, Ont
Here it is, chomod it 755 and link it thats it.

#!/usr/local/bin/perl

#####################################################################
#
# Script Title: Change Username v1.1
# Written By: Andy Tomaka{atom911} atom911@ubbhackers.com
# Last Modifies: June 16, 2000
#
#####################################################################

#####################################################################
# Set the variables the script needs #
#####################################################################
# The $trackfile variable is used to decide whether to write the
# new username and the old username to a file for admins to view
# Set the bariable to yes or no(CaSE sEnSTivE)
$trackfile = "yes";
# The $DaysLimit variable it used to disallow a user to change their
# name if they have changed their name with in X days where X is the
# numerical value of $DaysLimit. Set it to 0 if you don't want a
# limit, or 1, 2, etc for that amount of days
$DaysLimit = "7";


#####################################################################
# Do not change anything below this line unless you know what you #
# know what you are doing #
#####################################################################
# Parse the URL
READQS: {
@RQSPairs = split /&/, $ENV{'QUERY_STRING'};
foreach $RQSPair (@RQSPairs) {
my ($RQSName, $RQSValue) = split /=/, $RQSPair;
$RQSValue =~ s/+/ /g;
$RQSValue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex(1))/eg;
$QueryString{$RQSName} = $RQSValue;
}
}
# Parse the form
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/n/ /g; # replace newlines with spaces
$FORM{$name} = $value;
}


# Allows the script to work with HTML
print ("content-type:text/htmlnn");

# Substitute all require files here for the file
require "UltBB.setup";
require "Styles.file";
require "ubb_library.pl";
require "ubb_library2.pl";
require "Date.pl";

$today_julian_date = &today();
$JulianDateToday = $today_julian_date;

# Put $BGColor in the correct HTML format
$BGColor = qq~bgcolor="$BGColor"~;
# Put $PageBackground in the correct HTML format
$PageBackground = qq~background="$PageBackground"~;

# Decide what to do
if ($FORM{'action'} eq "usernamelogincheck") {
&usernamelogincheck;
exit;
} elsif ($FORM{'action'} eq "usernameformhtml") {
&usernameformhtml;
exit;
} elsif ($FORM{'action'} eq "usernamechange") {
&usernamechange;
exit;
} elsif ($QueryString{'action'} eq "ViewChanges") {
&usernameviewtrack;
exit;
} else {
&usernamelogin;
exit;
}

###############################################################
# The subroutine that handles logging in
###############################################################
sub usernamelogin {
print qq~
<HTML>
<HEAD><TITLE>$BBName - Change UserName</TITLE>
$HeaderInsert
</HEAD>
<BODY $BGColor $PageBackground text="$TextColor" link="$LinkColor" alink="$ActiveLinkColor" vlink="$VisitedLinkColor" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>
<FONT SIZE="2" FACE="$FontFace" COLOR="$TextColor">
$Header
</font>

<FONT SIZE="3" FACE="$FontFace" COLOR="$LinkColor"><B>Change UserName</B></FONT>



<FONT SIZE="$TextSize" FACE="$FontFace">
You can now modify your username! To modify your username, please login to the script that allows you to change your username.




<form method="post">
<INPUT TYPE="hidden" NAME="action" VALUE="usernamelogincheck">
<table border=0>
<tr>
<td>
<FONT SIZE="$TextSize" FACE="$FontFace"><B>UserName</B></FONT>
</td>
<td>
<INPUT TYPE="TEXT" NAME="UserName" SIZE=25 MAXLENGTH=25>
</td></tr>
<tr>
<td>
<B><FONT SIZE="$TextSize" FACE="$FontFace">Password</FONT></B>
</td>
<td>
<INPUT TYPE="PASSWORD" NAME="Password" SIZE=13 MAXLENGTH=13> <FONT SIZE="1" FACE="$FontFace"><A HREF="$CGIURL/Ultimate.cgi?action=lostpw">Forget your password?</A></font>
</td></tr>
</table>
<center>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit Identification">
<INPUT TYPE="RESET" NAME="Reset" VALUE="Clear Fields">
</center>
</form>



If you have previously registered, but forgotten your password, <A HREF="$CGIURL/Ultimate.cgi?action=lostpw">click here</A>.



$Footer
</FONT>
</BODY></HTML>
~;
}


###############################################################
# The Subroutine that checks the ID
###############################################################
sub usernamelogincheck {
# Set the Username and password from the form to $UserName and $Password
$UserName = $FORM{'UserName'};
$Password = $FORM{'Password'};
# See if emailfile.cgi exists
unless (-e "$MembersPath/emailfile.cgi") {
# If it doesn't exist, say we are upgrading
&UserNameHTML("We are upgrading our software at the moment and cannot process new registrations. Please try registering again in a little while. Thank you!");
exit;
}
# See if the temp file exists in members directory
if (-e "$MembersPath/temp.file") {
# If it does, then say we are upgrading
&UserNameHTML("We are temporarily upgrading our Memberships. This process only takes a minute or two. Please try registering again in a couple of minutes. Thank you!");
exit;
}
# See if temp file exists in the cgi directory
if (-e "$CGIPath/temp.file") {
# If it does, say we are upgrading
&UserNameHTML("We are temporarily upgrading our Memberships. This process only takes a minute or two. Please try registering again in a couple of minutes. Thank you!");
exit;
}
# Make sure Username and password fields were not blank
if (($UserName eq "")&#0124;&#0124;($Password eq "")) {
# If they weren't say fields were not complete.
&UserNameHTML("You did not complete all required form fields! Please go back and re-enter.");
} else {
$NameFound = "no";
# Open Profile
$ProfileNumber = &GetUserNumber($UserName);
if ($ProfileNumber ne "") {
$NameFound = "yes";
} else {
$NameFound = "no";
}

if ($NameFound eq "yes") {
#Check Password Now

@profile = &OpenProfile("$ProfileNumber.cgi");
if ($Password eq "$profile[1]") {
$pwmatch = "true";
&usernameformhtml;
}
}

if ($NameFound ne "yes") {
&UserNameHTML("We have no one registered with that user name. Use your back button to try again.");
}
if (($NameFound eq "yes") && ($pwmatch ne "true")) {
&UserNameHTML("Sorry, but the password you entered was not correct. Please try again. Use your Back button.");
}
} # end check for missing fields
}

###############################################################
# The subroutine that prints the form
###############################################################
sub usernameformhtml {
# Print the form HTML
print qq~
<HTML>
<HEAD><TITLE>Change Your UserName</TITLE>
$HeaderInsert
</HEAD>
<BODY $BGColor $PageBackground text="$TextColor" link="$LinkColor" alink="$ActiveLinkColor" vlink="$VisitedLinkColor" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>
<FONT SIZE="2" FACE="$FontFace" COLOR="$TextColor">
$Header
</font>

<FONT SIZE="3" FACE="$FontFace" COLOR="$LinkColor"><B>Change UserName</B></FONT>



<FONT SIZE="$TextSize" FACE="$FontFace">
Input your new username. This new username must follow all rules defined for usernameswhen you registered.




<form method="post">
<INPUT TYPE="hidden" NAME="action" VALUE="usernamechange">
<INPUT TYPE="hidden" NAME="oldusername" VALUE="$UserName">
<table border=0>
<tr>
<td>
<FONT SIZE="$TextSize" FACE="$FontFace"><B>Current UserName</B></FONT>
</td>
<td>
$profile[0]
</td></tr>
<tr>
<td>
<B><FONT SIZE="$TextSize" FACE="$FontFace">New UserName</FONT></B>
</td>
<td>
<input type="text" name="newusername" size="30">
</td></tr>
</table>
<center>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit New UserName">
<INPUT TYPE="RESET" NAME="Reset" VALUE="Restart">
</center>
</form>



$Footer
</FONT>
</BODY></HTML>
~;
}

###############################################################
# Subroutine that handles the changes
###############################################################
sub usernamechange {
$OldUserName = $FORM{'oldusername'};
$NewUserName = $FORM{'newusername'};
&usernamedatelegal($NewUserName,$OldUserName);
&usernamelegal($NewUserName);
if ($LegalUsername eq "False") {
&UserNameHTML("Your new username, <b>$NewUserName</b>, was either a duplicate, left blank, or contained illegal charactors. Please use your back button and submit a new name that corrects these problems.");
} else {
# Get the profile number
$ProfileNumber = &GetUserNumber($OldUserName);
# Open the profile in read mode
open (PROFILEREAD, "$MembersPath/$ProfileNumber.cgi");
# Write the contents of the profile to the variable @profile
@profile = <PROFILEREAD>;
# Closes profile
close (PROFILEREAD);

# Set the new username to $profile[0]
$profile[0] = $NewUserName;

# Open the profile in write mode
open (PROFILEWRITE, ">$MembersPath/$ProfileNumber.cgi");
# Print the new user name to the profile
print PROFILEWRITE "$profile[0]n";
# Make every variable in profile $line
foreach $line(@profile[1..15]) {
# Print the $line
print PROFILEWRITE "$line";
}
# Close the profile
close(PROFILEWRITE);
# Run the subroutine that pringts to the memberslist.cgi file
&usernamememberslist($NewUserName,$OldUserName);
# Check to see if $trackfile is equal to yes
if ($trackfile eq "yes") {
# Run the subroutine that creates the track file if $trackfile is equal to yes
&usernametrackfile($NewUserName,$OldUserName,$today_julian_date);
}
# Print ending HTML
print qq~
<HTML>
<HEAD><TITLE>$BBName - Change UserName Successful</TITLE>
$HeaderInsert
</HEAD>
<BODY $BGColor $PageBackground text="$TextColor" link="$LinkColor" alink="$ActiveLinkColor" vlink="$VisitedLinkColor" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>
<FONT SIZE="2" FACE="$FontFace" COLOR="$TextColor">
$Header
</font>

<FONT SIZE="3" FACE="$FontFace" COLOR="$LinkColor"><B>Change UserName Successful</B></FONT>



<FONT SIZE="$TextSize" FACE="$FontFace">
Your username has been changed successfully and is now <b>$NewUserName</b>. Please use this new name when posting notes.



If you made a typo while inputing your username, or would like to change it again, <A HREF="$CGIURL/ubbUserName.cgi">click here</A>.



$Footer
</FONT>
</BODY></HTML>
~;
}
}

###############################################################
# Subroutine that checks to see if the username is a duplicate
# or if it is an illegal name
###############################################################
sub usernamelegal {

$LegalUsername = "True";

# Begin duplicate check
# Parse username to UBB's liking
$NewUserName =~ s/s+/ /g;
# Get the Member List Array
&GetMemberListArray;
# Store something as $LCusername
$LCusername = lc($NewUserName);
# Check @members for duplicates
CHECKDUPLICATELEGAL: for $checkthis(@members) {
$LCcheckthis = lc($checkthis);
if ($LCcheckthis eq "$LCusername") {
$LegalUsername = ("False");
last CHECKDUPLICATELEGAL;
}
}

if ($Censor eq "ON") {
@censored = split(/ /, $censorwords);
CHECKCENSORLEGAL: for (@censored) {
if (m/({)(.*)(})/) {
$_ = ("$2");
}
if ($NewUserName =~ /$_/i) {
$LegalUsername = "False";
$CensorWord = $_;
last CHECKCENSORLEGAL;
}
}
}

if (($NewUserName eq "")&#0124;&#0124;($NewUserName =~ m/^s/)&#0124;&#0124;($NewUserName =~ m/&nbsp/)&#0124;&#0124;($NewUserName =~ m/s$/)&#0124;&#0124;($NewUserName =~ m/s{2,}/)&#0124;&#0124;($NewUserName =~ m/|!/)&#0124;&#0124;($NewUserName =~ m/||/)&#0124;&#0124;($NewUserName =~ m/|$/)&#0124;&#0124;($NewUserName =~ m/^|/)&#0124;&#0124;($NewUserName =~ m/></)&#0124;&#0124;($NewUserName =~ m/memberslist/)&#0124;&#0124;($NewUserName =~ m/emailfile/)&#0124;&#0124;($NewUserName =~ m/;/) &#0124;&#0124;($NewUserName !~ /^[a-zA-Z0-9!?#$@*&^+-~:][']/)&#0124;&#0124;($NewUserName !~ /[a-zA-Z0-9!?#$@*&^+-~:][']$/)) {
$LegalUsername = "False";
}
}


###############################################################
# Subroutine that writes the new username to the
# memberslist.cgi file
###############################################################
sub usernamememberslist {

open (LISTREAD, "$MembersPath/memberslist.cgi");
while(chomp($this=<LISTREAD&gt <img src="wink.gif" border="0" alt="" /> ) {
($un,$pn) = split(/|!!|/, $this);
if($un eq $OldUserName) {
push (@newcontents, qq($NewUserName|!!|$pnn));
} else {
push (@newcontents, qq($un|!!|$pnn));
}
}
close LISTREAD;
&Lock("lock.file");
open (LISTWRITE, ">$MembersPath/memberslist.cgi");
print LISTWRITE @newcontents;
close LISTWRITE;
&Unlock("lock.file");
chmod (0666, "$MembersPath/memberslist.cgi");

}

###############################################################
# Subroutine that writes to the username tracking file
###############################################################
sub usernametrackfile {
unless (-e "$CGIPath/changes.track") {
open (TRACKWRITE, ">$CGIPath/changes.track");
print TRACKWRITE qq($OldUserName&#0124;&#0124;$NewUserName&#0124;&#0124;$JulianDateTodayn);
close (TRACKWRITE);
chmod (0666, "$CGIPath/changes.track");
} else {
open (TRACKREAD, "$CGIPath/changes.track");
@newcontents = <TRACKREAD>;
push (@newcontents, qq($OldUserName&#0124;&#0124;$NewUserName&#0124;&#0124;$JulianDateTodayn));
close (TRACKREAD);
open (TRACKWRITE, ">$CGIPath/changes.track");
print TRACKWRITE @newcontents;
close (TRACKWRITE);
chmod (0666, "$CGIPath/changes.track");
}
}


###############################################################
# Subroutine that views the username tracking file
###############################################################
sub usernameviewtrack {
unless (-e "$CGIPath/changes.track") {
&UserNameHTML("No one has changed their username.");
} else {
print qq~
<html>
<head><title>Username Changes Tracking</title></head>
<body bgcolor="#FFFFFF" text="#000066" link="#FF0000" alink="#FF0000" vlink="#FF0000">

<center><h1>Username Changes Tracking</h1></center>
<center>
$BorderTop
<table width=$TableWidth2 border=0 cellspacing=1 cellpadding=4>
<tr bgcolor="$AltColumnColor1"><td><b><font face="$FontFace" size="2" color="$CategoryStripTextColor">Old UserName</font></b></td><td><b><font face="$FontFace" size="2" color="$CategoryStripTextColor">New UserName</b></font></td><td><b><font face="$FontFace" size="2" color="$CategoryStripTextColor">Date Changed</b></font></td></tr>
~;

open (TRACKREAD, "$CGIPath/changes.track");
@Tracking = <TRACKREAD>;
close (TRACKREAD);
foreach $line(@Tracking) {
@TrackVars = split(/||/, $line);
($month,$day,$year,$weekday) = &jdate($TrackVars[2]);
print qq~<tr><td valign="top" bgcolor="$AltColumnColor2"><font face="$FontFace" size="2" color="$CategoryStripTextColor">$TrackVars[0]</font></td><td valign="top" bgcolor="$AltColumnColor2"><font face="$FontFace" size="2" color="$CategoryStripTextColor">$TrackVars[1]</font></td><td valign="top" bgcolor="$AltColumnColor2"><font face="$FontFace" size="2" color="$CategoryStripTextColor">$month<b>/</b>$day<b>/</b>$year</font></td></tr>~;
}
print qq~
</table>
$BorderBottom
</center>
$Footer
</BODY>
</HTML>
~;
}
}

###############################################################
# Subroutine that checks if the user has waited the set amount
# of days since the last change.
###############################################################
sub usernamedatelegal {
open(TOOSOONREAD,"changes.track");
@TooSoon = <TOOSOONREAD>;
close(TOOSOONREAD);

foreach $line(@TooSoon) {
($CheckOldUserName, $CheckUserName, $CheckLastDate) = split(/||/, $line);
if ($OldUserName eq $CheckUserName) {
$JulianDateToday = &today();
$DaysWaited = $JulianDateToday - $CheckLastDate;
if ($DaysWaited < $DaysLimit) {
$DaysMore = $DaysLimit - $DaysWaited;
&UserNameHTML("You most wait at least <b>$DaysLimit</b> between name changes. Currently, you have only waited <b>$DaysWaited</b> days and must wait <b>$DaysMore</b> more days before changing your name again.");
exit;
}
}
}
}

###############################################################
# Subroutine that handles the standard HTML.
###############################################################
sub UserNameHTML {
my $Text = shift;
print qq~
<HTML>
<HEAD><TITLE>$BBName - Change UserName</TITLE>
$HeaderInsert
</HEAD>
<BODY $BGColor $PageBackground text="$TextColor" link="$LinkColor" alink="$ActiveLinkColor" vlink="$VisitedLinkColor" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 rightmargin=0>
<FONT SIZE="2" FACE="$FontFace" COLOR="$TextColor">
$Header
</font>
<A HREF="$CGIURL/Ultimate.cgi?action=intro&BypassCookie=true"><IMG SRC="$NonCGIURL/$BBTitle" BORDER=0></A>



<FONT SIZE="$TextSize" FACE="$FontFace">$Text</FONT>



$Footer
</FONT>
</BODY></HTML>
~;
}

###############################################################
# Subroutine that loads when a subroutine cannot be found
###############################################################
AUTOLOAD {
&UserNameHTML("Subroutine $AUTOLOAD not found. Please contact the administrator of this bulliten board.");
exit;
}

Top
#128110 - 12/19/01 06:44 PM Re: How to change user names but retain everything else?
svr Offline
Member

Registered: 09/28/01
Posts: 189
Hmm this lets the user change his/her name. That'll create headaches as it is untested (??). Is there any way I can do each change myself? thx again!

Top
#128111 - 12/19/01 08:05 PM Re: How to change user names but retain everything else?
Metallifukinca Offline
Member

Registered: 08/21/00
Posts: 620
Loc: Toronto, Ont
dude, its tested..
Works great, I have it on my boards.

Top
#128112 - 12/19/01 09:04 PM Re: How to change user names but retain everything else?
Lord Dexter Offline
Member

Registered: 05/25/01
Posts: 6503
Loc: Melbourne, Australia
Metallifukinca put it in a .txt file or something like that the scroll is long!

Top


Who's Online
0 registered (), 31 Guests and 18 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Ubb - Buy It!
best forum software
Latest Posts
I want to create a Self Search mod [Question]
by lightningrod
03/10/10 09:04 PM
If I create a new script, can I just upload it?
by lightningrod
03/10/10 05:35 PM
Notepad Creates Errors when working with PHP
by lightningrod
03/10/10 05:01 PM
Question on Adding a New Script ?
by lightningrod
03/10/10 06:39 AM
Disable Watch List option
by Mike_Tabat
03/09/10 01:27 PM
[7.x] [Pre-7.3] [Final] pJIRC Addon v0.5
by Gizmo
02/27/10 05:07 PM
How to Be a Great Host
by pinku
02/19/10 02:47 AM
New Mods
Disable Watch List option
by Mike_Tabat
02/18/10 09:14 AM
[7.x] Generic Page Outside of forum directory
by
01/14/07 10:58 PM
[7.x] [Pre-7.3] [Final] pJIRC Addon v0.5
by
07/30/06 10:42 PM
Newest Members
joshuasm02, Chosen, Vick, Bartman, Infinity Master
13496 Registered Users
Top Posters
AllenAyres 25554
JoshPet 11330
Rick 8373
LK 7396
Lord Dexter 6503
Greg Hard 5533
Charles Capps 5438
(Views)Popular Topics
Known public proxy servers 1028046
Finished-[6.5.2] Games Arcade Deluxe v1.9 327222
Integrated Index Page (IIP) 5.3.1 279924
Integrated Index Page (IIP) 5.1.1 279403
TLD Bv2.1 Released - Threads Links Directory 270427
[6.0x] Who's Online 4.0.0 [Finished] 230365
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 217518
[6.3.x] [beta] Hit Hack 2.0 179339
FlashChat & UBB.threads 161010
[7.x] Gizmo's Embedding BBCode (Pre UBB.T7.3) 154650
Forum Stats
13496 Members
59 Forums
37114 Topics
290378 Posts

Max Online: 686 @ 06/28/07 07:04 AM
Featured Member
Registered: 11/04/08
Posts: 7

 

 

 
fusionbb message board php hacks