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