thelextor / mwenhanced

Automatically exported from code.google.com/p/mwenhanced
0 stars 0 forks source link

Account management ~ character re-name #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. go to account management
2. select a different realm than which your character is on
3. Pick one of your characters, and change name.

What is the expected output? What do you see instead?

The expected output is to change YOUR characters name on YOUR realm (realm
1), instead you see that you changed SOMEONE ELSE'S characters name on
(realm 2) who had the SAME name as your character.

Please use labels and text to provide additional information.

I have an idea for a fix, working on it.

Original issue reported on code.google.com by wilson.steven10@gmail.com on 17 Feb 2010 at 3:21

GoogleCodeExporter commented 9 years ago
how would i change this to select the current selected realm?

if (isset($_POST['realm'])) {
    $db1 = $DBS[$_POST['realm']];

$user['cur_selected_realmd'] doesnt work.

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 3:35

GoogleCodeExporter commented 9 years ago
would it be:
    $db1 = $CHDB;

???

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 3:40

GoogleCodeExporter commented 9 years ago
$user['cur_selected_realmd'] should work, because in index.php is:

if ((int)$MW->getConfig->generic_values->realm_info->multirealm && 
isset($_REQUEST
['changerealm_to'])){ 
     setcookie("cur_selected_realmd", intval($_REQUEST['changerealm_to']), time()+
(3600*24)); // expire in 24 hour 
     $user['cur_selected_realmd'] = intval($_REQUEST['changerealm_to']); 
 }elseif ((int)$MW->getConfig->generic_values->realm_info->multirealm && isset
($_COOKIE['cur_selected_realmd'])){ 
     $user['cur_selected_realmd'] = intval($_COOKIE['cur_selected_realmd']); 
 }else{ 
     $user['cur_selected_realmd'] = $MW->getConfig->generic_values->realm_info-
>default_realm_id; 
 } 

Which should set $user['cur_selected_realmd'] to either the default realm or 
the 
currently selected realm.

Original comment by ionstorm66 on 17 Feb 2010 at 3:50

GoogleCodeExporter commented 9 years ago
Try "intval($_COOKIE['cur_selected_realmd']);"

Original comment by ionstorm66 on 17 Feb 2010 at 3:57

GoogleCodeExporter commented 9 years ago
works...i just get a "could not connect"

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 4:51

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think the way to do it is, add another function like this:

$account_check = check_account($name, $user['id']);
if ($account_check == -1) {
            echo "<p align='center'><font color='red'>" . $character_1 . $name .
$doesnt_belong_to_account .
                "</font></p>";
            exit();
        }

and the function looks like this:

function check_account($name,$user['id'],$db)
{
    change_db($db);
    $account_check = "SELECT `name` FROM `characters` WHERE `account` LIKE '$user['id']'";
    $check= (then it checks to see if the submitted character name ($name) is matched up
to the account id ($user['id']))
    {
        $row=mysql_fetch_array($check);
        $status=$row['account'];
        if ($status == $user['id'])
            return 1;
        else
            return 0;
    }else
        return -1;
}

something like that i dont know. Seem you know what your doing Ionstorm :D ... 
can
you write something like that? I suck at functions.

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 5:07

GoogleCodeExporter commented 9 years ago
I dont know, ive been messing with this thing for 4 hours and still cant get 
it. can
you give it a go Ionstorm?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 5:14

GoogleCodeExporter commented 9 years ago
ok i will look into it.

Original comment by ionstorm66 on 17 Feb 2010 at 5:22

GoogleCodeExporter commented 9 years ago
why have a realm select? why not just get the current realm?

Original comment by ionstorm66 on 17 Feb 2010 at 5:42

GoogleCodeExporter commented 9 years ago
well thats what ive been trying to do, but if i take the realm selecter away, 
then i
cant get it to work

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 5:45

GoogleCodeExporter commented 9 years ago
will this help you at all?

something like this?

$db1 = $DB->selectCell("SELECT id FROM `realmlist` WHERE
id=?d",$user['cur_selected_realmd']);

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 6:07

GoogleCodeExporter commented 9 years ago
I am still working on a fix. My intenet is being very slow so it is taking a 
while.

Original comment by ionstorm66 on 17 Feb 2010 at 6:55

GoogleCodeExporter commented 9 years ago
I found why $user['cur_selected_realmd'] wasn't working. 

$user['cur_selected_realmd'] =
$MW->getConfig->generic_values->realm_info->default_realm_id; 

should be

$user['cur_selected_realmd'] = (int)$MW->getConfig->generic_values->realm_info-
>default_realm_id; 

Original comment by ionstorm66 on 17 Feb 2010 at 7:15

GoogleCodeExporter commented 9 years ago
where at exactly is this line?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 7:22

GoogleCodeExporter commented 9 years ago
I am getting ready to commit the fixed index.php so it will set the cookie and
$user['cur_selected_realmd'] correctly. 

Original comment by ionstorm66 on 17 Feb 2010 at 7:23

GoogleCodeExporter commented 9 years ago
sounds good :)

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 7:32

GoogleCodeExporter commented 9 years ago
There r56 fixed the cookie issue and now character renames are locked to the 
current
realm.

Original comment by ionstorm66 on 17 Feb 2010 at 7:44

GoogleCodeExporter commented 9 years ago
The character doesnt rename the character. i think this is why:

in "./compnents/account/acount.manage.php" you have:

$db1 = $DBS[$_POST['realm']]

and in "./templates/offlike/account/account.manage.php" you have:

<option value='" . $DBS[$user['cur_selected_realmd']]['id'] . "'>" .
$DBS[$user['cur_selected_realmd']]['name'] .

so shouldnt ". $DBS[$user['cur_selected_realmd']]['id'] ." be 
"$DBS[$_POST['realm']]"?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 8:00

GoogleCodeExporter commented 9 years ago
or $db1 = $DBS[$user['cur_selected_realmd']]['id']?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 8:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
In this part of the code $user['cur_selected_realmd'], $_POST['realm'], and
$DBS[$user['cur_selected_realmd']]['id'] are the same. $DBS is an array of 
database
arrarys like this:

Array
(
    [1] => Array
        (
            [id] => 1
            [name] => Realm_Name1
            [port] => port1
            [server] => serverhost1
            [dbinfo] => 0
            [db] => characters_db1
            [mysql_host] => host1
            [mysql_user] => someuser1
            [mysql_pass] => somepass1
        )

    [2] => Array
        (
            [id] => 2
            [name] => Realm_Name2
            [port] => port2
            [server] => serverhost2
            [dbinfo] => 0
            [db] => characters_db2
            [mysql_host] => host2
            [mysql_user] => someuser2
            [mysql_pass] => somepass2
        )

)

Original comment by ionstorm66 on 17 Feb 2010 at 8:32

GoogleCodeExporter commented 9 years ago
I see now... At ny rate though, for some reason it wont change the name.. and it
doesnt give an error code or nothing.

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 8:40

GoogleCodeExporter commented 9 years ago
Do you think the
"./components/account/chartools/('functiontransfer.php','functionrename.php')" 
needs
to be re-wrote with your new code?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 8:48

GoogleCodeExporter commented 9 years ago
cant we do something much more simple for password change? like for example, 
use the
same code as changing the password in account managment:

$newpass = trim( $_POST['new_pass'] ) ;
        if ( strlen( $newpass ) > 3 )
        {
            $DB->query( "UPDATE account SET sha_pass_hash=? WHERE id=?", $sha_pass,
$user['id'] ) ;

have it some thing like this:

if ($_POST['rename']);
{
$change_name = $CHDB->query( "UPDATE `characters` SET `name`= '$newname' WHERE 
`name`
LIKE '$name'";
}

instead of having all those other files and the difficulty of it all?

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 9:35

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
* i meant character re-name not password change* 

I also for got to add this after that query:

mysql_query($change_name) or die (mysql_error());

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 9:38

GoogleCodeExporter commented 9 years ago
I found the fix: in "./components/account/chartools/functionrename.php" after
reverting back to revision 53, just added this line of code: "UPDATE 
`characters` SET
`name`= '$newname' WHERE `name` LIKE '$name' AND `account` = '$account_id'"

And this added to: "./components/account/account.manage.php"
$account_id = $user['id'];

I tested this code out myself over and over and works everytime.

Original comment by wilson.steven10@gmail.com on 17 Feb 2010 at 10:40