Thread: RSS feed
View Single Post
(#8)
juven14's Avatar
juven14 juven14 is offline
Moderator
juven14 is on a distinguished road
 
Posts: 1,305
Join Date: Mar 2006
Location: NJ/NYC Area
Default 09-07-2006, 10:46 AM

I've cleaned out the price descriptor stuff, you can try this, I didn't test it, but I don't think it should give an error.

PHP Code:
<?php
/*
* 68 Classifieds
*
* All source code & content (c) Copyright 2006, 68 Classifieds
* unless specifically noted otherwise.
*
* @Author $Author: Eric $ (68 Classifieds)
* @copyright 68 Classifieds
* @link http://www.68classifieds.com
* @version 3.1
* @$Revision: 1.2 $
* @Updated: $Date: 2006/06/21 12:45:41 $
* @package 68 Classifieds
*
*/
require_once('includes/init.php');

    
//now setup the search query
    
$count="";
    
$sSQL="SELECT p.id, p.owner, p.title, p.featured, p.section, p.description, p.price, p.dateadded, p.expiration, p.pBold, p.pHighlighted, u.state, u.city, u.country, u.username FROM ".PREFIX."products AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id WHERE p.expiration > NOW() AND p.display = 'Y' ";

    
//now get the search fields
    
if (isset($_REQUEST['type'])&& $_REQUEST['type']<>"")
    {
        
$sSQL .= " AND p.section = ".(int)$_REQUEST['type'];
    }
    if (isset(
$_REQUEST['state'])&& $_REQUEST['state']<>"")
    {
        
$sSQL .= " AND u.state = '".mysql_real_escape_string($_REQUEST['state'])."'";
    }
    if (isset(
$_REQUEST['city'])&& $_REQUEST['city']<>"")
    {
        
$sSQL .= " AND u.city = '".mysql_real_escape_string($_REQUEST['city'])."'";
    }
    if (isset(
$_REQUEST['country'])&& $_REQUEST['country']<>"")
    {
        
$sSQL .= " AND u.country = '".mysql_real_escape_string($_REQUEST['country'])."'";
    }
    if (isset(
$_REQUEST['owner'])&& $_REQUEST['owner']<>"")
    {
        
$sSQL .= " AND p.owner = ".(int)$_REQUEST['owner'];
    }
    if (isset(
$_REQUEST['searchtext'])&& $_REQUEST['searchtext']<>"")
    {
        
$searchtext=trim(mysql_real_escape_string($_REQUEST['searchtext']));
        
$sSQL .= " AND (p.title LIKE '%".$searchtext."%' OR p.description LIKE '%".$searchtext."%')";
    }
    
//search price//
    
$minprice=(int)trim(@$_REQUEST['minprice']);
    
$maxprice=(int)trim(@$_REQUEST['maxprice']);
    if(
$minprice == "")
        
$minprice=0;
    if(
$maxprice == "")
        
$maxprice=9999999;

    
$sSQL .= " AND p.price BETWEEN ". $minprice ." AND ". $maxprice;
    
//now group by
    
$sSQL .= " GROUP BY p.id, p.owner, p.title, p.featured, p.section, p.description, p.price, p.dateadded, p.expiration ,u.state, u.city, u.country";
    if(
$count>0)
    {
        
$sSQL.=" HAVING count(sValue) = ".$count;
    }
    
$sSQL .= " ORDER BY p.dateadded DESC";
    
    
//now limit
    
if(isset($_GET['limit']) && $_GET['limit']<>"")
    {
        
$sSQL .= " LIMIT ". (int)$_GET['limit'];
    }
    else
    {
        
$sSQL .= " LIMIT 15";
    }

    
//buld array of listings
    
$ads = array();
    
$result = $db->query($sSQL);
    while (
$rs=$result->fetch())
    {
        
$ads[] = $rs;
    }
    
    
// set XML type and nocache headers
    
header('Content-Type: text/xml');
    
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Pragma: public');

    
//feed information
    
echo '<?xml version="1.0" encoding="windows-1252"?>';
    echo
'<rss version="2.0">';
    echo
'<channel>';
    echo
'<title>'. $title .'</title>';
    echo
'<description>'. DESCRIPTION.'</description>';
    echo
'<link>'.URL.'</link>';
    echo
'<docs>http://blogs.law.harvard.edu/tech/rss</docs>';
    echo
'<lastBuildDate>' . gmdate('D, d M Y H:i:s') . '-0500</lastBuildDate>';
    echo
'<pubDate>' . gmdate('D, d M Y H:i:s') . '-0500</pubDate>';

    
// list returned threads
        
if (!empty($ads))
            {
                foreach (
$ads AS $listing)
                    {
                        
//item info
                        
if($listing[price] == 0)
                        {
                            
$price = '';
                        }
                        else
                        {
                            
$price = FormatCurrency($listing[price]);
                        }
                        if(
$price == '')
                        {
                            
$seperator = "";
                        }
                        else
                        {
                            
$seperator = ' ~ ';
                        }

                        echo
'<item>';
                        echo
'<title>' .  
                        
htmlspecialchars($listing[title]) .
                        
htmlspecialchars($seperator) .
                        
htmlspecialchars($price) .  
                        
'</title>';
                        
                        echo
'<description>'.  htmlspecialchars($listing[description]) . '</description>';
                        
                        echo
"<link>". URL ."/viewlisting.php?view=".$listing['id']."</link>";

                        
//get images
                        
$isSQL = sprintf("SELECT pid,image FROM ".PREFIX."prodimages WHERE pid = %s ORDER BY rank ASC LIMIT 1", $listing['id']);
                        
$iresult = $db->query($isSQL);
                        
$irs=$iresult->fetch();
                        
//picture
                        
if($irs['image']<>"")
                        {
                            echo
'<guid>'. URL . '/thumbs/small_' . $irs['image'] . '</guid>';
                        }
                        else
                        {
                            echo
'<guid>'. URL . '/images/nophoto.gif</guid>';
                        }
                        echo
'<pubDate>' . gmdate('D, d M Y H:i:s') . '-0500</pubDate>';


                        
//close the item
                        
echo '</item>';
                    }
            }

    
//close the feed
    
echo '</channel>';
    echo
'</rss>';
?>


Regards,

John
mods.auscity.com
v3.1.4 Developer

�By perseverance, study, and eternal desire, any man can become great.� George S. Patton