1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Base/View.php');
|
---|
4 |
|
---|
5 | class DebugView extends View
|
---|
6 | {
|
---|
7 | var $ItemListFormClass = array(
|
---|
8 | 'Title' => 'Restarty',
|
---|
9 | 'Table' => 'Debug',
|
---|
10 | 'Items' => array(
|
---|
11 | 'Time' => array('Type' => 'String', 'Caption' => 'Čas', 'Default' => ''),
|
---|
12 | 'MangosVersion' => array('Type' => 'String', 'Caption' => 'Verze emulátoru', 'Default' => ''),
|
---|
13 | 'DbVersion' => array('Type' => 'String', 'Caption' => 'Verze databáze', 'Default' => ''),
|
---|
14 | 'MaxPlayerCount' => array('Type' => 'Integer', 'Caption' => 'Max. online hráčů', 'Default' => ''),
|
---|
15 | 'Uptime' => array('Type' => 'String', 'Caption' => 'Doba běhu', 'Default' => ''),
|
---|
16 | ),
|
---|
17 | );
|
---|
18 | var $ItemFormClass = array(
|
---|
19 | 'Title' => 'Záznam restartu',
|
---|
20 | 'Table' => 'Debug',
|
---|
21 | 'Items' => array(
|
---|
22 | 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''),
|
---|
23 | 'MangosVersion' => array('Type' => 'String', 'Caption' => 'Verze emulátoru', 'Default' => ''),
|
---|
24 | 'DbVersion' => array('Type' => 'String', 'Caption' => 'Verze databáze', 'Default' => ''),
|
---|
25 | 'MaxPlayerCount' => array('Type' => 'Integer', 'Caption' => 'Max. online hráčů', 'Default' => ''),
|
---|
26 | 'Uptime' => array('Type' => 'String', 'Caption' => 'Doba běhu', 'Default' => ''),
|
---|
27 | ),
|
---|
28 | );
|
---|
29 |
|
---|
30 | function ShowListOnRow($Row)
|
---|
31 | {
|
---|
32 | $Row['Time'] = '<a href="?Module=Debug&Action=View&Id='.$Row['Id'].'&Show=Backtrace">'.str_replace(' ', ' ', $Row['Time']).'</a>';
|
---|
33 | $Row['Uptime'] = TimeToHumanTime($Row['Uptime']);
|
---|
34 | return($Row);
|
---|
35 | }
|
---|
36 |
|
---|
37 | function ItemList()
|
---|
38 | {
|
---|
39 | if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
|
---|
40 | {
|
---|
41 | $Realm = new Realm($this->System, $_GET['Id']);
|
---|
42 | if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
|
---|
43 | {
|
---|
44 | $Output = '<h4>Ladící záznamy restartů</h4>';
|
---|
45 | $Table = new Table($this->ItemListFormClass, $this->System);
|
---|
46 | $Table->OnRow = array($this, 'ShowListOnRow');
|
---|
47 | $Table->Definition['Table'] = '(SELECT * FROM Debug WHERE Realm='.$_GET['Id'].')';
|
---|
48 | $Table->LoadValuesFromDatabase($this->Database);
|
---|
49 | $Output .= $Table->Show();
|
---|
50 | if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)
|
---|
51 | {
|
---|
52 | //$Output .= '<br /><div style="text-align: center;"><a href="?Action=BackupAdd">Zálohovat</a></dev>';
|
---|
53 | }
|
---|
54 | } else $this->SystemMessage('Ladící záznamy', 'Nemáte oprávnění');
|
---|
55 | } else $Output .= USER_BAD_ROLE;
|
---|
56 | return($Output);
|
---|
57 | }
|
---|
58 |
|
---|
59 | function Item()
|
---|
60 | {
|
---|
61 | if($this->System->Modules['User']->User['Role'] >= USER_ROLE_USER)
|
---|
62 | {
|
---|
63 | $Realm = new Realm($this->System, $_GET['Id']);
|
---|
64 | if(($this->System->Modules['User']->User['Id'] == $Realm->GetUser()) or ($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR))
|
---|
65 | {
|
---|
66 | $Output = '<div>Ladící informace serveru</div>';
|
---|
67 |
|
---|
68 | $MangosDebug = new MangosDebug($this->System, $this->System);
|
---|
69 | $Form = new Form($this->System, $this->ItemFormClass);
|
---|
70 | if($Form->LoadValuesFromDatabase($_GET['Id']))
|
---|
71 | {
|
---|
72 | $Form->Values['Uptime'] = TimeToHumanTime($Form->Values['Uptime']);
|
---|
73 | $Output .= $Form->ShowTable();
|
---|
74 |
|
---|
75 | $Output .= '<a href="?Module=Debug&Action=View&Id='.$_GET['Id'].'&Show=Backtrace">Backtrace</a>'.
|
---|
76 | ' <a href="?Module=Debug&Action=View&Id='.$_GET['Id'].'&Show=Log">Mangos log</a>'.
|
---|
77 | ' <a href="?Module=Debug&Action=View&Id='.$_GET['Id'].'&Show=Error">Console error log</a>'.
|
---|
78 | ' <a href="?Module=Debug&Action=View&Id='.$_GET['Id'].'&Show=DbErrors">Database error log</a>'.
|
---|
79 | ' <a href="?Module=Debug&Action=View&Id='.$_GET['Id'].'&Show=Configuration">Mangos configuration</a>'.
|
---|
80 | '<hr>';
|
---|
81 | if(array_key_exists('Show', $_GET))
|
---|
82 | {
|
---|
83 | $Show = addslashes($_GET['Show']);
|
---|
84 | switch($Show)
|
---|
85 | {
|
---|
86 | case 'Backtrace':
|
---|
87 | $DbResult = $this->Database->select('Debug', 'Backtrace', 'Id='.$_GET['Id']);
|
---|
88 | $DbRow = $DbResult->fetch_assoc();
|
---|
89 | $Content = htmlspecialchars($DbRow['Backtrace']);
|
---|
90 | for($I = 1; $I < $MangosDebug->MaxMangosThreadCount; $I++)
|
---|
91 | {
|
---|
92 | $Content = str_replace('Thread '.$I.' ', '<hr><strong id="'.$I.'">Thread '.$I.'</strong>', $Content);
|
---|
93 | $Content = str_replace(' '.$I.' Thread ', '<a href="#'.$I.'"">'.$I.' Thread</a>', $Content);
|
---|
94 | }
|
---|
95 | $Output .= '<strong>Backtrace:</strong> <br><pre>'.$Content.'</pre>';
|
---|
96 | break;
|
---|
97 | case 'Log':
|
---|
98 | $DbResult = $this->Database->select('Debug', 'Log', 'Id='.$_GET['Id']);
|
---|
99 | $DbRow = $DbResult->fetch_assoc();
|
---|
100 | $Output .= '<strong>Console standard output log:</strong> <br><pre>'.htmlspecialchars($DbRow['Log']).'</pre>';
|
---|
101 | break;
|
---|
102 | case 'Error':
|
---|
103 | $DbResult = $this->Database->select('Debug', 'ErrorLog', 'Id='.$_GET['Id']);
|
---|
104 | $DbRow = $DbResult->fetch_assoc();
|
---|
105 | $Output .= '<strong>Console error log:</strong> <br><pre>'.htmlspecialchars($DbRow['ErrorLog']).'</pre>';
|
---|
106 | break;
|
---|
107 | case 'DbErrors':
|
---|
108 | $DbResult = $this->Database->select('Debug', 'DbErrors', 'Id='.$_GET['Id']);
|
---|
109 | $DbRow = $DbResult->fetch_assoc();
|
---|
110 | $Output .= '<strong>Database error log:</strong> <br><pre>'.htmlspecialchars($DbRow['DbErrors']).'</pre>';
|
---|
111 | break;
|
---|
112 | case 'Configuration':
|
---|
113 | $DbResult = $this->Database->select('Debug', 'Configuration', 'Id='.$_GET['Id']);
|
---|
114 | $DbRow = $DbResult->fetch_assoc();
|
---|
115 | $Output .= '<strong>Mangos configuration:</strong> <br><pre>'.htmlspecialchars($DbRow['Configuration']).'</pre>';
|
---|
116 | break;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | } else $Output = 'Položka nenalezena';
|
---|
120 | } else $this->SystemMessage('Ladící informace', 'Nemáte oprávnění');
|
---|
121 | } else $Output = USER_BAD_ROLE;
|
---|
122 | return($Output);
|
---|
123 | }
|
---|
124 | }
|
---|