source: trunk/www/shell.php@ 53

Last change on this file since 53 was 53, checked in by george, 16 years ago
  • Přidáno: Funkce pro generování patchlistu.
  • Přidáno: Testovací funkce pro čtení z logovací roury.
File size: 4.7 KB
Line 
1<?php
2
3include('global.php');
4
5class Shell extends Module
6{
7 var $Database;
8
9 function __construct($Database)
10 {
11 $this->Database = $Database;
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->Database, $Server['Id'], 1);
20 $Server = new Server($this->Database, $Server['Id']);
21 $History->AddValue($Server->GetUsedMemory());
22 }
23 }
24
25 function Show()
26 {
27 global $System;
28
29 $Output = '';
30 if(count($_SERVER['argv']) > 1)
31 {
32 $Command = $_SERVER['argv'][1];
33 if($Command == 'ServerProcessLog')
34 {
35 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
36 {
37 $MangosDebug = new MangosDebug($this->Database);
38 $Output = $MangosDebug->ProcessLog($_SERVER['argv'][2]);
39 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
40 } else
41 if($Command == 'ServerLock')
42 {
43 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
44 {
45 $Server = new Server($this->Database, $_SERVER['argv'][2]);
46 $Server->Lock();
47 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
48 } else
49 if($Command == 'ServerUnLock')
50 {
51 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
52 {
53 $Server = new Server($this->Database, $_SERVER['argv'][2]);
54 $Server->UnLock();
55 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru.';
56 } else
57 if($Command == 'EmulatorLock')
58 {
59 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
60 {
61 $Emulator = new Emulator($this->Database, $_SERVER['argv'][2]);
62 $Emulator->Lock();
63 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.';
64 } else
65 if($Command == 'EmulatorUnLock')
66 {
67 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
68 {
69 $Emulator = new Emulator($this->Database, $_SERVER['argv'][2]);
70 $Emulator->UnLock();
71 } else $Output = 'Jako druhý parameter je nutno zadat Id emulátoru.';
72 } else
73 if($Command == 'BackupLock')
74 {
75 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
76 {
77 $Backup = new Backup($this->Database, $_SERVER['argv'][2]);
78 $Backup->Lock();
79 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.';
80 } else
81 if($Command == 'BackupUnLock')
82 {
83 if((count($_SERVER['argv']) > 2) and is_numeric($_SERVER['argv'][2]))
84 {
85 $Backup = new Backup($this->Database, $_SERVER['argv'][2]);
86 $Backup->UnLock();
87 } else $Output = 'Jako druhý parameter je nutno zadat Id zálohy.';
88 } else
89 if($Command == 'TaskProcess')
90 {
91 $Task = new Task($this->Database);
92 $Task->ProcessAllCycle();
93 } else
94 if($Command == 'ServerStartAll')
95 {
96 $DbResult = $this->Database->select('Server', 'Id');
97 while($DbRow = $DbResult->fetch_assoc())
98 {
99 $Server = new Server($this->Database, $DbRow['Id']);
100 $System->Modules['User']->User['Id'] = $Server->Server['User'];
101 $Server->Start();
102 }
103 } else
104 if($Command == 'BackupCreateAll')
105 {
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 == 'ServerDatabaseChange')
127 {
128 if((count($_SERVER['argv']) > 3) and is_numeric($_SERVER['argv'][2]) and is_numeric($_SERVER['argv'][3]))
129 {
130 $Server = new Server($this->Database, $_SERVER['argv'][2]);
131 $Server->ChangeDatabaseId($_SERVER['argv'][3]);
132 } else $Output = 'Jako druhý parameter je nutno zadat Id serveru, jako třetí Id databáze.';
133 } else
134 $Output = 'Neznámý příkaz '.$Command;
135 } else $Output = 'Jako první parameter je nutno zadat povel.';
136 return($Output);
137 }
138}
139
140$Shell = new Shell($Database);
141echo($Shell->Show());
142
143?>
Note: See TracBrowser for help on using the repository browser.