============================================================================================================================
Modification Title: RSS Feed Mod

Version: 1.0

Author: Area51mafia

Description:
This modification will provide a Valid RSS feed for your 20 Recent Posts in the last 2 days.
This modification will provide a Valid RSS feed for each forum, displaying the last 20 threads in the last 2 days.
This modification will provide restrictions so guests and members can't view forums they are not allowed to.
This modification will provide the ability to turn the RSS Feed on and off.
This modification will also provide messages if the user viewing the RSS Feed is banned, if the board is off, or if the RSS Feed is off.
The RSS Feed matches the character encoding of the members selected lang file.
If you have the Copyright Notice installed this modification will provide the copyright element in your feed.
If you are running a brand new board with no posts and are installing this, you may wish to change the $charset in the lang files to UTF-8, then nearly all languages will be supported, as well as special characters.

Supported Version: XMB 1.9.5 SP1

Updated for 1.9.5 by: WormHole @ XMB Garage

Installation Note: Before adding this modification to your forum, you should back up all files related to this modification.

License Note: This modification is released under the GPL License v3. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
===================================
Go To Administration Panel --> Insert Raw SQL
===================================

Upload provided file named "SQL.txt" & click "Submit Changes" button.

============================================================================================================================
=======
Step 2:
=======
==============
Edit File: cp.php
==============
==========
Find Code:
==========

        if (!empty($avatarlist)) {
            $avchecked[1] = true;
        } elseif (!empty($avataroff)) {
            $avchecked[2] = true;
        } else {
            $avchecked[0] = true;
        }

===============
Add Code Below:
===============

        // RSS Feed Mod Begin
        $rss_status_on = $rss_status_off = '';
        switch ($SETTINGS['rss_status']) {
            case 'on':
                $rss_status_on = $selHTML;
                break;
            default:
                $rss_status_off = $selHTML;
                break;
        }

        $rss_postview_on = $rss_postview_off = '';
        switch ($SETTINGS['rss_postview']) {
            case 'on':
                $rss_postview_on = $selHTML;
                break;
            default:
                $rss_postview_off = $selHTML;
                break;
        }
        // RSS Feed Mod End

==========
Find Code:
==========

        $lang['spell_checker'] .= $spell_off_reason;

===============
Add Code Below:
===============

        // RSS Feed Mod Begin
        $SETTINGS['rss_description'] = stripslashes($SETTINGS['rss_description']);
        // RSS Feed Mod End

==========
Find Code:
==========

        printsetting2($lang['bbname'], "bbnamenew", $SETTINGS['bbname'], "50");

===============
Add Code Below:
===============

        // RSS Feed Mod Begin
        printsetting2($lang['rss_description'], "rss_descriptionnew", $SETTINGS['rss_description'], "50");
        // RSS Feed Mod End

==========
Find Code:
==========

        printsetting1($lang['reportpoststatus'], 'reportpostnew', $reportposton, $reportpostoff);

===============
Add Code Below:
===============

        // RSS Feed Mod Begin
        printsetting1($lang['rss_status'], 'rss_statusnew', $rss_status_on, $rss_status_off);
        printsetting1($lang['rss_postview'], 'rss_postview', $rss_postview_on, $rss_postview_off);
        // RSS Feed Mod End

==========
Find Code:
==========

        $tickercontentsnew = addslashes($tickercontentsnew);

===============
Add Code Below:
===============

        // RSS Feed Mod Begin
        $rss_descriptionnew = addslashes($rss_descriptionnew);
        // RSS Feed Mod Begin

==========
Find Code:
==========

$db->query("UPDATE $table_settings SET

==============================
Find Code At End Of Above Statement:
==============================

");

================
Replace Code With:
================

, rss_status='$rss_statusnew', rss_description='$rss_descriptionnew', rss_postview='$rss_postviewnew'");

============================================================================================================================
=======
Step 3:
=======
================
Edit File: header.php
================
==========
Find Code:
==========

if ($action != 'attachment' && !($action == 'templates' && isset($download)) && !($action == 'themes' && isset($download))) {
    header("Content-type: text/html");
}

================
Replace Code With:
================

if ($action != 'attachment' && !($action == 'templates' && isset($download)) && !($action == 'themes' && isset($download) && false === strpos($url, "rss.php"))) {
    header("Content-type: text/html");
}

==========
Find Code:
==========

put_cookie('xmblva', $onlinetime, ($onlinetime + (86400*365)), $cookiepath, $cookiedomain);

if (isset($xmblvb)) {
    $thetime = $xmblvb;
} elseif (isset($xmblva)) {
    $thetime = $xmblva;
} else {
    $thetime = $onlinetime;
}

put_cookie('xmblvb', $thetime, ($onlinetime + 600), $cookiepath, $cookiedomain);

$lastvisit = $thetime;
$lastvisit2 = $lastvisit - 540;

============================================================================
Replace Code With:
(So the RSS Feed doesn't set the cookie for the board and show you as online if you're just viewing the feed)
============================================================================

if (false === strpos($url, "rss.php")) {
    put_cookie('xmblva', $onlinetime, ($onlinetime + (86400*365)), $cookiepath, $cookiedomain);

    if (isset($xmblvb)) {
        $thetime = $xmblvb;
    } elseif (isset($xmblva)) {
        $thetime = $xmblva;
    } else {
        $thetime = $onlinetime;
    }

    put_cookie('xmblvb', $thetime, ($onlinetime + 600), $cookiepath, $cookiedomain);

    $lastvisit = $thetime;
    $lastvisit2 = $lastvisit - 540;
}

==========
Find Code:
==========

if ($bbstatus == 'off' && !(X_ADMIN) && false === strpos($url, 'misc.php') && false === strpos($url, 'member.php')) {
    eval('$css = "'.template('css').'";');
    error(stripslashes($bboffreason));
}

================
Replace Code With:
================

if ($bbstatus == 'off' && !(X_ADMIN) && false === strpos($url, 'misc.php') && false === strpos($url, 'member.php') && false === strpos($url, "rss.php")) {
    eval('$css = "'.template('css').'";');
    error(stripslashes($bboffreason));
}

==========
Find Code:
==========

if (!X_ADMIN && ($self['status'] == 'Banned' || $result)) {
    eval('$css = "'.template('css').'";');
    error($lang['bannedmessage']);
}

================
Replace Code With:
================

if (!X_ADMIN && ($self['status'] == 'Banned' || $result ) && false === strpos($url, 'rss.php')) {
    eval('$css = "'.template('css').'";');
    error($lang['bannedmessage']);
}

==========
Find Code:
==========

// 'Forum Rules'-link
if ($SETTINGS['bbrules'] == "on") {
    $links[] = "<img src=\"$imgdir/bbrules.gif\" alt=\"$lang[altrules]\" border=\"0\" /> <a href=\"faq.php?page=forumrules\"><font class=\"navtd\">$lang[textbbrules]</font></a>";
}

===============
Add Code Below:
===============

// RSS Feed Mod Begin
if ($SETTINGS['rss_status'] == 'on') {
    $links[] = "<img src=\"$imgdir/rss-icon.gif\" alt=\"$lang[rssfeed]\" border=\"0\" /> <a href=\"rss.php\"><font class=\"navtd\">$lang[rssfeed]</font></a>";
}

============================================================================================================================
=======
Step 4:
=======
=====================
Edit File: forumdisplay.php
=====================
==========
Find Code:
==========

if (!$notexist) {
    if (!postperm($forum, 'thread')) {
        $newtopiclink = '';
        $newpolllink = '';
    } else {
        if (X_GUEST && isset($forum['guestposting']) && $forum['guestposting'] != 'on') {
            $newtopiclink = '';
            $newpolllink = '';
        } else {
            eval('$newtopiclink = "'.template('forumdisplay_newtopic').'";');
            if(isset($forum['pollstatus']) && $forum['pollstatus'] != 'off') {
                eval('$newpolllink = "'.template('forumdisplay_newpoll').'";');
            } else {
                $newpolllink = '';
            }
        }
    }
}

===============
Add Code Below:
===============

if ($SETTINGS['rss_status'] == 'on') {
    $forumrss = "<a href=\"rss.php?action=forum&fid=$fid\">$lang[rss_forum]</a>";
} else {
    $forumrss = '';
}

============================================================================================================================
=======
Step 5:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above  ?>
============================

// RSS Feed Mod Begin
$lang['rssfeed'] = "RSS Feed";
$lang['rsshack'] = "XMB RSS Feed Hack";
$lang['rsshacknoperm'] = "You do not have permission to view threads in this forum";
$lang['rsshackvisitrest'] = '<br /><br />Click here to view this thread started by ';
$lang['rsshacknoposts'] = "There have been no new posts.";
$lang['rsshackoff'] = "The RSS Feed is currently offline.";
$lang['rsshackfidnotvalid'] = "The FID you have specified is invalid.";
$lang['rss_status'] = "RSS Feed Status:";
$lang['rss_description'] = "Forum Description for RSS Feed:";
$lang['rss_postview'] = "Allow Viewing of Full Post in RSS Feed:";
$lang['rss_forum'] = "View this Forum's RSS Feed";
// RSS Feed Mod End

============================================================================================================================
=======
Step 6:
=======
===============================
Go To Administration Panel --> Templates
======================================
Edit Templates: forumdisplay & forumdisplay_admin
======================================
============================
Find Code (2 times in each template):
============================

<tr>
<td class="post" align="right">&nbsp;$newtopiclink$newpolllink</td>
</tr>

==================
Replace Code With:
==================

<tr>
<td class="smalltxt" align="left">&nbsp;$forumrss</td>
<td class="post" align="right">&nbsp;$newtopiclink$newpolllink</td>
</tr>

============================================================================================================================
=======
Step 7:
=======
===============================
Go To Administration Panel --> Templates
===============================
====================
Create New Template: rss
====================
===========================
Add Code & Click Submit Changes:
===========================

<?xml version="1.0" encoding="$charset"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel>
<title><![CDATA[$bbname]]></title>
<link>$full_url</link>
$rssdescription
$copyrightnote
<sy:updatePeriod>hourly</sy:updatePeriod>
<sy:updateFrequency>10</sy:updateFrequency>
<sy:updateBase>1970-01-01T00:00+00:00</sy:updateBase>
<dc:language>en-us</dc:language>
<dc:creator>$lang[rsshack]</dc:creator>
<dc:date>$dcdate</dc:date>
$items
</channel>
</rss>

============================================================================================================================
=======
Step 8:
=======
===============================
Go To Administration Panel --> Templates
===============================
=========================
Create New Template: rss_items
=========================
===========================
Add Code & Click Submit Changes:
===========================

<item>
<title><![CDATA[$thread[subject]]]></title>
<link>$threadlink</link>
<content:encoded><![CDATA[$message]]></content:encoded>
<category><![CDATA[$forum[name]]]></category>
<dc:creator><![CDATA[$authorlink]]></dc:creator>
<dc:date>$lastpostdate</dc:date>
</item>

============================================================================================================================
=======
Step 9:
=======
===============================
Go To Administration Panel --> Templates
===============================
=========================
Create New Template: rss_other
=========================
===========================
Add Code & Click Submit Changes:
===========================

<item>
<description><![CDATA[$description]]></description>
</item>

============================================================================================================================
========
Step 10:
========

Upload all affected files to your forum directory.
Upload rss.php to your forum directory.
Upload rss-icon.gif to your theme folders.

============================================================================================================================
Enjoy!