-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunction_flottes.php
More file actions
336 lines (282 loc) · 11.3 KB
/
function_flottes.php
File metadata and controls
336 lines (282 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<style type="text/css">
@import url("./mod/flottes/style.css");
</style>
<?php
/***************************************************************************
* filename : function_flottes.php
* desc. : 1.0.3
* Link : https://www.ogsteam.eu
* Author : Conrad des Dragons
* created :
* modified : AirBAT
***************************************************************************/
//secu
if (!defined('IN_SPYOGAME')) {
die("Hacking attempt");
}
// fin de secu
// insertion du langage flotte
require_once("./mod/flottes/flottes_lang.php");
// Fonctions
function mod_flottes_get_ship($ship, $add = false)
{
global $user_data, $mod_flottes_lang, $db, $members_data, $table_prefix;
$user_empire = user_get_empire($user_data["user_id"]);
$user_building = $user_empire["building"];
// FLOTTESTOEMPIRE ajout de $table_prefix dans global
$lines = array();
$ship = stripcslashes($ship);
$ship = str_replace("PT-5", "PT", $ship);
$ship = str_replace("GT-50", "GT", $ship);
$lines = explode(chr(10), $ship);
$datei = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$OK = false;
$out = "";
$get_ship = array("PT" => 0, "GT" => 0, "CLE" => 0, "CLO" => 0, "CR" => 0, "VB" => 0, "VC" => 0, "REC" => 0, "SE" => 0, "BMD" => 0, "DST" => 0, "EDLM" => 0, "TRA" => 0, "SAT" => 0);
foreach ($lines as $line) {
$arr = array();
$line = trim($line);
if (strpos($line, "Type de vaisseau") === 0) {
$OK = true;
continue;
}
// On enlève le séparateur décimal
$line = str_replace('.', '', $line);
if ($OK && preg_match("/^([\D\s]+)\s+(\d+)/", $line, $arr)) {
foreach ($mod_flottes_lang as $key => $name) {
if ($name == trim($arr[1])) {
$get_ship[$key] = $arr[2];
break;
}
}
continue;
}
}
if ($get_ship["SAT"] == 0) {
$get_ship["SAT"] = $user_building[$_POST['planet_id']]["Sat"];
}
if ($add) {
if (isset($_POST['planet_id'])) {
$request = "DELETE FROM " . TABLE_MOD_FLOTTES . " WHERE user_id=" . $user_data['user_id'] . " AND planet_id=" . $_POST['planet_id'];
if (!($result = $db->sql_query($request))) {
$out = "Erreur de base de donnée";
echo $out;
} else $result = $db->sql_query($request);
} else {
$out = "selectionnez une planète.";
}
} else {
$request = "UPDATE " . TABLE_MOD_FLOTTES . " SET " . TABLE_MOD_FLOTTES . ".planet_id=(SELECT " . TABLE_USER_BUILDING . ".planet_id FROM " . TABLE_USER_BUILDING . " WHERE ";
$request .= TABLE_USER_BUILDING . ".planet_name=" . TABLE_MOD_FLOTTES . ".planet_name AND ";
$request .= TABLE_USER_BUILDING . ".coordinates=" . TABLE_MOD_FLOTTES . ".coordinates AND ";
$request .= TABLE_USER_BUILDING . ".user_id=" . TABLE_MOD_FLOTTES . ".user_id )";
$request .= " WHERE " . TABLE_MOD_FLOTTES . ".user_id=" . $user_data['user_id'] . " ";
if (!($result = $db->sql_query($request))) {
$out = "Erreur de base de donnée";
echo $out;
}
$sql = "SELECT planet_id from " . TABLE_MOD_FLOTTES . " WHERE planet_id=" . $_POST['planet_id'] . " AND user_id=" . $user_data['user_id'];
if (!($result = $db->sql_query($sql))) {
$out .= "selectionnez une planète.";
} else {
$result = $db->sql_query($sql);
$nameid = $db->sql_numrows($result);
if ($nameid == 1) {
$request = "UPDATE " . TABLE_MOD_FLOTTES . " SET";
foreach ($get_ship as $key => $value) {
$request .= " `" . $key . "`=" . $value . ", ";
}
if (isset($user_building[$_POST['planet_id']]["planet_name"]) & $user_building[$_POST['planet_id']]["planet_name"] != '') {
$nom_planet = $user_building[$_POST['planet_id']]["planet_name"];
$coord_planet = $user_building[$_POST['planet_id']]["coordinates"];
} else {
$nom_planet = $_POST['planet_id'];
$coord_planet = "0";
}
if ($coord_planet == "" or $coord_planet == NULL) $coord_planet = "0";
$request .= " `planet_name`='" . $nom_planet . "', ";
$request .= " `coordinates`='" . $coord_planet . "', ";
$request .= " `date`=" . $datei;
$request .= " WHERE user_id=" . $user_data['user_id'];
$request .= " AND planet_id=" . $_POST['planet_id'];
$db->sql_query($request);
$request = "DELETE FROM " . TABLE_MOD_FLOTTES . " WHERE planet_id=0";
$db->sql_query($request);
} else {
$request = "INSERT INTO " . TABLE_MOD_FLOTTES . " (user_id, planet_id) VALUES (" . $user_data['user_id'] . ", " . $_POST['planet_id'] . " )";
if (!($result = $db->sql_query($request))) {
$out = "selectionnez une planète.";
} else {
if (isset($user_building[$_POST['planet_id']]["planet_name"]) & $user_building[$_POST['planet_id']]["planet_name"] != '') {
$nom_planet = $user_building[$_POST['planet_id']]["planet_name"];
$coord_planet = $user_building[$_POST['planet_id']]["coordinates"];
} else {
$nom_planet = $_POST['planet_id'];
$coord_planet = "0";
}
if ($coord_planet == "" or $coord_planet == NULL) $coord_planet = "0";
$request = "UPDATE " . TABLE_MOD_FLOTTES . " SET planet_name ='" . $nom_planet . "'";
$request .= ", coordinates='" . $coord_planet . "'";
$request .= ", date=" . $datei;
$request .= " WHERE user_id=" . $user_data['user_id'];
$request .= " AND planet_id=" . $_POST['planet_id'];
$db->sql_query($request);
$request = "UPDATE " . TABLE_MOD_FLOTTES . " SET";
foreach ($get_ship as $key => $value) {
$request .= " `" . $key . "`=" . $value . ", ";
}
$request = substr($request, 0, strlen($request) - 2);
$request .= " WHERE user_id=" . $user_data['user_id'];
$request .= " AND planet_id=" . $_POST['planet_id'];
$db->sql_query($request);
$request = "DELETE FROM " . TABLE_MOD_FLOTTES . " WHERE planet_id=0";
$db->sql_query($request);
}
}
}
}
}
function buttons_bar($subaction)
{
global $user_data;
// mise en place de la banniere
echo '<table class="flottes_h">';
echo '<tr>';
echo '<td class="flottes_h">Mod Flottes</td>';
echo '</tr>';
echo '</table>';
// mise en place du menu
echo '<table class="menu">';
echo '<tr align="center">';
// ------------------------
// BOUTON Flottes
if (($subaction == "flottes") || (!isset($subaction))) {
echo '<td class="menu_on" width="12.5%">Flottes</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=flottes\';">' . "\n";
echo 'Flottes' . "\n";
echo '</td>' . "\n";
}
// ------------------------
// BOUTON BBCode
if ($subaction == "bbcode") {
echo '<td class="menu_on" width="12.5%">Export BBCode</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=bbcode\';">' . "\n";
echo 'Export BBCode' . "\n";
echo '</td>' . "\n";
}
// ------------------------
// BOUTON BBCode 2
if ($subaction == "bbcode2") {
echo '<td class="menu_on" width="12.5%">Export BBCode Détaillé</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=bbcode2\';">' . "\n";
echo 'Export BBCode Détaillé' . "\n";
echo '</td>' . "\n";
}
// ------------------------
// BOUTON MyBB
if ($subaction == "mybb") {
echo '<td class="menu_on" width="12.5%">Export MyBB Détaillé</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=mybb\';">' . "\n";
echo 'Export MyBB Détaillé' . "\n";
echo '</td>' . "\n";
}
// ------------------------
// BOUTON Graphe
if ($subaction == "graphe") {
echo '<td class="menu_on" width="12.5%">Graphe de répartition de flotte</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=graphe\';">' . "\n";
echo 'Graphe de répartition de flotte' . "\n";
echo '</td>' . "\n";
}
// ------------------------
// BOUTON Admin
if ($user_data["user_admin"] == 1) {
if ($subaction == "admin") {
echo '<td class="menu_on" width="12.5%">Administration</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=admin\';">' . "\n";
echo 'Administration' . "\n";
echo '</td>' . "\n";
}
}
// ------------------------
// BOUTON Xtense2
if ($user_data["user_admin"] == 1) {
if ($subaction == "xtense2") {
echo '<td class="menu_on" width="12.5%">Xtense2</td>' . "\n";
} else {
echo '<td class="menu_off" width="12.5%" onclick="window.location = \'index.php?action=flottes&subaction=xtense2\';">' . "\n";
echo 'Xtense2' . "\n";
echo '</td>' . "\n";
}
}
echo '</tr>' . "\n";
echo '</table>' . "\n";
}
// fin du menu
// ------------------------
function sauve_color($TCF, $TCFO, $TCFU, $TCFP, $TCFA, $TCB1, $TCB2, $TCB3, $TCB4, $TCB5, $TGA, $TPLA)
{
global $db;
$request = "UPDATE " . TABLE_MOD_FLOTTES_ADM . " SET color_fleet='" . $TCF . "', color_fleet_old='" . $TCFO . "', color_fleet_user='" . $TCFU . "', ";
$request .= "color_fleet_point='" . $TCFP . "', color_fleet_alli='" . $TCFA . "', ";
$request .= "color_bbc_1='" . $TCB1 . "', color_bbc_2='" . $TCB2 . "', color_bbc_3='" . $TCB3 . "', color_bbc_4='" . $TCB4 . "', color_bbc_5='" . $TCB5 . "', ";
$request .= "GAME='" . $TGA . "', nbpla='" . $TPLA . "' ";
$request .= "WHERE group_name='mod_flottes'";
if ($result = $db->sql_query($request)) {
$out = "Couleurs mises à jour";
} else {
$out = "selectionnez une planète.";
}
echo $out;
}
function compte_planet($iduser, $nbpla, $game)
{
// FLOTTESTOEMPIRE ajout de $table_prefix dans global
global $user_data, $mod_flottes_lang, $db, $members_data, $table_prefix, $nb_planet;
if (!isset($nbpla) || $nbpla == 0) $nbpla = $nb_planet;
$request = "select planet_id ";
$request .= " from " . TABLE_USER_BUILDING;
$request .= " where user_id = " . $iduser;
$request .= " and planet_id < 299 ";
$request .= " order by planet_id";
$result = $db->sql_query($request);
$nbplanet = $db->sql_numrows($result);
if ($nbplanet < $nbpla) {
$page = 0;
} elseif ($game == 'OGAME') {
$page = 1;
} else {
$page = floor($nbplanet / $nbpla);
}
$nbpla++;
$col = floor($nbpla / ($page + 1));
$affpla = array($nbplanet, $page, $col, $nbpla);
return $affpla;
}
function active_xtense2($act)
{
global $db, $table_prefix;
define("TABLE_XTENSE_CALLBACKS", $table_prefix . "xtense_callbacks");
define("TABLE_MOD", $table_prefix . "mod");
if ($act == "active") {
$q_modid = 'SELECT `id` FROM `' . TABLE_MOD . '` WHERE `title`="Flottes" LIMIT 1';
$r_modid = $db->sql_query($q_modid);
$r_modid1 = $db->sql_fetch_row($r_modid);
$mod_id = $r_modid1[0];
$db->sql_query("INSERT INTO " . TABLE_XTENSE_CALLBACKS . " (mod_id, function, type, active) VALUES ('$mod_id', 'flottes_import_fleet', 'fleet', 1)");
}
if ($act == "desactive") {
$q_modid = 'SELECT `id` FROM `' . TABLE_MOD . '` WHERE `title`="Flottes" LIMIT 1';
$r_modid = $db->sql_query($q_modid);
$r_modid1 = $db->sql_fetch_row($r_modid);
$mod_id = $r_modid1[0];
$db->sql_query("DELETE FROM " . TABLE_XTENSE_CALLBACKS . " WHERE `mod_id`='$mod_id'");
}
}
?>