Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Sep 2001
Posts: 194
S
svr Offline OP
Member
OP Offline
Member
S
Joined: Sep 2001
Posts: 194
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!

Sponsored Links
Joined: May 2001
Posts: 6,708
L
Member
Offline
Member
L
Joined: May 2001
Posts: 6,708
There is a name change hack you can install. I think it's in the database but I'm not sure.

Joined: Aug 2000
Posts: 569
M
Member
Offline
Member
M
Joined: Aug 2000
Posts: 569
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} [email protected]
# 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~

$BBName - Change UserName
$HeaderInsert



$Header


Change UserName




You can now modify your username! To modify your username, please login to the script that allows you to change your username.














UserName



Password

Forget your password?









If you have previously registered, but forgotten your password, click here.



$Footer


~;
}


###############################################################
# 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 "")||($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~

Change Your UserName
$HeaderInsert



$Header


Change UserName




Input your new username. This new username must follow all rules defined for usernameswhen you registered.















Current UserName

$profile[0]

New UserName











$Footer


~;
}

###############################################################
# 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, $NewUserName, 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 = ;
# 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~

$BBName - Change UserName Successful
$HeaderInsert



$Header


Change UserName Successful




Your username has been changed successfully and is now $NewUserName. Please use this new name when posting notes.



If you made a typo while inputing your username, or would like to change it again, click here.



$Footer


~;
}
}

###############################################################
# 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 "")||($NewUserName =~ m/^s/)||($NewUserName =~ m/ /)||($NewUserName =~ m/s$/)||($NewUserName =~ m/s{2,}/)||($NewUserName =~ m/|!/)||($NewUserName =~ m/||/)||($NewUserName =~ m/|$/)||($NewUserName =~ m/^|/)||($NewUserName =~ m/> $LegalUsername = "False";
}
}


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

open (LISTREAD, "$MembersPath/memberslist.cgi");
while(chomp($this= ) {
($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||$NewUserName||$JulianDateTodayn);
close (TRACKWRITE);
chmod (0666, "$CGIPath/changes.track");
} else {
open (TRACKREAD, "$CGIPath/changes.track");
@newcontents = ;
push (@newcontents, qq($OldUserName||$NewUserName||$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~

Username Changes Tracking


Username Changes Tracking



$BorderTop


~;

open (TRACKREAD, "$CGIPath/changes.track");
@Tracking = ;
close (TRACKREAD);
foreach $line(@Tracking) {
@TrackVars = split(/||/, $line);
($month,$day,$year,$weekday) = &jdate($TrackVars[2]);
print qq~
~;
}
print qq~
Old UserNameNew UserNameDate Changed
$TrackVars[0]$TrackVars[1]$month/$day/$year

$BorderBottom

$Footer


~;
}
}

###############################################################
# Subroutine that checks if the user has waited the set amount
# of days since the last change.
###############################################################
sub usernamedatelegal {
open(TOOSOONREAD,"changes.track");
@TooSoon = ;
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 $DaysLimit between name changes. Currently, you have only waited $DaysWaited days and must wait $DaysMore more days before changing your name again.");
exit;
}
}
}
}

###############################################################
# Subroutine that handles the standard HTML.
###############################################################
sub UserNameHTML {
my $Text = shift;
print qq~

$BBName - Change UserName
$HeaderInsert



$Header





$Text



$Footer


~;
}

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

Joined: Sep 2001
Posts: 194
S
svr Offline OP
Member
OP Offline
Member
S
Joined: Sep 2001
Posts: 194
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!

Joined: Aug 2000
Posts: 569
M
Member
Offline
Member
M
Joined: Aug 2000
Posts: 569
dude, its tested..
Works great, I have it on my boards.

Sponsored Links
Joined: May 2001
Posts: 6,708
L
Member
Offline
Member
L
Joined: May 2001
Posts: 6,708
Metallifukinca put it in a .txt file or something like that the scroll is long!


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,569
Posts293,914
Members13,847
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,829
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 81
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2022 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Snapshot build 20220917)