Code Duplication    Length = 17-17 lines in 2 locations

main/install/install.lib.php 1 location

@@ 410-426 (lines=17) @@
407
 * @param   string  $directory  Full path to a directory
408
 * @return  array   A list of files and dirs in the directory
409
 */
410
function my_directory_to_array($directory)
411
{
412
    $array_items = array();
413
    if ($handle = opendir($directory)) {
414
        while (false !== ($file = readdir($handle))) {
415
            if ($file != "." && $file != "..") {
416
                if (is_dir($directory. "/" . $file)) {
417
                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
418
                    $file = $directory . "/" . $file;
419
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
420
                }
421
            }
422
        }
423
        closedir($handle);
424
    }
425
    return $array_items;
426
}
427
428
/**
429
 * This function returns the value of a parameter from the configuration file

main/work/work.lib.php 1 location

@@ 1056-1072 (lines=17) @@
1053
 * @author  Julio Montoya Dokeos
1054
 * @version April 2008
1055
 */
1056
function directory_to_array($directory)
1057
{
1058
    $array_items = array();
1059
    if ($handle = @opendir($directory)) {
1060
        while (false !== ($file = readdir($handle))) {
1061
            if ($file != '.' && $file != '..') {
1062
                if (is_dir($directory. '/' . $file)) {
1063
                    $array_items = array_merge($array_items, directory_to_array($directory. '/' . $file));
1064
                    $file = $directory . '/' . $file;
1065
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
1066
                }
1067
            }
1068
        }
1069
        closedir($handle);
1070
    }
1071
    return $array_items;
1072
}
1073
1074
/**
1075
 * Insert into the DB of the course all the directories