Code Duplication    Length = 27-31 lines in 2 locations

api/functions.php 2 locations

@@ 515-541 (lines=27) @@
512
                    WHERE inactif = %i AND id IN %ls", "0", $array_items
513
                );
514
                $x = 0;
515
                foreach ($response as $data)
516
                {
517
                    // build the path to the Item
518
                    $path = "";
519
                    $arbo = $tree->getPath($data['id_tree'], true);
520
                    foreach ($arbo as $elem) {
521
                        if (empty($path)) {
522
                            $path = stripslashes($elem->title);
523
                        } else {
524
                            $path .= " > ".stripslashes($elem->title);
525
                        }
526
                    }
527
528
                    // prepare output
529
                    $json[$x]['id'] = $data['id'];
530
                    $json[$x]['label'] = mb_convert_encoding($data['label'], mb_detect_encoding($data['label']), 'UTF-8');
531
                    $json[$x]['description'] = mb_convert_encoding($data['description'], mb_detect_encoding($data['description']), 'UTF-8');
532
                    $json[$x]['login'] = mb_convert_encoding($data['login'], mb_detect_encoding($data['login']), 'UTF-8');
533
                    $json[$x]['email'] = mb_convert_encoding($data['email'], mb_detect_encoding($data['email']), 'UTF-8');
534
                    $json[$x]['url'] = mb_convert_encoding($data['url'], mb_detect_encoding($data['url']), 'UTF-8');
535
                    $crypt_pw = cryption($data['pw'], "", "decrypt");
536
                    $json[$x]['pw'] = $crypt_pw['string'];
537
                    $json[$x]['folder_id'] = $data['id_tree'];
538
                    $json[$x]['path'] = $path;
539
540
                    $x++;
541
                }
542
            }
543
544
            if (isset($json) && $json) {
@@ 324-354 (lines=31) @@
321
                    WHERE inactif='0' AND ".$condition, $condition_value
322
                );
323
                $x = 0;
324
                foreach ($response as $data)
325
                {
326
                    // build the path to the Item
327
                    $path = "";
328
                    $arbo = $tree->getPath($data['id_tree'], true);
329
                    foreach ($arbo as $elem) {
330
                        if (empty($path)) {
331
                            $path = stripslashes($elem->title);
332
                        } else {
333
                            $path .= " > ".stripslashes($elem->title);
334
                        }
335
                    }
336
337
                    // prepare output
338
                    $json[$x]['id'] = $data['id'];
339
                    $json[$x]['label'] = mb_convert_encoding($data['label'], mb_detect_encoding($data['label']), 'UTF-8');
340
                    $json[$x]['description'] = mb_convert_encoding($data['description'], mb_detect_encoding($data['description']), 'UTF-8');
341
                    $json[$x]['login'] = mb_convert_encoding($data['login'], mb_detect_encoding($data['login']), 'UTF-8');
342
                    $json[$x]['email'] = mb_convert_encoding($data['email'], mb_detect_encoding($data['email']), 'UTF-8');
343
                    $json[$x]['url'] = mb_convert_encoding($data['url'], mb_detect_encoding($data['url']), 'UTF-8');
344
                    $crypt_pw = cryption(
345
                        $data['pw'],
346
                        "",
347
                        "decrypt"
348
                    );
349
                    $json[$x]['pw'] = $crypt_pw['string'];
350
                    $json[$x]['folder_id'] = $data['id_tree'];
351
                    $json[$x]['path'] = $path;
352
353
                    $x++;
354
                }
355
            } else if ($GLOBALS['request'][1] == "userpw") {
356
                /*
357
                * READ USER ITEMS