* the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
/*
 * Load required includes
 */
require_once "config.php";
require_once "rss_conf.php";
require_once "funcsv2.php";
/*
 * Check to see if a category was requested and if the request is valid. If not
 * check for subcategories, otherwise show the whole feed.
 */
if (!$enable_rss_cache) {
    if (isset($_GET["category"]) && strlen($_GET["category"]) > 0 && strpos($_GET["category"], " ") === false) {
        doRSS(true, true, $_GET["category"]);
    } elseif (isset($_GET["subcategory"]) && is_numeric($_GET["subcategory"])) {
        doRSS(true, true, "", false, $_GET["subcategory"]);
    } else {
        doRSS(true, true);
    }
}
        $fpRSS = fopen($rssfile, "wb");
        if ($fpRSS === false) {
            if ($extlogtype >= EXTLOG_MINIMAL) {
                error_log("\tFailed to open file " . $_SERVER["DOCUMENT_ROOT"] . "{$path_to_rss_cache}/{$recordRSS['0']}.xml for writing! Are permissions correct?\r\n", 3, $extlogfile);
            }
        }
        doRSS(false, false, $recordRSS[0], $fpRSS);
    }
    /*
     * Process the subgroups
     */
    while ($recordRSS = mysql_fetch_row($rstSubCategories)) {
        if ($extlogtype >= EXTLOG_VERBOSE) {
            error_log("\tWriting subcategory {$recordRSS['0']}.xml rss info to file\r\n", 3, $extlogfile);
        }
        $rssfile = $path_to_rss_cache . "/" . $recordRSS[0] . ".xml";
        $fpRSS = fopen($rssfile, "wb");
        if ($fpRSS === false) {
            if ($extlogtype >= EXTLOG_MINIMAL) {
                error_log("\tFailed to open file " . $_SERVER["DOCUMENT_ROOT"] . "{$path_to_rss_cache}/{$recordRSS['0']}.xml for writing! Are permissions correct?\r\n", 3, $extlogfile);
            }
        }
        doRSS(false, false, false, $fpRSS, $recordRSS[0]);
    }
    $script_stoptime = time();
    $execution_time = $script_stoptime - $script_starttime;
    if ($extlogtype >= EXTLOG_MINIMAL) {
        error_log(date("Y-M-d/H:i:s (l)", $script_stoptime) . " -- Script terminated normally, execution time was {$execution_time} second(s).\r\n", 3, $extlogfile);
    }
    exit;
}