source: trunk/gh_system/export_system/index.php@ 494

Last change on this file since 494 was 494, checked in by amun, 16 years ago

Zaheslováno, Waypointy se exportují podle seznamu NPC k exportu

File size: 7.9 KB
Line 
1<?
2include("../conn.php");
3
4$heslo = $_GET['heslo'];
5
6if(!empty($heslo) AND $heslo!=$admin):
7$chyba = "<font color=red>Špatné heslo!</font>";
8$heslo = 0;
9endif;
10if(empty($heslo)):
11if(!empty($chyba)):
12echo"<p align=center>$chyba<br />";
13endif;
14echo"<form method=GET action=''><p align=center>Heslo: <input type=password name=heslo><br /><br />";
15echo"<input type=submit value='Přihlásit'></form>";
16
17else:
18
19$q = $_GET['q'];
20$err = $_GET['err'];
21$info = $_GET['info'];
22$err_text = array("Toto ID nebylo nalezeno v databázi!", "Při vkládání do seznamu došlo k chybě!", "Při exportu došlo k chybě!", "Položku se nepodařilo vymazat ze seznamu!");
23$info_text = array("Přidání do seznamu proběhlo úspěšně!", "Export proběhl vpořádku", "Vymazání položky ze seznamu proběhlo úspěšně");
24
25if(empty($q)){
26//////////////////////////////////////////////////////////Základní zobrazení
27
28
29
30
31if(!empty($err)):
32$err = $err - 1;
33echo"<p align=center><font color=red><b>$err_text[$err]</b></font>";
34endif;
35if(!empty($info)):
36$info = $info - 1;
37echo"<p align=center><font color=green><b>$info_text[$info]</b></font>";
38endif;
39
40echo"<br />
41<br />
42";
43
44echo"<form method=post action=index.php?q=1&i=gameobject&heslo=$heslo><input type=submit value='Přidat object do seznamu exportovaných'></form>";
45echo"<form method=post action=index.php?q=1&i=creature&heslo=$heslo><input type=submit value='Přidat NPC do seznamu exportovaných'></form>";
46
47echo"<br><br>";
48echo"<form method=post action=index.php?q=3&i=gameobject&heslo=$heslo><input type=submit value='Zobrazit seznam objectů'></form>";
49echo"<form method=post action=index.php?q=3&i=creature&heslo=$heslo><input type=submit value='Zobrazit seznam NPC'></form>";
50
51echo"<br><br>";
52echo"<form method=post action=index.php?q=2&i=gameobject&heslo=$heslo><input type=submit value='Vytvořit export objectů'></form>";
53echo"<form method=post action=index.php?q=2&i=creature&heslo=$heslo><input type=submit value='Vytvořit export NPC'></form>";
54echo"<form method=post action=index.php?q=2&i=creature_movement&heslo=$heslo><input type=submit value='Vytvořit export Waypointu'></form>";
55
56} elseif($q==1){
57//////////////////////////////////////////////////////////Přidávání do seznamů exportovaných
58$typ = $_GET['i'];
59$instal = $_POST['instal'];
60
61
62if(empty($instal)):
63////formulář před přidáním
64echo"<form method=post action=index.php?q=1&i=$typ&heslo=$heslo>
65ID ($typ): <input type=\"text\" name='guid'><br />
66<input type=hidden name=instal value=1>
67<input type=submit value='Přidat do seznamu'>
68</form>
69";
70else:
71////instalace do seznamu
72$guid = $_POST['guid'];
73
74mysql_connect($SQL_Server, $SQL_Uzivatel, $SQL_Heslo);
75 mysql_select_db($Databaze_world);
76 mysql_query("SET NAMES 'utf8'");
77$existuje_guid = mysql_num_rows(mysql_query("SELECT id from $typ where id=$guid"));
78
79 if($existuje_guid==0):
80 echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?err=1&heslo=$heslo\">";
81 else:
82 mysql_select_db($Databaze);
83 $pridat_do_seznamu = mysql_query("insert into export_list values ('$typ', '$guid')");
84
85 if($pridat_do_seznamu):
86 echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?info=1&heslo=$heslo\">";
87 else:
88 echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?err=2&heslo=$heslo\">";
89 endif;
90
91 endif;
92endif;
93
94} elseif($q==2){
95//////////////////////////////////////////////////////////Export
96$typ = $_GET['i'];
97$datum = date("Y-m-d");
98////////////////Vytvoření souboru:
99if($typ=="creature_movement"):
100$soubor = fopen("waypoint.sql", "w");
101else:
102$soubor = fopen("$typ.sql", "w");
103endif;
104
105$hotovo = 0;
106$x = 0;
107
108mysql_connect($SQL_Server, $SQL_Uzivatel, $SQL_Heslo);
109 mysql_select_db($Databaze);
110 mysql_query("SET NAMES 'utf8'");
111
112 if($typ=="creature_movement"):
113 $vyhledat_guid_exportovanych = mysql_query("select * from export_list where typ='creature'");
114 else:
115 $vyhledat_guid_exportovanych = mysql_query("select * from export_list where typ='$typ'");
116 endif;
117
118 while($row = mysql_fetch_array($vyhledat_guid_exportovanych)){
119 $guid_exp = $row['guid'];
120
121 mysql_select_db($Databaze_world);
122 mysql_query("SET NAMES 'utf8'");
123 $vypsat_data_exportovanych = mysql_query("select * from $typ where id=$guid_exp");
124 $pocet_exportovanych = mysql_num_rows(mysql_query("select id from $typ where id=$guid_exp"));
125 while($a = mysql_fetch_array($vypsat_data_exportovanych)):
126
127 if($typ=="gameobject"):
128
129 $prikaz = "INSERT INTO gamobject values('', '".$a['id']."', '".$a['map']."', '".$a['spawnMask']."', '".$a['position_x']."', '".$a['position_y']."', '".$a['position_z']."', '".$a['orientation']."', '".$a['rotation0']."', '".$a['rotation1']."', '".$a['rotation2']."', '".$a['rotation3']."', '".$a['spawntimesecs']."', '".$a['animprogress']."', '".$a['state']."');";
130 $prikaz .= "\n";
131
132 elseif($typ=="creature"):
133 $prikaz = "INSERT INTO creature values('', '".$a['id']."', '".$a['map']."', '".$a['spawnMask']."', '".$a['modelid']."', , '".$a['equipment_id']."', '".$a['position_x']."', '".$a['position_y']."', '".$a['position_z']."', '".$a['orientation']."', '".$a['spawntimesecs']."', '".$a['spawndist']."', '".$a['currentwaypoint']."', '".$a['curhealth']."', '".$a['curmana']."', '".$a['DeathState']."', '".$a['MovementType']."');";
134 $prikaz .= "\n";
135
136 elseif($typ=="creature_movement"):
137 $prikaz = "INSERT INTO creature_movement values('".$a['id']."', '".$a['point']."', '".$a['position_x']."', '".$a['position_y']."', '".$a['position_z']."', '".$a['waittime']."', '".$a['text1']."', '".$a['text2']."', '".$a['text3']."', '".$a['text4']."', '".$a['text5']."', '".$a['emote']."', '".$a['spell']."', '".$a['wpguid']."', '".$a['orientation']."', '".$a['model1']."', '".$a['model2']."');";
138 $prikaz .= "\n";
139 endif;
140
141 $zapis = fwrite($soubor,$prikaz);
142
143 if($zapis):
144$hotovo = $hotovo + 1;
145 endif;
146
147 $x = $x + 1;
148 endwhile;
149 ////////////////vložení informací do souboru:
150
151
152
153 }
154fclose($soubor);
155if($hotovo==$x):
156echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?info=2&heslo=$heslo\">";
157else:
158echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?err=3&heslo=$heslo\">";
159endif;
160
161} elseif($q==3){
162//////////////////////////////////////////////////////////Zobrazení seznamu
163$typ = $_GET['i'];
164$delete = $_POST['delete'];
165
166if(empty($delete)):
167if(!empty($err)):
168$err = $err - 1;
169echo"<p align=center><font color=red><b>$err_text[$err]</b></font>";
170endif;
171if(!empty($info)):
172$info = $info - 1;
173echo"<p align=center><font color=green><b>$info_text[$info]</b></font>";
174endif;
175echo"<p align=center>Seznam $typ ID k exportu<br>
176<table align=center><tr><td><b>ID</b><td>&nbsp;";
177mysql_connect($SQL_Server, $SQL_Uzivatel, $SQL_Heslo);
178 mysql_select_db($Databaze);
179 mysql_query("SET NAMES 'utf8'");
180 $vyhledat_data_v_seznamu = mysql_query("select * from export_list where typ='$typ'");
181 while($row = mysql_fetch_array($vyhledat_data_v_seznamu)){
182 $id = $row['guid'];
183 echo"<tr><td>$id</td><form method=post action=index.php?q=3&i=$typ&heslo=$heslo><td><input type=hidden name=delete value=1><input type=hidden name=id value='$id'><input type=submit value='Smazat ze seznamu'></form>";
184
185 }
186echo"</table><br>
187<br>
188<a href=index.php?heslo=$heslo><-- Zpět do menu</a>";
189elseif($delete==1):
190//////////////////////////////////////////////////////////Mazání ze seznamu
191$id = $_POST['id'];
192
193mysql_connect($SQL_Server, $SQL_Uzivatel, $SQL_Heslo);
194 mysql_select_db($Databaze);
195 mysql_query("SET NAMES 'utf8'");
196 $vyhledat_data_v_seznamu = mysql_query("delete from export_list where guid='$id' LIMIT 1");
197 if($vyhledat_data_v_seznamu):
198 echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?q=3&i=$typ&info=3&heslo=$heslo\">";
199 else:
200 echo"<meta http-equiv=\"refresh\" content=\"0.1;url=index.php?q=3&i=$typ&err=4&heslo=$heslo\">";
201 endif;
202endif;
203}
204
205endif;
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
Note: See TracBrowser for help on using the repository browser.