1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/module.php');
|
---|
4 |
|
---|
5 | class Realm extends Module
|
---|
6 | {
|
---|
7 | var $Id;
|
---|
8 |
|
---|
9 | function __construct($System, $Id)
|
---|
10 | {
|
---|
11 | parent::__construct($System);
|
---|
12 | $this->Id = $Id;
|
---|
13 | $DbResult = $this->Database->query('SELECT * FROM Realm WHERE Id='.$Id.' AND Enabled=1');
|
---|
14 | $this->Data = $DbResult->fetch_assoc();
|
---|
15 | $this->CharactersDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseCharacters']);
|
---|
16 | $this->CharactersDatabase->select_db($this->Data['DatabaseCharacters']);
|
---|
17 | if($this->CharactersDatabase->connect_error)
|
---|
18 | {
|
---|
19 | die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->Database->connect_error);
|
---|
20 | }
|
---|
21 | $this->CharactersDatabase->charset($this->Config['Database']['Charset']);
|
---|
22 |
|
---|
23 | $this->MangosDatabase = new Database($this->Data['DatabaseHost'], $this->Data['DatabaseUser'], $this->Data['DatabasePassword'], $this->Data['DatabaseMangos']);
|
---|
24 | $this->MangosDatabase->select_db($this->Data['DatabaseMangos']);
|
---|
25 | if($this->MangosDatabase->connect_error)
|
---|
26 | {
|
---|
27 | die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->MangosDatabase->connect_error);
|
---|
28 | }
|
---|
29 | $this->MangosDatabase->charset($this->Config['Database']['Charset']);
|
---|
30 | }
|
---|
31 |
|
---|
32 | function OnlineCharactersCount()
|
---|
33 | {
|
---|
34 | if($this->CharactersDatabase->connect_error) return(0);
|
---|
35 | else {
|
---|
36 | $DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1');
|
---|
37 | $DbRow = $DbResult->fetch_row();
|
---|
38 | return($DbRow[0]);
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | function OnlineStateImage($Status)
|
---|
43 | {
|
---|
44 | if($Status) return('<img src="imgs/inc/on.gif" alt="online" /> <span style="text-color: #234303; text-size: 4;">Online</span>');
|
---|
45 | else return('<img src="imgs/inc/off.gif" alt="offline" /> <span style="text-color: #990000; text-size: 4;">Offline</span>');
|
---|
46 | }
|
---|
47 |
|
---|
48 | function Uptime()
|
---|
49 | {
|
---|
50 | $Database->OpenLogonServerDatabase();
|
---|
51 | $row = $Database->query('SELECT `starttime`, `uptime` FROM `uptime` WHERE `realmid`='.$this->Id.' ORDER BY `starttime` DESC LIMIT 1')
|
---|
52 | ->fetch_array();
|
---|
53 | $uptime = round($row['uptime'] / 3600);
|
---|
54 | return($uptime);
|
---|
55 | }
|
---|
56 |
|
---|
57 | public function CharacterCount()
|
---|
58 | {
|
---|
59 | if($this->CharactersDatabase->connect_error) return('');
|
---|
60 | else {
|
---|
61 | $DbResult = $this->CharactersDatabase->query('SELECT COUNT(*) FROM `characters`');
|
---|
62 | $DbRow = $DbResult->fetch_row();
|
---|
63 | return($DbRow[0]);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | public function GuidToCharName($guid)
|
---|
68 | {
|
---|
69 | if($this->CharactersDatabase->connect_error) return(0);
|
---|
70 | else {
|
---|
71 | $row = $this->CharactersDatabase->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array();
|
---|
72 | return($row['name']);
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | public function ShowGmLog($log)
|
---|
77 | {
|
---|
78 | echo('<table border="1" width="540">'.
|
---|
79 | '<tr>
|
---|
80 | <th>Čas</th>
|
---|
81 | <th>GM</th>
|
---|
82 | <th>Příkaz</th>
|
---|
83 | <th>Vybrán</th>
|
---|
84 | </tr>');
|
---|
85 | $gm_log = ereg_replace("\n",";",$log);
|
---|
86 | $gm_log = explode(";",$gm_log);
|
---|
87 | $gm_log = array_reverse($gm_log);
|
---|
88 | foreach($gm_log as $row)
|
---|
89 | {
|
---|
90 | if (strpos($row,"Command:") == true)
|
---|
91 | {
|
---|
92 | $edited = str_replace(" Command: ", ";", $row); // 0 - time
|
---|
93 | $edited = str_replace(" (Account: ", ";", $edited); // 1 - command
|
---|
94 | $edited = str_replace(" [Player: ", ";", $edited); // 2 - gm
|
---|
95 | $edited = str_replace(" Selected: ", ";", $edited); // 3 - position
|
---|
96 | $edited = str_replace(" (GUID: ", ";", $edited); // 4 - selected
|
---|
97 | $edited = str_replace(")]", ";", $edited); // 5 - selected guid
|
---|
98 | $edited_arr = explode(";",$edited);
|
---|
99 | if($edited_arr[4] == "player") $sel_name = " - ".$this->GuidToCharName($edited_arr[5]);
|
---|
100 | else $sel_name = '';
|
---|
101 | $human_date = $this -> HumanDate($edited_arr[0]);
|
---|
102 | echo('<tr>
|
---|
103 | <td><font size="2">'.$human_date.'</font></td>
|
---|
104 | <td>'.$edited_arr[2].'</td>
|
---|
105 | <td>'.$edited_arr[1].'</td>
|
---|
106 | <td>'.$edited_arr[4].$sel_name.'</td>
|
---|
107 | </tr>');
|
---|
108 | }
|
---|
109 | if(strpos($row, 'mail item:') == true)
|
---|
110 | {
|
---|
111 | $edited = str_replace(" GM ", ";", $row);
|
---|
112 | $edited = str_replace(" (Account: ", ";", $edited);
|
---|
113 | $edited = str_replace(") mail item: ", ";", $edited);
|
---|
114 | $edited = str_replace(" (Account: ", ";", $edited);
|
---|
115 | $edited = str_replace(")", "", $edited);
|
---|
116 | $edited_arr = explode(";",$edited);
|
---|
117 | $human_date = $this -> HumanDate($edited_arr[0]);
|
---|
118 | echo('<tr>
|
---|
119 | <td><font size="2">'.$human_date.'</font></td>
|
---|
120 | <td>'.$edited_arr[1].'</td>
|
---|
121 | <td>Send : '.$edited_arr[3].')</td>
|
---|
122 | <td>-</td>
|
---|
123 | </tr>');
|
---|
124 | }
|
---|
125 | if(strpos($row,"trade:") == true)
|
---|
126 | {
|
---|
127 | $edited = str_replace(" GM ", ";", $row);
|
---|
128 | $edited = str_replace(" (Account: ", ";", $edited);
|
---|
129 | $edited = str_replace(") trade: ", ";", $edited);
|
---|
130 | $edited = str_replace(" (Account: ", ";", $edited);
|
---|
131 | $edited = str_replace(")", "", $edited);
|
---|
132 | $edited_arr = explode(";",$edited);
|
---|
133 |
|
---|
134 | $human_date = $this -> HumanDate ($edited_arr[0]);
|
---|
135 | echo('<tr>
|
---|
136 | <td><font size="2">'.$human_date.'</font></td>
|
---|
137 | <td>'.$edited_arr[1].'</td>
|
---|
138 | <td>Trade : '.$edited_arr[3].')</td>
|
---|
139 | <td>-</td>
|
---|
140 | </tr>');
|
---|
141 | }
|
---|
142 | }
|
---|
143 | echo('</table>');
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | ?>
|
---|