public static function getInstance() { if (self::$instance == NULL) { self::$instance = new FeedCache(); } return self::$instance; }
function handleRequest() { $type = param('q', 'tag'); $outputType = param('f', 'html'); switch ($type) { case 'item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->getItem(param('itemid')); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'download-item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->downloadItem(param('itemid')); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'save-item': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->saveItem(param('itemid'), param('save', 1)); $view = zf_createView($outputType); $view->renderArticle($item); break; case 'summary': //refresh: always from cache $zf_aggregator = new Aggregator(); $item = $zf_aggregator->getItem(param('itemid')); $view = zf_createView($outputType); $view->renderSummary($item); break; case 'channel': //refresh: user defined $zf_aggregator = new Aggregator(); $feed = $zf_aggregator->getPublisherFeed(param('id'), param('mode', ZF_REFRESHMODE == 'automatic' ? 'auto' : 'none'), param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1)); $view = zf_createView($outputType); $view->renderFeed($feed, array('groupbyday' => false, 'decoration' => int_param('decoration'), 'summary' => param('sum', 1) == 1)); break; case 'tag': //refresh: always auto refresh for tag view // if html output & sorted by feed, trim every single item // according to subcription's settings $sort = param('sort', ZF_SORT); if ($sort == 'feed' && strstr($outputType, 'html')) { $groupbyday = false; $aggregate = false; } else { // otherwise just aggregate in a single feed $groupbyday = true; $aggregate = true; } $zf_aggregator = new Aggregator(); $tag = param('tag', ZF_HOMETAG); $feeds = $zf_aggregator->getFeedsForTag($tag, $aggregate, $trim = param('trim', 'auto'), int_param('onlynew', ZF_ONLYNEW == 'no' ? 0 : 1)); zf_debugRuntime("before rendering"); $view = zf_createView($outputType); $view->renderFeedList($feeds, array('groupbyday' => $groupbyday, 'summary' => int_param('sum', 1) == 1, 'tag' => $tag)); break; case 'subs': //only JSON $subs = SubscriptionStorage::getInstance()->getSortedActiveSubscriptions(param('tag', '')); if (!headers_sent()) { header('Content-Type: application/json; charset=' . ZF_ENCODING); } echo json_encode($subs, JSON_FORCE_OBJECT); break; case 'tags': $tags = SubscriptionStorage::getInstance()->getTags(); if (!headers_sent()) { header('Content-Type: application/json; charset=' . ZF_ENCODING); } echo json_encode($tags, JSON_FORCE_OBJECT); break; case 'force-refresh': // only internal use // TODO: check API key $sub = SubscriptionStorage::getInstance()->getSubscription(param('id')); FeedCache::getInstance()->updateSingle($sub->source); echo $sub->source->title . ' DONE. '; break; case 'refresh-all': $subs = SubscriptionStorage::getInstance()->getActiveSubscriptions(param('tag', '')); FeedCache::getInstance()->update($subs); echo ' DONE. '; break; } }
public function __construct() { $this->cache = FeedCache::getInstance(); }
<!DOCTYPE html> <html> <head> <title>ZebraFeeds jobs</title> </head> <body> <?php require_once __DIR__ . '/../init.php'; if ($_GET['key'] != md5(ZF_ADMINNAME . ZF_ADMINPASS)) { echo "No authorization<br/>"; exit; } $subs = SubscriptionStorage::getInstance()->getActiveSubscriptions(); FeedCache::getInstance()->update($subs, 'auto'); echo 'complete'; ?> </body> </html>
$fvideo = 'videos.limit(' . $limitvideo . ').type(uploaded).fields(name,source,description,picture,id),'; } else { $fvideo = ''; } if ($showevents == true) { $events = 'events.limit(6).fields(name,start_time,location,id,description),'; } else { $events = ''; } if ($showcomments == true) { $fcomments = 'comments.limit(' . $totalcomments . ').summary(true),'; } else { $fcomments = ''; } $url = 'https://graph.facebook.com/v2.0/' . $user . '?fields=' . $albums . 'about,' . $events . 'hours,' . $fvideo . 'username,website,company_overview,phone,description,mission,location,name,likes,category_list,picture,category,parking,cover,' . $newstype . '.limit(' . $feeditems . ').fields(' . $fcomments . 'name,object_id,description,message,type,link,caption,id,created_time,full_picture,source,picture,status_type,story,likes.limit(1).summary(true))&locale=' . $lang . '&access_token=' . $tokenID . '|' . $tokenSECRET; $feed_cache = new FeedCache('./cache/' . $user . '.json', $url, $cachetime); $profile = json_decode($feed_cache->get_data(), true); if ($profile == '') { echo 'No facebook feed !'; exit; } if (isset($profile['error'])) { echo $profile['error']['message']; exit; } /** * Make clickable links from URLs in text. */ function _make_url_clickable_cb($matches) { $ret = '';
case 'subscriptions': include 'includes/subscriptions.php'; break; case 'addnew': include 'includes/addnewfeed.php'; break; case 'config': include 'includes/changeconfig.php'; break; case 'compact': FeedCache::getInstance()->compact(); echo '<div id="core"><h3>Compact</h3>'; echo 'Cache compacted</div>'; break; case 'flush': FeedCache::getInstance()->flush(); echo '<div id="core"><h3>Clean up</h3>'; echo "Flushed cache"; echo '<br/><br/></div>'; break; case 'store': Header('Content-Type: text/html; charset=' . ZF_ENCODING); $storage = SubscriptionStorage::getInstance(); $id = $_POST['id']; $sub = $storage->getSubscription($id); if ($sub) { $sub->title = $_POST['title']; $sub->xmlurl = $_POST['xmlurl']; $sub->description = $_POST['description']; $sub->position = $_POST['position']; $sub->shownItems = $_POST['shownitems'];