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"); }
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 handleRSS($results) { $app =& Dataface_Application::getInstance(); $record =& $app->getRecord(); $query =& $app->getQuery(); import('feedcreator.class.php'); import('Dataface/FeedTool.php'); $ft = new Dataface_FeedTool(); $rss = new UniversalFeedCreator(); $rss->encoding = $app->_conf['oe']; //$rss->useCached(); // use cached version if age<1 hour $del =& $record->_table->getDelegate(); if (!$del or !method_exists($del, 'getSingleRecordSearchFeed')) { $del =& $app->getDelegate(); } if ($del and method_exists($del, 'getSingleRecordSearchFeed')) { $feedInfo = $del->getSingleRecordSearchFeed($record, $query); if (!$feedInfo) { $feedInfo = array(); } } if (isset($feedInfo['title'])) { $rss->title = $feedInfo['title']; } else { $rss->title = $record->getTitle() . '[ Search for "' . $query['--subsearch'] . '"]'; } if (isset($feedInfo['description'])) { $rss->description = $feedInfo['description']; } else { $rss->description = ''; } if (isset($feedInfo['link'])) { $rss->link = $feedInfo['link']; } else { $rss->link = htmlentities(df_absolute_url($app->url('') . '&--subsearch=' . urlencode($query['--subsearch']))); } $rss->syndicationURL = $rss->link; $records = array(); foreach ($results as $result) { foreach ($result as $rec) { $records[] = $rec->toRecord(); } } uasort($records, array($this, 'cmp_last_modified')); foreach ($records as $rec) { if ($rec->checkPermission('view') and $rec->checkPermission('view in rss')) { $rss->addItem($ft->createFeedItem($rec)); } } if (!$query['--subsearch']) { $rss->addItem($ft->createFeedItem($record)); } header("Content-Type: application/xml; charset=" . $app->_conf['oe']); echo $rss->createFeed('RSS2.0'); exit; }
function showRSSActivity(&$rows) { $app = JFactory::getApplication(); // Load feed creator class require_once JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'assets' . DS . 'feedcreator' . DS . 'feedcreator.php'; $rssfile = $app->getCfg('tmp_path') . '/rssAUPactivity.xml'; $rss = new UniversalFeedCreator(); $rss->title = $app->getCfg('sitename'); $rss->description = JText::_('AUP_LASTACTIVITY'); $rss->link = JURI::base(); $rss->syndicationURL = JURI::base(); $rss->cssStyleSheet = NULL; $rss->descriptionHtmlSyndicated = true; if ($rows) { foreach ($rows as $row) { // exceptions private data if ($row->plugin_function == 'plgaup_getcouponcode_vm' || $row->plugin_function == 'plgaup_alphagetcouponcode_vm' || $row->plugin_function == 'sysplgaup_buypointswithpaypal') { $datareference = ''; } switch ($row->plugin_function) { case 'sysplgaup_dailylogin': case 'plgaup_dailylogin': $row->datareference = JHTML::_('date', $row->datareference, JText::_('DATE_FORMAT_LC1')); break; case 'plgaup_getcouponcode_vm': case 'plgaup_alphagetcouponcode_vm': case 'sysplgaup_buypointswithpaypal': $row->datareference = ''; break; default: } $datareference = $row->datareference != '' ? ' (' . $row->datareference . ')' : ''; // special format //if ( $row->plugin_function=='sysplgaup_dailylogin' ) $datareference = ''; $item = new FeedItem(); $item->title = htmlspecialchars($row->usrname, ENT_QUOTES, 'UTF-8'); $item->description = JText::_($row->rule_name) . "{$datareference} / " . $row->last_points . " " . JText::_('AUP_POINTS'); $item->descriptionTruncSize = 250; $item->descriptionHtmlSyndicated = true; @($date = $row->insert_date ? date('r', strtotime($row->insert_date)) : ''); $item->date = $date; $item->source = JURI::base(); $rss->addItem($item); } } // save feed file $rss->saveFeed('RSS2.0', $rssfile); }
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 create_xml($fileName, &$list, &$ads, &$columns) { global $gorumroll; include FEED_DIR . "/feedcreator.class.php"; $ufc = new UniversalFeedCreator(); $ufc->descriptionHtmlSyndicated = TRUE; $ufc->title = $list->listTitle; $ufc->description = $list->listDescription; $ctrl =& new AppController("customlist/{$list->id}"); $ufc->link = $ctrl->makeUrl(TRUE); $ufc->syndicationURL = $gorumroll->ctrl->makeUrl(TRUE); // link to this page $owner = new User(); foreach ($ads as $ad) { $item = new FeedItem(); $item->descriptionHtmlSyndicated = TRUE; $item->title = $ad->getTitle(FALSE); $ctrl = $ad->getLinkCtrl($item->title); $item->link = $ctrl->makeUrl(TRUE); $item->description = $ad->getDescription(FALSE); // without htmlspecialchars() $item->date = (int) $ad->creationtime->getTimestamp(); $item->additionalElements = array(); foreach ($columns as $column) { if (isset($ad->{$column->columnIndex})) { if ($column->userField) { $owner->{$column->userColumnIndex} = $ad->{$column->columnIndex}; $content = $owner->showListVal($column->userColumnIndex, "", TRUE); } else { $content = $ad->showListVal($column->columnIndex, "", TRUE); } $item->additionalElements[$column->showListVal("name")] = array("html" => $column->allowHtml || $column->type == customfield_url || $column->type == customfield_picture || $column->type == customfield_media || $column->columnIndex == "cName" || $column->userColumnIndex == "email", "content" => $content); } } $ufc->addItem($item); } $ufc->saveFeed($list->xmlType, $fileName, FALSE); }
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); }
/** * records history events in rss/rss_$project->id.xml * * must be called from a project-related page! * * * @param project - current project object used in: proj.inc.php <- function call */ static function updateRSS($project) { global $PH; global $auth; if (!$project) { return NULL; } /** * only show changes by others */ if (Auth::isAnonymousUser()) { $not_modified_by = NULL; } else { $not_modified_by = $auth->cur_user->id; } ### get all the changes (array of history items) ## $changes = ChangeLine::getChangeLines(array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => 20, 'type' => array(ITEM_TASK, ITEM_FILE), 'limit_offset' => 0)); /* $changes= DbProjectItem::getAll(array( 'project' => $project->id, # query only this project history 'alive_only' => false, # get deleted entries 'visible_only' => false, # ignore user viewing rights 'limit_rowcount' => 20, # show only last 20 entries in rss feed #'show_assignments' => false, # ignore simple assignment events )); */ $url = confGet('SELF_PROTOCOL') . '://' . confGet('SELF_URL'); # url part of the link to the task $from_domain = confGet('SELF_DOMAIN'); # domain url if (confGet('USE_MOD_REWRITE')) { $url = str_replace('index.php', '', $url); } ### define general rss file settings ### $rss = new UniversalFeedCreator(); $rss->title = "StreberPM: " . $project->name; $rss->description = "Latest Project News"; $rss->link = "{$url}?go=projView&prj={$project->id}"; $rss->syndicationURL = $url; # go through all retrieved changes and create rss feed foreach ($changes as $ch) { $item = $ch->item; $name_author = __('???'); if ($person = Person::getVisibleById($item->modified_by)) { $name_author = $person->name; } $str_updated = ''; if ($new = $ch->item->isChangedForUser()) { if ($new == 1) { $str_updated = __('New'); } else { $str_updated = __('Updated'); } } $feeditem = new FeedItem(); $feeditem->title = $item->name . " (" . $ch->txt_what . ' ' . __("by") . ' ' . $name_author . ")"; $feeditem->link = $url . "?go=itemView&item={$item->id}"; $feeditem->date = gmdate("r", strToGMTime($item->modified)); $feeditem->source = $url; $feeditem->author = $name_author; switch ($ch->type) { case ChangeLine::COMMENTED: $feeditem->description = $ch->html_details; break; case ChangeLine::NEW_TASK: $feeditem->description = str_replace("\n", "<br>", $item->description); break; default: $feeditem->description = $ch->type . " " . str_replace("\n", "<br>", $item->description); break; } $rss->addItem($feeditem); } /** * all history items processed ... * save the rss 2.0 feed to rss/rss_$project->id.xml ... * false stands for not showing the resulting feed file -> create in background */ $rss->saveFeed("RSS2.0", "_rss/proj_{$project->id}.xml", false); }
function generate_feed($feed, $uniqueid, $rss_version, $changes, $itemurl, $urlparam, $id, $title, $titleId, $desc, $descId, $dateId, $authorId) { global $tikiIndex; global $userslib; if ($rss_version == '') { // override version if set as request parameter if (isset($_REQUEST["ver"])) { $ver = $_REQUEST["ver"]; $rss_version = $this->get_rss_version($ver); } else { $rss_version = 9; // default to RSS 0.91 } } else { $rss_version = $this->get_rss_version($rss_version); } $now = date("U"); $output = $this->get_from_cache($uniqueid, $rss_version); if ($output != "EMPTY") { return $output; } $urlarray = parse_url($_SERVER["REQUEST_URI"]); /* this gets the correct directory name aka dirname when tikiwiki is on the main directory, i mean when ur site is www.yoursite.com, the dirname of your site is "/" and when tikiwiki is not on main directory, i mean www.yoursite.com/tiki, the dirname returns "/tiki". so, on URLs, we just need to add a extra slash when the tikiwiki isnt on the main directory, what means, dirname($urlarray["path"]) equals to "/tiki", otherwise we can ommit them. This is a quick hack to solve the infamous double-slash problem, which was introduced somewhen after 1.9.0 release http://dev.tikiwiki.org/tiki-view_tracker_item.php?trackerId=5&itemId=291 */ $dirname = dirname($urlarray["path"]) != "/" ? "/" : ""; $url = htmlspecialchars($this->httpPrefix() . $_SERVER["REQUEST_URI"]); $home = htmlspecialchars($this->httpPrefix() . dirname($urlarray["path"]) . $dirname . $tikiIndex); $img = htmlspecialchars($this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "img/tiki.jpg"); $title = htmlspecialchars($title); $desc = htmlspecialchars($desc); $read = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . $itemurl; // different stylesheets for atom and rss $cssStyleSheet = ""; $xslStyleSheet = ""; $encoding = "ISO-8859-1"; $encoding = "UTF-8"; $contenttype = "application/xml"; // valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS // valid format ids : 9 , 1 , 2 , 3 , 4 , 6 , 5 , 7 , 8 switch ($rss_version) { case "1": // RSS 1.0 $cssStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/rss-style.css"; break; case "2": // RSS 2.0 $cssStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/rss-style.css"; $xslStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/rss20.xsl"; break; case "3": // PIE 0.1 break; case "4": // MBOX $contenttype = "text/plain"; break; case "5": // ATOM0.3 $cssStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/atom-style.css"; break; case "6": // OPML $xslStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/opml.xsl"; break; case "7": // HTML $contenttype = "text/plain"; break; case "8": // JS $contenttype = "text/javascript"; break; case "9": // RSS 0.91 $cssStyleSheet = $this->httpPrefix() . dirname($urlarray["path"]) . $dirname . "lib/rss/rss-style.css"; break; } $rss = new UniversalFeedCreator(); $rss->title = $title; $rss->description = $desc; //optional $rss->descriptionTruncSize = 500; $rss->descriptionHtmlSyndicated = true; $rss->cssStyleSheet = htmlspecialchars($cssStyleSheet); $rss->xslStyleSheet = htmlspecialchars($xslStyleSheet); $rss->encoding = $encoding; $rss->language = $this->get_preference("rssfeed_language", "en-us"); $rss->editor = $this->get_preference("rssfeed_editor", ""); $rss->webmaster = $this->get_preference("rssfeed_webmaster", ""); $rss->link = $url; $rss->feedURL = $url; $image = new FeedImage(); $image->title = tra("tikiwiki logo"); $image->url = $img; $image->link = $home; $image->description = tra(sprintf("Feed provided by %s. Click to visit.", $home)); //optional $image->descriptionTruncSize = 500; $image->descriptionHtmlSyndicated = true; $rss->image = $image; global $dbTiki; if (!isset($userslib)) { $userslib = new Userslib($dbTiki); } foreach ($changes["data"] as $data) { $item = new FeedItem(); $item->title = $data["{$titleId}"]; // 2 parameters to replace if ($urlparam != '') { $item->link = sprintf($read, urlencode($data["{$id}"]), urlencode($data["{$urlparam}"])); } else { $item->link = sprintf($read, urlencode($data["{$id}"])); } if (isset($data["{$descId}"])) { $item->description = $data["{$descId}"]; } else { $item->description = ""; } //optional //item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; $item->date = (int) $data["{$dateId}"]; $item->source = $url; $item->author = ""; if ($authorId != "") { if ($userslib->user_exists($data["{$authorId}"])) { $item->author = $data["{$authorId}"]; // only use realname <email> if existing and $tmp = ""; if ($this->get_user_preference($data["{$authorId}"], 'user_information', 'private') == 'public') { $tmp = $this->get_user_preference($data["{$authorId}"], "realName"); } $epublic = $this->get_user_preference($data["{$authorId}"], 'email is public', 'n'); if ($epublic != 'n') { $res = $userslib->get_user_info($data["{$authorId}"], false); if ($tmp != "") { $tmp .= ' '; } $tmp .= "<" . scrambleEmail($res['email'], $epublic) . ">"; } if ($tmp != "") { $item->author = $tmp; } } else { $item->author = $data["{$authorId}"]; } } $rss->addItem($item); } $data = $rss->createFeed($this->get_rss_version_name($rss_version)); $this->put_to_cache($uniqueid, (int) $data, $rss_version); $output = array(); $output["data"] = $data; $output["content-type"] = $contenttype; $output["encoding"] = $encoding; return $output; }
header('WWW-Authenticate: Basic realm="ownCloud Login"'); header('HTTP/1.0 401 Unauthorized'); exit; } $lang = OC_Preferences::getValue($uid, 'core', 'lang', OC_L10N::findLanguage()); $l = OC_L10N::get('notify', $lang); //TODO: use different feed creator library (like Zend_Feed) and switch html flag to true $notifications = OC_Notify::getNotifications($uid, 50, $lang, false); $baseAddress = (isset($_SERVER["HTTPS"]) ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"]; $rssURI = $baseAddress . $baseuri . 'feed.rss'; $atomURI = $baseAddress . $baseuri . 'feed.atom'; $feed = new UniversalFeedCreator(); $feed->title = $l->t('ownCloud notifications'); $feed->description = $l->t('ownCloud notification stream of the user "%s".', array($uid)); $feed->link = $baseAddress . OC::$WEBROOT; $feed->syndicationURL = $baseAddress . $_SERVER["PHP_SELF"]; $feed->image = new FeedImage(); $feed->image->title = 'ownCloud'; $feed->image->url = $baseAddress . OCP\Util::imagePath('core', 'logo-inverted.png'); $feed->image->link = $feed->link; foreach ($notifications as $notification) { $item = new FeedItem(); $item->title = strip_tags($notification["summary"]); $item->date = strtotime($notification["moment"]); $item->link = OCP\Util::linkToAbsolute("notify", "go.php", array("id" => $notification["id"])); $item->description = $notification["content"]; //TODO image $item->author = "ownCloud (" . $notification["app"] . " app)"; $feed->addItem($item); } $feed->outputFeed($type);
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); }
$repository = "http://svn.svnkit.com/repos/svnkit/tags/"; $contents = read_contents($repository); if (!$contents) { echo $rss->createFeed(); exit; } $items = publish_rss20($repository, $contents, "http://www.svnkit.com/"); for($i = 0; $i < count($items); $i++) { $item = $items[$i]; $rssitem = new FeedItem(); $rssitem->title = $item["title"]; $rssitem->source = $item["source"]; $rssitem->link = $item["link"]; $rssitem->author = $item["author"]; $rssitem->date = $item["date"]; $rssitem->authorEmail = "*****@*****.**"; $rssitem->editorEmail = "*****@*****.**"; $rssitem->description = $item["rss_description"]; $rss->addItem($rssitem); } $rss->saveFeed("RSS2.0", $cacheFile); readfile($cacheFile); exit; ?>
/** * 掲示板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 _showrss() { $app = JFactory::getApplication(); // Load feed creator class require_once JPATH_SITE . DS . 'includes' . DS . 'feedcreator.class.php'; $rssfile = $app->getCfg('tmp_path') . '/rss.xml'; $rss = new UniversalFeedCreator(); $rss->title = $app->getCfg('sitename'); $rss->description = $app->getCfg('MetaDesc'); $rss->link = JURI::base(); $rss->syndicationURL = JURI::base(); $rss->cssStyleSheet = NULL; $rss->descriptionHtmlSyndicated = true; $rows = $this->rows; if ($rows) { foreach ($rows as $row) { $item = new FeedItem(); $sluggy = $row->slug; if ($row->catslug && $sluggy != '') { $sluggy .= "&catid=" . $row->catslug; } $sluggy .= "&directory=" . $this->menuid; $item->title = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC2')) . " - " . stripslashes($row->title); $item->link = JURI::base() . "/" . $row->href . $sluggy; $item->description = $row->text != '' ? $row->text : $row->fulltext; $item->descriptionTruncSize = 250; $item->descriptionHtmlSyndicated = true; @($date = $row->created ? date('r', strtotime($row->created)) : ''); $item->date = $date; $item->source = JURI::base(); $rss->addItem($item); } } // save feed file $rss->saveFeed('RSS2.0', $rssfile); }
function outputtorss($code, $line = "10") { global $apps_path, $web_title; include_once "{$apps_path['libs']}/gpl/feedcreator.class.php"; $code = strtoupper($code); if (!$line) { $line = "10"; } $format_output = "RSS0.91"; $rss = new UniversalFeedCreator(); $db_query1 = "SELECT * FROM playsms_tblSMSIncoming WHERE in_code='{$code}' ORDER BY in_datetime DESC LIMIT 0,{$line}"; $db_result1 = dba_query($db_query1); while ($db_row1 = dba_fetch_array($db_result1)) { $title = $db_row1[in_masked]; $description = $db_row1[in_msg]; $datetime = $db_row1[in_datetime]; $items = new FeedItem(); $items->title = $title; $items->description = $description; $items->comments = $datetime; $items->date = strtotime($datetime); $rss->addItem($items); } $feeds = $rss->createFeed($format_output); return $feeds; }
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); }
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); }
/** * 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); }
function rss() { $database = JFactory::getDBO(); $cfg = BidsHelperTools::getConfig(); ob_end_clean(); $feed = $cfg->bid_opt_RSS_feedtype; $cat = JRequest::getInt('cat', ''); $user = JRequest::getInt('user', ''); $limit = $cfg->bid_opt_RSS_description ? intval($cfg->bid_opt_RSS_nritems) : intval($cfg->bid_opt_nr_items_per_page); if (!$limit) $limit = 10; require_once (JPATH_COMPONENT_SITE.DS.'libraries'.DS.'feedcreator'.DS.'feedcreator.php'); $rss = new UniversalFeedCreator(); $rss->title = $cfg->bid_opt_RSS_title; $rss->description = $cfg->bid_opt_RSS_description; $rss->link = htmlspecialchars(JURI::root()); $rss->syndicationURL = htmlspecialchars(JURI::root()); $rss->cssStyleSheet = null; $rss->encoding = 'UTF-8'; $where = " where a.published=1 and a.close_offer=0 and a.close_by_admin=0 "; if ($cat) { if (!$cfg->bid_opt_inner_categories) { $where .= " and a.cat = '" . $cat . "' "; } else { $catOb = BidsHelperTools::getCategoryModel(); $cTree = $catOb->getCategoryTree($cat,true); $cat_ids = array(); if ($cTree) { foreach ($cTree as $cc) { if (!empty($cc->id)) { $cat_ids[] = $cc->id; } } } if (count($cat_ids)) $cat_ids = implode(",", $cat_ids); $where .= " and ( a.cat IN (" . $cat_ids . ") )"; } } if ($user) { $where .= " AND userid=".$database->quote($user); } $database->setQuery("select a.* from #__bid_auctions a left join #__categories c on c.id=a.cat ".$where." order by id desc", 0, $limit); $rows = $database->loadObjectList(); for ($i = 0; $i < count($rows); $i++) { $auction = $rows[$i]; $item_link = JHtml::_('auctiondetails.auctionDetailsURL',$auction, false); // removes all formating from the intro text for the description text $item_description = $auction->description; $item_description = JFilterOutput::cleanText($item_description); $item_description = html_entity_decode($item_description); // load individual item creator class $item = new FeedItem(); // item info $item->title = $auction->title; $item->link = $item_link; $item->description = $item_description; $item->source = $rss->link; $item->date = date('r', strtotime($auction->start_date)); $database->setQuery( "select title from #__categories where id=".$database->quote($auction->cat) ); $item->category = $database->loadResult(); $rss->addItem($item); } echo $rss->createFeed($feed); }
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"); }
$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']; } } else { $strUrl = $strDomain . '/' . $strModuleID . '/detail.php?id=' . $val['id']; } $objItem->link = $strUrl; $objItem->description = $val['summary']; //optional $objItem->descriptionTruncSize = 500; $objItem->descriptionHtmlSyndicated = true; $objItem->date = strtotime($val['submit_date']); $objItem->source = $strDomain; $objItem->author = $_SERVER['HTTP_HOST']; $objRss->addItem($objItem); } echo $objRss->saveFeed("RSS2.0", $arrGSmarty['cache_dir'] . $objRss->_generateFilename());
function sms_board_output_rss($keyword, $line = "10", $format = "RSS0.91") { global $core_config; $keyword = strtoupper($keyword); $line = $line ? $line : '10'; $format_output = $format ? $format : "RSS0.91"; include_once $core_config['apps_path']['plug'] . "/feature/sms_board/lib/external/feedcreator/feedcreator.class.php"; $rss = new UniversalFeedCreator(); $rss->title = $core_config['main']['web_title']; $rss->description = _('SMS Board') . ' ' . $keyword; $db_query1 = "SELECT * FROM " . _DB_PREF_ . "_featureBoard_log WHERE in_keyword='{$keyword}' ORDER BY in_datetime DESC LIMIT {$line}"; $db_result1 = dba_query($db_query1); while ($db_row1 = dba_fetch_array($db_result1)) { $title = $db_row1['in_masked']; $description = $db_row1['in_msg']; $datetime = core_display_datetime($db_row1['in_datetime']); $items = new FeedItem(); $items->title = $title; $items->description = $description; $items->comments = $datetime; $items->date = strtotime($datetime); $rss->addItem($items); } $feeds = $rss->createFeed($format_output); return $feeds; }
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"); }
// <link rel="x-stanza-cover-image" type="image/jpeg" href="cover.php?filename=$file"/> $coverLink = new LinkItem(); $coverLink->rel = "x-stanza-cover-image"; $coverLink->type = "image/jpeg"; $coverLink->href = "cover.php?filename={$file}"; $item->addLink($coverLink); $thumbnailLink = new LinkItem(); $thumbnailLink->rel = "x-stanza-cover-image-thumbnail"; $thumbnailLink->type = "image/jpeg"; $thumbnailLink->href = "cover.php?filename={$file}&type=thumb"; $item->addLink($thumbnailLink); // <link rel="x-stanza-cover-image" type="image/jpeg" href="/get/cover/3"/> // <link rel="x-stanza-cover-image-thumbnail" type="image/jpeg" href="/get/thumb/3"/> // if there is no description set it to be the same as the titke if ($ebook->getDcDescription() == "") { $item->description = $item->title; } else { $item->description = strip_tags($ebook->getDcDescription()); } // sometimes DcCreator is an array, so make sure we display in both cases if (is_array($ebook->getDcCreator())) { $item->author = implode(', ', $ebook->getDcCreator()); } else { $item->author = $ebook->getDcCreator(); } $atom->addItem($item); } } // can also saveFeed(format, filename) if we want $atom->outputFeed("ATOM1.0"); closedir($dir);
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"); }
function sms_board_output_rss($keyword, $line = "10") { global $apps_path, $web_title; include_once $apps_path['plug'] . "/feature/sms_board/lib/external/feedcreator/feedcreator.class.php"; $keyword = strtoupper($keyword); if (!$line) { $line = "10"; } $format_output = "RSS0.91"; $rss = new UniversalFeedCreator(); $db_query1 = "SELECT * FROM " . _DB_PREF_ . "_featureBoard_log WHERE in_keyword='{$keyword}' ORDER BY in_datetime DESC LIMIT 0,{$line}"; $db_result1 = dba_query($db_query1); while ($db_row1 = dba_fetch_array($db_result1)) { $title = $db_row1['in_masked']; $description = $db_row1['in_msg']; $datetime = $db_row1['in_datetime']; $items = new FeedItem(); $items->title = $title; $items->description = $description; $items->comments = $datetime; $items->date = strtotime($datetime); $rss->addItem($items); } $feeds = $rss->createFeed($format_output); return $feeds; }
/** * 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; } }
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"; $rss->addItem($item); } } echo $rss->createFeed();
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); }