Beispiel #1
0
            $destdir = $destdir . '/';
        }
    }
}
// var_dump ($idlist);
// print "\n";
$countor = 0;
foreach ($idlist as $id) {
    $radioinfo = analyze_radiomedia($id);
    print "start id : {$id}\n";
    logwrite("start id : {$id}");
    if ($radioinfo === false) {
        logwrite("Analyze_radiomedia failed id : {$id} error : " . curl_error($ch));
        continue;
    }
    $finename = build_filename($radioinfo, $id);
    if ($destdir) {
        $finename = $destdir . $finename;
    }
    if (file_exists($finename)) {
        if (filesize($finename) < 1024) {
            print "{$finename} is exists. but too small. Overwrite.  filesize : " . filesize($finename) . "\n";
        } else {
            print "{$finename} is exists. skip this file. filesize : " . filesize($finename) . "\n";
            continue;
        }
    }
    downloadfiles($radioinfo['moviePath']['pc'], $finename);
    $countor++;
}
?>
Beispiel #2
0
}
$app->get('/', function ($request, $response, $args) {
    return $this->renderer->render($response, 'index.phtml', $args);
});
$app->get('/about', function ($request, $response, $args) {
    return $this->renderer->render($response, 'about.phtml', $args);
});
$app->get('/texts', function ($request, $response, $args) {
    return $response->withHeader('Content-type', 'application/json')->write(file_get_contents('./texts/texts.json'));
});
$app->get('/randomtext', function ($request, $response, $args) {
    $all_texts = json_decode(file_get_contents('./texts/texts.json'), true);
    // pick a random text, block
    // but always have an offset of 0
    $keys = array_keys($all_texts);
    $text_key = $keys[array_rand($keys)];
    $text = $all_texts[$text_key];
    $block = rand(1, $text['blocks'] - 1);
    $content = file_get_contents(build_filename($text_key, $block));
    return $response->withHeader('Content-type', 'application/json')->write(json_encode(array('text' => $text_key, 'block' => $block, 'offset' => 0, 'content' => $content)));
});
$app->get('/text/{text}/{block}', function ($request, $response, $args) {
    $text = $request->getAttribute('text');
    $block = $request->getAttribute('block');
    $file = build_filename($text, $block);
    if (strpos($text, '.') !== false || strpos($block, '.') !== false || !file_exists($file)) {
        return $response->withStatus(405);
    }
    $content = file_get_contents($file);
    return $response->withHeader('Content-type', 'application/json')->write(json_encode(compact('content')));
});