Code Duplication    Length = 12-12 lines in 2 locations

main/exercise/hotpotatoes.lib.php 2 locations

@@ 339-350 (lines=12) @@
336
function GenerateHpFolder($folder)
337
{
338
    $filelist = array();
339
    if ($dir = @opendir($folder)) {
340
        while (($file = readdir($dir)) !== false) {
341
            if ($file != '.') {
342
                if ($file != '..') {
343
                    $full_name = $folder.'/'.$file;
344
                    if (is_dir($full_name)) {
345
                        $filelist[] = $file;
346
                    }
347
               }
348
            }
349
        }
350
    }
351
    $w = 0;
352
    do {
353
        $name = FillFolderName(mt_rand(1, 99999), 6);
@@ 401-412 (lines=12) @@
398
{
399
    $folder = GetFolderPath($path);
400
    $dflag = 0;
401
    if ($dir = @opendir($folder)) {
402
        while (($file = readdir($dir)) !== false) {
403
            if ($file != '.') {
404
                if ($file != '..') {
405
                    $full_name = $folder.'/'.$file;
406
                    if (is_dir($full_name)) {
407
                        $dflag = 1;    // first directory
408
                    }
409
                }
410
            }
411
        }
412
    }
413
    return $dflag;
414
}
415