Thread: RSS Error
View Single Post
  #8  
Old 13th July 2008, 04:48
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 2,113
Default Re: RSS Error
We well start with please replace the footer with copy rite info as stated in the rules.
then you can replace your backend.php with
Code:
<?php
/*
*-------------------------------phpMyBitTorrent--------------------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*--------------   Created By Antonio Anzivino (aka DJ Echelon)   --------------*
*-------------               http://www.p2pmania.it               -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*-------------              http://www.bittorrent.com             -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*--   This program is free software; you can redistribute it and/or modify   --*
*--   it under the terms of the GNU General Public License as published by   --*
*--   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 --*
*--                                                                          --*
*------------------------------------------------------------------------------*
*------              ?2005 phpMyBitTorrent Development Team              ------*
*-----------               http://phpmybittorrent.com               -----------*
*------------------------------------------------------------------------------*
*/

require_once("include/config_lite.php");
function searchfield($s) {
        return preg_replace(array('/[^a-z0-9]/si', '/^\s*/s', '/\s*$/s', '/\s+/s'), array(" ", "", "", " "), $s);
}


//Last Torrents
if (!isset($op)) $op = "";
switch($op) {
        case "category": {
                $sql = "SELECT id, name, descr, seeders, leechers, category FROM ".$db_prefix."_torrents 
				WHERE banned = 'no' AND visible = 'yes' AND category = '".$cat."' AND password IS NULL 
				ORDER BY tot_peer, seeders, completed, added DESC LIMIT 10;";
				$sql_cat = "SELECT name FROM ".$db_prefix."_categories 
				WHERE id = ".$cat."";
                $res = $db->sql_query($sql_cat);
                $cat_row = $db->sql_fetchrow($res);
                $descr = "Best 10 Torrents for Category ".$cat_row['name']." on ".$sitename."' (files feed)";
                break;
        }
        case "best": {
                $sql = "SELECT id, name, descr, seeders, leechers, category, owner, added FROM ".$db_prefix."_torrents WHERE banned = 'no' AND visible = 'yes' AND password IS NULL ORDER BY tot_peer, seeders, completed, added DESC LIMIT 10;";
                $descr = "Best 10 Torrents on ".$sitename."' (files feed)";
                break;
        }
        case "search": {
		        if(!isset($dead))
				$rssdead ="AND visible = 'yes' ";
				else
				$rssdead = "";
                if (!isset($search)) $search = "";
                $cat = (isset($cat)) ? intval($cat) : 0;
                $orderby = (isset($orderby)) ? intval($orderby) : -1;
                $sql = "SELECT id, name, descr, seeders, leechers, category FROM ".$db_prefix."_torrents  WHERE banned = 'no' ".$rssdead." AND password IS NULL ";
                if (!empty($search)) $sql .= " AND search_text LIKE ('%".addslashes(searchfield($search))."%') ";
                if (!isset($ordertype) OR $ordertype != "ASC") $ordertype = "DESC";
                if (isset($incldead) AND $incldead != "true") $sql .= "AND visible = 'yes' ";
                if ($cat > 0) $sql .= " AND category = '".$cat."' ";

switch ($orderby) {
        case 0: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.added ".$ordertype;
                break;
        }
	case 1: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.seeders ".$ordertype;
                break;
        }
        case 2: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.leechers ".$ordertype;
                break;
        }
        case 3: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.tot_peer ".$ordertype;
                break;
        }
	case 4: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.downloaded ".$ordertype;
                break;
        }
        
        case 5: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.ratingsum ".$ordertype;
                break;
        }
	case 6: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.name ".$ordertype;
                break;
        }
        case 7: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.size ".$ordertype;
                break;
        }
        case 8: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.numfiles ".$ordertype;
                break;
        }
        default: {
                $sql .= "ORDER BY ".$db_prefix."_torrents.id ".$ordertype;
        }
                }
                $sql .= " LIMIT 10;";
                $descr = "Results for search term '".$search." on ".$sitename."' (files feed)";
                break;
        }
        case "last":
        default: {
                $sql = "SELECT id, name, descr, seeders, leechers, category, owner, added FROM ".$db_prefix."_torrents WHERE banned = 'no' AND visible = 'yes' AND password IS NULL ORDER BY added DESC LIMIT 10;";
                $descr = "The Latest 10 Torrents on ".$sitename." (files feed)";
        }
}


$res = $db->sql_query($sql);
$rss = '';
$rss .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>'.$sitename.'</title>
    <link>'.$siteurl.'/</link>
    <description>'.$descr.'</description>
    <language>en-us</language>';

while ($row = $db->sql_fetchrow($res)) {
                $cat = "SELECT name FROM ".$db_prefix."_categories WHERE id = ".$row["category"]." ;";
$cat2 = $db->sql_query($cat);
$cat3 = $db->sql_fetchrow($cat2);
                $sql_own = "SELECT username FROM ".$db_prefix."_users WHERE id = ".$row["owner"]." ;";
$sql_own1 = $db->sql_query($sql_own);
$owner = $db->sql_fetchrow($sql_own1);


        $ids = $row["id"];
        $names = $row["name"];
        $descrption = "&lt;font size=\"3\"&gt;&lt;b&gt;Category:&lt;/b&gt;&lt;/font&gt; ".$cat3["name"]."&lt;br /&gt;&lt;font size=\"3\"&gt;&lt;b&gt;Description:&lt;/b&gt;&lt;br /&gt;&lt;/font&gt; ".htmlspecialchars($row["descr"])."&lt;br /&gt; &lt;font size=\"3\"&gt;&lt;b&gt;Seeders: &lt;/b&gt;&lt;/font&gt;".$row["seeders"]."&lt;br /&gt; &lt;font size=\"3\"&gt;&lt;b&gt;Leeches: &lt;/b&gt;&lt;/font&gt;".$row["leechers"];
$rss .='<item>
      <title>'.$names.'</title>
      <link>'.$siteurl.'/details.php?id='.$ids.'</link>
      <description>'.$descrption.'</description>
	  <dc:creator>'.$owner['username'].'</dc:creator>
    </item>';
      }
$rss .='  </channel>
</rss>';

$db->sql_freeresult($res);
$db->sql_freeresult($cat2);
$db->sql_freeresult($sql_own1);

if (!$persistency) $db->sql_close();

echo ($rss);

die();
?>
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Manager™ forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote