Code Duplication    Length = 68-68 lines in 2 locations

install/cli-install.php 1 location

@@ 889-956 (lines=68) @@
886
    }
887
}
888
889
if (!function_exists('parse_docblock')) {
890
    function parse_docblock($element_dir, $filename)
891
    {
892
        $params = array();
893
        $fullpath = $element_dir . '/' . $filename;
894
        if (is_readable($fullpath)) {
895
            $tpl = @fopen($fullpath, "r");
896
            if ($tpl) {
897
                $params['filename'] = $filename;
898
                $docblock_start_found = false;
899
                $name_found = false;
900
                $description_found = false;
901
902
                while (!feof($tpl)) {
903
                    $line = fgets($tpl);
904
                    if (!$docblock_start_found) {
905
                        // find docblock start
906
                        if (strpos($line, '/**') !== false) {
907
                            $docblock_start_found = true;
908
                        }
909
                        continue;
910
                    } elseif (!$name_found) {
911
                        // find name
912
                        $ma = null;
913
                        if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
914
                            $params['name'] = trim($ma[1]);
915
                            $name_found = !empty($params['name']);
916
                        }
917
                        continue;
918
                    } elseif (!$description_found) {
919
                        // find description
920
                        $ma = null;
921
                        if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
922
                            $params['description'] = trim($ma[1]);
923
                            $description_found = !empty($params['description']);
924
                        }
925
                        continue;
926
                    } else {
927
                        $ma = null;
928
                        if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
929
                            $param = trim($ma[1]);
930
                            $val = trim($ma[2]);
931
                            if (!empty($param) && !empty($val)) {
932
                                if ($param == 'internal') {
933
                                    $ma = null;
934
                                    if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
935
                                        $param = trim($ma[1]);
936
                                        $val = trim($ma[2]);
937
                                    }
938
                                    //if($val !== '0' && (empty($param) || empty($val))) {
939
                                    if (empty($param)) {
940
                                        continue;
941
                                    }
942
                                }
943
                                $params[$param] = $val;
944
                            }
945
                        } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
946
                            break;
947
                        }
948
                    }
949
                }
950
                @fclose($tpl);
951
            }
952
        }
953
954
        return $params;
955
    }
956
}
957
958
include $path . "src/sqlParser.class.php";
959
$sqlParser = new SqlParser($database_server, $database_user, $database_password, str_replace("`", "", $dbase),

install/src/functions.php 1 location

@@ 468-535 (lines=68) @@
465
    }
466
}
467
468
if (!function_exists('parse_docblock')) {
469
    function parse_docblock($element_dir, $filename)
470
    {
471
        $params = array();
472
        $fullpath = $element_dir . '/' . $filename;
473
        if (is_readable($fullpath)) {
474
            $tpl = @fopen($fullpath, "r");
475
            if ($tpl) {
476
                $params['filename'] = $filename;
477
                $docblock_start_found = false;
478
                $name_found = false;
479
                $description_found = false;
480
481
                while (!feof($tpl)) {
482
                    $line = fgets($tpl);
483
                    if (!$docblock_start_found) {
484
                        // find docblock start
485
                        if (strpos($line, '/**') !== false) {
486
                            $docblock_start_found = true;
487
                        }
488
                        continue;
489
                    } elseif (!$name_found) {
490
                        // find name
491
                        $ma = null;
492
                        if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
493
                            $params['name'] = trim($ma[1]);
494
                            $name_found = !empty($params['name']);
495
                        }
496
                        continue;
497
                    } elseif (!$description_found) {
498
                        // find description
499
                        $ma = null;
500
                        if (preg_match("/^\s+\*\s+(.+)/", $line, $ma)) {
501
                            $params['description'] = trim($ma[1]);
502
                            $description_found = !empty($params['description']);
503
                        }
504
                        continue;
505
                    } else {
506
                        $ma = null;
507
                        if (preg_match("/^\s+\*\s+\@([^\s]+)\s+(.+)/", $line, $ma)) {
508
                            $param = trim($ma[1]);
509
                            $val = trim($ma[2]);
510
                            if (!empty($param) && !empty($val)) {
511
                                if ($param == 'internal') {
512
                                    $ma = null;
513
                                    if (preg_match("/\@([^\s]+)\s+(.+)/", $val, $ma)) {
514
                                        $param = trim($ma[1]);
515
                                        $val = trim($ma[2]);
516
                                    }
517
                                    //if($val !== '0' && (empty($param) || empty($val))) {
518
                                    if (empty($param)) {
519
                                        continue;
520
                                    }
521
                                }
522
                                $params[$param] = $val;
523
                            }
524
                        } elseif (preg_match("/^\s*\*\/\s*$/", $line)) {
525
                            break;
526
                        }
527
                    }
528
                }
529
                @fclose($tpl);
530
            }
531
        }
532
533
        return $params;
534
    }
535
}
536
537
if (!function_exists('parseProperties')) {
538
    /**