コード例 #1
0
ファイル: index.php プロジェクト: NIIF/DiscoJuice-Backend
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Allow-Methods: HEAD, GET, OPTIONS, POST, DELETE, PATCH");
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Origin, Accept, Content-Type");
header("Access-Control-Expose-Headers: Authorization, X-Requested-With, Origin, Accept, Content-Type");
$profiling = microtime(true);
error_log("Time START    :     ======> " . (microtime(true) - $profiling));
try {
    $response = null;
    $parameters = null;
    $body = null;
    if (DiscoUtils::route('options', '.*', $parameters)) {
        header('Content-Type: application/json; charset=utf-8');
        exit;
    }
    $store = new DiscoStore();
    $logostore = new DiscoStoreLogos();
    if (DiscoUtils::route('get', '^/$', $parameters, $body)) {
        header('Content-Type: text/plain; charset=utf-8');
        echo "Welcome to DiscoJuice API\n" . "Consult documentation for details about using the API.\n" . "http://discojuice.org";
        exit;
    } else {
        if (DiscoUtils::route('get', '^/feeds$', $parameters, $body)) {
            $list = $store->getFeedList();
            $response = Feed::toJSONlist($list);
            // $response = $list;
        } else {
            if (DiscoUtils::route('get', '^/geo$', $parameters, $body)) {
                $geoservice = new GeoService();
                $data = array();
                $clientIP = $_SERVER['REMOTE_ADDR'];
コード例 #2
0
ファイル: pushFeeds.php プロジェクト: NIIF/DiscoJuice-Backend
require dirname(dirname(__FILE__)) . '/lib/autoload.php';
$command = new Commando\Command();
// $command->option()
//     ->describedAs('Command to run: default is update.');
// $command->option('f')
// 	->aka('feed')
// 	->describedAs('The feed identifier to load.');
// $command->option('cache-only')
// 	->boolean()
// 	->describedAs('Do not load metadata, only use existing cache.');
if ($command[0] === 'termcolor') {
    phpterm_demo();
    exit;
}
$feeds = json_decode(file_get_contents(dirname($BASE) . '/etc/feeds.js'), TRUE);
$dj = new DiscoStore();
foreach ($feeds as $key => $feed) {
    $feed['id'] = $key;
    $dj->insertOrUpdateFeed($feed);
    print_r($feed);
}
exit;
$backend = new DiscoJuiceBackend();
if ($command['cache-only']) {
    DiscoUtils::log("Running in cache-only mode");
    $backend->enableCacheOnly(true);
}
DiscoUtils::log("DiscoJuice update script. Now updating metadata.", true);
if ($command['feed']) {
    $backend->updateFeed($command['feed']);
} else {