1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Base/Model.php');
|
---|
4 |
|
---|
5 | class Shell extends Model
|
---|
6 | {
|
---|
7 | var $Database;
|
---|
8 |
|
---|
9 | function __construct($System)
|
---|
10 | {
|
---|
11 | parent::__construct($System);
|
---|
12 | }
|
---|
13 |
|
---|
14 | function HistoryUpdate()
|
---|
15 | {
|
---|
16 | $DbResult = $this->Database->query('SELECT Id FROM Server');
|
---|
17 | while($Server = $DbResult->fetch_assoc())
|
---|
18 | {
|
---|
19 | $History = new History($this->System, $Server['Id'], 1);
|
---|
20 | $Server = new Server($this->System, $Server['Id']);
|
---|
21 | $History->AddValue($Server->GetUsedMemory());
|
---|
22 | }
|
---|
23 | }
|
---|
24 |
|
---|
25 | function Show()
|
---|
26 | {
|
---|
27 | $Output = '';
|
---|
28 | if(count($_SERVER['argv']) > 1)
|
---|
29 | {
|
---|
30 | $Command = $_SERVER['argv'][1];
|
---|
31 | if($Command == 'ServerProcessLog')
|
---|
32 | {
|
---|
33 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
34 | {
|
---|
35 | $MangosDebug = new MangosDebug($this->System);
|
---|
36 | $Output = $MangosDebug->ProcessLog($_SERVER['argv'][2]);
|
---|
37 | } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
|
---|
38 | } else
|
---|
39 | if($Command == 'ServerLock')
|
---|
40 | {
|
---|
41 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
42 | {
|
---|
43 | $Server = new Server($this->System, $_SERVER['argv'][2]);
|
---|
44 | $Server->Lock();
|
---|
45 | } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
|
---|
46 | } else
|
---|
47 | if($Command == 'ServerUnLock')
|
---|
48 | {
|
---|
49 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
50 | {
|
---|
51 | $Server = new Server($this->System, $_SERVER['argv'][2]);
|
---|
52 | $Server->UnLock();
|
---|
53 | } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
|
---|
54 | } else
|
---|
55 | if($Command == 'RealmLock')
|
---|
56 | {
|
---|
57 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
58 | {
|
---|
59 | $Realm = new Realm($this->System, $_SERVER['argv'][2]);
|
---|
60 | $Realm->Lock();
|
---|
61 | } else $Output = 'Jako druhý parameter je nutno zadat Id světa.';
|
---|
62 | } else
|
---|
63 | if($Command == 'RealmUnLock')
|
---|
64 | {
|
---|
65 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
66 | {
|
---|
67 | $Realm = new Realm($this->System, $_SERVER['argv'][2]);
|
---|
68 | $Realm->UnLock();
|
---|
69 | } else $Output = 'Jako druhý parameter je nutno zadat Id světa.';
|
---|
70 | } else
|
---|
71 | if($Command == 'EmulatorLock')
|
---|
72 | {
|
---|
73 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
74 | {
|
---|
75 | $Emulator = new Emulator($this->System, $_SERVER['argv'][2]);
|
---|
76 | $Emulator->Lock();
|
---|
77 | } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.';
|
---|
78 | } else
|
---|
79 | if($Command == 'EmulatorUnLock')
|
---|
80 | {
|
---|
81 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
82 | {
|
---|
83 | $Emulator = new Emulator($this->System, $_SERVER['argv'][2]);
|
---|
84 | $Emulator->UnLock();
|
---|
85 | } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.';
|
---|
86 | } else
|
---|
87 | if($Command == 'BackupLock')
|
---|
88 | {
|
---|
89 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
90 | {
|
---|
91 | $Backup = new Backup($this->System, $_SERVER['argv'][2]);
|
---|
92 | $Backup->Lock();
|
---|
93 | } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.';
|
---|
94 | } else
|
---|
95 | if($Command == 'BackupUnLock')
|
---|
96 | {
|
---|
97 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
98 | {
|
---|
99 | $Backup = new Backup($this->System, $_SERVER['argv'][2]);
|
---|
100 | $Backup->UnLock();
|
---|
101 | } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.';
|
---|
102 | } else
|
---|
103 | if($Command == 'TaskProcess')
|
---|
104 | {
|
---|
105 | $Task = new Task($this->System);
|
---|
106 | $Task->ProcessAllCycle();
|
---|
107 | } else
|
---|
108 | if($Command == 'ServerStartAll')
|
---|
109 | {
|
---|
110 | // Start servers
|
---|
111 | $DbResult = $this->Database->select('Server', 'Id');
|
---|
112 | while($DbRow = $DbResult->fetch_assoc())
|
---|
113 | {
|
---|
114 | $Server = new Server($this->System, $DbRow['Id']);
|
---|
115 | $this->System->Modules['User']->User['Id'] = $Server->Server['User'];
|
---|
116 | $Server->Start();
|
---|
117 | }
|
---|
118 | // Start realmd
|
---|
119 | $DbResult = $this->Database->select('Realm', 'Id');
|
---|
120 | while($DbRow = $DbResult->fetch_assoc())
|
---|
121 | {
|
---|
122 | $Realm = new Realm($this->System, $DbRow['Id']);
|
---|
123 | $this->System->Modules['User']->User['Id'] = $Realm->Data['User'];
|
---|
124 | $Realm->Start();
|
---|
125 | }
|
---|
126 | } else
|
---|
127 | if($Command == 'BackupCreateAll')
|
---|
128 | {
|
---|
129 | // Servers
|
---|
130 | $Backup = new Backup($this->System, 0);
|
---|
131 | $DbResult = $this->Database->select('Server', 'Id, User');
|
---|
132 | while($DbRow = $DbResult->fetch_assoc())
|
---|
133 | {
|
---|
134 | $this->System->Modules['User']->User['Id'] = $DbRow['User'];
|
---|
135 | $Backup->Create($DbRow['Id']);
|
---|
136 | }
|
---|
137 | } else
|
---|
138 | if($Command == 'ServerProcessLogPipe')
|
---|
139 | {
|
---|
140 | if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
|
---|
141 | {
|
---|
142 | $Server = new Server($this->System, $_SERVER['argv'][2]);
|
---|
143 | $Server->ProcessLog();
|
---|
144 | } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
|
---|
145 | } else
|
---|
146 | if($Command == 'HistoryUpdate')
|
---|
147 | {
|
---|
148 | $this->HistoryUpdate();
|
---|
149 | } else
|
---|
150 | if($Command == 'UpdateState')
|
---|
151 | {
|
---|
152 | $Realm = new Realm($this->System, 0);
|
---|
153 | $Realm->UpdateStateAll();
|
---|
154 | $Server = new Server($this->System, 0);
|
---|
155 | $Server->UpdateStateAll();
|
---|
156 | } else
|
---|
157 | if($Command == 'ServerDatabaseChange')
|
---|
158 | {
|
---|
159 | if((count($_SERVER['argv']) > 3) and is_numeric($_SERVER['argv'][2]) and is_numeric($_SERVER['argv'][3]))
|
---|
160 | {
|
---|
161 | $Server = new Server($this->System, $_SERVER['argv'][2]);
|
---|
162 | $Server->ChangeDatabaseId($_SERVER['argv'][3]);
|
---|
163 | } else $Output = 'Jako druhý parameter je nutno zadat Id serveru, jako třetí Id databáze.';
|
---|
164 | } else
|
---|
165 | if($Command == 'RealmDatabaseChange')
|
---|
166 | {
|
---|
167 | if((count($_SERVER['argv']) > 3) and is_numeric($_SERVER['argv'][2]) and is_numeric($_SERVER['argv'][3]))
|
---|
168 | {
|
---|
169 | $Realm = new Realm($this->System, $_SERVER['argv'][2]);
|
---|
170 | $Realm->ChangeDatabaseId($_SERVER['argv'][3]);
|
---|
171 | } else $Output = 'Jako druhý parameter je nutno zadat Id světa, jako třetí Id databáze.';
|
---|
172 | } else
|
---|
173 | $Output = 'Neznámý příkaz '.$Command;
|
---|
174 | } else $Output = 'Jako první parameter je nutno zadat povel.';
|
---|
175 | return($Output);
|
---|
176 | }
|
---|
177 | }
|
---|