1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../includes/zip.lib.php');
|
---|
4 | include_once(dirname(__FILE__).'/../../includes/dbc.php');
|
---|
5 | include_once(dirname(__FILE__).'/CreateAddon.php');
|
---|
6 |
|
---|
7 | //ini_set('memory_limit', '100M');
|
---|
8 |
|
---|
9 | function CreateZipFromDir(&$Zip, $Path, $ZipPath)
|
---|
10 | {
|
---|
11 | //echo($Path.'<br />');
|
---|
12 | $FileList = scandir($Path);
|
---|
13 | foreach($FileList as $FileName)
|
---|
14 | {
|
---|
15 | if(file_exists($Path.$FileName) and ($FileName != '.') and ($FileName != '..'))
|
---|
16 | {
|
---|
17 | //echo($Path.$FileName.'<br />');
|
---|
18 | if(is_dir($Path.$FileName)) CreateZipFromDir($Zip, $Path.$FileName.'/', $ZipPath.$FileName.'/');
|
---|
19 | else $Zip->addFile(file_get_contents($Path.$FileName), $ZipPath.$FileName);
|
---|
20 | }
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | function OutputAoWoWToFile($ExportId)
|
---|
25 | {
|
---|
26 | global $System, $Config;
|
---|
27 |
|
---|
28 | $Output = '';
|
---|
29 | $Export = new Export($System);
|
---|
30 | $Export->Id = $ExportId;
|
---|
31 | $Export->Init();
|
---|
32 | if(function_exists('gzcompress'))
|
---|
33 | {
|
---|
34 | $SaveFilename = $Export->TempDir.'CzAoWoW_SQL.zip';
|
---|
35 | $SQLFilename = 'CzAoWoW_SQL.sql';
|
---|
36 | $BufferZip = $Export->ExportToAoWoWSQL();
|
---|
37 | $ZipFile = new zipfile();
|
---|
38 | $ZipFile->addFile($BufferZip, $SQLFilename);
|
---|
39 | $Buffer = $ZipFile->file();
|
---|
40 | file_put_contents($SaveFilename, $Buffer);
|
---|
41 | } else $Output .= ShowMessage('Funkce pro tvorbu Zip souboru není podporována.', MESSAGE_CRITICAL);
|
---|
42 | //$Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
43 | // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'.
|
---|
44 | // '</script>';
|
---|
45 |
|
---|
46 | $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
|
---|
47 | '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzAoWoW_SQL.zip').'">'.$SQLFilename.'</a><br />'.
|
---|
48 | 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.';
|
---|
49 | return($Output);
|
---|
50 | }
|
---|
51 |
|
---|
52 | function OutputAoWoWToHTML($ExportId)
|
---|
53 | {
|
---|
54 | global $System, $Config;
|
---|
55 |
|
---|
56 | $Export = new Export($System);
|
---|
57 | $Export->Id = $ExportId;
|
---|
58 |
|
---|
59 | $Output = 'Vygenerovaný SQL kód: <br /><pre class="SQLCode">'.
|
---|
60 | htmlspecialchars($Export->ExportToAoWoWSQL()).
|
---|
61 | '</pre>';
|
---|
62 | return($Output );
|
---|
63 | }
|
---|
64 |
|
---|
65 | function OutputMangosSQLToFile($ExportId)
|
---|
66 | {
|
---|
67 | global $System, $Config;
|
---|
68 |
|
---|
69 | $Output = '';
|
---|
70 | $Export = new Export($System);
|
---|
71 | $Export->Id = $ExportId;
|
---|
72 | $Export->Init();
|
---|
73 | if(function_exists('gzcompress'))
|
---|
74 | {
|
---|
75 | $SaveFilename = $Export->TempDir.'CzWoW_SQL.zip';
|
---|
76 | $SQLFilename = 'CzWoW_SQL.sql';
|
---|
77 | $BufferZip = $Export->ExportToMangosSQL();
|
---|
78 | $ZipFile = new zipfile();
|
---|
79 | $ZipFile->addFile($BufferZip, $SQLFilename);
|
---|
80 | $Buffer = $ZipFile->file();
|
---|
81 | file_put_contents($SaveFilename, $Buffer);
|
---|
82 | } else $Output .= ShowMessage('Funkce pro tvorbu Zip souboru není podporována.', MESSAGE_CRITICAL);
|
---|
83 | //$Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
84 | // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'.
|
---|
85 | // '</script>';
|
---|
86 |
|
---|
87 | $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
|
---|
88 | '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_SQL.zip').'">'.$SQLFilename.'</a><br />'.
|
---|
89 | 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.';
|
---|
90 | return($Output);
|
---|
91 | }
|
---|
92 |
|
---|
93 | function OutputMangosSQLToHTML($ExportId)
|
---|
94 | {
|
---|
95 | global $System;
|
---|
96 |
|
---|
97 | $Export = new Export($System);
|
---|
98 | $Export->Id = $ExportId;
|
---|
99 | $Export->Init();
|
---|
100 | $Output = 'Vygenerovaný SQL kód: <br /><pre class="SQLCode">'.
|
---|
101 | htmlspecialchars($Export->ExportToMangosSQL()).
|
---|
102 | '</pre>';
|
---|
103 | return($Output);
|
---|
104 | }
|
---|
105 |
|
---|
106 | function OutputAddon($ExportId)
|
---|
107 | {
|
---|
108 | global $System;
|
---|
109 |
|
---|
110 | if(function_exists('gzcompress'))
|
---|
111 | {
|
---|
112 | $Addon = new ExportAddon($System);
|
---|
113 | $Addon->Id = $ExportId;
|
---|
114 | $Addon->Init();
|
---|
115 | $Output = $Addon->MakeAddon();
|
---|
116 |
|
---|
117 | $Output .= 'Generování addonu...<br />';
|
---|
118 | $SaveFilename = $Addon->TempDir.'CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip';
|
---|
119 | $Zip = new zipfile();
|
---|
120 | CreateZipFromDir($Zip, $Addon->TempDir.'CzWoW/', 'CzWoW/');
|
---|
121 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/OptionsFrame.xml'), 'CzWoW/OptionsFrame.xml');
|
---|
122 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.xml'), 'CzWoW/CzWoW.xml');
|
---|
123 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.toc'), 'CzWoW/CzWoW.toc');
|
---|
124 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/CzWoW.lua'), 'CzWoW/CzWoW.lua');
|
---|
125 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/GameMenuFrame.xml'), 'CzWoW/GameMenuFrame.xml');
|
---|
126 | $Zip->addFile(file_get_contents(dirname(__FILE__).'/files/'.$Addon->ClientVersion['Version'].'/CzWoW/Localization.lua'), 'CzWoW/Localization.lua');
|
---|
127 | $Buffer = $Zip->file();
|
---|
128 | file_put_contents($SaveFilename, $Buffer);
|
---|
129 | $Output .= 'Hotovo<br /><br />';
|
---|
130 | } else $Output = ShowMessage('Funkce pro tvorbu Zip souboru není podporována.', MESSAGE_CRITICAL);
|
---|
131 | //$Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
132 | // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'.
|
---|
133 | // '</script>';
|
---|
134 |
|
---|
135 | $Output .= 'Soubor ke stažení: '.
|
---|
136 | '<a href="'.$System->Link('/'.$Addon->TempDirRelative.'CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip').'">CzWoW_Addon-'.$Addon->ClientVersion['Version'].'.zip</a><br />'.
|
---|
137 | 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.';
|
---|
138 | $Output .= '<br /><strong>Použití ve hře</strong><br />Menu addonu ve hře vyvoláte povelem /czwow.';
|
---|
139 | return($Output);
|
---|
140 | }
|
---|
141 |
|
---|
142 | function OutputXMLToFile($ExportId)
|
---|
143 | {
|
---|
144 | global $Config, $System;
|
---|
145 |
|
---|
146 | $Output = '';
|
---|
147 | $Export = new Export($System);
|
---|
148 | $Export->Id = $ExportId;
|
---|
149 | $Export->Init();
|
---|
150 | if(function_exists('gzcompress'))
|
---|
151 | {
|
---|
152 | $SaveFilename = $Export->TempDir.'CzWoW_XML.zip';
|
---|
153 | $SQLFilename = 'CzWoW_XML.sql';
|
---|
154 | $BufferZip = $Export->ExportToXML();
|
---|
155 | $ZipFile = new zipfile();
|
---|
156 | $ZipFile->addFile($BufferZip, $SQLFilename);
|
---|
157 | $Buffer = $ZipFile->file();
|
---|
158 | file_put_contents($SaveFilename, $Buffer);
|
---|
159 | } else $Output .= ShowMessage('Funkce pro tvorbu Zip souboru není podporována.', MESSAGE_CRITICAL);
|
---|
160 | //$Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
161 | // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'.
|
---|
162 | // '</script>';
|
---|
163 |
|
---|
164 | $Output .= 'Pokud nezačalo stahování, soubor by mělo jít stáhnout pomocí tohoto odkazu: '.
|
---|
165 | '<a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_XML.zip').'">CzWoW_SQL.zip</a><br />'.
|
---|
166 | 'Pokud se vám zdá, že filtr na export nefunguje, vymažte si vyrovnávací paměť prohlížeče a zkuste stáhnout soubor znovu.';
|
---|
167 | return($Output);
|
---|
168 | }
|
---|
169 |
|
---|
170 | function OutputXMLToHTML($ExportId)
|
---|
171 | {
|
---|
172 | global $System;
|
---|
173 |
|
---|
174 | $Export = new Export($System);
|
---|
175 | $Export->Id = $ExportId;
|
---|
176 | $Export->Init();
|
---|
177 | $Output = 'Vygenerované XML: <br /><pre class="SQLCode">'.
|
---|
178 | htmlspecialchars($Export->ExportToXML()).
|
---|
179 | '</pre>';
|
---|
180 | return($Output);
|
---|
181 | }
|
---|
182 |
|
---|
183 | function OutputDBCToFile($ExportId)
|
---|
184 | {
|
---|
185 | global $System;
|
---|
186 |
|
---|
187 | $Output = '';
|
---|
188 | if(array_key_exists('Regenerate', $_POST))
|
---|
189 | {
|
---|
190 | $System->Database->query('UPDATE ExportTask SET TimeStart = NOW(), TimeFinish = NULL WHERE Export = '.$ExportId);
|
---|
191 | $Output .= ShowMessage('Soubor zařazen znovu ke zpracování do fronty.');
|
---|
192 | }
|
---|
193 |
|
---|
194 | $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />';
|
---|
195 | $Output .= 'U DBC souborů export textů funguje jinak, protože generování je náročné, jsou požadavky zařazovány do fronty a postupně zpracovávány.<br />DBC soubory je nutné zabalit do souboru patch-enGB-5.MPQ uvnitř složky "DBFilesClient" a hru spouštět přes upravený spouštěcí soubor. Zabalit je můžete pomocí programu <a href="../download/mpqediten32.zip">Ladik\'s MPQ Editor</a>. Stav vygenerování můžete sledovat na této stránce.<br /><br />';
|
---|
196 |
|
---|
197 | $Export = new Export($System);
|
---|
198 | $Export->Id = $ExportId;
|
---|
199 | $Export->Init();
|
---|
200 | $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId);
|
---|
201 | if($DbResult->num_rows == 0)
|
---|
202 | {
|
---|
203 | $System->Database->query('INSERT INTO ExportTask (`Export` ,`TimeStart` ) VALUES ('.$ExportId.', NOW())');
|
---|
204 | $this->System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování dbc souboru', LOG_TYPE_DOWNLOAD);
|
---|
205 | if (file_exists($Export->TempDir.'progress')) unlink($Export->TempDir.'progress');
|
---|
206 | }
|
---|
207 |
|
---|
208 | $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId);
|
---|
209 | $ExportTask = $DbResult->fetch_assoc();
|
---|
210 | if($ExportTask['TimeFinish'] > $ExportTask['TimeStart'])
|
---|
211 | {
|
---|
212 | $Output .= '<strong>Souhrný balík: <a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_DBC.zip').'">CzWoW_DBC.zip</a></strong><br/>';
|
---|
213 | $DbResult = $System->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$Export->Id.' AND `Group`.`DBCFileName` != ""');
|
---|
214 | while($Group = $DbResult->fetch_assoc())
|
---|
215 | {
|
---|
216 | if(file_exists($Export->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc'))
|
---|
217 | $Output .= '<a href="'.$System->Link('/'.$Export->TempDirRelative.'dbc/'.$Group['DBCFileName'].'.dbc').'">'.$Group['DBCFileName'].'.dbc</a><br/>';
|
---|
218 | }
|
---|
219 | } else {
|
---|
220 |
|
---|
221 | $Line = 0;
|
---|
222 | if (file_exists (dirname(__FILE__).'/../../'.$Export->TempDirRelative.'progress')) {
|
---|
223 | $File = new FileStream();
|
---|
224 | $File->OpenFile(dirname(__FILE__).'/../../'.$Export->TempDirRelative.'progress');
|
---|
225 | $Line = $File->ReadLine();
|
---|
226 | }
|
---|
227 | $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
228 | 'setTimeout("parent.location.href=\''.$System->Link('/export/?Action=View&Tab=7&ExportId='.$Export->Id).'\'", 3000)'.
|
---|
229 | '</script>';
|
---|
230 | $Output .= ' <strong>Dokončeno procent: '.ProgressBar(300, $Line).'</strong>';
|
---|
231 | $Output .= '<br/><br/><strong>Soubor čeká na zpracování ve frontě.</strong><br/>';
|
---|
232 | }
|
---|
233 | return($Output);
|
---|
234 | }
|
---|
235 | function OutputEXEToFile($ExportId)
|
---|
236 | {
|
---|
237 | global $System;
|
---|
238 |
|
---|
239 | $Output = '';
|
---|
240 | if(array_key_exists('Regenerate', $_POST))
|
---|
241 | {
|
---|
242 | $System->Database->query('UPDATE ExportTask SET TimeStart = NOW(), TimeFinish = NULL WHERE Export = '.$ExportId);
|
---|
243 | $Output .= ShowMessage('Soubor zařazen znovu ke zpracování do fronty.');
|
---|
244 | if (file_exists($Export->TempDir.'progress')) unlink($Export->TempDir.'progress');
|
---|
245 | }
|
---|
246 |
|
---|
247 | $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />';
|
---|
248 | $Output .= 'U souhrné instalace češtiny funguje export textů jinak, protože generování je náročné, jsou požadavky zařazovány do fronty a postupně zpracovávány.<br /><br />';
|
---|
249 |
|
---|
250 | $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId);
|
---|
251 | if($DbResult->num_rows == 0)
|
---|
252 | {
|
---|
253 | $System->Database->query('INSERT INTO ExportTask (`Export` ,`TimeStart` ) VALUES ('.$ExportId.', NOW())');
|
---|
254 | $this->System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování dbc souboru', LOG_TYPE_DOWNLOAD);
|
---|
255 | }
|
---|
256 |
|
---|
257 | $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId);
|
---|
258 | $ExportTask = $DbResult->fetch_assoc();
|
---|
259 | $Export = new Export($System);
|
---|
260 | $Export->Id = $ExportId;
|
---|
261 | $Export->Init();
|
---|
262 | $Export->LoadFilters();
|
---|
263 | if($ExportTask['TimeFinish'] > $ExportTask['TimeStart'])
|
---|
264 | {
|
---|
265 | // unlink($Export->TempDirRelative.'progress');
|
---|
266 | $Output .= '<strong>Souhrný EXE balík: <a href="'.$System->Link('/'.$Export->TempDirRelative.'Instalace_CzechWoW_'.$Export->ClientVersion['Version'].'.exe').'">Instalace_CzechWoW_'.$Export->ClientVersion['Version'].'.exe</a></strong><br/>';
|
---|
267 |
|
---|
268 | } else {
|
---|
269 |
|
---|
270 | $Line = 0;
|
---|
271 | if (file_exists (dirname(__FILE__).'/../../'.$Export->TempDirRelative.'progress')) {
|
---|
272 | $File = new FileStream();
|
---|
273 | $File->OpenFile(dirname(__FILE__).'/../../'.$Export->TempDirRelative.'progress');
|
---|
274 | $Line = $File->ReadLine();
|
---|
275 | }
|
---|
276 | $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
277 | 'setTimeout("parent.location.href=\''.$System->Link('/export/?Action=View&Tab=7&ExportId='.$Export->Id).'\'", 3000)'.
|
---|
278 | '</script>';
|
---|
279 | $Output .= ' <strong>Dokončeno procent: '.ProgressBar(300, $Line).'</strong>';
|
---|
280 | $Output .= '<br/><br/><strong>Soubor čeká na zpracování ve frontě.</strong><br/>';
|
---|
281 | }
|
---|
282 | return($Output);
|
---|
283 | }
|
---|
284 |
|
---|
285 | function OutputLua($ExportId)
|
---|
286 | {
|
---|
287 | global $System, $Config;
|
---|
288 |
|
---|
289 | $Export = new Export($System);
|
---|
290 | $Export->Id = $ExportId;
|
---|
291 | $Export->Init();
|
---|
292 |
|
---|
293 | if(function_exists('gzcompress'))
|
---|
294 | {
|
---|
295 | $Output = 'Generování lua souborů...<br />';
|
---|
296 | $Export->ExportToLua();
|
---|
297 | $SaveFilename = $Export->TempDir.'CzWoW_Lua.zip';
|
---|
298 | $ZipFile = new zipfile();
|
---|
299 | CreateZipFromDir($ZipFile, $Export->TempDir.'lua/', '');
|
---|
300 | $Buffer = $ZipFile->file();
|
---|
301 | file_put_contents($SaveFilename, $Buffer);
|
---|
302 | $Output .= 'Hotovo<br /><br />';
|
---|
303 | } else $Output = ShowMessage('Funkce pro tvorbu Zip souboru není podporována.', MESSAGE_CRITICAL);
|
---|
304 | //$Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
|
---|
305 | // 'setTimeout("parent.location.href=\''.$SaveFilename.'\'", 3000)'.
|
---|
306 | // '</script>';
|
---|
307 |
|
---|
308 | $Output .= '<strong>Soubory:</strong><br/>'.
|
---|
309 | 'Souhrný archív <a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_Lua.zip').'">CzWoW_Lua.zip</a><br />';
|
---|
310 | $DbResult = $System->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$Export->Id.' AND `Group`.`LuaFileName` != ""');
|
---|
311 | while($Group = $DbResult->fetch_assoc())
|
---|
312 | {
|
---|
313 | $Output .= '<a href="'.$System->Link('/'.$Export->TempDirRelative.'lua/'.$Group['LuaFileName'].'.lua').'">'.$Group['LuaFileName'].'.lua</a><br/>';
|
---|
314 | }
|
---|
315 | $Output .= '<br /><br /><strong>Použití ve hře</strong><br />Ze souborů vytvořte MPQ archív a nahrajte ho do hry do podsložky jako Data/enUS/patch-enUS-5.MPQ nebo Data/enUS/patch-enGB-5.MPQ. Pro starší verze hry než 3.2.0 je nutné spouštět hru pomocí programu WoWMe.exe (WoW Model Editor Fix).';
|
---|
316 | return($Output);
|
---|
317 | }
|
---|
318 |
|
---|
319 | function ExportOutput($ExportId, $Type)
|
---|
320 | {
|
---|
321 | if($Type == 1) $Output = OutputMangosSQLToHTML($ExportId);
|
---|
322 | else if($Type == 2) $Output = OutputMangosSQLToFile($ExportId);
|
---|
323 | else if($Type == 3) $Output = OutputAoWoWToHTML($ExportId);
|
---|
324 | else if($Type == 4) $Output = OutputAoWoWToFile($ExportId);
|
---|
325 | else if($Type == 5) $Output = OutputXMLToHTML($ExportId);
|
---|
326 | else if($Type == 6) $Output = OutputXMLToFile($ExportId);
|
---|
327 | else if($Type == 7) $Output = OutputAddon($ExportId);
|
---|
328 | else if($Type == 8) $Output = OutputLua($ExportId);
|
---|
329 | else if($Type == 9) $Output = OutputDBCToFile($ExportId);
|
---|
330 | else if($Type == 10) $Output = OutputEXEToFile($ExportId);
|
---|
331 | else $Output = ShowMessage('Nebyl vybrán žádný formát výstupu.', MESSAGE_CRITICAL);
|
---|
332 | return($Output);
|
---|
333 | }
|
---|