/** * Build the blog search index * * @param boolean $isCount * @return boolean */ public function buildBlogAction() { $isCount = $this->getRequest()->getParam('pretend'); $index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->feed); require_once 'Ifphp/models/Feeds.php'; $feeds = new Feeds(); $allFeeds = $feeds->getAll(); if ($isCount) { echo $allFeeds->count() . 'feeds would have been added to blog index'; exit; } foreach ($allFeeds as $feed) { $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('pid', $feed->id)); $doc->addField(Zend_Search_Lucene_Field::Text('title', $feed->title)); $doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $feed->siteUrl)); $doc->addField(Zend_Search_Lucene_Field::Text('feedUrl', $feed->url)); $doc->addField(Zend_Search_Lucene_Field::Text('created', $feed->created)); $doc->addField(Zend_Search_Lucene_Field::Keyword('language', $feed->language)); $doc->addField(Zend_Search_Lucene_Field::Keyword('category', $feed->category)); $doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'feed')); $doc->addField(Zend_Search_Lucene_Field::UnStored('description', $feed->description)); $index->addDocument($doc); } // chown(Zend_Registry::getInstance()->search->feed,'www-data'); }
/** * * @param Feed $feed */ public function addFeed(Feed $feed) { $posts = new Posts(); $posts->clear(); $feeds = new Feeds(); $feeds->clear(); }
public function getSubscriptionsScheme($userId) { $rowSet = $this->fetchAll(array('user_id = ?' => $userId)); $feeds = array(); foreach ($rowSet as $row) { $feeds[] = array($row->feed_id, $this->feeds->getTitle($row->feed_id)); } return $feeds; }
public function viewAction() { $categories = new Categories(); $feeds = new Feeds(); $this->view->category = $categories->getBySlug($this->getRequest()->getParam('id')); $this->view->category->feeds = $feeds->getByCategory($this->view->category->id); $posts = new Posts(); $limit = 10; $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1; $this->view->posts = $posts->getByCategory($this->view->category->id, $page, $limit); $total = $posts->getByCategory($this->view->category->id, 1, 0, true)->total; $this->view->paginator = Zend_Paginator::factory($total); $this->view->paginator->setCurrentPageNumber($page); $this->view->paginator->setItemCountPerPage($limit); }
public static function get_instance($sp = null) { if (!isset(self::$instance)) { self::$instance = new Feeds($sp); } return self::$instance; }
/** * feed_list_table() - {@internal Missing Short Description}} * * {@internal Missing Long Description}} */ function feed_list_table() { //Defined in admin panel $feeds = Feeds::get_instance()->getAll(); $j = 0; $table = ''; if (is_array($feeds) && !empty($feeds)) { foreach ($feeds as $this_feed) { $table .= ' <tr id="feed-' . $j . '" class="' . ($j % 2 ? 'alt' : '') . '"> <td class="name-col"><span>' . stripslashes($this_feed['name']) . '</span></td> <td class="url-col"><span>' . $this_feed['feed'] . '</span></td> <!--<td class="cat-col"><span>' . $this_feed['cat'] . '</span></td>--> ' . apply_filters('admin-feeds-infocol', '', $this_feed, $j) . ' <!--<td class="change-col"><a href="feeds.php?change=' . $j . '&action=change" class="change_link">' . _r('Change') . '</a></td>--> <td class="remove-col"><a href="feeds.php?remove=' . $j . '&action=remove">' . _r('Remove') . '</a></td> ' . apply_filters('admin-feeds-actioncol', '', $this_feed, $j) . ' </tr>'; ++$j; } } else { $table = '<tr id="nofeeds"><td>' . _r('You don\'t currently have any feeds. Try <a href="#add_form">adding some</a>.') . '</td></tr>'; } return $table; }
public function viewAction() { $categories = new Categories(); $feeds = new Feeds(); $this->view->category = $categories->getBySlug($this->getRequest()->getParam('id')); $this->view->category->feeds = $feeds->getByCategory($this->view->category->id); $posts = new Posts(); $limit = 5; $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1; $this->view->posts = $posts->getByCategory($this->view->category->id, $page, $limit); $total = $posts->getByCategory($this->view->category->id, 1, 0, true)->total; $this->view->paginator = Zend_Paginator::factory($total); $this->view->paginator->setCurrentPageNumber($page); $this->view->paginator->setItemCountPerPage($limit); $this->view->keywords = implode('', array('ifphp', 'news aggragator', 'support,' . $this->view->categpry->title)); //TODO add paging }
public function viewAction() { if (!$this->_request->id) { $this->_helper->getHelper('Redirector')->goto('view', 'portal'); return; } $this->view->id = $this->_request->id; $this->view->feed = $this->feeds->get($this->view->id); $this->view->group = $this->feeds->getGroup($this->view->feed['group_id']); }
/** * Update feed * * @param string $feed feed url to update */ public function update($feed = null) { $this->_init(); require_once 'Ifphp/models/Feeds.php'; $feeds = new Feeds(); if ($feed) { $feed = $feeds->getBySiteUrl($feed); if (!$feed) { return; } else { $this->updateFeed($feed); } } else { $tfeeds = $feeds->fetchAll($feeds->select()); if ($this->_registry->getRequest()->isPretend()) { echo 'This would update ' . $tfeeds->count() . ' feeds'; exit; } foreach ($tfeeds as $feed) { $this->updateFeed($feed); } } }
/** * Build the blog search index * * @param boolean $isCount * @return boolean */ protected function buildBlogSearch($isCount = false) { $index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->feed); require_once 'Ifphp/models/Feeds.php'; $feeds = new Feeds(); $allFeeds = $feeds->getAll(); if ($isCount) { echo $allFeeds->count() . 'feeds would have been added to blog index'; return true; } foreach ($allFeeds as $feed) { $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('pid', $feed->id)); $doc->addField(Zend_Search_Lucene_Field::Text('title', $feed->title)); $doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $feed->siteUrl)); $doc->addField(Zend_Search_Lucene_Field::Text('feedUrl', $feed->url)); $doc->addField(Zend_Search_Lucene_Field::Text('language', $feed->language)); $doc->addField(Zend_Search_Lucene_Field::Text('category', $feed->category)); $doc->addField(Zend_Search_Lucene_Field::UnStored('description', $feed->description)); $index->addDocument($doc); } chown(Zend_Registry::getInstance()->search['feed'], 'www-data'); return true; }
public function index() { //$feed = \Feeds::make('http://www.swellinfo.com/rss/surf/long-beach-island-new-jersey.xml'); $feed = \Feeds::make('http://www.ndbc.noaa.gov/rss/ndbc_obs_search.php?lat=39.6398N&lon=74.1816W&radius=50'); $items = []; foreach ($feed->get_items() as $id => $item) { $items[$id]['permalink'] = $item->get_permalink(); $items[$id]['title'] = $item->get_title(); $items[$id]['description'] = htmlspecialchars($item->get_description()); $items[$id]['posted'] = $item->get_date('j F Y | g:i a'); } $data = array('title' => $feed->get_title(), 'permalink' => $feed->get_permalink(), 'items' => $items); return $this->response->ok($data); //return \Response::make(); }
public static function run() { if (isset($_GET['test'])) { return self::success_page('xyz'); } if (isset($_GET['test2'])) { return self::sub_page('FAIL'); } if (empty($_POST['url'])) { return self::sub_page(); } try { $_GET['url'] = $_POST['url']; $result = Feeds::get_instance()->add($_POST['url'], $_POST['name']); } catch (Exception $e) { return self::sub_page($e->getMessage()); } return self::success_page($result); }
/** * The default action - show the home page */ public function groupAction() { $user = $this->authenticate(); // group view $feedId = (int) $this->getRequest()->getParam('feedId'); if (!$feedId) { $feedId = Feeds::ROOT_GROUP_ID; } $currentFeed = $this->feeds->get($feedId); // get predessecors $this->view->parents = $this->feeds->listParents($feedId); if ($this->view->parents === null) { $this->view->parents = array(); // XXX error! } $this->view->feed = $currentFeed; $visibleFeeds = $this->getSubscriptions($user['id'], $currentFeed); $this->view->feeds = $visibleFeeds; $this->view->user = $user; }
<?php /* |-------------------------------------------------------------------------- | Routes File |-------------------------------------------------------------------------- | | Here is where you will register all of the routes in an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { $feedA = Feeds::make('http://globalnews.ca/bc/feed', 5); $global = array('title' => $feedA->get_title(), 'permalink' => $feedA->get_permalink(), 'items' => $feedA->get_items(0, 5)); $feedB = Feeds::make('http://business.financialpost.com/feed', 5); $financial = array('title' => $feedB->get_title(), 'permalink' => $feedB->get_permalink(), 'items' => $feedB->get_items(0, 5)); return view('welcome')->withFinancial($financial)->withGlobal($global); }); /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | This route group applies the "web" middleware group to every route | it contains. The "web" middleware group is defined in your HTTP | kernel and includes session state, CSRF protection, and more. | */ Route::group(['middleware' => 'web'], function () { Route::auth();
* @author Feed on Feeds Team * @package Lilina * @version 1.0 * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ /** */ define('LILINA_PATH', dirname(__FILE__)); define('LILINA_INCPATH', LILINA_PATH . '/inc'); define('LILINA_PAGE', 'favicon'); // Hide errors ini_set('display_errors', false); require_once LILINA_INCPATH . '/contrib/simplepie.class.php'; require_once LILINA_INCPATH . '/core/conf.php'; require_once LILINA_INCPATH . '/core/plugin-functions.php'; if (isset($_GET['feed'])) { $feed = Feeds::get_instance()->get($_GET['feed']); if ($feed !== false && $feed['icon'] === true) { $data = new DataHandler(get_option('cachedir')); $data = $data->load($feed['id'] . '.ico'); if ($data !== null) { $icon = unserialize($data); header('Content-Type: ' . $icon['type']); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days echo $icon['body']; die; } } $_GET['i'] = 'default'; } if (!isset($_GET['i'])) {
// news $context['components']['news'] = $text; // list extra boxes $text = ''; if ($anchor = Sections::lookup('extra_boxes')) { // the maximum number of boxes is a global parameter if (!isset($context['site_extra_maximum']) || !$context['site_extra_maximum']) { $context['site_extra_maximum'] = 7; } // articles to be displayed as extra boxes if ($items =& Articles::list_for_anchor_by('publication', $anchor, 0, $context['site_extra_maximum'], 'boxes')) { foreach ($items as $title => $attributes) { $text .= Skin::build_box($title, $attributes['content'], 'boxes', $attributes['id']) . "\n"; } } } // boxes $context['components']['boxes'] = $text; // referrals, if any if (Surfer::is_associate() || isset($context['with_referrals']) && $context['with_referrals'] == 'Y') { $context['components']['referrals'] =& Skin::build_referrals('index.php'); } // // compute navigation information -- $context['navigation'] // // a meta link to a feeding page $context['page_header'] .= "\n" . '<link rel="alternate" href="' . $context['url_to_root'] . Feeds::get_url('rss') . '" title="RSS" type="application/rss+xml" />'; // a meta link to our blogging interface $context['page_header'] .= "\n" . '<link rel="EditURI" href="' . $context['url_to_home'] . $context['url_to_root'] . 'services/describe.php" title="RSD" type="application/rsd+xml" />'; // render the skin render_skin();
static function init($db) { Feeds::$db = $db; }
/** * Gets all feeds and returns as an array * * @return array List of feeds and associated data */ function get_feeds() { return apply_filters('get_feeds', Feeds::get_instance()->getAll()); }
/** * Check for the existence of a feed based on a ID * * @deprecated Use Feeds::get_instance()->get($id) instead * Checks whether the supplied feed is in the feed list * @param string $id ID to lookup * @return array|bool Returns the feed array if found, false otherwise */ function feed_exists($id) { return !!Feeds::get_instance()->get($id); }
} catch (Zend_Search_Lucene_Exception $e) { $log->info("Failed opening or creating index in {$indexpath}"); $log->info($e->getMessage()); echo "Unable to open or create index: {$e->getMessage()}"; exit(1); } $log->info('Crawler loads db'); // load DB configuration $config = new Zend_Config_Ini('../config/zportal.ini', 'database'); Zend_Registry::set('config', $config); // create DB connection $db = Zend_DB::factory($config->adapter, $config->params->toArray()); /* @var $db Zend_DB_Adapter_Abstract */ // Store database handler as default adapter Zend_Db_Table_Abstract::setDefaultAdapter($db); $table = new Feeds(); $list = $table->fetchAll(); $targets = 0; foreach ($list as $item) { if ($item->type != 'feed') { continue; } $log->info("Fetched " . $item->url); $xml = file_get_contents($item->url); if (!$xml) { $log->info("Error fetching " . $item->url); continue; } // in case the update frequency is not specified, set a default of 5 minutes $date = new Zend_Date(); $item->updated = $date->get(Zend_Date::W3C);
if (Feeds::add($_POST['url'])) { $_SESSION['message'] = "Feed added."; } else { $_SESSION['message'] = "Failed to add feed to database."; } $f3->reroute("/feeds"); }); $f3->route('POST /feeds/edit', function ($f3) { global $db; admin_check(); readonly_check(); for ($i = 1; $i <= count($_POST["feed_url"]); $i++) { if (isset($_POST["delete"][$i])) { Feeds::delete($_POST["feed_url"][$i]); } else { Feeds::update($_POST["feed_url"][$i], $_POST["title"][$i], $_POST["site_url"][$i]); } } $_SESSION['message'] = 'Changes saved.'; $f3->reroute("/feeds"); }); /******************************/ /**** Admin login & logout ****/ /******************************/ $f3->route('GET /admin', function ($f3) { admin_check(); /** Retrieve event info **/ $events_info = ["submitted" => 0, "approved" => 0, "old" => 0]; $r = Events::$db->exec('SELECT count(*) AS count FROM events WHERE state IS "submitted" OR state IS "imported"'); $events_info['submitted'] = $r[0]['count']; $r = Events::$db->exec('SELECT count(*) AS count FROM events WHERE state="approved"');
/** * Resend activation email */ public function resendActivationAction() { $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/forms.ini'); $this->view->form = new Zend_Form($config->feed->resendactivation); if ($this->getRequest()->isPost() && $this->view->form->isValid($_POST)) { $feeds = new Feeds(); $users = new Users(); $user = $users->getByEmail($this->view->form->email->getValue()); $feed = $feeds->getBySiteUrlAndUserId($this->view->form->url->getValue(), $user->id); if ($feed) { $this->sendActivationEmail($feed, $user); } else { $this->view->form->email->markAsError(); } } }
/** * Edit feed * * @param integer $feed_id * @param array $data * @return boolean true on succes, or false on fail */ public function edit_feed($feed_id, $data) { if (!$this->check_token()) { return false; } $sm = vivvo_lite_site::get_instance(); if ($sm->user and $sm->user->can('MANAGE_PLUGIN', 'feed_importer')) { if (!vivvo_hooks_manager::call('feed_edit', array(&$feed_id, &$data))) { return vivvo_hooks_manager::get_status(); } $feed_list = new Feeds_list(); $feed_list->search(array()); if (!empty($data['feed'])) { $remove_keys = array_diff(array_keys($feed_list->list), array_keys($data['feed'])); } else { $remove_keys = array_keys($feed_list->list); } if (!empty($remove_keys)) { $feed_list->sql_delete_list($this->_post_master, $remove_keys); } $edit_keys = $feed_list->get_list_ids(); $feed_check = array(); require_once VIVVO_FS_INSTALL_ROOT . 'lib/simplepie/simplepie.php'; if (is_array($edit_keys) and !empty($edit_keys)) { foreach ($edit_keys as $edit_key) { if (!in_array($data['feed'][$edit_key]['feed'], $feed_check)) { $feed_check[] = $data['feed'][$edit_key]['feed']; $feed_list->list[$edit_key]->set_feed($data['feed'][$edit_key]['feed']); $feed_list->list[$edit_key]->set_category_id($data['feed'][$edit_key]['category_id']); $feed_list->list[$edit_key]->set_author($data['feed'][$edit_key]['author']); $simplepie = new SimplePie(); $simplepie->enable_cache(false); $simplepie->set_feed_url($data['feed'][$edit_key]['feed']); @$simplepie->init(); if (!$simplepie->error()) { $feed_list->list[$edit_key]->set_favicon($simplepie->get_favicon()); $this->_post_master->set_data_object($feed_list->list[$edit_key]); $this->_post_master->sql_update(); } } else { $this->_post_master->set_data_object($feed_list->list[$edit_key]); $this->_post_master->sql_delete(); } } } if (is_array($data['new_feed']) and !empty($data['new_feed'])) { foreach ($data['new_feed'] as $add_key => $value) { if (!in_array($data['new_feed'][$add_key]['feed'], $feed_check)) { $feed_check[] = $data['new_feed'][$add_key]['feed']; $new_feed_object = new Feeds(); $new_feed_object->set_feed($data['new_feed'][$add_key]['feed']); $new_feed_object->set_category_id($data['new_feed'][$add_key]['category_id']); $new_feed_object->set_author($data['new_feed'][$add_key]['author']); $simplepie = new SimplePie(); $simplepie->enable_cache(false); $simplepie->set_feed_url($data['new_feed'][$add_key]['feed']); @$simplepie->init(); if (!$simplepie->error()) { $new_feed_object->set_favicon($simplepie->get_favicon()); $this->_post_master->set_data_object($new_feed_object); $this->_post_master->sql_insert(); } } } } return true; } else { $this->set_error_code(10103); // you don't have sufficient privileges for this action return false; } }
/** * Page header */ protected function page() { header('Content-Type: text/html; charset=utf-8'); $feeds = Feeds::get_instance()->getAll(); foreach ($feeds as &$feed) { $feed = $feed['id']; } $feeds = array_values($feeds); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title><?php _e('Item Updater'); ?> — <?php echo get_option('sitename'); ?> </title> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/reset.css" /> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> install.css" /> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/iu.css" /> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/json2.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> admin/resources/iu.js"></script> <script type="text/javascript"> ItemUpdater.location = "<?php echo get_option('baseurl'); ?> "; ItemUpdater.feeds = <?php echo json_encode($feeds); ?> ; </script> </head> <body class="updater"> <div id="content"> <h1 id="title"><?php _e('Lilina Item Updater'); ?> </h1> <p><?php _e('Now beginning update of feeds. This might take a while. You must have Javascript enabled.'); ?> </p> <p class="js-hide"><?php _e('You need to have Javascript enabled to run the updater.'); ?> </p> <ul id="updatelist"> </ul> <p id="loading"><?php _e('Updating...'); ?> </p> <div id="finished"> <p><?php _e('Finished updating.'); ?> </p> <p><?php echo sprintf(_r('<a href="%1$s">Return to %2$s</a>.'), get_option('baseurl'), get_option('sitename')); ?> </p> </div> </div> <div id="footer"> <p>Powered by <a href="http://getlilina.org/">Lilina</a> <span class="version">1.0-bleeding</span>. Read the <a href="http://codex.getlilina.org/">documentation</a> or get help on the <a href="http://getlilina.org/forums/">forums</a></p> </div> </body> </html> <?php }
_e('Edit your feeds'); ?> </a></li> <li><a href="settings.php"><?php _e('Change your settings'); ?> </a></li> </ul> <div class="dashbox" id="contain_feeds"> <h3><?php _e('Current Feeds'); ?> </h3> <ul> <?php $feed_list = Feeds::get_instance()->getAll(); if (is_array($feed_list)) { foreach ($feed_list as $this_feed) { if (isset($this_feed['name']) && !empty($this_feed['name'])) { echo ' <li><a href="' . $this_feed['feed'] . '">' . stripslashes($this_feed['name']) . '</a></li>'; } else { echo ' <li><a href="' . $this_feed['feed'] . '">' . _r('(No title specified)') . '</a></li>'; } } } else { echo '<li>' . _r('No feeds installed yet.') . '</li>'; } ?> </ul>
/** * Check for the existence of a feed based on a URL * * Checks whether the supplied feed is in the feed list * @param string $url URL to lookup * @return array|bool Returns the feed array if found, false otherwise */ function feed_exists($url) { global $data; foreach (Feeds::get_instance()->getAll() as $feed) { if ($feed['url'] === $url || strpos($feed['url'], $url)) { return $feed; } } return false; }
?> </h1> <?php if (count(Feeds::get_instance()->getAll()) === 0) { ?> <p><?php _e("Firstly, thanks for using Lilina! To help you settle in, we've included a few nifty tools in Lilina, just to help you get started."); ?> </p> <?php } else { $updated = get_option('last_updated'); if (!$updated) { $message = sprintf(_r('You currently have %d items in %d feeds. Never updated.', count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()))); } else { $message = sprintf(_r('You currently have %d items in %d feeds. Last updated %s.'), count(Items::get_instance()->get_items()), count(Feeds::get_instance()->getAll()), relative_time($updated)); } ?> <p><?php echo $message; ?> </p> <?php } ?> <h2><?php _e('Import'); ?> </h2> <p><?php _e("We can import from any service which supports an open standard called OPML. Here's some services you can import from:");
} $user->phone_number = $_REQUEST['userCell']; $prompt = FALSE; } } else { echo '<p style="color:red">Please enter a valid cell phone number (only numeric characters).</p>'; $_REQUEST['userCell'] = ''; exit; } } $user->send_email = $_REQUEST['receive_email'] == 'yes'; $user->send_sms_text = $_REQUEST['receive_sms_text'] == 'yes'; $user->send_sms_link = $_REQUEST['receive_sms_link'] == 'yes'; $feedinfos = array(); if ($_REQUEST['feed'] != NULL) { foreach ($_REQUEST['feed'] as $index => $currentFeed) { if (!empty($currentFeed)) { $feedinfos[] = array('url' => $currentFeed, 'name' => $currentFeed); } } $prompt = FALSE; } $user->feeds = Feeds::create($feedinfos); if ($prompt == FALSE) { print '<p style="color:navy;">Update Successful.</p>'; print '<a href="index.php">Here is your homepage!</a>'; print '</br></br>'; } } else { echo '<p style="color:navy;">Edit your user information here.</p>'; }
/** * Callback for feeds.get */ public static function feeds_get() { return Feeds::get_instance()->getAll(); }
/** * Create an RSS Feed * * @param string $title - feed title * @param string $link - url feed title should point to * @param string $description - feed description * @param array $items - $items[0] = array('title'=>TITLE, 'link'=>URL, 'date'=>TIMESTAMP, 'description'=>DESCRIPTION) */ public function rss($title = '', $link = '', $description = '', $items = array()) { $feeds = Feeds::instance(); $feeds->rss($this, $title, $link, $description, $items); }