rendered paste body<?php########################### MaNGOS 2.0.12 -> 2.1.3 ## Character Converter ## by ## Alex/AT ## -modified by- ## indomit & EleGoS ###########################define('DB_SERVER', 'localhost');define('DB_USER', 'mangos');define('DB_PASS', 'password');define('DB_DB', 'mangos');define('SQL_SCREEN',0); # 1 for output an SQL query, 0 for writing an sql fileerror_reporting(0);set_time_limit(0);function echobr($s) { echo $s."</td></tr>"; }function error($s) { echobr("<font color=#FF0000>".$s."<font>"); }function success($s) { echobr("<font color=#00EE00>".$s."<font>"); }if (!mysql_connect(DB_SERVER, DB_USER, DB_PASS)){ die("Cannot connect to mysql server <b>".DB_SERVER."</b> with user <b>".DB_USER."</b>. Please check defines inside php script."); }if (!mysql_select_db(DB_DB)){ die("Cannot find database <b>".DB_DB."</b>. Please check defines inside php script."); }$r = mysql_query('select `guid`, `name`, `data` from `character`');if (!$r){ die("Cannot find table `character`, or it is broken"); }if(!SQL_SCREEN) $fh = fopen('2_0_12-to-2_1_3.sql', 'wb');echo "<table border = 1 cellpadding=3 cellspacing=0 width=800>";echo "<tr><th>Guid</th><th>Name</th><th>Message</th></tr>";while ($row = mysql_fetch_assoc($r)){ echo "<tr>"; $guid = $row['guid']; $name = $row['name']; $data = explode(' ', trim($row['data'])); echo "<td>$guid</td><td>$name</td><td>"; if ($data[count($data) - 1] === '') unset($data[count($data) - 1]); if (!is_array($data)) { error("has invalid data field"); continue; } if (count($data) == 0x59C) { success("is already converted"); continue; } if (count($data) != 0x58E) { error("has unknown version of data field (count = ".count($data).", must be = ". 0x58E.")"); continue; } # convert for ($i = 0x358; $i < 0x58E; $i++) $data[$i - 2] = $data[$i]; for ($i = 0x58B; $i >= 0x586; $i--) $data[$i + 6] = $data[$i]; $data[0x59B] = $data[0x591]; for ($i = 0x57D; $i <= 0x58B; $i++) $data[$i] = 0; for ($i = 0x591; $i <= 0x59A; $i++) $data[$i] = 0; ksort($data); if (count($data) != 0x59C) { error("encountered conversion error"); continue; } $output .= 'UPDATE `character` SET `data` = "'.implode(' ', $data).'" WHERE `guid` = '.$guid.";\n"; success("converted succesfully");}mysql_close();echo "</table><br><br>";if(!SQL_SCREEN){ fwrite($fh, $output); fclose($fh); echo "Execute 2_0_12-to-2_1_3.sql from folder of this script<br>";}else{ echo "Execute this sql-query:<br><br> <textarea wrap=off rows=20 cols=100 >".$output."</textarea>";}echo "<br>Do not forget backup your characters!";?>