Beispiel #1
0
    forbidden();
}
$db = preg_replace('/[^a-z0-9]/i', '', $db);
try {
    $tt = @Tyrant::connect("/tmp/{$db}.sock", 0);
} catch (Tyrant_Exception $e) {
    include "../lib/spyc.php";
    if (!file_exists("../{$db}.yaml")) {
        forbidden('genome does not exist');
    }
    $genome_config = Spyc::YAMLLoad("../{$db}.yaml");
    try {
        if (!is_array($genome_config['output_tch'])) {
            throw new Exception("ttserver should be local");
        }
        $tt = @Tyrant::connect($genome_config['output_tch'][0], $genome_config['output_tch'][1]);
    } catch (Exception $e) {
        forbidden('Could not connect to ttserver');
    }
}
header('Content-Type: ' . (substr($f, -4) == ".png" ? 'image/png' : 'application/json'));
$value = $tt[$f];
if ($value === null) {
    header('HTTP/1.1 404 Not Found');
} else {
    header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 3) . " GMT");
    header('Cache-Control: public, max-age=10800');
    if ($value == '-') {
        echo $tt['.null'];
    } else {
        echo $value;
Beispiel #2
0
$genome_config = Spyc::YAMLLoad("../{$db}.yaml");
$ucsc_config = Spyc::YAMLLoad("../ucsc.yaml");
$serve_tracks = array();
foreach ($genome_config['serve_tracks'] as $trk) {
    $serve_tracks[$trk['n']] = true;
}
$query = "db={$db}&position={$pos}";
$tt = NULL;
if (isset($genome_config['search_tch'])) {
    include '../lib/Tyrant.php';
    try {
        if (is_array($genome_config['search_tch'])) {
            $tt = @Tyrant::connect($genome_config['search_tch'][0], $genome_config['search_tch'][1]);
        } else {
            $sock = preg_replace('/[^a-z0-9.]|\\.tch$/i', '', $genome_config['search_tch']);
            $tt = @Tyrant::connect("/tmp/{$sock}.sock", 0);
        }
        $value = $tt[$query];
        if ($value !== NULL) {
            echo gzinflate($value);
            exit;
        }
    } catch (Exception $e) {
        $tt = NULL;
    }
}
$url = "{$ucsc_config['browser_hosts']['local']}{$ucsc_config['browser_urls']['tracks']}?{$query}";
if (function_exists('curl_init')) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);