Code Duplication    Length = 17-17 lines in 2 locations

main/install/install.lib.php 1 location

@@ 427-443 (lines=17) @@
424
 * @param   string  $directory  Full path to a directory
425
 * @return  array   A list of files and dirs in the directory
426
 */
427
function my_directory_to_array($directory)
428
{
429
    $array_items = array();
430
    if ($handle = opendir($directory)) {
431
        while (false !== ($file = readdir($handle))) {
432
            if ($file != "." && $file != "..") {
433
                if (is_dir($directory. "/" . $file)) {
434
                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
435
                    $file = $directory . "/" . $file;
436
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
437
                }
438
            }
439
        }
440
        closedir($handle);
441
    }
442
    return $array_items;
443
}
444
445
/**
446
 * This function returns the value of a parameter from the configuration file

main/work/work.lib.php 1 location

@@ 981-997 (lines=17) @@
978
 * @author  Julio Montoya Dokeos
979
 * @version April 2008
980
 */
981
function directory_to_array($directory)
982
{
983
    $array_items = array();
984
    if ($handle = @opendir($directory)) {
985
        while (false !== ($file = readdir($handle))) {
986
            if ($file != '.' && $file != '..') {
987
                if (is_dir($directory. '/' . $file)) {
988
                    $array_items = array_merge($array_items, directory_to_array($directory. '/' . $file));
989
                    $file = $directory . '/' . $file;
990
                    $array_items[] = preg_replace("/\/\//si", '/', $file);
991
                }
992
            }
993
        }
994
        closedir($handle);
995
    }
996
    return $array_items;
997
}
998
999
/**
1000
 * Insert into the DB of the course all the directories