Id = $Id;
$DbResult = $this->Database->query('SELECT * FROM Realm WHERE Id='.$Id.' AND Enabled=1');
$this->Data = $DbResult->fetch_assoc();
$this->CharactersDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseCharacters']);
$this->CharactersDatabase->select_db($this->Data['DatabaseCharacters']);
if($this->CharactersDatabase->connect_error)
{
die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->Database->connect_error);
}
$this->CharactersDatabase->charset($this->Config['Database']['Charset']);
$this->MangosDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseMangos']);
$this->MangosDatabase->select_db($this->Data['DatabaseMangos']);
if($this->MangosDatabase->connect_error)
{
die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->MangosDatabase->connect_error);
}
$this->MangosDatabase->charset($this->Config['Database']['Charset']);
}
function OnlineCharactersCount()
{
if($this->CharactersDatabase->connect_error) return(0);
else {
$DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1');
$DbRow = $DbResult->fetch_row();
return($DbRow[0]);
}
}
function OnlineStateImage($Status)
{
global $html;
if($Status) return(' Mimo provoz');
else return(' V provozu');
}
function Uptime()
{
$Database->OpenLogonServerDatabase();
$row = $Database->query('SELECT `starttime`, `uptime` FROM `uptime` WHERE `realmid`='.$this->Id.' ORDER BY `starttime` DESC LIMIT 1')
->fetch_array();
$uptime = round($row['uptime'] / 3600);
return($uptime);
}
public function CharacterCount()
{
if($this->CharactersDatabase->connect_error) return('');
else {
$DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters`');
$DbRow = $DbResult->fetch_row();
return($DbRow[0]);
}
}
public function GuidToCharName($guid)
{
if($this->CharactersDatabase->connect_error) return(0);
else {
$row = $this->CharactersDatabase->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array();
return($row['name']);
}
}
public function ShowGmLog($log)
{
echo('
'.
'
Čas |
GM |
Příkaz |
Vybrán |
');
$gm_log = ereg_replace("\n",";",$log);
$gm_log = explode(";",$gm_log);
$gm_log = array_reverse($gm_log);
foreach($gm_log as $row)
{
if (strpos($row,"Command:") == true)
{
$edited = str_replace(" Command: ", ";", $row); // 0 - time
$edited = str_replace(" (Account: ", ";", $edited); // 1 - command
$edited = str_replace(" [Player: ", ";", $edited); // 2 - gm
$edited = str_replace(" Selected: ", ";", $edited); // 3 - position
$edited = str_replace(" (GUID: ", ";", $edited); // 4 - selected
$edited = str_replace(")]", ";", $edited); // 5 - selected guid
$edited_arr = explode(";",$edited);
if($edited_arr[4] == "player") $sel_name = " - ".$this->GuidToCharName($edited_arr[5]);
else $sel_name = '';
$human_date = $this -> HumanDate($edited_arr[0]);
echo('
'.$human_date.' |
'.$edited_arr[2].' |
'.$edited_arr[1].' |
'.$edited_arr[4].$sel_name.' |
');
}
if(strpos($row, 'mail item:') == true)
{
$edited = str_replace(" GM ", ";", $row);
$edited = str_replace(" (Account: ", ";", $edited);
$edited = str_replace(") mail item: ", ";", $edited);
$edited = str_replace(" (Account: ", ";", $edited);
$edited = str_replace(")", "", $edited);
$edited_arr = explode(";",$edited);
$human_date = $this -> HumanDate($edited_arr[0]);
echo('
'.$human_date.' |
'.$edited_arr[1].' |
Send : '.$edited_arr[3].') |
- |
');
}
if(strpos($row,"trade:") == true)
{
$edited = str_replace(" GM ", ";", $row);
$edited = str_replace(" (Account: ", ";", $edited);
$edited = str_replace(") trade: ", ";", $edited);
$edited = str_replace(" (Account: ", ";", $edited);
$edited = str_replace(")", "", $edited);
$edited_arr = explode(";",$edited);
$human_date = $this -> HumanDate ($edited_arr[0]);
echo('
'.$human_date.' |
'.$edited_arr[1].' |
Trade : '.$edited_arr[3].') |
- |
');
}
}
echo('
');
}
function WoWEmuStat()
{
global $Config;
$Result =
'\r\n".
" \r\n".
" \r\n".
" 0.16\r\n".
" Admin\r\n".
" Server\r\n".
" 0 weeks 1 days 0 hours 0 mins\r\n".
" \r\n".
" \r\n".
" \r\n".
" 200\r\n".
" 0\r\n".
" 0\r\n".
" 0.00%\r\n".
" \r\n".
" \r\n".
" 600\r\n".
" 95222\r\n".
" 7594525\r\n".
" 1.50%\r\n".
" \r\n".
" \r\n".
" \r\n";
if($this->CharactersDatabase->connect_error) return(0);
else {
$DbResult = $this->CharactersDatabase->query('SELECT *, CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(`data`, " ", '.$Config['Mangos']['CharacterDataOffset']['Level'].' + 1), " ", -1) AS UNSIGNED) AS level FROM `characters` WHERE `online` = 1');
while($DbRow = $DbResult->fetch_assoc())
{
$Result .= " \r\n".
" ".$DbRow['name']."\r\n".
" ".$DbRow['race']."\r\n".
" ".$DbRow['class']."\r\n".
" ".$DbRow['level']."\r\n".
" \r\n".
" xxx\r\n".
" 10\r\n".
" 0\r\n".
" 178.12.14.2\r\n".
" \r\n";
}
}
$Result .= " \r\n".
" \r\n";
return($Result);
}
}
?>