Which fields need to be updated? For unstuck PHP

Dear Sir / Madam ,

We’re writing a script unstuck ASP.NET language.

Which fields from the database “Characters” to update for

unstuck character/S ?

I got a sample file.

However, some fields use in the file PHP is not Database trinitycore.


<?php


echo "<html><body>";

echo "<center><table>";

echo "<tr><td colspan=2 align=center></td></tr>";


include('_config.php');

global $aHost, $aDatabase, $aPort, $aUsername, $aPass, $cHost, $cDatabase, $cDatabase2, $cPort, $cUsername, $cPass;

if(isset($_POST['submit']))

{

$account = $_POST['account'];

$password = $_POST['password'];

$character = $_POST['character'];


$acct = "";

//get make sure the character exists on the correct account and password is the same

$con = mysql_connect($aHost.":".$aPort, $aUsername, $aPass) or die(mysql_error());

mysql_select_db($aDatabase) or die(mysql_error());

//Remove bullshit characters from user entered data

$account = mysql_real_escape_string($account);

$password = mysql_real_escape_string($password);

$acct = mysql_real_escape_string($acct);


$query = "SELECT acct FROM accounts WHERE login ='".$account."' AND password = '".$password."'";

$result = mysql_query($query) or die(mysql_error());

$numrows = mysql_num_rows($result);

//if no rows, user entered invalid data

if ($numrows == 0)

{

die("Account name or password is incorrect!");

}

elseif ($numrows == 1)

{

$row = mysql_fetch_array($result);

$acct = $row[0];


//get accnt# from characters table where the name is character $character

$con = mysql_connect($cHost.":".$cPort, $cUsername, $cPass) or die(mysql_error());

mysql_select_db($cDatabase) or die(mysql_error());

//Remove bullshit characters from user entered data

$character = mysql_real_escape_string($character);

$query = "SELECT acct FROM characters WHERE name = '".$character."'";

$result = mysql_query($query) or die(mysql_error());

$numrows = mysql_num_rows($result);

echo "<tr><td align=center>";

//if no rows exist, the character does not exist

if($numrows == 0)

{


$con = mysql_connect($cHost.":".$cPort, $cUsername, $cPass) or die(mysql_error());

mysql_select_db($cDatabase2) or die(mysql_error());

$character = mysql_real_escape_string($character);

$query = "SELECT acct FROM characters WHERE name = '".$character."'";

$result = mysql_query($query) or die(mysql_error());

$numrows = mysql_num_rows($result);

echo "<tr><td align=center>";

//if no rows exist, the character does not exist

if($numrows == 0)

{

die("No such character exists on that account!");

}

elseif($numrows == 1)


{


$row = mysql_fetch_array($result);

$acct = $row[0];

}

}


//update the character table to set the character to hearth location

$query = "UPDATE `characters` SET `deathstate` = 0 , `player_flags` =0 , `auras` =0 WHERE name = '".$character."'";

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

}

$query = "UPDATE `characters` SET `deathstate` = 0 , `player_flags` =0 , `auras` =0 WHERE name = '".$character."'";

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

echo "<center>";

echo "<br />";

echo "<br />";

echo "The Character with the name '<b>".$character."</b>' under Account '<b>".$account."</b>' has been revived!<br>";

echo "<a href='/playertools/revive.php'>Back</a>";

echo "</td></tr>";

//close mysql connection

mysql_close();

}

//if page is loaded, display unstuck form

else

{


echo "<center>";

echo "<form name=myform method=post action'/revive.php'>";

echo "<br />";

echo "<h1><u><b>Character Revive</b></u></h1>";

echo "<br />";

echo "<tr><td width=125>Account: </td><td><input type=text name=account value=''></td></tr>";

echo "<br />";

echo "<tr><td width=125>Character: </td><td><input type=text name=character value=''></td></tr>";

echo "<br />";

echo "<tr><td width=125>Password: </td><td><input type=password name=password value=''></td></tr>";

echo "<br />";

echo "<tr><td colspan=2 align=center><br><input type=submit name=submit value=Revive></td></tr>";

echo "</form>";

}

echo "<center>";

echo "</table>";

echo "<br />";

echo "<br />";

echo "<small>You <b>MUST</b> be offline for this tool to successfully work</small><br /><br />";

echo "<br />";

echo " ";

echo "<br />";

echo "</center>";

?>

For EXample :

//update the character table to set the character to hearth location

$query = “UPDATE characters SET deathstate = 0 , player_flags =0 , auras =0 WHERE name = '”.$character.“'”;

Fileds : deathstate , player_flags , auras

Sorry. tour English is bad.

PHP is not ASP.NET, and you can’t make ASP.NET suck less by writing an unsuck script in PHP.

Well you could write a C++ script that generate a PHP page, which in turn pretends to be a less sucky ASP.NET page. That said you could do yourself a favor and look at the character database, it’s documented in the Wiki: http://www.trinitycore.info/DB:Characters

Use soap instead direct db write and the command .tele name $home (where is character name and $home is the coords of where the player have the inn) (for example tele name goyan $home)

  • using soap doesnt require character/account to be logged out. There are many example soap scripts posted on forum. All you need to do is to setup a gm account with proper security level (but i bet you allready have few of those).

PHP is not ASP.NET, and you can’t make ASP.NET suck less by writing an unsuck script in PHP.

Post of the month.

Short anwser:

UPDATE characters SET position_x='', position_y='', position_z='', zone='', map='' WHERE guid='';

Response:

Realize with the above code it was possible to change other account characters, only thing checked was if the name and password entered is vaild? /emoticons/default_wacko.png Also this code dosen’t work with TrinityCore. looks like this is for another core perhaps?

Would be static or ridiculous trying to case it out, and why bother we have character_bind data /emoticons/default_biggrin.png
Complete rewrite of the above script, that actually works…

//include(‘_config.php’);

// global $aHost, $aDatabase, $aPort, $aUsername, $aPass, $cHost, $cDatabase, $cDatabase2, $cPort, $cUsername, $cPass; ?
// why are we using globals? we haven't left the current scope.

$auth_db = array(
    'ip'    =>  "localhost",
    'user'  =>  "trinity",
    'pass'  =>  "trinity",
    'db'    =>  "auth",

);

$character_db = array(
    'ip'    =>  "localhost",
    'user'  =>  "trinity",
    'pass'  =>  "trinity",
    'db'    =>  "characters"

);

if(isset($_POST['submit']))
{
$mysql_connect = mysqli_connect($auth_db['ip'],$auth_db['user'],$auth_db['pass']) or die("Unable to connect to the database.");
	 mysqli_select_db($mysql_connect,$auth_db['db']) or die("Unable to connect to the database.");

$account = array(
    'username'  => mysqli_real_escape_string($mysql_connect,$_POST['account']),
    'password'  => mysqli_real_escape_string($mysql_connect,$_POST['password']),
    'character' => mysqli_real_escape_string($mysql_connect,$_POST['character'])
);

$password = strtoupper("".$account['username'].":".$account['password']."");
$shaPassHash = mysqli_real_escape_string($mysql_connect,SHA1($password));

$result = mysqli_query($mysql_connect,"SELECT * FROM account WHERE username ='".$account['username']."' AND sha_pass_hash='".$shaPassHash."'") or die(mysql_error());
$numrows = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);

if ($numrows == 0)
{
    die("Account name or password is incorrect!");
}

if($row['online'] == 1)
{
    die('You cannot be logged in to complete this action!');
}

elseif ($numrows == 1)
{

mysqli_select_db($mysql_connect,$character_db['db']) or die("Unable to connect to the database.");
$result = mysqli_query($mysql_connect,"SELECT * FROM characters WHERE name='".$account['character']."' AND account='".$row['id']."'") or die(mysql_error());
$numrows = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);

    if($numrows == 0)
    {
	    die("No such character exists on that account!");
    }
    elseif($numrows == 1)
    {
	    $getXYZ =  mysqli_query($mysql_connect,"SELECT * FROM character_homebind WHERE guid='".$row['guid']."'");
	    $XYZ = mysqli_fetch_assoc($getXYZ);
    }

//update the character table to set the character to hearth location
mysqli_query($mysql_connect,"UPDATE characters SET position_x='".$XYZ['posX']."', position_y='".$XYZ['posY']."', position_z='".$XYZ['posZ']."', zone='".$XYZ['zoneId']."',map='".$XYZ['mapId']."' WHERE guid='".$row['guid']."'") or die(mysql_error());
mysqli_query($mysql_connect,"DELETE FROM character_aura WHERE guid ='".$row['guid']."' AND spell=20584 OR guid ='".$row['guid']."' AND spell=8326") or die(mysql_error());
mysqli_close($mysql_connect);
}

echo "<center>
    <br />
    <br />
    The Character with the name '<b>".$_POST['character']."</b>' under Account '<b>".$_POST['account']."</b>' has been revived!<br>
    <a href='/playertools/revive.php'>Back</a>
    </td></tr>";
}
//if page is loaded, display unstuck form
else
{
echo "
    <html><body><center><table><tr><td colspan=2 align=center></td></tr>
    <center>
    <form name=myform method=post action'/revive.php'>
    <br />
    <h1><u><b>Character Revive</b></u></h1>
    <br />
    <tr><td width=125>Account: </td><td><input type=text name=account value=''></td></tr>
    <br />
    <tr><td width=125>Character: </td><td><input type=text name=character value=''></td></tr>
    <br />
    <tr><td width=125>Password: </td><td><input type=password name=password value=''></td></tr>
    <br />
    <tr><td colspan=2 align=center><br><input type=submit name=submit value=Revive></td></tr>
    </form>";
}
echo "
    <center>
    </table>
    <br />
    <br />
    <small>You <b>MUST</b> be offline for this tool to successfully work</small><br /><br />
    <br />
    <br />
    </center>";

?>

<?php

crs.php

Easy, because that adition to tele name was added to avoid the need of access db from webpage and to allow ppl to unstuck without the need of disconect.

where is the unlike button???

Why these faggots try to re-invent the wheel???

what are you referring to? $home isn’t defined… and defining would require a faction check, then an assumption of where they should be teleported… please explain?

Are you bashing me or the other moderator? I’m confused.Also the unlike button is at the same place as the like button. (changes when you press it /emoticons/default_ohmy.png)

$home is CORE defined it teleports the character to the inn location, no need of faction check, research and read before write.

Session Time: Sun Nov 20 00:00:00 2011

[13:45:36] TrinityCore: thumsoul master * r831f2f4 / (2 files in 2 dirs):

[13:45:44] TrinityCore: Core/Commands: Allow “$home” to be second parameter of .tele name, to teleport players to homebind

my mistake. I checked locally, an I’m still on an older revision.

crs_soap.php

forgot to remove the if ‘online’ die so you’ll probably wanna find and delete

if($row['online'] == 1) { die('You cannot be logged in to complete this action!'); }[/php]

EDIT: Wait

what the hell? I’m running TrinityCore rev. 2012-05-03 12:45:28 -0300 (a8a5b5a8f02b+) $home is an unknown teleport location.Also now that I’m thinking about it, wouldn’t this ONLY work if the player is online? /emoticons/default_huh.png

I tried both online and offline and it works. And no, maybe the user can have client crash and need to be teleported offline.

dont understand why $home isn’t functioning that way for me, but owell.