function scan_directory()
{
    global $suite, $total_tests, $total_failures, $testRunner;
    $d = opendir(".");
    while ($entry = readdir($d)) {
        if ($entry == "." || $entry == "..") {
            /** ignore these directories **/
        } else {
            if (is_dir($entry)) {
                chdir($entry);
                scan_directory();
                chdir("..");
            } else {
                if (preg_match("/^[T|t]est/", $entry) && (preg_match("/[.]php3?\$/", $entry) || preg_match("/[.]inc\$/", $entry))) {
                    if (!defined("OPT_BE_BRIEF")) {
                        print "Requiring file ... {$entry}<br>\n";
                    }
                    require_once $entry;
                    // because we run into memory problems if we include
                    // all files and then run the tests, we run the test suite
                    // after each include.
                    $result = $testRunner->run($suite);
                    mkdb_check_did_db_fail_calls();
                    $total_tests += $result->countTests();
                    $total_failures += $result->countFailures();
                    unset_global('queries');
                    $result = '';
                    $suite = new TestSuite();
                }
            }
        }
    }
    closedir($d);
}
Example #2
0
function scan_directory($strDir)
{
    global $arrDone;
    $arrFiles = scandir($strDir);
    $string = "";
    var_dump($strDir);
    foreach ($arrFiles as $val) {
        //var_dump($val);
        if ($val == "." || $val == ".." || $val == "" || $val == "/") {
            continue;
        }
        if (is_dir($strDir . '/' . $val)) {
            $string .= scan_directory($strDir . '/' . $val);
        } else {
            if (in_array($strDir . '/' . $val, $arrDone)) {
                continue;
            } else {
                $arrDone[] = $strDir . '/' . $val;
            }
            var_dump($strDir . '/' . $val);
            $string .= "/* " . $strDir . '/' . $val . " */ \n" . file_get_contents($strDir . '/' . $val);
        }
    }
    return $string;
}
/**
* Recursive directory scanner
*
* param path - str: the path to scan with no trailing slash
* param allowed_filetypes  arr: mp3, ogg etc
* param media_scanner str: the media scanner object
*/
function scan_directory($path, $allowed_filetypes, $media_scanner, $id3_scanner)
{
    $dp = opendir($path);
    while ($filename = readdir($dp)) {
        //create the full pathname and streeme pathname
        $full_file_path = $path . '/' . $filename;
        //skip hidden files/folders
        if ($filename[0] === '.') {
            continue;
        }
        //it's a directory, recurse from this level
        if (is_dir($full_file_path)) {
            scan_directory($full_file_path, $allowed_filetypes, $media_scanner, $id3_scanner);
            continue;
        }
        //Stat the file
        $file_stat = stat($full_file_path);
        //is it a usable file?
        if ($file_stat['size'] === 0 || !in_array(strtolower(substr($filename, -3)), $allowed_filetypes)) {
            continue;
        }
        $streeme_path_name = iconv(sfConfig::get('app_filesystem_encoding', 'ISO-8859-1'), 'UTF-8//TRANSLIT', $full_file_path);
        //has it been scanned before?
        if ($media_scanner->is_scanned($streeme_path_name, $file_stat['mtime'])) {
            continue;
        }
        echo "Scanning " . $filename . "\n";
        //get the file information from pathinfo in case we need a substitute song name
        $pinfo = pathinfo($full_file_path);
        /**
         * Pure ugliness - there's 3 possible containers for scraps of ID3 data - they're in order of preference and data integrity
         * Tempted to move this to its own container
         * high    high    medium    none
         * apex -> id3v2 -> id3v1 -> null
         * getID3 is a bit of a tricky lib to work with, but it has great features
         */
        $value = $id3_scanner->analyze($full_file_path);
        $tags = $value['tags'];
        //track number is a nuisance - regress to find the tags
        if (isset($tags['id3v1']['track'][0]) && is_int($tags['id3v1']['track'][0])) {
            //could be an int
            $tracknumber = $tags['id3v1']['track'][0];
        } else {
            if (isset($tags['id3v2']['track_number'][0]) && !empty($tags['id3v2']['track_number'][0])) {
                //or it could be 5/12
                $temp = explode('/', $tags['id3v2']['track_number'][0]);
                $tracknumber = $temp[0];
            } else {
                if (isset($tags['ape']['track_number'][0]) && !empty($tags['ape']['track_number'][0])) {
                    //or it could be 5/12 APEX
                    $temp = explode('/', $tags['ape']['track_number'][0]);
                    $tracknumber = $temp[0];
                } else {
                    //or it's missing
                    $tracknumber = 0;
                }
            }
        }
        $song_array = array();
        $song_array['artist_name'] = StreemeUtil::xmlize_utf8_string(@$tags['ape']['artist'][0] ? @$tags['ape']['artist'][0] : ($tags['id3v2']['artist'][0] ? $tags['id3v2']['artist'][0] : ($tags['id3v1']['artist'][0] ? $tags['id3v1']['artist'][0] : null)));
        $song_array['album_name'] = StreemeUtil::xmlize_utf8_string(@$tags['ape']['album'][0] ? @$tags['ape']['album'][0] : ($tags['id3v2']['album'][0] ? $tags['id3v2']['album'][0] : ($tags['id3v1']['album'][0] ? $tags['id3v1']['album'][0] : null)));
        $song_array['song_name'] = StreemeUtil::xmlize_utf8_string(@@$tags['ape']['title'][0] ? @$tags['ape']['title'][0] : ($tags['id3v2']['title'][0] ? $tags['id3v2']['title'][0] : ($tags['id3v1']['title'][0] ? $tags['id3v1']['title'][0] : $pinfo['filename'])));
        $song_array['song_length'] = $value['playtime_string'];
        $song_array['accurate_length'] = floor((double) $value['playtime_seconds'] * 1000);
        $song_array['genre_name'] = @$tags['ape']['genre'][0] ? @$tags['ape']['genre'][0] : ($tags['id3v2']['genre'] ? $tags['id3v2']['genre'][0] : ($tags['id3v1']['genre'][0] ? $tags['id3v1']['genre'][0] : null));
        $song_array['filesize'] = $file_stat['size'];
        $song_array['bitrate'] = floor((int) $value['audio']['bitrate'] / 1000);
        $song_array['yearpublished'] = @$tags['ape']['year'][0] ? @$tags['ape']['year'][0] : ($tags['id3v2']['year'][0] ? $tags['id3v2']['year'][0] : ($tags['id3v1']['year'][0] ? $tags['id3v1']['year'][0] : null));
        $song_array['tracknumber'] = $tracknumber;
        $song_array['label'] = StreemeUtil::xmlize_utf8_string(@$tags['ape']['label'][0] ? @$tags['ape']['label'][0] : ($tags['id3v2']['label'][0] ? $tags['id3v2']['label'][0] : null));
        //not available in V1
        $song_array['mtime'] = $file_stat['mtime'];
        $song_array['atime'] = $file_stat['atime'];
        $song_array['filename'] = $streeme_path_name;
        unset($value, $tags, $file_stat, $temp);
        //free the RAM used by the temp containters
        /* End Ugliness */
        $media_scanner->add_song($song_array);
    }
    closedir($dp);
}
Example #4
0
$photo_repository = photo_repository(isset($_GET['repo']) ? $_GET['repo'] : 'head');
function scan_directory($directory, $pattern)
{
    $files = array();
    $dh = @opendir($directory);
    if ($dh !== false) {
        while (($filename = readdir($dh)) !== false) {
            if (preg_match($pattern, $filename) && is_file($directory . DIRECTORY_SEPARATOR . $filename)) {
                $files[] = $filename;
            }
        }
        closedir($dh);
    }
    return $files;
}
$allfiles = scan_directory($photo_repository->directory(), "/(jpg|jpeg|png|gif|bmp)/i");
// Returns a javascript expression, suitable for onclick, to perform cropping of a particular photo.
function photo_crop_expression($basename)
{
    global $photo_repository;
    return htmlspecialchars('showPhotoCropModal(this, "' . $photo_repository->name() . '", "' . $basename . '", ' . time() . ')', ENT_QUOTES, 'UTF-8');
}
// TODO: line-height?  "End of photos" text aligns with thumbnail image bottom.
// *** Both div's are overhanging the bottom by the amount taken up by the banner and refresh button!
// *** height=100% could be at issue.
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Assign Racer Photos</title>