C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\mamFM\components\com_rss\rss.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
/**
* @version $Id: rss.php 2287 2006-02-11 16:03:50Z 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':
        
feedFrontpagefalse );
        break;

    default:
        
feedFrontpagetrue );
        break;
}

/*
* Creates feed from Content Iems associated to teh frontpage component
*/
function feedFrontpage$showFeed ) {
    global 
$database$mainframe;
    global 
$mosConfig_live_site$mosConfig_offset$mosConfig_absolute_path$mosConfig_cachepath;

    
$nullDate $database->getNullDate();
    
// pull id of syndication component
    
$query "SELECT a.id"
    
"\n FROM #__components AS a"
    
"\n WHERE 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');
    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     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');
    
$info'cache_time' ]         = $params->def'cache_time'3600 );
    
$info'count' ]            = $params->def'count');
    
$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' ] == -) {
        
$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');
    
$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''' );

    
// 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' ] = strtolowerstr_replace'.'''$info'feed' ] ) );
        
        
// security check to limit arbitrary file creation.
        
switch ( $info'file' ] ) {
            case 
'rss091':            
            case 
'rss10':            
            case 
'rss20':            
            case 
'atom03':            
            case 
'opml':            
                
$filename $info'file' ] .'.xml';
                break;
            
            default:
                echo 
_NOT_AUTH;
                return;
                break;            
        }
    }
    
// 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;
    }

    
$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, UNIX_TIMESTAMP( a.created ) AS created_ts, cat.title AS cat_title, sec.title AS section_title"
    
"\n FROM #__content AS a"
    
$join
    
"\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"
    
$and
    
"\n AND a.access = 0"
    
"\n AND ( publish_up = '$nullDate' OR publish_up <= '$now' )"
    
"\n AND ( publish_down = '$nullDate' 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 );

        
// url link to article
        // & used instead of &amp; as this is converted by feed creator
        
$item_link '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 ( 
$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 );
}
?>