Code Duplication    Length = 5-5 lines in 14 locations

install/upgrade_run_2.1.26.php 3 locations

@@ 144-148 (lines=5) @@
141
    "timestamp",
142
    "VARCHAR(50) NOT NULL"
143
);
144
if ($res === false) {
145
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field Timestamp to table Cache! '.mysqli_error($db_link).'!"}]';
146
    mysqli_close($db_link);
147
    exit();
148
}
149
150
// add field url to cache table
151
$res = addColumnIfNotExist(
@@ 156-160 (lines=5) @@
153
    "url",
154
    "VARCHAR(500) NOT NULL DEFAULT '0'"
155
);
156
if ($res === false) {
157
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field Url to table Cache! '.mysqli_error($db_link).'!"}]';
158
    mysqli_close($db_link);
159
    exit();
160
}
161
162
// add field can_manage_all_users to users table
163
$res = addColumnIfNotExist(
@@ 168-172 (lines=5) @@
165
    "can_manage_all_users",
166
    "tinyint(1) NOT NULL DEFAULT '0'"
167
);
168
if ($res === false) {
169
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field can_manage_all_users to table Users! '.mysqli_error($db_link).'!"}]';
170
    mysqli_close($db_link);
171
    exit();
172
}
173
174
// check that API doesn't exist
175
$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT *  FROM `".$pre."users` WHERE id = '".API_USER_ID."'"));

install/upgrade_run_2.1.27.php 11 locations

@@ 209-213 (lines=5) @@
206
    "agses-usercardid",
207
    "VARCHAR(12) NOT NULL DEFAULT '0'"
208
);
209
if ($res === false) {
210
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field agses-usercardid to table Users! '.mysqli_error($db_link).'!"}]';
211
    mysqli_close($db_link);
212
    exit();
213
}
214
215
216
// add field encrypted_data to Categories table
@@ 222-226 (lines=5) @@
219
    "encrypted_data",
220
    "TINYINT(1) NOT NULL DEFAULT '1'"
221
);
222
if ($res === false) {
223
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_data to table categories! '.mysqli_error($db_link).'!"}]';
224
    mysqli_close($db_link);
225
    exit();
226
}
227
228
229
// alter table USERS - user_language
@@ 269-273 (lines=5) @@
266
    "encrypted_data",
267
    "TINYINT(1) NOT NULL DEFAULT '1'"
268
);
269
if ($res === false) {
270
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_data to table CATEGORIES! '.mysqli_error($db_link).'!"}]';
271
    mysqli_close($db_link);
272
    exit();
273
}
274
275
mysqli_query(
276
    $db_link,
@@ 289-293 (lines=5) @@
286
    "encryption_type",
287
    "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
288
);
289
if ($res === false) {
290
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table ITEMS! '.mysqli_error($db_link).'!"}]';
291
    mysqli_close($db_link);
292
    exit();
293
}
294
295
296
// add field encryption_type to categories_items table
@@ 302-306 (lines=5) @@
299
    "encryption_type",
300
    "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
301
);
302
if ($res === false) {
303
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table categories_items! '.mysqli_error($db_link).'!"}]';
304
    mysqli_close($db_link);
305
    exit();
306
}
307
308
309
// add field encryption_type to LOG_ITEMS table
@@ 315-319 (lines=5) @@
312
    "encryption_type",
313
    "VARCHAR(20) NOT NULL DEFAULT 'not_set'"
314
);
315
if ($res === false) {
316
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encryption_type to table LOG_ITEMS! '.mysqli_error($db_link).'!"}]';
317
    mysqli_close($db_link);
318
    exit();
319
}
320
321
322
// add field URL to CACHE table
@@ 328-332 (lines=5) @@
325
    "encryption_type",
326
    "VARCHAR(500) NOT NULL DEFAULT '0'"
327
);
328
if ($res === false) {
329
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field URL to table CACHE! '.mysqli_error($db_link).'!"}]';
330
    mysqli_close($db_link);
331
    exit();
332
}
333
334
335
// add field timestamp to CACHE table
@@ 341-345 (lines=5) @@
338
    "timestamp",
339
    "VARCHAR(50) DEFAULT NULL DEFAULT '0'"
340
);
341
if ($res === false) {
342
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field url to table CACHE! '.mysqli_error($db_link).'!"}]';
343
    mysqli_close($db_link);
344
    exit();
345
}
346
347
348
// add field url to CACHE table
@@ 354-358 (lines=5) @@
351
    "url",
352
    "VARCHAR(500) DEFAULT NULL"
353
);
354
if ($res === false) {
355
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field timestamp to table CACHE! '.mysqli_error($db_link).'!"}]';
356
    mysqli_close($db_link);
357
    exit();
358
}
359
360
//-- generate new DEFUSE key
361
if (!isset($session_tp_defuse_installed) || $session_tp_defuse_installed === false) {
@@ 456-460 (lines=5) @@
453
    "encrypted_psk",
454
    "TEXT NOT NULL"
455
);
456
if ($res === false) {
457
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field encrypted_psk to table Users! '.mysqli_error($db_link).'!"}]';
458
    mysqli_close($db_link);
459
    exit();
460
}
461
462
463
// add new admin setting "manager_move_item"
@@ 624-628 (lines=5) @@
621
    "status",
622
    "VARCHAR(50) NOT NULL DEFAULT '0'"
623
);
624
if ($res === false) {
625
    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field agses-usercardid to table Users! '.mysqli_error($db_link).'!"}]';
626
    mysqli_close($db_link);
627
    exit();
628
}
629
630
// fill in this new field with the current "encryption-file" status
631
$tmp = mysqli_fetch_row(mysqli_query($db_link, "SELECT valeur FROM `".$pre."misc` WHERE type = 'admin' AND intitule = 'enable_attachment_encryption'"));