function get_all_favicons() { if (Config\get('favicons') == 0) { return array(); } return Database::getInstance('db')->hashtable('favicons')->getAll('feed_id', 'file'); }
function download($url) { if ((bool) Config\get('debug_mode')) { Logger::enable(); } $client = Client::getInstance(); $client->setUserAgent(Config\HTTP_USER_AGENT); $client->enablePassthroughMode(); $client->execute($url); Config\write_debug(); }
function pinboard_add(array $item) { $params = array('auth_token' => Config\get('pinboard_token'), 'format' => 'json', 'url' => $item['url'], 'description' => $item['title'], 'tags' => Config\get('pinboard_tags')); $url = 'https://api.pinboard.in/v1/posts/add?' . http_build_query($params); $client = api_call($url); if ($client !== false) { $response = json_decode($client->getContent(), true); return is_array($response) && $response['result_code'] === 'done'; } return false; }
<?php require __DIR__ . '/common.php'; use JsonRPC\Server; use PicoFeed\PicoFeedException; use Model\Config; $server = new Server(); $server->authentication(array(Config\get('username') => Config\get('api_token'))); // Get version $server->register('app.version', function () { return array('version' => APP_VERSION); }); // Get all feeds $server->register('feed.list', function () { return Model\Feed\get_all(); }); // Get one feed $server->register('feed.info', function ($feed_id) { return Model\Feed\get($feed_id); }); // Add a new feed $server->register('feed.create', function ($url) { try { $result = Model\Feed\create($url); } catch (PicoFeedException $e) { $result = false; } catch (UnexpectedValueException $e) { $result = false; } Model\Config\write_debug(); return $result;
function get_all_favicons() { if (Config\get('favicons') == 0) { return array(); } $result = Database::getInstance('db')->table('favicons')->columns('favicons_feeds.feed_id', 'favicons.type', 'favicons.hash')->join('favicons_feeds', 'favicon_id', 'id')->findAll(); $map = array(); foreach ($result as $row) { $map[$row['feed_id']] = array("type" => $row['type'], "hash" => $row['hash']); } return $map; }
function download_content_id($item_id) { $item = get($item_id); $content = download_content_url($item['url']); if (!empty($content)) { if (!Config\get('nocontent')) { // Save content Database::getInstance('db')->table('items')->eq('id', $item['id'])->save(array('content' => $content)); } Config\write_debug(); return array('result' => true, 'content' => $content); } Config\write_debug(); return array('result' => false, 'content' => ''); }