1 | <?php
|
---|
2 |
|
---|
3 | function WithOutDiacritical($teststring){
|
---|
4 | $teststring=StrTr($teststring, "áäčďéěëíňóöřšťúůüýžÁÄČĎÉĚËÍŇÓÖŘŠŤÚŮÜÝŽ", "aacdeeeinoorstuuuyzAACDEEEINOORSTUUUYZ");
|
---|
5 |
|
---|
6 | return $teststring;
|
---|
7 | }
|
---|
8 |
|
---|
9 | $Diacritical = @$_POST['Diacritical'];
|
---|
10 | if (array_key_exists('CZ', $_POST)) $CZ = $_POST['CZ'];
|
---|
11 | if (array_key_exists('SK', $_POST)) $SK = $_POST['SK'];
|
---|
12 | if (array_key_exists('OtherLanguage', $_POST)) $OtherLanguage = $_POST['OtherLanguage'];
|
---|
13 | if (array_key_exists('Use', $_POST)) $Use = $_POST['Use'];
|
---|
14 | $Type = $_POST['Type'];
|
---|
15 | $Export = $_POST['Export'];
|
---|
16 | $AddTitle = $_POST['AddTitle'];
|
---|
17 | $NumberVote = $_POST['NumberVote'];
|
---|
18 | $Vote = $_POST['Vote'];
|
---|
19 | $users = @$_POST['users'];
|
---|
20 |
|
---|
21 | $BufferHeader = '
|
---|
22 | /* Generated by maron web translate application
|
---|
23 | ============================================
|
---|
24 |
|
---|
25 | WebProject: '.$Config['Web']['BaseURL'].'
|
---|
26 | E-mail: maron2@centrum.cz
|
---|
27 | DateExport: '.date("m.d.y H:i").'
|
---|
28 | Znaková sada: '.$Config['Database']['Charset'].' / '.$Config['Web']['Charset'].'
|
---|
29 | Diakritika: '.$Diacritical.'
|
---|
30 | Počet nutných hlasů: '.$NumberVote.'
|
---|
31 | Známka vyšší jak: '.$Vote.'
|
---|
32 | Tabulky:
|
---|
33 | Quests: '.@$_POST['Quests'].'
|
---|
34 | NPC_text: '.@$_POST['NPC_texts'].'
|
---|
35 | page_text: '.@$_POST['page_texts'].' */
|
---|
36 |
|
---|
37 | ';
|
---|
38 |
|
---|
39 | if (isset($Use)) $BufferHeader .= 'USE `mangos`;
|
---|
40 |
|
---|
41 | ';
|
---|
42 |
|
---|
43 |
|
---|
44 | $WhereLang = '';
|
---|
45 | if (isset($CZ)) $WhereLang .= " Language = '1'";
|
---|
46 | if (isset($SK)) {
|
---|
47 | if ($WhereLang <> '')
|
---|
48 | $WhereLang .= " OR Language = '2'";
|
---|
49 | else
|
---|
50 | $WhereLang .= "Language = '2'";
|
---|
51 | }
|
---|
52 | if (isset($OtherLanguage)) {
|
---|
53 | if ($WhereLang <> '')
|
---|
54 | $WhereLang .= " OR Language = '3'";
|
---|
55 | else
|
---|
56 | $WhereLang .= "Language = '3'";
|
---|
57 | }
|
---|
58 |
|
---|
59 | $WhereUsers = '';
|
---|
60 |
|
---|
61 | for ($i=0; $i<Count($users); $i++):
|
---|
62 | if ($WhereUsers <> '')
|
---|
63 | $WhereUsers .= " OR User = ".$users[$i];
|
---|
64 | else
|
---|
65 | $WhereUsers .= " User = ".$users[$i];
|
---|
66 | endfor;
|
---|
67 |
|
---|
68 |
|
---|
69 | if (array_key_exists('Quests', $_POST)) {
|
---|
70 | $AddDetails = @$_POST['AddDetails'];
|
---|
71 | $AddObjectives = @$_POST['AddObjectives'];
|
---|
72 | $AddOfferRewardText = @$_POST['AddOfferRewardText'];
|
---|
73 | $AddRequestItemsText = @$_POST['AddRequestItemsText'];
|
---|
74 | $AddEndText = @$_POST['AddEndText'];
|
---|
75 | $AddObjectiveText1 = @$_POST['AddObjectiveText1'];
|
---|
76 | $AddObjectiveText2 = @$_POST['AddObjectiveText2'];
|
---|
77 | $AddObjectiveText3 = @$_POST['AddObjectiveText3'];
|
---|
78 | $AddObjectiveText4 = @$_POST['AddObjectiveText4'];
|
---|
79 |
|
---|
80 | if (($Export == 'Mangos') and (Licence(2) == False)) {die('Nemáte oprávnění');}
|
---|
81 |
|
---|
82 |
|
---|
83 | $sql = "SELECT * FROM quests.quests WHERE Complete = '1' AND CountVote >= '$NumberVote' AND Vote >= '$Vote'";
|
---|
84 |
|
---|
85 | if ($WhereLang <> '') $sql .= " AND ($WhereLang)";
|
---|
86 | if ($WhereUsers <> '') $sql .= "AND ($WhereUsers)";
|
---|
87 |
|
---|
88 | // echo $sql;
|
---|
89 |
|
---|
90 | $i = 0;
|
---|
91 | $ID = $Database->SQLCommand($sql." ORDER BY vote");
|
---|
92 | while ($Line = mysql_fetch_array($ID)) {
|
---|
93 | $entry = $Line['entry'];
|
---|
94 | $Title = mysql_escape_string($Line['Title']);
|
---|
95 | $Details = mysql_escape_string($Line['Details']);
|
---|
96 | $Objectives = mysql_escape_string($Line['Objectives']);
|
---|
97 | $OfferRewardText = mysql_escape_string($Line['OfferRewardText']);
|
---|
98 | $RequestItemsText = mysql_escape_string($Line['RequestItemsText']);
|
---|
99 | $EndText = mysql_escape_string($Line['EndText']);
|
---|
100 | $ObjectiveText1 = mysql_escape_string($Line['ObjectiveText1']);
|
---|
101 | $ObjectiveText2 = mysql_escape_string($Line['ObjectiveText2']);
|
---|
102 | $ObjectiveText3 = mysql_escape_string($Line['ObjectiveText3']);
|
---|
103 | $ObjectiveText4 = mysql_escape_string($Line['ObjectiveText4']);
|
---|
104 |
|
---|
105 | if ($AddTitle == 'Translate')
|
---|
106 | $Title = "Title = '$Title'";
|
---|
107 | else {
|
---|
108 | $IDtitle = $Database->SQLCommand("SELECT Title FROM quests.quests WHERE entry = '$entry' AND Language = '0'");
|
---|
109 | $Linetitle = mysql_fetch_array($IDtitle);
|
---|
110 |
|
---|
111 | if ($AddTitle == 'EN') {
|
---|
112 | $Title = "Title = '".$Linetitle['Title']."'";
|
---|
113 | }
|
---|
114 | if ($AddTitle == 'Both') {
|
---|
115 | $Title = "Title = '$Title (".$Linetitle['Title'].")'";
|
---|
116 | }
|
---|
117 | }
|
---|
118 | if (($Details <> '') and ($AddDetails))
|
---|
119 | $Details = "Details = '$Details', ";
|
---|
120 | else $Details = '';
|
---|
121 | if ($Objectives <> '' and $AddObjectives)
|
---|
122 | $Objectives = 'Objectives = \''.$Objectives.'\', ';
|
---|
123 | else $Objectives= '';
|
---|
124 | if ($OfferRewardText <> '' and $AddOfferRewardText)
|
---|
125 | $OfferRewardText = 'OfferRewardText = \''.$OfferRewardText.'\', ';
|
---|
126 | else $OfferRewardText = '';
|
---|
127 | if ($RequestItemsText <> '' and $AddRequestItemsText)
|
---|
128 | $RequestItemsText = 'RequestItemsText = \''.$RequestItemsText.'\', ';
|
---|
129 | else $RequestItemsText = '';
|
---|
130 | // echo $entry.$Details;
|
---|
131 | // UPDATE SET Title = '', Title = '$Title', Details = '$Details', Objectives = '$Objectives', OfferRewardText = '$OfferRewardText', RequestItemsText = '$RequestItemsText' WHWRE entry = '$entry'
|
---|
132 | $sql = "UPDATE quest_template SET $Details $Objectives $OfferRewardText $RequestItemsText $Title WHERE entry = '$entry';";
|
---|
133 | if ($Diacritical == False) $sql=WithOutDiacritical($sql);
|
---|
134 |
|
---|
135 | $Buffer[$i] = $sql;
|
---|
136 | ++$i;
|
---|
137 |
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | //export npc_textů
|
---|
142 | $x = 0;
|
---|
143 | if (array_key_exists('NPC_texts', $_POST)) {
|
---|
144 |
|
---|
145 | $sql = "SELECT * FROM npc_text WHERE Complete = '1' AND CountVote >= '$NumberVote' AND Vote >= '$Vote'";
|
---|
146 |
|
---|
147 | if ($WhereLang <> '') $sql .= " AND ($WhereLang)";
|
---|
148 | if ($WhereUsers <> '') $sql .= "AND ($WhereUsers)";
|
---|
149 |
|
---|
150 | $ID = $Database->SQLCommand($sql." ORDER BY vote");
|
---|
151 | while ($Line = mysql_fetch_array($ID)) {
|
---|
152 |
|
---|
153 | $sql = "UPDATE npc_text SET ";
|
---|
154 | for ($i=0; $i<count($npc_text); ++$i) {
|
---|
155 | if ($Line[$npc_text[$i]] <> '')
|
---|
156 | $sql .= " ".$npc_text[$i]." = '".mysql_escape_string($Line[$npc_text[$i]])."' , ";
|
---|
157 | }
|
---|
158 | $sql .= " ID = '".$Line['entry']."' WHERE ID = ".$Line['entry'].";";
|
---|
159 |
|
---|
160 | if ($Diacritical == False) $sql=WithOutDiacritical($sql);
|
---|
161 |
|
---|
162 | $BufferNPC[$x] = $sql;
|
---|
163 | ++$x;
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | //export page_textů
|
---|
168 | $x = 0;
|
---|
169 | if (array_key_exists('page_texts', $_POST)) {
|
---|
170 |
|
---|
171 | $sql = "SELECT * FROM page_text WHERE Complete = '1' AND CountVote >= '$NumberVote' AND Vote >= '$Vote'";
|
---|
172 |
|
---|
173 | if ($WhereLang <> '') $sql .= " AND ($WhereLang)";
|
---|
174 | if ($WhereUsers <> '') $sql .= "AND ($WhereUsers)";
|
---|
175 |
|
---|
176 | $ID = $Database->SQLCommand($sql." ORDER BY vote");
|
---|
177 | while ($Line = mysql_fetch_array($ID)) {
|
---|
178 |
|
---|
179 | $sql = "UPDATE page_text SET ";
|
---|
180 | for ($i=0; $i<count($page_text); ++$i) {
|
---|
181 | if ($Line[$page_text[$i]] <> '')
|
---|
182 | $sql .= " ".$page_text[$i]." = '".mysql_escape_string($Line[$page_text[$i]])."' , ";
|
---|
183 | }
|
---|
184 | $sql .= " entry = '".$Line['entry']."' WHERE entry = ".$Line['entry'].";";
|
---|
185 |
|
---|
186 | if ($Diacritical == False) $sql=WithOutDiacritical($sql);
|
---|
187 |
|
---|
188 | $Bufferpage[$x] = $sql;
|
---|
189 | ++$x;
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | //vypisování
|
---|
194 | if ($Export == 'Display') {
|
---|
195 | echo 'Vygenerovaný SQL kód: <br /><textarea rows="30" cols="100">';
|
---|
196 | echo $BufferHeader;
|
---|
197 | for ($i=0; $i<count(@$Buffer); ++$i) {
|
---|
198 | echo $Buffer[$i].'
|
---|
199 | ';
|
---|
200 | }
|
---|
201 | for ($i=0; $i<count(@$BufferNPC); ++$i) {
|
---|
202 | echo $BufferNPC[$i].'
|
---|
203 | ';
|
---|
204 | }
|
---|
205 | for ($i=0; $i<count(@$Bufferpage); ++$i) {
|
---|
206 | echo $Bufferpage[$i].'
|
---|
207 | ';
|
---|
208 | }
|
---|
209 | echo '</textarea>';
|
---|
210 | }
|
---|
211 |
|
---|
212 | if ($Export == 'Mangos') {
|
---|
213 | $Database->SelectDatabase($Config['Database']['DatabaseMangos']);
|
---|
214 | for ($i=0; $i<count(@$Buffer); ++$i) {
|
---|
215 | $Database->SQLCommand($Buffer[$i]);
|
---|
216 | }
|
---|
217 | for ($i=0; $i<count(@$BufferNPC); ++$i) {
|
---|
218 | $Database->SQLCommand($BufferNPC[$i]);
|
---|
219 | }
|
---|
220 | for ($i=0; $i<count(@$Bufferpage); ++$i) {
|
---|
221 | $Database->SQLCommand($Bufferpage[$i]);
|
---|
222 | }
|
---|
223 | echo 'Hotovo!';
|
---|
224 | }
|
---|
225 |
|
---|
226 | if ($Export == 'Zip') {
|
---|
227 | if (function_exists('gzcompress')) {
|
---|
228 | $save_filename = 'SqlTranslate.zip';
|
---|
229 | $SQL_filename = 'SqlTranslate.sql';
|
---|
230 |
|
---|
231 | $BufferZip = $BufferHeader;
|
---|
232 | for ($i=0; $i<count(@$Buffer); ++$i) {
|
---|
233 | $BufferZip .= $Buffer[$i].'
|
---|
234 | ';
|
---|
235 | }
|
---|
236 | for ($i=0; $i<count(@$BufferNPC); ++$i) {
|
---|
237 | $BufferZip .= $BufferNPC[$i].'
|
---|
238 | ';
|
---|
239 | }
|
---|
240 | for ($i=0; $i<count(@$Bufferpage); ++$i) {
|
---|
241 | $BufferZip .= $Bufferpage[$i].'
|
---|
242 | ';
|
---|
243 | }
|
---|
244 |
|
---|
245 | // echo $BufferZip.'<br><br><br>';
|
---|
246 |
|
---|
247 | $zipfile = new zipfile();
|
---|
248 | $zipfile -> addFile($BufferZip, $SQL_filename);
|
---|
249 | $Buffer = $zipfile -> file();
|
---|
250 |
|
---|
251 | // echo $Buffer.'<br><br><br>';
|
---|
252 |
|
---|
253 | $file_handle = fopen($save_filename, 'w');
|
---|
254 | $write_result = fwrite($file_handle, $Buffer);
|
---|
255 | fclose($file_handle);
|
---|
256 | // header("Location: ".$save_filename);
|
---|
257 |
|
---|
258 | } else echo 'Vyskytla se chyba!';
|
---|
259 | echo '
|
---|
260 | <script type="text/javascript" language="JavaScript" charset="iso-8859-2">
|
---|
261 | setTimeout("parent.location.href=\''.$save_filename.'\'",1000)
|
---|
262 | </script>';
|
---|
263 |
|
---|
264 | echo '
|
---|
265 | Pokud nezačalo stahování soubor by mělo jít stáhnout z tohoto odkazu:
|
---|
266 | <a href="'.$save_filename.'">'.$save_filename.'</a><br />
|
---|
267 | 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.';
|
---|
268 | }
|
---|
269 |
|
---|
270 | WriteLog('Stažení SQL souboru: Typ Exportu: <b>'.$Export.'</b> Diakritika: <b>'.$Diacritical.'</b>
|
---|
271 | Počet nutných hlasů: <b>'.$NumberVote.'</b> Známka vyšší jak: <b>'.$Vote.'</b>', 2);
|
---|
272 |
|
---|
273 | ?>
|
---|