function createXML($title = '', $url = '', $rssurl = '', $description = '', $query = NULL) { require_once PATH_CORE . '/utilities/feedcreator.class.php'; $rssFeed = new UniversalFeedCreator(); $rssFeed->useCached(); // use cached version if age<1 hour $rssFeed->title = $title; $rssFeed->link = $url; $rssFeed->syndicationURL = $rssFeedurl; $rssFeed->description = $description; $rssFeed->descriptionTruncSize = 500; $rssFeed->descriptionHtmlSyndicated = true; $rssFeed->language = "en-us"; $number = $this->db->countQ($query); while ($data = $this->db->readQ($query)) { $item = new FeedItem(); $temptitle = str_replace("\\'", "'", $data->title); $temptitle = str_replace('\\"', '"', $temptitle); $item->title = $temptitle; $item->link = $this->baseUrl . '?p=read&cid=' . $data->siteContentId . '&viaRSS'; $tempdesc = str_replace("\\'", "'", $data->caption); $tempdesc = str_replace('\\"', '"', $tempdesc); $tempdesc = $this->utilObj->shorten($tempdesc, 500); $item->description = $this->safexml($tempdesc); $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; $item->date = $data->mydate; $item->source = $this->baseUrl; $rssFeed->addItem($item); } $temp_file = PATH_CACHE . '/rss' . rand(1, 1000) . '.tmp'; $text = $rssFeed->saveFeed("RSS2.0", $temp_file, false); return $text; }
function index() { global $G; include_once CLASS_PATH . 'feedcreator.class.php'; $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = $G['setting']['site_name']; $rss->description = $this->setting->getValue("site_description"); $rss->link = URL; $rss->syndicationURL = URL . "rss.php"; //announce $announce = $this->setting->dbstuff->GetArray("SELECT * FROM {$this->setting->table_prefix}announcements ORDER BY display_order ASC,id DESC LIMIT 0,5"); if (!empty($announce)) { foreach ($announce as $key => $val) { $item = new FeedItem(); $item->title = $val['subject']; $item->link = $this->url(array("module" => "announce", "id" => $val['id'])); $item->description = $val['message']; $item->date = $val['created']; $item->source = $this->url(array("module" => "announce", "id" => $val['id'])); $item->author = $G['setting']['company_name']; $rss->addItem($item); } } $image = new FeedImage(); $image->title = $G['setting']['site_banner_word']; $image->url = URL . STATICURL . "images/logo.jpg"; $image->link = URL; $image->description = $rss->description; $rss->image = $image; $rss->saveFeed("RSS1.0", DATA_PATH . "appcache/rss.xml"); }
public function index() { $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->title = app_conf("SHOP_TITLE") . " - " . app_conf("SHOP_SEO_TITLE"); $rss->description = app_conf("SHOP_SEO_TITLE"); //optional $rss->descriptionTruncSize = 500; $rss->descriptionHtmlSyndicated = true; $rss->link = get_domain() . APP_ROOT; $rss->syndicationURL = get_domain() . APP_ROOT; //optional $image->descriptionTruncSize = 500; $image->descriptionHtmlSyndicated = true; $domain = app_conf("PUBLIC_DOMAIN_ROOT") == '' ? get_domain() . $GLOBALS['IMG_APP_ROOT'] : app_conf("PUBLIC_DOMAIN_ROOT"); $city = get_current_deal_city(); $city_id = $city['id']; $deal_list = get_deal_list(app_conf("DEAL_PAGE_SIZE"), 0, 0, array(DEAL_ONLINE), " buy_type <> 1 or ( is_shop = 1 and is_effect =1 and is_delete = 0 and buy_type <> 1)"); $deal_list = $deal_list['list']; foreach ($deal_list as $data) { $item = new FeedItem(); if ($data['uname'] != '') { $gurl = url("shop", "goods", array("id" => $data['uname'])); } else { $gurl = url("shop", "goods", array("id" => $data['id'])); } $data['url'] = $gurl; $item->title = msubstr($data['name'], 0, 30); $item->link = get_domain() . $data['url']; $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']); $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']); $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']); $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>"; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; if ($data['end_time'] != 0) { $item->date = date('r', $data['end_time']); } $item->source = $data['url']; $item->author = app_conf("SHOP_TITLE"); $rss->addItem($item); } $rss->saveFeed($format = "RSS0.91", $filename = APP_ROOT_PATH . "public/runtime/app/tpl_caches/rss.xml"); }
public static function indexAction() { $rss = new \UniversalFeedCreator(); $rss->useCached('RSS1.0', ROOT_DIR . '/runtime/rss.xml'); $rss->title = P_TITLE; $rss->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX; $rss->syndicationURL = $rss->link . '/feed'; $posts = \BWBlog\Post::list_all([], 1, 0); foreach ($posts as $post) { $item = new \FeedItem(); $item->title = $post['title']; $item->link = ENV_PREFERED_PROTOCOL . '://' . CONFIG_HOST . P_PREFIX . $post['rest_url']; $item->description = $post['content']['html']; $item->date = $post['time']['main']; $rss->addItem($item); } echo $rss->saveFeed('RSS1.0', ROOT_DIR . '/runtime/rss.xml'); }
function fab_feed($type, $filename, $timeout) { global $sitename, $slogan, $nuke_url, $backend_image, $backend_title, $backend_width, $backend_height, $backend_language, $storyhome; include "lib/feedcreator.class.php"; $rss = new UniversalFeedCreator(); $rss->useCached($type, $filename, $timeout); $rss->title = $sitename; $rss->description = $slogan; $rss->descriptionTruncSize = 250; $rss->descriptionHtmlSyndicated = true; $rss->link = $nuke_url; $rss->syndicationURL = $nuke_url . "/backend.php?op=" . $type; $image = new FeedImage(); $image->title = $sitename; $image->url = $backend_image; $image->link = $nuke_url; $image->description = $backend_title; $image->width = $backend_width; $image->height = $backend_height; $rss->image = $image; $xtab = news_aff("index", "where ihome='0' and archive='0'", $storyhome, ""); $story_limit = 0; while ($story_limit < $storyhome and $story_limit < sizeof($xtab)) { list($sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant, $notes) = $xtab[$story_limit]; $story_limit++; $item = new FeedItem(); $item->title = preview_local_langue($backend_language, str_replace(""", "\"", $title)); $item->link = $nuke_url . "/article.php?sid={$sid}"; $item->description = meta_lang(preview_local_langue($backend_language, $hometext)); $item->descriptionHtmlSyndicated = true; $item->date = convertdateTOtimestamp($time) + $gmt * 3600; $item->source = $nuke_url; $item->author = $aid; $rss->addItem($item); } echo $rss->saveFeed($type, $filename); }
function feed($id, $showFeed) { global $database, $mainframe; global $mosConfig_live_site, $mosConfig_offset, $mosConfig_absolute_path; $params = rdRss::getParameters($id); //print_r($params); // set filename for live bookmarks feed if (!$showFeed & $params->live_bookmark) { // standard bookmark filename $params->file = $mosConfig_absolute_path . '/cache/' . $params->live_bookmark . "_" . $id; } else { // set filename for rss feeds $params->file = strtolower(str_replace('.', '', $params->feed)); $params->file = $mosConfig_absolute_path . '/cache/' . $params->file . "_" . $id . '.xml'; } // load feed creator class $rss = new UniversalFeedCreator(); // load image creator class $image = new FeedImage(); // loads cache file if ($showFeed && $params->cache) { $rss->useCached($params->feed, $params->file, $params->cache_time); } $rss->title = $params->title; $rss->description = $params->description; $rss->link = $params->link; $rss->syndicationURL = $params->link; $rss->cssStyleSheet = NULL; $rss->encoding = $params->encoding; if ($params->image) { $image->url = $params->image; $image->link = $params->link; $image->title = $params->image_alt; $image->description = $params->description; // loads image info into rss array $rss->image = $image; } if ($id == '1') { $fp = 1; } else { $fp = 0; } $rows = rdRss::getData($params, $fp); if (count($rows) && $params->published) { foreach ($rows as $row) { // title for particular item $item_title = htmlspecialchars($row->title); $item_title = html_entity_decode($item_title); // url link to article // & used instead of & as this is converted by feed creator $item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $mainframe->getItemid($row->id); $item_link = sefRelToAbs($item_link); // removes all formating from the intro text for the description text $item_description = $row->introtext; $item_description = mosHTML::cleanText($item_description); $item_description = html_entity_decode($item_description); if ($params->limit_text) { if ($params->text_length) { // limits description text to x words $item_description_array = split(' ', $item_description); $count = count($item_description_array); if ($count > $params->text_length) { $item_description = ''; for ($a = 0; $a < $params->text_length; $a++) { $item_description .= $item_description_array[$a] . ' '; } $item_description = trim($item_description); $item_description .= '...'; } } else { // do not include description when text_length = 0 $item_description = NULL; } } // load individual item creator class $item = new FeedItem(); // item info $item->title = $item_title; $item->link = $item_link; $item->description = $item_description; $item->source = $params->link; $item->date = date('r', $row->created_ts); // loads item info into rss array $rss->addItem($item); } } //save feed file $rss->saveFeed($params->feed, $params->file, $showFeed); }
/** * 掲示板RSSを出力する * * @param $community_row 対象コミュニティ情報 * @param $bbs_row_array 掲示板親記事一覧 * @param $params パラメータ等 */ static function print_bbs_rss($community_row, $bbs_row_array, $params) { // 使用クラス: acs/webapp/lib/feedcreator/feedcreator.class.php $rss = new UniversalFeedCreator(); // 概要等 <channel> $rss->useCached(); $rss->title = $community_row['community_name']; // コミュニティ名 $rss->description = $community_row['community_profile']['contents_value']; // プロフィール (公開範囲別) $rss->link = $params['base_url'] . $community_row['top_page_url']; // コミュニティトップページURL $rss->url = $params['base_url'] . $community_row['image_url']; // 画像URL <image rdf:resource="..."> $rss->syndicationURL = $rss_syndication_url; // 自身のURL <channel rdf:about="..."> // ロゴ画像 <image> $image = new FeedImage(); $image->title = $community_row['image_title']; // ファイル名 $image->link = ACSMsg::get_mdmsg(__FILE__, 'M006'); // 研究室ロゴ画像 $image->url = $params['base_url'] . $community_row['image_url']; $rss->image = $image; // 1件のダイアリー: <item> foreach ($bbs_row_array as $index => $bbs_row) { // CRLF → LF $body = preg_replace('/\\r\\n/', "\n", $bbs_row['body']); $item = new FeedItem(); $item->post_date = $bbs_row['post_date']; $item->title = $bbs_row['subject']; $item->link = $params['base_url'] . $bbs_row['bbs_res_url']; $item->description = $body; if ($bbs_row['file_url'] != '') { $item->image_link = $params['base_url'] . $bbs_row['file_url']; } $item->description2 = $body; //第2の本文 <content:encoded> $rss->addItem($item); } // http-header mb_http_output('pass'); header('Content-type: application/xml; charset=UTF-8'); echo mb_convert_encoding($rss->createFeed("RSS1.0"), 'UTF-8', mb_internal_encoding()); }
function feedFrontpage($showFeed) { global $database, $mainframe; global $mosConfig_live_site, $mosConfig_cachepath; $nullDate = $database->getNullDate(); // pull id of syndication component $query = "SELECT a.id" . "\n FROM #__components AS a" . "\n WHERE ( a.admin_menu_link = 'option=com_syndicate' OR a.admin_menu_link = 'option=com_syndicate&hidemainmenu=1' )" . "\n AND a.option = 'com_syndicate'"; $database->setQuery($query); $id = $database->loadResult(); // load syndication parameters $component = new mosComponent($database); $component->load((int) $id); $params = new mosParameters($component->params); // test if security check is enbled $check = $params->def('check', 1); if ($check) { // test if rssfeed module is published // if not disable access $query = "SELECT m.id" . "\n FROM #__modules AS m" . "\n WHERE m.module = 'mod_rssfeed'" . "\n AND m.published = 1"; $database->setQuery($query); $check = $database->loadResultArray(); if (empty($check)) { mosNotAuth(); return; } } $now = _CURRENT_SERVER_TIME; $iso = split('=', _ISO); // parameter intilization $info['date'] = date('r'); $info['year'] = date('Y'); $info['encoding'] = $iso[1]; $info['link'] = htmlspecialchars($mosConfig_live_site); $info['cache'] = $params->def('cache', 1); $info['cache_time'] = $params->def('cache_time', 3600); $info['count'] = $params->def('count', 5); $info['orderby'] = $params->def('orderby', ''); $info['title'] = $params->def('title', 'Joomla! powered Site'); $info['description'] = $params->def('description', 'Joomla! site syndication'); $info['image_file'] = $params->def('image_file', 'joomla_rss.png'); if ($info['image_file'] == -1) { $info['image'] = NULL; } else { $info['image'] = $mosConfig_live_site . '/images/M_images/' . $info['image_file']; } $info['image_alt'] = $params->def('image_alt', 'Powered by Joomla!'); $info['limit_text'] = $params->def('limit_text', 0); $info['text_length'] = $params->def('text_length', 20); // get feed type from url $info['feed'] = strval(mosGetParam($_GET, 'feed', 'RSS2.0')); // live bookmarks $info['live_bookmark'] = $params->def('live_bookmark', ''); $info['bookmark_file'] = $params->def('bookmark_file', ''); // set filename for live bookmarks feed if (!$showFeed & $info['live_bookmark']) { if ($info['bookmark_file']) { // custom bookmark filename $filename = $info['bookmark_file']; } else { // standard bookmark filename $filename = $info['live_bookmark']; } } else { // set filename for rss feeds $info['file'] = strtolower(str_replace('.', '', $info['feed'])); // security check to limit arbitrary file creation. // and to allow disabling/enabling of selected feed types switch ($info['file']) { case 'rss091': if (!$params->get('rss091', 1)) { echo _NOT_AUTH; return; } break; case 'rss10': if (!$params->get('rss10', 1)) { echo _NOT_AUTH; return; } break; case 'rss20': if (!$params->get('rss20', 1)) { echo _NOT_AUTH; return; } break; case 'atom03': if (!$params->get('atom03', 1)) { echo _NOT_AUTH; return; } break; case 'opml': if (!$params->get('opml', 1)) { echo _NOT_AUTH; return; } break; default: echo _NOT_AUTH; return; break; } } $filename = $info['file'] . '.xml'; // security check to stop server path disclosure if (strstr($filename, '/')) { echo _NOT_AUTH; return; } $info['file'] = $mosConfig_cachepath . '/' . $filename; // load feed creator class $rss = new UniversalFeedCreator(); // load image creator class $image = new FeedImage(); // loads cache file if ($showFeed && $info['cache']) { $rss->useCached($info['feed'], $info['file'], $info['cache_time']); } $rss->title = $info['title']; $rss->description = $info['description']; $rss->link = $info['link']; $rss->syndicationURL = $info['link']; $rss->cssStyleSheet = NULL; $rss->encoding = $info['encoding']; if ($info['image']) { $image->url = $info['image']; $image->link = $info['link']; $image->title = $info['image_alt']; $image->description = $info['description']; // loads image info into rss array $rss->image = $image; } // Determine ordering for sql switch (strtolower($info['orderby'])) { case 'date': $orderby = 'a.created'; break; case 'rdate': $orderby = 'a.created DESC'; break; case 'alpha': $orderby = 'a.title'; break; case 'ralpha': $orderby = 'a.title DESC'; break; case 'hits': $orderby = 'a.hits DESC'; break; case 'rhits': $orderby = 'a.hits ASC'; break; case 'front': $orderby = 'f.ordering'; break; default: $orderby = 'f.ordering'; break; } // query of frontpage content items $query = "SELECT a.*, u.name AS author, u.usertype, UNIX_TIMESTAMP( a.created ) AS created_ts, cat.title AS cat_title, sec.title AS section_title" . "\n FROM #__content AS a" . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__categories AS cat ON cat.id = a.catid" . "\n LEFT JOIN #__sections AS sec ON sec.id = a.sectionid" . "\n WHERE a.state = 1" . "\n AND cat.published = 1" . "\n AND sec.published = 1" . "\n AND a.access = 0" . "\n AND cat.access = 0" . "\n AND sec.access = 0" . "\n AND ( a.publish_up = " . $database->Quote($nullDate) . " OR a.publish_up <= " . $database->Quote($now) . " )" . "\n AND ( a.publish_down = " . $database->Quote($nullDate) . " OR a.publish_down >= " . $database->Quote($now) . " )" . "\n ORDER BY {$orderby}"; $database->setQuery($query, 0, $info['count']); $rows = $database->loadObjectList(); foreach ($rows as $row) { // title for particular item $item_title = htmlspecialchars($row->title); $item_title = html_entity_decode($item_title); // url link to article // & used instead of & as this is converted by feed creator $_Itemid = ''; $itemid = $mainframe->getItemid($row->id); if ($itemid) { $_Itemid = '&Itemid=' . $itemid; } $item_link = 'index.php?option=com_content&task=view&id=' . $row->id . $_Itemid; $item_link = sefRelToAbs($item_link); // removes all formating from the intro text for the description text $item_description = $row->introtext; $item_description = mosHTML::cleanText($item_description); $item_description = html_entity_decode($item_description); if ($info['limit_text']) { if ($info['text_length']) { // limits description text to x words $item_description_array = split(' ', $item_description); $count = count($item_description_array); if ($count > $info['text_length']) { $item_description = ''; for ($a = 0; $a < $info['text_length']; $a++) { $item_description .= $item_description_array[$a] . ' '; } $item_description = trim($item_description); $item_description .= '...'; } } else { // do not include description when text_length = 0 $item_description = NULL; } } // load individual item creator class $item = new FeedItem(); // item info $item->title = $item_title; $item->link = $item_link; $item->description = $item_description; $item->source = $info['link']; $item->date = date('r', $row->created_ts); $item->category = $row->section_title . ' - ' . $row->cat_title; // loads item info into rss array $rss->addItem($item); } // save feed file $rss->saveFeed($info['feed'], $info['file'], $showFeed); }
/** * Show given array as RSS page */ function show_rss_page($data = [], $params = []) { require_php_lib('yf_feedcreator'); $rss = new UniversalFeedCreator(); if (!isset($params['use_cached']) || !empty($params['use_cached'])) { $rss->useCached(); } $rss->title = _prepare_html(!empty($params['feed_title']) ? $params['feed_title'] : 'Site feed title'); $rss->description = _prepare_html(!empty($params['feed_desc']) ? $params['feed_desc'] : 'Site feed description'); // optional feed params $rss->descriptionTruncSize = !empty($params['feed_trunc_size']) ? intval($params['item_trunc_size']) : 500; $rss->descriptionHtmlSyndicated = isset($params['feed_insert_html']) ? (bool) $params['feed_insert_html'] : true; $rss->link = _prepare_html(process_url($params['feed_url'] ?: './?object=' . $_GET['object'])); $this->self_link = $rss->link; $rss->syndicationURL = _prepare_html(process_url($params['feed_source'] ?: './?object=' . $_GET['object'] . '&action=' . $_GET['action'] . (!empty($_GET['id']) ? '&id=' . $_GET['id'] : ''))); if (!empty($this->SHOW_RSS_ENCODING)) { $rss->encoding = $this->SHOW_RSS_ENCODING; } foreach ((array) $data as $A) { $item = new FeedItem(); if (isset($A['date'])) { $A['date'] = intval($A['date']); } if (isset($A['link'])) { $A['link'] = process_url($A['link']); } // Process known fields foreach ((array) $this->avail_item_fields as $field_name) { if (isset($A[$field_name])) { $item->{$field_name} = $A[$field_name]; } } if (!isset($item->guid)) { $item->guid = $A['link'] . '#' . md5($params['feed_source'] . '&' . $A['date'] . '&' . $A['title'] . '&' . $A['author']); } // optional params $item->descriptionTruncSize = !empty($params['item_trunc_size']) ? intval($params['item_trunc_size']) : $this->DESC_TRUNC_SIZE; $item->descriptionHtmlSyndicated = isset($params['item_insert_html']) ? (bool) $params['item_insert_html'] : true; // optional (enclosure) // Sample: $A['enclosure'] = array('url'=>'http://lh3.ggpht.com/smoliarov/Rwygj8ucrbE/AAAAAAAABIA/UkNlwQ7eniw/_200708.jpg','length'=>'65036','type'=>'image/jpeg'); if (!empty($A['enclosure']) && is_array($A['enclosure'])) { $E = $A['enclosure']; $item->enclosure = new EnclosureItem(); $item->enclosure->url = _prepare_html($E['url']); $item->enclosure->length = intval($E['length']); $item->enclosure->type = _prepare_html($E['type']); } $rss->addItem($item); } // Set format of the resulting feed $feed_format = isset($params['feed_format']) && in_array($params['feed_format'], $this->avail_formats) ? $params['feed_format'] : 'RSS2.0'; $feed_file_name = $params['feed_file_name']; if (!strlen($feed_file_name)) { $feed_file_name = md5($_SERVER['HTTP_HOST'] . '_' . $rss->title . $rss->description . $this->self_link); } $feed_file_name = common()->_propose_url_from_name($feed_file_name); $feed_cache_path = $this->FEEDS_CACHE_PATH . $feed_file_name . '.xml'; $feed_cache_dir = dirname($feed_cache_path); if (!file_exists($feed_cache_dir)) { _mkdir_m($feed_cache_dir); } $feed_redirect = $params['return_feed_text'] ? false : true; $body = $rss->saveFeed($feed_format, $feed_cache_path, $feed_redirect); if (!empty($params['return_feed_text'])) { if ($body) { return $body; } elseif (file_exists($feed_cache_path)) { return file_get_contents($feed_cache_path); } } else { main()->NO_GRAPHICS = true; echo $body; } }
/** * buildRSS * * @access protected * @author halt <*****@*****.**> */ function buildRSS($r_data, $r_filepath, $r_type = "RSS1.0") { require_once "feedcreator.class.php"; $rss = new UniversalFeedCreator(); //$rss->encoding = 'UTF-8'; can't override FeedCreator::encoding :-< $rss->useCached(); $rss->title = $r_data['title']; $rss->description = $r_data['description']; $rss->link = $r_data['link']; //$rss->syndicationURL = "http://www.dailyphp.net/".$PHP_SELF; if (isset($r_data['image'])) { $image = new FeedImage(); $image->title = $r_data['image']['title']; $image->url = $r_data['image']['url']; $image->link = $r_data['image']['link']; $image->description = $r_data['image']['description']; $rss->image = $image; } foreach ($r_data['feeds'] as $feed) { $item = new FeedItem(); $item->title = $feed['title']; $item->link = $feed['link']; $item->description = $feed['description']; $item->date = $feed['date']; $item->source = $feed['source']; $item->author = $feed['author']; $rss->addItem($item); } $rss->saveFeed($r_type, $r_filepath); }
/** * createFeed * * URL-Parameters: ?items=15 or 30 */ public function action_getfeed() { // Load Feedcreator Class if (false === class_exists('UniversalFeedCreator', false)) { include ROOT_LIBRARIES . 'feedcreator/feedcreator.class.php'; } /** * Get Number of Feed Items to create */ $feed_items = (int) $this->request->getParameter('items'); // Set Number of Items Range 0<15 || MAX 30 if ($feed_items == null or $feed_items < 15) { $feed_items = self::getConfigValue('feed_items', '15'); } elseif ($feed_items > 15) { $feed_items = 30; } /** * Get Format of Feed to create */ // white list for valid feed format strings $feed_format_array = array('RSS0.91', 'RSS1.0', 'RSS2.0', 'MBOX', 'OPML', 'ATOM', 'ATOM0.3', 'HTML', 'JS'); // get format from request $feed_format = (string) $this->request->getParameter('format'); // check its a valid string or set default if (in_array($feed_format, $feed_format_array) == false or $feed_format === null) { $feed_format = self::getConfigValue('feed_format', 'RSS2.0'); } /** * Create Main Feed Object */ $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->title = self::getConfigValue('feed_title', 'Feedname'); $rss->description = self::getConfigValue('feed_description', 'Descriptiontext'); // optional $rss->descriptionTruncSize = 500; $rss->descriptionHtmlSyndicated = true; $rss->link = "http://www.clanswebsite.net/news"; $rss->syndicationURL = "http://www.clanwebsite.net/" . $_SERVER['PHP_SELF']; /** * Create Feed Image Object */ $image = new FeedImage(); $image->title = self::getConfigValue('feed_imagetitle', 'logo'); $image->url = self::getConfigValue('feed_image', 'http://www.clanwebsite.net/images/logo.gif'); $image->link = self::getConfigValue('feed_imageurl', 'http://www.clanwebsite.net'); $image->description = self::getConfigValue('feed_imagedescription', 'Feed provided by clanwebsite.net. Click to visit.'); // optional $image->descriptionTruncSize = 500; $image->descriptionHtmlSyndicated = true; // Set Feed Image Object to Main Feed Object $rss->image = $image; // Fetch News via Doctrine $news_array = Doctrine::getTable('CsNews')->fetchNewsForFeed(); /** * Loop over Dataset */ foreach ($news_array as $key => $news) { /** * Create Feed Item Object */ $item = new FeedItem(); $item->title = $news['news_title']; $item->link = WWW_ROOT . 'index.php?mod=news&action=showone&id=' . $news['news_id']; $item->description = $news['news_body']; // optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; $item->date = $news['created_at']; $item->source = "http://www.clanwebsite.net"; $item->author = $news['CsUsers']['nick']; // Set Feed Item Object to Main Feed Object $rss->addItem($item); } /** * Set Feed Format and save to file * * Valid $feed_format strings are: * RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), MBOX, OPML, ATOM, ATOM0.3, HTML, JS */ $rss->saveFeed($feed_format, ROOT_MOD . 'news/newsfeed-' . $feed_items . '.xml'); }
/** * Genera el RSS.XML con una clase bajada de internet, * ya voy a mejorar eso, pero por ahora NO. * * @return string */ function make_rss() { global $db, $preferences; $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age < 1 hour $rss->title = preg_replace("/(\\<)(.*?)(\\>)/mi", "", $preferences['site_name']); $rss->description = $preferences['site_description']; $rss->link = $preferences['site_url']; $rss->syndicationURL = $preferences['site_url'] . '/rss.xml'; list($data) = get_posts(); foreach ($data as $key => $value) { $item = new FeedItem(); $item->title = preg_replace("/(\\<)(.*?)(\\>)/mi", "", $value['title']); $item->link = $preferences['site_url'] . '/?id_posts=' . $value['id_posts']; $item->description = $value['content']; $item->date = $value['date']; $item->source = $preferences['site_url']; $item->author = $value['user']; $rss->addItem($item); } return $rss->saveFeed("RSS1.0", "../rss.xml", false); }
} $info['image_alt'] = $params->def('image_alt', 'Powered by Mambo 4.5.1'); $info['limit_text'] = $params->def('limit_text', 1); $info['text_length'] = $params->def('text_length', 20); // load feed creator class $rss = new UniversalFeedCreator(); // load image creator class $image = new FeedImage(); // get feedtype from url $info['feed '] = mosGetParam($_GET, 'feed', 'RSS2.0'); // set filename for feed $info['file '] = strtolower(str_replace('.', '', $info['feed '])); $info['file '] = $GLOBALS['mosConfig_absolute_path'] . '/cache/' . $info['file '] . '.xml'; // loads cache file if ($info['cache']) { $rss->useCached($info['feed '], $info['file '], $info['cache_time']); } $rss->title = $info['title']; $rss->description = $info['description']; $rss->link = $info['link']; $rss->syndicationURL = $info['link']; $rss->cssStyleSheet = NULL; $rss->encoding = split('=', _ISO); $image->url = $info['image']; $image->link = $info['link']; $image->title = $info['image_alt']; $image->description = $info['description']; // loads image info into rss array $rss->image = $image; // Determine ordering for sql switch (strtolower($info['orderby'])) {
public function index() { $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->title = app_conf("SHOP_TITLE") . " - " . app_conf("SHOP_SEO_TITLE"); $rss->description = app_conf("SHOP_SEO_TITLE"); //optional $rss->descriptionTruncSize = 500; $rss->descriptionHtmlSyndicated = true; $rss->link = get_domain() . APP_ROOT; $rss->syndicationURL = get_domain() . APP_ROOT; //optional $image->descriptionTruncSize = 500; $image->descriptionHtmlSyndicated = true; //对图片路径的修复 if ($GLOBALS['distribution_cfg']['OSS_TYPE'] && $GLOBALS['distribution_cfg']['OSS_TYPE'] != "NONE") { $domain = $GLOBALS['distribution_cfg']['OSS_DOMAIN']; } else { $domain = SITE_DOMAIN . APP_ROOT; } $city = City::locate_city(); $city_id = $city['id']; $tuan_list = get_deal_list(10, array(DEAL_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_shop = 0 and is_effect =1 and is_delete = 0 and buy_type <> 1", " create_time desc "); $tuan_list = $tuan_list['list']; foreach ($tuan_list as $data) { $item = new FeedItem(); $gurl = url("index", "deal#" . $data['id']); $data['url'] = $gurl; $item->title = msubstr($data['name'], 0, 30); $item->link = get_domain() . $data['url']; $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']); $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']); $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']); $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>"; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; if ($data['end_time'] != 0) { $item->date = date('r', $data['end_time']); } $item->source = $data['url']; $item->author = app_conf("SHOP_TITLE"); $rss->addItem($item); } $deal_list = get_deal_list(10, array(DEAL_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_shop = 1 and is_effect =1 and is_delete = 0 and buy_type <> 1", " create_time desc "); $deal_list = $deal_list['list']; foreach ($deal_list as $data) { $item = new FeedItem(); $gurl = url("index", "deal#" . $data['id']); $data['url'] = $gurl; $item->title = msubstr($data['name'], 0, 30); $item->link = get_domain() . $data['url']; $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']); $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']); $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']); $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>"; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; if ($data['end_time'] != 0) { $item->date = date('r', $data['end_time']); } $item->source = $data['url']; $item->author = app_conf("SHOP_TITLE"); $rss->addItem($item); } $youhui_list = get_youhui_list(10, array(YOUHUI_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_effect =1 ", " create_time desc "); $youhui_list = $youhui_list['list']; foreach ($youhui_list as $data) { $item = new FeedItem(); $gurl = url("index", "youhui#" . $data['id']); $data['url'] = $gurl; $item->title = msubstr($data['name'], 0, 30); $item->link = get_domain() . $data['url']; $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']); $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']); $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']); $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>"; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; if ($data['end_time'] != 0) { $item->date = date('r', $data['end_time']); } $item->source = $data['url']; $item->author = app_conf("SHOP_TITLE"); $rss->addItem($item); } $event_list = get_event_list(10, array(EVENT_ONLINE), array("cid" => 0, "city_id" => 0), '', " is_effect =1 ", " sort asc "); $event_list = $event_list['list']; foreach ($event_list as $data) { $item = new FeedItem(); $gurl = url("index", "event#" . $data['id']); $data['url'] = $gurl; $item->title = msubstr($data['name'], 0, 30); $item->link = get_domain() . $data['url']; $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']); $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']); $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']); $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>"; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; if ($data['end_time'] != 0) { $item->date = date('r', $data['end_time']); } $item->source = $data['url']; $item->author = app_conf("SHOP_TITLE"); $rss->addItem($item); } $rss->saveFeed($format = "RSS0.91", $filename = APP_ROOT_PATH . "public/runtime/app/tpl_caches/rss.xml"); }
function cached_feed($feed_info) { global $sess, $mosConfig_cachepath; // load feed creator class require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/feedcreator.class.php'; $products = getProducts($feed_info); if (empty($products)) { return; } $mosConfig_cachepath = empty($mosConfig_cachepath) ? $GLOBALS['mosConfig_absolute_path'] . '/cache' : $mosConfig_cachepath; $filename = $mosConfig_cachepath . "/productfeed_" . $feed_info['feed'] . "_catid{$feed_info['category_id']}.xml"; // load feed creator class $rss = new UniversalFeedCreator(); // load image creator class $image = new FeedImage(); // loads cache file if ($feed_info['cache']) { $rss->useCached($feed_info['feed'], $filename, $feed_info['cache_time']); } $rss->title = $feed_info['title']; $rss->description = $feed_info['feed_description']; $rss->link = htmlspecialchars($feed_info['link']); $rss->cssStyleSheet = NULL; $rss->encoding = $feed_info['encoding']; $feed_image = $feed_info['image_file']; if ($feed_image) { $image->url = $feed_image; $image->link = $rss->link; $image->title = $feed_info['image_alt']; $image->description = $rss->description; // loads image info into rss array $rss->image = $image; } // parameter intilization $feed_date = date('r'); $feed_year = date('Y'); $limit = min($feed_info['product_number'], 200); $limit_text = $feed_info['limit_desc']; $text_length = $feed_info['text_length']; foreach ($products as $product) { // load individual item creator class $item = new FeedItem(); // item info $product_link = $sess->url($GLOBALS['mosConfig_live_site'] . '/index.php?product_id=' . $product['id'] . '&page=shop.product_details&category_id=' . $product['category_id'] . '&flypage=' . $product['category_flypage'], true); $item->title = htmlspecialchars($product['name']); $item->link = vmHtmlEntityDecode($product_link); $item->source = $product_link; $item->description = getProductDescription($product, $feed_info); $item->date = date('r', $product['cdate']); $item->category = htmlspecialchars($product['category_name']); // loads item info into rss array $rss->addItem($item); } while (@ob_end_clean()) { } // save feed file $rss->saveFeed($feed_info['feed'], $filename); }
} else { $FEED['structureID'] = ''; } } if (empty($FEED['filename'])) { $FEED['filename'] = md5($custom . $FEED['title']) . '.xml'; } $FEED['filename'] = 'content/rss/' . $FEED['defaultFormat'] . '-' . $FEED['filename']; $FEED['maxentries'] = intval($FEED['maxentries']); $FEED['useauthor'] = intval($FEED['useauthor']); $FEED['encoding'] = empty($FEED['encoding']) ? 'utf-8' : $FEED['encoding']; $FEED['timeZone'] = empty($FEED['timeZone']) ? '+01:00' : $FEED['timeZone']; define('FEED_ENCODING', trim(strtolower($FEED['encoding']))); define("TIME_ZONE", $FEED['timeZone']); $rss = new UniversalFeedCreator(); $rss->useCached($FEED['defaultFormat'], $FEED['filename'], intval($FEED['cacheTTL'])); $rss->title = $FEED['title']; $rss->description = $FEED['description']; $rss->link = $FEED['link']; $rss->syndicationURL = $FEED['syndicationURL']; $rss->encoding = FEED_ENCODING; if (!empty($FEED['feedAuthor'])) { $rss->editor = $FEED['feedAuthor']; } if (!empty($FEED['feedEmail'])) { $rss->editorEmail = $FEED['feedEmail']; } if (!empty($FEED['imagesrc'])) { $image = new FeedImage(); $image->title = $FEED['imagetitle']; $image->url = $FEED['imagesrc'];
public static function createRSSFile($data, $file_path) { #TODO: create RSS $rss = new UniversalFeedCreator(); $rss->useCached(); // use cached version if age<1 hour $rss->title = $data->title; $rss->description = $data->description; //optional $rss->descriptionTruncSize = 500; $rss->descriptionHtmlSyndicated = true; $rss->link = $data->link; $rss->syndicationURL = get_site_url(); // $image = new FeedImage(); // $image->title = "dailyphp.net logo"; // $image->url = "http://www.dailyphp.net/images/logo.gif"; // $image->link = get_site_url(); // $image->description = "Feed provided by dailyphp.net. Click to visit."; //optional // $image->descriptionTruncSize = 500; // $image->descriptionHtmlSyndicated = true; // $rss->image = $image; $items = $data->items; foreach ($items as $item) { $feed_item = new FeedItem(); $feed_item->title = $item->title; $feed_item->link = $item->link; $feed_item->description = $item->description; /* //optional $feed_item->descriptionTruncSize = 500; $feed_item->descriptionHtmlSyndicated = true; //optional (enclosure) $feed_item->enclosure = new EnclosureItem(); $feed_item->enclosure->url='http://http://www.dailyphp.net/media/voice.mp3'; $feed_item->enclosure->length="950230"; $feed_item->enclosure->type='audio/x-mpeg'; */ $date = isset($item->date) ? $item->date : ''; if (!$date) { $date = ''; } $feed_item->date = $date; // $feed_item->source = $item->source; $feed_item->author = $item->author; $rss->addItem($feed_item); } // valid format strings are: RSS091, RSS10, RSS20, PIE01 (deprecated), // MBOX, OPML, ATOM, ATOM10, ATOM03, HTML, JS $rss->saveFeed("RSS20", $file_path, false); //to generate "on-the-fly" // $rss->outputFeed("RSS20"); }
<?php set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang'); include_once "aur.inc"; include_once "feedcreator.class.php"; #detect prefix $protocol = $_SERVER["HTTPS"] == 'on' ? "https" : "http"; $host = $_SERVER['HTTP_HOST']; #If there's a cached version <1hr old, won't regenerate now $rss = new UniversalFeedCreator(); $rss->useCached("RSS2.0", "/tmp/aur-newestpkg.xml", 1800); #All the general RSS setup $rss->title = "AUR Newest Packages"; $rss->description = "The latest and greatest packages in the AUR"; $rss->link = "{$protocol}://{$host}"; $rss->syndicationURL = "{$protocol}://{$host}/rss.php"; $image = new FeedImage(); $image->title = "AUR"; $image->url = "{$protocol}://{$host}/images/AUR-logo-80.png"; $image->link = $rss->link; $image->description = "AUR Newest Packages Feed"; $rss->image = $image; #Get the latest packages and add items for them $dbh = db_connect(); $q = "SELECT * FROM Packages "; $q .= "WHERE DummyPkg != 1 "; $q .= "ORDER BY SubmittedTS DESC "; $q .= "LIMIT 0 , 20"; $result = db_query($q, $dbh); while ($row = mysql_fetch_assoc($result)) { $item = new FeedItem();
$rootpath .= '/'; } $epubdir = $rootpath . $param; // check it exists $dir = @opendir($epubdir) or die("Unable to open {$rootpath}"); // the request url without this filename $scriptpath = explode("/", $_SERVER["REQUEST_URI"]); // delete the last element $scriptpath[count($scriptpath) - 1] = ""; $scriptpath = implode("/", $scriptpath); $url = "http://" . $_SERVER["SERVER_NAME"] . $scriptpath; $scripturl = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; header('Content-type: application/xml'); //define channel $atom = new UniversalFeedCreator(); $atom->useCached(); $atom->title = "Books in {$epubdir}"; // todo: replace with a $catalogname field $atom->description = "epub files on my server"; $atom->link = "http://mydomain.net/"; $atom->syndicationURL = $scripturl; // sort the files by date so the most recent is first in the feed // preg_find(pattern, starting dir, args) $files = preg_find('/\\.epub$/', $epubdir, PREG_FIND_RECURSIVE | PREG_FIND_RETURNASSOC | PREG_FIND_SORTBASENAME | PREG_FIND_SORTDESC); $files = array_keys($files); // add the files to the feed foreach ($files as $file) { if (is_file($file)) { $ebook = new ebookRead($file); // entries $item = new FeedItem();
<? include($_SERVER["DOCUMENT_ROOT"] . "/feed/feedcreator.class.php"); include($_SERVER["DOCUMENT_ROOT"] . "/feed/rss_util.php"); include($_SERVER["DOCUMENT_ROOT"] . "/stats/counter.php"); $cacheFile = $_SERVER["DOCUMENT_ROOT"] . "/feed/rss22.cache"; if (file_exists($cacheFile)) { // if (time() - filemtime($cacheFile) <= 3600) { readfile($cacheFile); return; // } } $rss = new UniversalFeedCreator(); $rss->useCached("RSS2.0", $cacheFile); $rss->title = "TMate SVNKit"; $rss->description = "TMate SVNKit Library Change Log"; $rss->link = "http://svnkit.com/"; $rss->syndicationURL = "http://svnkit.com/" . $PHP_SELF; $rss->author = "TMate Software"; $rss->editor = "TMate Software"; $rss->authorEmail = "*****@*****.**"; $rss->editorEmail = "*****@*****.**"; $repository = "http://svn.svnkit.com/repos/svnkit/tags/"; $contents = read_contents($repository); if (!$contents) { echo $rss->createFeed(); exit; }
} if ($format == 'KML') { if (!isset($_GET['simple'])) { $_GET['simple'] = 1; } //default to on $extension = empty($_GET['simple']) ? 'kml' : 'simple.kml'; } elseif ($format == 'GPX') { $extension = 'gpx'; } else { $extension = 'xml'; } $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/events-{$format}-" . empty($_GET['admin']) . ".{$extension}"; $rss = new UniversalFeedCreator(); if (empty($_GET['refresh'])) { $rss->useCached($format, $rssfile); } $rss->title = 'Geograph Events'; $rss->link = "http://{$_SERVER['HTTP_HOST']}/article/"; $rss->description = "Upcoming Geograph British Isles Events"; if (empty($_GET['admin'])) { $isadmin = 0; $rss->syndicationURL = "http://{$_SERVER['HTTP_HOST']}/events/syndicator.php?format={$format}"; } else { $isadmin = 1; $rss->title = 'Geograph Pending Articles'; $rss->syndicationURL = "http://{$_SERVER['HTTP_HOST']}/article/syndicator.php?format={$format}&admin=1"; } if ($format == 'KML' || $format == 'GeoRSS' || $format == 'GPX') { require_once 'geograph/conversions.class.php'; require_once 'geograph/gridsquare.class.php';
function decks() { $criteria = $_GET['show']; if (!isset($criteria)) { die("error in receiving feed criteria!"); } $feed_type = $_GET['output']; if (!isset($feed_type)) { $feed_type = "RSS1.0"; } $deckList = new DeckList(); switch ($criteria) { case "new": $title = "SlideWiki -- New Presentations"; $description = "list of new presentations"; $link = "http://slidewiki.org/search/order/date"; $syndicationURL = "http://slidewiki.org/feed/decks/new"; $decks = $deckList->getAllDecks(15); break; case "popular": $title = "SlideWiki -- Popular Presentations"; $description = "list of popular presentations"; $link = "http://slidewiki.org/search/order/popularity"; $syndicationURL = "http://slidewiki.org/feed/decks/popular"; $decks = $deckList->getAllPopular(15); break; case "featured": $title = "SlideWiki -- Featured Presentations"; $description = "list of featured presentations"; $link = "http://slidewiki.org/search/order/featured"; $syndicationURL = "http://slidewiki.org/feed/decks/featured"; $decks = $deckList->getAllFeatured(15); break; } //define channel $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = $title; $rss->description = $description; $rss->link = $link; $rss->syndicationURL = $syndicationURL; //channel items/entries foreach ($decks as $deck) { $item = new FeedItem(); $item->title = $deck->title; $item->link = "http://slidewiki.org/deck/" . $deck->id . '_' . $deck->slug_title; $item->description = $deck->abstract; $item->source = "http://slidewiki.org/"; $item->date = strtotime($deck->revisionTime); $item->author = $deck->owner->username; $rss->addItem($item); } //Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS $rss->outputFeed($feed_type); }
if (isset($cacheid)) { $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/{$cacheid}-{$pg}-{$format}{$opt_expand}.{$extension}"; $rss_timeout = 3600; } elseif (isset($_GET['i']) && is_numeric($_GET['i'])) { $pg = !empty($_GET['page']) ? intval(str_replace('/', '', $_GET['page'])) : 1; $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/{$_GET['i']}-{$pg}-{$format}{$opt_expand}.{$extension}"; $rss_timeout = 3600; } elseif (isset($_GET['u']) && is_numeric($_GET['u'])) { $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/u{$_GET['u']}-{$format}{$opt_expand}.{$extension}"; $rss_timeout = 1800; } else { $rssfile = $_SERVER['DOCUMENT_ROOT'] . "/rss/{$format}{$opt_expand}.{$extension}"; $rss_timeout = 900; } $rss = new UniversalFeedCreator(); $rss->useCached($format, $rssfile, $rss_timeout); $rss->title = 'Geograph British Isles'; $rss->link = "http://{$_SERVER['HTTP_HOST']}/"; /** * Create a query the first time round! */ if (isset($q)) { require_once 'geograph/searchcriteria.class.php'; require_once 'geograph/searchengine.class.php'; require_once 'geograph/searchenginebuilder.class.php'; $engine = new SearchEngineBuilder('#'); $engine->searchuse = "syndicator"; $_GET['i'] = $engine->buildSimpleQuery($q, $CONF['default_search_distance'], false, isset($_GET['u']) ? $_GET['u'] : 0); if (function_exists('symlink') && isset($cacheid)) { //create a link so cache can be access as original query(cacheid) or directly via its 'i' number later... symlink($_SERVER['DOCUMENT_ROOT'] . "/rss/{$cacheid}-{$pg}-{$format}{$opt_expand}.{$extension}", $_SERVER['DOCUMENT_ROOT'] . "/rss/{$_GET['i']}-{$pg}-{$format}{$opt_expand}.{$extension}");
/** * writes sitemap to file */ function writeSitemap($FILE) { global $SETTINGS, $openFile_error, $LAYOUT; $LAYOUT->setTitle("Writing sitemap"); $website = $SETTINGS[PSNG_WEBSITE]; if (substr($website, -1, 1) == '/') { $website = substr($website, 0, strlen($website) - 1); } $numb = 0; $txtfilehandle = null; $htmlfilehandle = null; if (isset($SETTINGS[PSNG_SITEMAP_FILE]) && strlen($SETTINGS[PSNG_SITEMAP_FILE]) > 0) { $gsg = new GsgXml($SETTINGS[PSNG_WEBSITE]); $gsg->setGssHeader($SETTINGS[PSNG_GSSHEADER] == 1); // set usage of gss header } if (isset($SETTINGS[PSNG_TXTSITEMAP_FILE]) && strlen($SETTINGS[PSNG_TXTSITEMAP_FILE]) > 0) { $txtfilehandle = openFile($SETTINGS[PSNG_PAGEROOT] . $SETTINGS[PSNG_TXTSITEMAP_FILE], TRUE); if ($txtfilehandle === FALSE) { $LAYOUT->addError($openFile_error, 'Could not write txt sitemap file'); } } if (isset($SETTINGS[PSNG_HTMLSITEMAP_FILE]) && strlen($SETTINGS[PSNG_HTMLSITEMAP_FILE]) > 0) { $htmlfilehandle = openFile($SETTINGS[PSNG_PAGEROOT] . $SETTINGS[PSNG_HTMLSITEMAP_FILE], TRUE); if ($htmlfilehandle === FALSE) { $LAYOUT->addError($openFile_error, 'Could not write html sitemap file'); } } if (isset($SETTINGS[PSNG_RSSSITEMAP_FILE]) && strlen($SETTINGS[PSNG_RSSSITEMAP_FILE]) > 0) { $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "Sitemap of " . $SETTINGS[PSNG_WEBSITE]; // TODO use description? //$rss->description = "daily news from the PHP scripting world"; $rss->link = $SETTINGS[PSNG_WEBSITE]; $rss->syndicationURL = $SETTINGS[PSNG_WEBSITE] . $SETTINGS[PSNG_RSSSITEMAP_FILE]; // TODO use image ??? /* $image = new FeedImage(); $image->title = "dailyphp.net logo"; $image->url = "http://www.dailyphp.net/images/logo.gif"; $image->link = "http://www.dailyphp.net"; $image->description = "Feed provided by dailyphp.net. Click to visit."; $rss->image = $image; */ } foreach ($FILE as $numb => $value) { if ($value[PSNG_FILE_ENABLED] != '') { debug($value, "Adding file " . $value[PSNG_FILE_URL]); if (isset($txtfilehandle)) { fputs($txtfilehandle, $value[PSNG_FILE_URL] . "\n"); } if (isset($SETTINGS[PSNG_RSSSITEMAP_FILE]) && strlen($SETTINGS[PSNG_RSSSITEMAP_FILE]) > 0) { $item = new FeedItem(); $item->title = $value[PSNG_FILE_TITLE]; $item->link = $value[PSNG_FILE_URL]; //$item->description = $data->short; $item->date = $value[PSNG_FILE_LASTMOD]; //$item->source = "http://www.dailyphp.net"; //$item->author = "John Doe"; $rss->addItem($item); } if (isset($htmlfilehandle)) { // todo handle this in an external class (takes the urls and titles, writes a nice and clean sitemap file) fputs($htmlfilehandle, '<a href="' . $value[PSNG_FILE_URL] . '" title="' . $value[PSNG_FILE_TITLE] . '">' . $value[PSNG_FILE_TITLE] . '</a><br />' . "\n"); } if (isset($SETTINGS[PSNG_SITEMAP_FILE]) && strlen($SETTINGS[PSNG_SITEMAP_FILE]) > 0) { if ($gsg->addUrl($value[PSNG_FILE_URL], FALSE, $value[PSNG_LASTMOD], FALSE, $value[PSNG_CHANGEFREQ], $value[PSNG_PRIORITY]) === FALSE) { $LAYOUT->addError($value[PSNG_FILE_URL], 'Could not add file to sitemap' . $gsg->errorMsg); } } } else { debug($value[PSNG_FILE_URL], 'Not enabled, so not writing file to sitemap'); } } if (isset($SETTINGS[PSNG_SITEMAP_FILE]) && strlen($SETTINGS[PSNG_SITEMAP_FILE]) > 0) { $filehandle = openFile($SETTINGS[PSNG_PAGEROOT] . $SETTINGS[PSNG_SITEMAP_FILE], TRUE); if ($filehandle === FALSE) { $LAYOUT->addError($openFile_error, 'Could not write xml sitemap'); return FALSE; } $xml = $gsg->output(TRUE, $SETTINGS[PSNG_COMPRESS_SITEMAP], FALSE); fputs($filehandle, $xml); fclose($filehandle); } if (isset($txtfilehandle)) { fclose($txtfilehandle); } if (isset($htmlfilehandle)) { fclose($htmlfilehandle); } if (isset($SETTINGS[PSNG_RSSSITEMAP_FILE]) && strlen($SETTINGS[PSNG_RSSSITEMAP_FILE]) > 0) { $rss->saveFeed("RSS1.0", $SETTINGS[PSNG_PAGEROOT] . $SETTINGS[PSNG_RSSSITEMAP_FILE], false); } if (isset($SETTINGS[PSNG_HTMLSITEMAP_FILE]) && strlen($SETTINGS[PSNG_HTMLSITEMAP_FILE]) > 0) { $rss->saveFeed("HTML", $SETTINGS[PSNG_PAGEROOT] . $SETTINGS[PSNG_HTMLSITEMAP_FILE], false); } if ($numb > 50000) { $LAYOUT->addWarning('Not implemented: split result into files with only 50000 entries', 'Only 50000 entries are allowed in one sitemap file at the moment!'); } $LAYOUT->addSuccess('Sitemap successfuly created and saved to <a href="' . $SETTINGS[PSNG_SITEMAP_URL] . '" target="_blank">' . basename($SETTINGS[PSNG_SITEMAP_FILE]) . '</a>!'); if (isset($SETTINGS[PSNG_TXTSITEMAP_FILE]) && strlen($SETTINGS[PSNG_TXTSITEMAP_FILE]) > 0) { $LAYOUT->addSuccess('Txt-Sitemap successfuly created and saved to <a href="' . $SETTINGS[PSNG_TXTSITEMAP_FILE] . '" target="_blank">' . basename($SETTINGS[PSNG_TXTSITEMAP_FILE]) . '</a>!'); } if (isset($SETTINGS[PSNG_HTMLSITEMAP_FILE]) && strlen($SETTINGS[PSNG_HTMLSITEMAP_FILE]) > 0) { $LAYOUT->addSuccess('HTML-Sitemap successfuly created and saved to <a href="' . $SETTINGS[PSNG_HTMLSITEMAP_FILE] . '" target="_blank">' . basename($SETTINGS[PSNG_HTMLSITEMAP_FILE]) . '</a>!'); } if (isset($SETTINGS[PSNG_RSSSITEMAP_FILE]) && strlen($SETTINGS[PSNG_RSSSITEMAP_FILE]) > 0) { $LAYOUT->addSuccess('RSS-Sitemap successfuly created and saved to <a href="' . $SETTINGS[PSNG_RSSSITEMAP_FILE] . '" target="_blank">' . basename($SETTINGS[PSNG_RSSSITEMAP_FILE]) . '</a>!'); } $LAYOUT->addText('<form action="' . $SETTINGS[PSNG_SCRIPT] . '" method="post">' . "\n" . '<input type="hidden" name="' . PSNG_SETTINGS_ACTION . '" value="' . PSNG_ACTION_SETTINGS_PINGGOOGLE . '">' . "\n" . '<input type="Submit" value="Submit to search engines" name="submit">' . "\n" . '</form>' . "\n"); return TRUE; }
} if (!isset($f[$action])) { $t = current($f); $action = $t['class']; } $format = $f[$action]; if ($format['header'] == 1) { $h = false; } else { $h = true; } // Header of feeds $rss = new UniversalFeedCreator(); $rss->encoding = 'UTF-8'; $rss->setDir("feeds/topics_"); $rss->useCached($action, '', $h); $rss->title = $config['fname']; $rss->description = $config['fdesc']; $rss->link = $config['furl'] . "/forum.php"; $rss->language = $lang->phrase('rss_language'); $rss->ttl = $config['rssttl']; $rss->copyright = $config['fname']; $rss->lastBuildDate = time(); $rss->editor = $config['fname']; if ($config['syndication_insert_email'] == 1) { $rss->editorEmail = $config['forenmail']; } else { $rss->editorEmail = ''; } // Dirty permission hack I $my->p = $slog->Permissions(0, GROUP_GUEST, false);
} //类别ID $arrWhere = array(); $arrLink = array(); $arrWhere[] = "pass='******'"; if (!empty($_GET['type_id'])) { $intTypeID = intval($_GET['type_id']); $arrWhere[] = "type_roue_id like '%:" . $intTypeID . ":%'"; $arrLink[] = 'type_id=' . $intTypeID; } $strWhere = implode(' AND ', $arrWhere); $strWhere = 'where ' . $strWhere; $arrInfoList = check::getAPI($strModuleID, "getInfoList", "{$strWhere}^ ORDER BY topflag DESC,submit_date DESC^0^{$arrGPage['page_size']}^true^^0"); $strDomain = 'http://' . $_SERVER['HTTP_HOST']; $objRss = new UniversalFeedCreator(); $objRss->useCached(); $objRss->title = $arrGMeta[$strModuleID]['meta']['Title'] . 'RSS订阅 -' . $arrGWeb['name']; $objRss->description = $arrGMeta[$strModuleID]['meta']['Description'] . 'RSS订阅 -' . $arrGWeb['name']; $objRss->descriptionTruncSize = 500; $objRss->descriptionHtmlSyndicated = true; $objRss->link = $strDomain . "/" . $strModuleID . '/'; $objRss->syndicationURL = $strDomain . '/' . $_SERVER["PHP_SELF"]; foreach ($arrInfoList as $key => $val) { $objItem = new FeedItem(); $objItem->title = $val['title']; $strDir = ceil($val['id'] / $arrGCache['cache_filenum']); if ($arrGWeb['URL_static']) { if ($arrGWeb['file_static']) { $strUrl = $strDomain . '/' . $arrGWeb['cache_url'] . '/' . $strModuleID . '-' . $strDir . '/' . $val['id'] . $arrGWeb['file_suffix']; } else { $strUrl = $strDomain . '/' . $strModuleID . '/detail/id-' . $val['id'] . $arrGWeb['file_suffix'];
//if type is Summaries then get numwords from db $numWords = $this->numWords > 0 ? $this->numWords : 10000; // numWord == 0 represents ALL /*if type is RSS then use admin defined default if (($this->type=="RSS") || ($this->type=="RSSSUMM")) { //$this->type = "RSS".$row->defaultType; $this->type = "RSS2.0";// TO-DO } */ //make a feed id based filename $filename = JPATH_COMPONENT . DS . "feed" . DS . "feed" . $feedid . ".xml"; $rss = new UniversalFeedCreator(); //Use cache if docache is set to 1 if (intval($docache) == 1) { $rss->useCached($this->type, $filename, $this->cache); // use cached version if age<1 hour. May not return! } //$rss->title = htmlspecialchars($this->title, ENT_QUOTES); $rss->title = $this->title; $rss->description = $this->description; $rss->link = JURI::root(); $u = JFactory::getURI(); $rss->syndicationURL = $u->toString(); $rss->descriptionHtmlSyndicated = true; $image = new FeedImage(); $image->title = $mainframe->getCfg('sitename'); $image->url = $this->imgUrl; $image->link = JURI::root(); $image->description = $mainframe->getCfg('sitename'); $image->descriptionHtmlSyndicated = true;
protected function generateRss($key, $items, $title, $nopre = false) { // This is not a layout page $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); // Set the timezone to the user timezone $timezone = $this->_properties->getProperty('timezone'); date_default_timezone_set($timezone); // Get a few user preferences $config = Zend_Registry::get("configuration"); $root = Zend_Registry::get("root"); $host = $this->getHostname(); $preamble = $nopre ? false : $this->_properties->getProperty('preamble', true); $username = $this->_user->username; // Get the domain right $domain = Zend_Registry::get("host"); // Get the cache path for feeds if (isset($config->path->feeds)) { $path = $config->path->feeds; } else { $path = dirname($root) . "/feeds/"; } // Render the RSS feed // Go ahead and display the page $rss = new UniversalFeedCreator(); $rss->encoding = "UTF-8"; // Get the cached object $rss_key = "RSS_" . $username . "_" . md5($key); $rss->useCached("RSS2.0", $path . "/{$rss_key}.xml", 300); // use cached version if age<10 minutes // Get all the items and build rss $rss->title = $title; $rss->descriptionTruncSize = 0; $rss->descriptionHtmlSyndicated = true; $rss->link = "http://{$domain}"; if (isset($items) && is_array($items)) { for ($i = 0; $i < count($items); $i++) { $item = $items[$i]; $source_id = $item->getSource(); $item_id = $item->getID(); $type = $item->getType(); $slug = $item->getSlug(); $title = $item->getTitle(); $pream = $preamble ? $item->getPreamble() : ""; $entry = new FeedItem(); $entry->guid = "/entry/{$source_id}/{$item_id}"; $entry->title = $pream . ($title ? $title : "Untitled"); $entry->link = "http://{$domain}/entry/{$slug}"; $entry->description = $item->getRssBody(); $entry->descriptionHtmlSyndicated = true; $entry->source = $item->getLink(); $entry->descriptionTruncSize = 0; $entry->date = (int) $item->getTimestamp(); $entry->author = $username; if ($type == SourceItem::AUDIO_TYPE) { $enclosure = array(); $enclosure['url'] = $item->getAudioUrl(); $enclosure['type'] = "audio/mpeg"; $entry->enclosure = $enclosure; } $rss->addItem($entry); } } $rss->saveFeed("RSS2.0", $path . "/{$rss_key}.xml"); }
case "staff": $rss_feed_name = "Staff Feed"; $notice_where_clause = "(a.`target` = 'all' OR a.`target` = 'staff')"; break; case "student": default: $rss_feed_name = "Student Feed" . ((int) $TARGET ? ", Class of " . $TARGET : ""); $notice_where_clause = "(" . ((int) $TARGET ? "a.`target`=" . $db->qstr($TARGET) . " OR " : "") . "a.`target` = 'all' OR a.`target` = 'students')"; break; } if (isset($_GET["o"]) && ($sanitized = clean_input($_GET["o"], array("int")))) { $ORGANISATION = $sanitized; $notice_where_clause .= 'AND (a.`organisation_id` IS NULL OR a.`organisation_id` = ' . $ORGANISATION . ')'; } $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "Undergrad Notices: " . $rss_feed_name; $rss->description = "Announcements, Schedule Changes, Updates and more from the Undergraduate Medicial Education Office, Queen's University."; $rss->link = ENTRADA_URL . "/dashboard"; $rss->syndicationURL = ENTRADA_URL . "/notices/" . $TARGET; $query = "\n\t\tSELECT a.*\n\t\tFROM `notices` AS a\n\t\tWHERE " . ($notice_where_clause ? $notice_where_clause . " AND" : "") . "\n\t\t(a.`display_from`='0' OR a.`display_from` <= '" . time() . "')\n\t\tORDER BY a.`updated_date` DESC, a.`display_from` DESC"; $results = USE_CACHE ? $db->CacheGetAll(CACHE_TIMEOUT, $query) : $db->GetAll($query); if ($results) { foreach ($results as $result) { $item = new FeedItem(); $item->title = $result["notice_summary"]; $item->link = ENTRADA_URL . "/dashboard"; $item->description = $result["notice_summary"]; $item->date = unixstamp_to_iso8601((int) $result["display_from"] ? $result["display_from"] : time()); $item->source = ENTRADA_URL . "/dashboard"; $item->author = "Undergraduate Medical Office";
function feedFrontpage($showFeed) { global $database, $mainframe; global $mosConfig_live_site, $mosConfig_offset, $mosConfig_sef, $mosConfig_absolute_path; // get id of the syndication component $query = "SELECT a.id" . "\n FROM #__components AS a" . "\n WHERE a.name = 'Syndicate'"; $database->setQuery($query); $id = $database->loadResult(); // load the row from the database table $row = new mosComponent($database); $row->load($id); // get syndication param definitions $params =& new mosParameters($row->params, $mainframe->getPath('com_xml', $row->option), 'component'); $query = "SELECT id FROM #__modules WHERE published=1 AND module='mod_rssfeed'"; $database->setQuery($query); if (!$database->loadResult()) { mosNotAuth(); return; } $now = date('Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60); $iso = split('=', _ISO); // parameter intilization $info['date'] = date('r'); $info['year'] = date('Y'); $info['encoding'] = $iso[1]; $info['link'] = htmlspecialchars($mosConfig_live_site); $info['cache'] = $params->def('cache', 1); $info['cache_time'] = $params->def('cache_time', 3600); $info['count'] = $params->def('count', 5); $info['orderby'] = $params->def('orderby', ''); $info['title'] = $params->def('title', 'Powered by Mambo'); $info['description'] = $params->def('description', 'Mambo site syndication'); $info['image_file'] = $params->def('image_file', 'mambo_rss.png'); if ($info['image_file'] == -1) { $info['image'] = NULL; } else { $info['image'] = $mosConfig_live_site . '/images/M_images/' . $info['image_file']; } $info['image_alt'] = $params->def('image_alt', 'Powered by Mambo'); $info['limit_text'] = $params->def('limit_text', 1); $info['text_length'] = $params->def('text_length', 20); // get feed type from url $info['feed'] = mosGetParam($_GET, 'feed', 'RSS2.0'); // live bookmarks $info['live_bookmark'] = $params->def('live_bookmark', ''); $info['bookmark_file'] = $params->def('bookmark_file', ''); // content to syndicate // $info[ 'content' ] = $params->def( 'content', -1 ); // set filename for live bookmarks feed if (!$showFeed & $info['live_bookmark']) { if ($info['bookmark_file']) { // custom bookmark filename $info['file'] = $mosConfig_absolute_path . '/cache/' . $info['bookmark_file']; } else { // standard bookmark filename $info['file'] = $mosConfig_absolute_path . '/cache/' . $info['live_bookmark']; } } else { // set filename for rss feeds $info['file'] = getFeedType($info['feed']); if (!$info['file']) { return; } } // load feed creator class $rss = new UniversalFeedCreator(); // load image creator class $image = new FeedImage(); // loads cache file if ($showFeed && $info['cache']) { $rss->useCached($info['feed'], $info['file'], $info['cache_time']); } $rss->title = $info['title']; $rss->description = $info['description']; $rss->link = $info['link']; $rss->syndicationURL = $info['link']; $rss->cssStyleSheet = NULL; $rss->encoding = $info['encoding']; if ($info['image']) { $image->url = $info['image']; $image->link = $info['link']; $image->title = $info['image_alt']; $image->description = $info['description']; // loads image info into rss array $rss->image = $image; } // Determine ordering for sql switch (strtolower($info['orderby'])) { case 'date': $orderby = 'a.created'; break; case 'rdate': $orderby = 'a.created DESC'; break; case 'alpha': $orderby = 'a.title'; break; case 'ralpha': $orderby = 'a.title DESC'; break; case 'hits': $orderby = 'a.hits DESC'; break; case 'rhits': $orderby = 'a.hits ASC'; break; case 'front': $orderby = 'f.ordering'; break; default: $orderby = 'f.ordering'; break; } $join = "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"; $_and = ''; // query of frontpage content items $query = "SELECT a.*, u.name AS author, u.usertype" . "\n FROM #__content AS a" . $join . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n WHERE a.state = '1'" . $_and . "\n AND a.access = 0" . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '" . $now . "' )" . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '" . $now . "' )" . "\n ORDER BY " . $orderby . ($info['count'] ? "\n LIMIT " . $info['count'] : ''); $database->setQuery($query); $rows = $database->loadObjectList(); foreach ($rows as $row) { // title for particular item $item_title = htmlspecialchars($row->title); $item_title = html_entity_decode($item_title); // article author $item_author = $row->author; $ItemID = $mainframe->getItemid($row->id); if ($ItemID == 0) { //If the content item is not tied to a menu and the ItemID is 0 then the URL fails with SEF on //Reset to frontpage if this is the case $ItemID = 1; } // url link to article (& used instead of & as this is converted by feed creator) /* Build the $item_link a bit differently for SEF since sefRelToAbs doesn't convert the URL properly when passed $mosConfig_live_site. No SEF needs $mosConfig_live_site, else & becomes an issue. */ if ($mosConfig_sef == 1) { $item_link = 'index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $ItemID; } else { $item_link = $mosConfig_live_site . '/index.php?option=com_content&task=view&id=' . $row->id . '&Itemid=' . $ItemID; } $item_link = sefRelToAbs($item_link); // removes all formating from the intro text for the description text $item_description = $row->introtext; $item_description = mosHTML::cleanText($item_description); $item_description = html_entity_decode($item_description); if ($info['limit_text']) { if ($info['text_length']) { // limits description text to x words $item_description_array = split(' ', $item_description); $count = count($item_description_array); if ($count > $info['text_length']) { $item_description = ''; for ($a = 0; $a < $info['text_length']; $a++) { $item_description .= $item_description_array[$a] . ' '; } $item_description = trim($item_description); $item_description .= '...'; } } else { // do not include description when text_length = 0 $item_description = NULL; } } // load individual item creator class $item = new FeedItem(); // item info $item->title = $item_title; $item->link = $item_link; $item->description = $item_description; $item->source = $info['link']; $item->author = $item_author; // loads item info into rss array $rss->addItem($item); } // save feed file $rss->saveFeed($info['feed'], $info['file'], $showFeed); }