Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # xrobau@gmail.com - Code released under GPLV3.
- # Used on mcau.org
- #
- # Iterate through FORUM database. Compare each username there with pex table.
- # If Donator -
- # UPDATE `vbulletin`.`user` SET `usergroupid` = '9' WHERE `user`.`userid` = userid
- # If NOT Donator
- # if user.userid=9 (currently are a donator)
- # update to 10 (ex donator)
- # fi
- # fi
- use DBI;
- use Data::Dumper;
- $vbulletin = DBI->connect('DBI:mysql:vbulletin;host=XXXX', 'YYYY', 'ZZZ') || die "Could not connect to database: $DBI::errstr";
- $pex = DBI->connect('DBI:mysql:permissionsex;host=XXXX', 'YYYY', 'ZZZ') || die "Could not connect to database: $DBI::errstr";
- $vbmcname = $vbulletin->prepare('SELECT `userfield`.`field4` from `userfield`,`user` where `userfield`.`userid`=`user`.`userid` and `user`.`username`=?');
- $pexq = $pex->prepare('SELECT parent from permissions_inheritance where child like ?');
- # Get all the users from the forum
- my $vusers = $vbulletin->selectall_hashref('SELECT username,userid,usergroupid from user', 'username');
- # Go through them all.
- foreach my $query_username (keys %$vusers) {
- my $username = $vusers->{$query_username}->{username};
- my $group = isDonator($username);
- if ($group eq "donators") {
- print "$username is a D - set him to ID 9\n";
- $vbulletin->do("UPDATE `user` set `usergroupid` = 9 where `user`.`username`='$username'");
- $vbulletin->do("UPDATE `user` set `usertitle` = 'MCAU Donator' where `user`.`username`='$username'");
- } elsif ($vusers->{$query_username}->{usergroupid} eq "9") {
- print "Checking now.. $username - ";
- # If they've been manually set, it means that they've probably got a valid donator name in their profile.
- # Lets check that.
- $vbmcname->execute($username);
- (my $result) = $vbmcname->fetchrow_array();
- if (isDonator($result) eq "donators") {
- print "Found $result as a minecraft account\n";
- } else {
- if ($group eq "users") {
- print "$username is no longer a D. Set to 10\n";
- $vbulletin->do("UPDATE `user` set `usergroupid` = 10 where `user`.`username`='$username'");
- }
- }
- }
- }
- sub isDonator($) {
- my $user = shift @_;
- # Get their group from pex..
- $pexq->execute($user);
- (my $result) = $pexq->fetchrow_array();
- return $result;
- }
Add Comment
Please, Sign In to add comment