- md5
- 69c611cbc8ac8182965f1aca8629e4bd
- sha1
- 7f13f6a5300743942ba194e46e7657cf357e96d4
- sha256
- e0af02ca7855832abc2cc10f5a27427967d9b4f0a5a329c5c5666ff334e33deb
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
<?php
/**
* @version $Id: rss.php 3718 2006-05-29 06:48:03Z stingrey $
* @package Joomla
* @subpackage Syndicate
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
// load feed creator class
require_once( $mosConfig_absolute_path .'/includes/feedcreator.class.php' );
$info = null;
$rss = null;
switch ( $task ) {
case 'live_bookmark':
feedFrontpage( false );
break;
default:
feedFrontpage( true );
break;
}
/*
* Creates feed from Content Iems associated to teh frontpage component
*/
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( $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 = '$nullDate' OR a.publish_up <= '$now' )"
. "\n AND ( a.publish_down = '$nullDate' OR a.publish_down >= '$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 );
}
?>
The same content is in 2 releases, Joomla 1.0.9 to 1.0.10. See them all, or every version of this file.