Example #1
0
function get_files_of_type_in_directory($directory, $filetypes)
{
    $files = get_files_in_directory($directory);
    // damn php closures are ugly :D
    $filtered = array_filter($files, function ($filename) use($filetypes) {
        $path = "channels/{$filename}";
        return in_array(pathinfo($path)["extension"], $filetypes);
    });
    $result = [];
    foreach ($filtered as $file) {
        array_push($result, $file);
    }
    return $result;
}
Example #2
0
        $diff[$hist] = $histogram;
    }
    $smarty->assign("diff", $diff);
    foreach (array("", "1", "2") as $cvs_id) {
        $cvs_export = array();
        foreach ($xml->{"histogram" . $cvs_id}->{"rgb"} as $rgb) {
            $add = array();
            $add['r'] = $rgb->attributes()->{"r"};
            $add['g'] = $rgb->attributes()->{"g"};
            $add['b'] = $rgb->attributes()->{"b"};
            $cvs_export[] = $add;
        }
        $smarty->assign("cvs_export" . $cvs_id, $cvs_export);
    }
    $profiles = array();
    foreach (get_files_in_directory($config["profiles"], "xml") as $profile_file) {
        $profiles[] = $profile_file;
    }
    $smarty->assign("cputime", (string) $xml->{"cputime"});
    $smarty->assign("profiles", $profiles);
    $smarty->assign('template', 'result.tpl');
    $smarty->assign('selected', 'compare');
    $smarty->display('layout.tpl');
    // $smarty->display('result.tpl');
} else {
    if ($op == "jhove" && count($files) == 1) {
        $file1 = escapeshellcmd($config['destination'] . $files[0]);
        header("content-type: text/xml");
        $result = jhove($file1);
        //header("content-type: text/xml");
        print $result->asXML();