Code Duplication    Length = 17-17 lines in 2 locations

main/work/work.lib.php 1 location

@@ 959-975 (lines=17) @@
956
 * @author  Julio Montoya
957
 * @version April 2008
958
 */
959
function directory_to_array($directory)
960
{
961
    $array_items = array();
962
    if ($handle = @opendir($directory)) {
963
        while (false !== ($file = readdir($handle))) {
964
            if ($file != '.' && $file != '..') {
965
                if (is_dir($directory. '/' . $file)) {
966
                    $array_items = array_merge($array_items, directory_to_array($directory. '/' . $file));
967
                    $file = $directory . '/' . $file;
968
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
969
                }
970
            }
971
        }
972
        closedir($handle);
973
    }
974
975
    return $array_items;
976
}
977
978
/**

main/install/install.lib.php 1 location

@@ 440-456 (lines=17) @@
437
 * @param   string  $directory  Full path to a directory
438
 * @return  array   A list of files and dirs in the directory
439
 */
440
function my_directory_to_array($directory)
441
{
442
    $array_items = array();
443
    if ($handle = opendir($directory)) {
444
        while (false !== ($file = readdir($handle))) {
445
            if ($file != "." && $file != "..") {
446
                if (is_dir($directory. "/" . $file)) {
447
                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
448
                    $file = $directory . "/" . $file;
449
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
450
                }
451
            }
452
        }
453
        closedir($handle);
454
    }
455
    return $array_items;
456
}
457
458
/**
459
 * This function returns the value of a parameter from the configuration file