ludachris
12-08-2007, 08:10 PM
I guess I need to modify this code so it will work with the vb rss manager. I was under the impression you could use any external rss feed with the rss feed manager. Anyway, this rss feed resides in a classifieds directory outside of the forums directory. It's a list of all new classified ads (posted in the photopost classifieds script). I'm trying to get it to post a new thread in a specified forum when there's a new classified ad posted. Here's the code:
<?php
//////////////////////////// COPYRIGHT NOTICE //////////////////////////////
// Script: RSS.PHP
// Developed by: Chuck Scannell & Michael Pierce
// http://www.photopost.com
//
// This script uses the feedcreator.class.php script avaiable from:
//
// http://www.bitfolge.de/rsscreator-en.html
//
// Copy this script and the feedcreator.class.php script to your Classifieds
// directory and then load the rss.php script in your browser. You will be
// prompted with a set of links to the actual feed pages which can then
// be used by your readers.
//
// This code is provided without warrenty and may be modified to suit your
// needs.
//////////////////////////// COPYRIGHT NOTICE //////////////////////////////
define( 'THIS_SCRIPT', "pprss" );
require "pp-inc.php";
include("feedcreator.class.php");
typecast($_REQUEST, array('cat' => STRING, 'type' => STRING));
authenticate();
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = $Globals['webname'];
$rss->description = null;
$rss->link = $Globals['maindir'];
$rss->feedURL = $Globals['maindir'].$PHP_SELF;
// If you wish to include an image as part of your feed, then you can uncomment and fill in the
// items for the variables below
//$image = new FeedImage();
//$image->title = $Globals['webname']. "logo";
//$image->url = "http://www.dailyphp.net/images/logo.gif";
//$image->link = $Globals['maindir'];
//$image->description = "Feed provided by {$Globals['webname']}. Click to visit.";
//$rss->image = $image;
$curcheck = ppmysql_query("SELECT symbol FROM {$Globals['pp_db_prefix']}currency WHERE code = '{$Globals['currency']}'", $link);
list( $csymbol ) = mysql_fetch_row($curcheck);
// Now lets grab our feed info...
$catcache = array();
if ( !empty( $cat ) ) {
$res = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}products WHERE cat='$cat' ORDER BY date DESC LIMIT 50", $link);
}
else {
$res = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}products ORDER BY date DESC LIMIT 50", $link);
}
while ($data = mysql_fetch_array($res)) {
$thiscat = $data['cat'];
if ( $CatPerms['ugview'][$thiscat] == 0 ) {
if ( $catcache[$thiscat] == "" ) {
$catcache[$thiscat] = is_image_private( $data['cat'] );
}
if ( $catcache[$thiscat] == "no" ) {
$item = new FeedItem();
$item->title = $data['title'];
$item->link = "{$Globals['maindir']}/showproduct.php?product=". $data['id'];
// Get the thumbnail
$thumb = get_imagethumb( $data['bigimage'], $data['cat'], $data['userid'], 1 );
$thumb = "<a href=\"{$Globals['maindir']}/showproduct.php?product={$data['id']}\" target=\"_blank\">$thumb</a>";
// Add description?
if ( !empty($data['description']) ) $data['description'] = "<br /><br />Description: ". $data['description'];
// Add Price?
if ( $data['price'] > 0 ) $data['description'] .= "<br /><br />Price: {$csymbol}{$data['price']}";
// Add comments indicator?
if ( $data['numcom'] > 1 ) $data['description'] .= "<br /><br />{$data['numcom']} comments";
elseif ( $data['numcom'] == 1 ) $data['description'] .= "<br /><br />{$data['numcom']} comment";
$item->description = "$thumb<br /><br />Posted by: ". $data['user'] . $data['description'];
$item->date = (int)$data['date'];
$item->source = $Globals['maindir'];
list( $ruserid, $rusername ) = get_userinfo( $data['user'] );
$item->author = $rusername;
$rss->addItem($item);
}
}
}
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS
if ( $type == "rss" ) $typestr = "RSS0.91";
elseif ( $type == "rss1" ) $typestr = "RSS1.0";
elseif ( $type == "rss2" ) $typestr = "RSS2.0";
elseif ( $type == "pie" ) $typestr = "PIE0.1";
elseif ( $type == "mbox" ) $typestr = "MBOX";
elseif ( $type == "opml" ) $typestr = "OPML";
elseif ( $type == "atom" ) $typestr = "ATOM0.3";
elseif ( $type == "html" ) $typestr = "HTML";
elseif ( $type == "js" ) $typestr = "JS";
if ( !isset($typestr) ) {
diewell( "This gallery is capable of providing RSS feeds for those who wish to view this gallery with their RSS reader.<br /><br />
Select from the types of feeds below or Copy Link to your reader:<br /><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss&cat=$cat\">RSS0.91</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss1&cat=$cat\">RSS1.0</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss2&cat=$cat\">RSS2.0</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=js&cat=$cat\">JavaScript</a><br />" );
}
echo $rss->saveFeed($typestr, "{$Globals['datafull']}feed.xml");
?>
<?php
//////////////////////////// COPYRIGHT NOTICE //////////////////////////////
// Script: RSS.PHP
// Developed by: Chuck Scannell & Michael Pierce
// http://www.photopost.com
//
// This script uses the feedcreator.class.php script avaiable from:
//
// http://www.bitfolge.de/rsscreator-en.html
//
// Copy this script and the feedcreator.class.php script to your Classifieds
// directory and then load the rss.php script in your browser. You will be
// prompted with a set of links to the actual feed pages which can then
// be used by your readers.
//
// This code is provided without warrenty and may be modified to suit your
// needs.
//////////////////////////// COPYRIGHT NOTICE //////////////////////////////
define( 'THIS_SCRIPT', "pprss" );
require "pp-inc.php";
include("feedcreator.class.php");
typecast($_REQUEST, array('cat' => STRING, 'type' => STRING));
authenticate();
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = $Globals['webname'];
$rss->description = null;
$rss->link = $Globals['maindir'];
$rss->feedURL = $Globals['maindir'].$PHP_SELF;
// If you wish to include an image as part of your feed, then you can uncomment and fill in the
// items for the variables below
//$image = new FeedImage();
//$image->title = $Globals['webname']. "logo";
//$image->url = "http://www.dailyphp.net/images/logo.gif";
//$image->link = $Globals['maindir'];
//$image->description = "Feed provided by {$Globals['webname']}. Click to visit.";
//$rss->image = $image;
$curcheck = ppmysql_query("SELECT symbol FROM {$Globals['pp_db_prefix']}currency WHERE code = '{$Globals['currency']}'", $link);
list( $csymbol ) = mysql_fetch_row($curcheck);
// Now lets grab our feed info...
$catcache = array();
if ( !empty( $cat ) ) {
$res = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}products WHERE cat='$cat' ORDER BY date DESC LIMIT 50", $link);
}
else {
$res = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}products ORDER BY date DESC LIMIT 50", $link);
}
while ($data = mysql_fetch_array($res)) {
$thiscat = $data['cat'];
if ( $CatPerms['ugview'][$thiscat] == 0 ) {
if ( $catcache[$thiscat] == "" ) {
$catcache[$thiscat] = is_image_private( $data['cat'] );
}
if ( $catcache[$thiscat] == "no" ) {
$item = new FeedItem();
$item->title = $data['title'];
$item->link = "{$Globals['maindir']}/showproduct.php?product=". $data['id'];
// Get the thumbnail
$thumb = get_imagethumb( $data['bigimage'], $data['cat'], $data['userid'], 1 );
$thumb = "<a href=\"{$Globals['maindir']}/showproduct.php?product={$data['id']}\" target=\"_blank\">$thumb</a>";
// Add description?
if ( !empty($data['description']) ) $data['description'] = "<br /><br />Description: ". $data['description'];
// Add Price?
if ( $data['price'] > 0 ) $data['description'] .= "<br /><br />Price: {$csymbol}{$data['price']}";
// Add comments indicator?
if ( $data['numcom'] > 1 ) $data['description'] .= "<br /><br />{$data['numcom']} comments";
elseif ( $data['numcom'] == 1 ) $data['description'] .= "<br /><br />{$data['numcom']} comment";
$item->description = "$thumb<br /><br />Posted by: ". $data['user'] . $data['description'];
$item->date = (int)$data['date'];
$item->source = $Globals['maindir'];
list( $ruserid, $rusername ) = get_userinfo( $data['user'] );
$item->author = $rusername;
$rss->addItem($item);
}
}
}
// valid format strings are: RSS0.91, RSS1.0, RSS2.0, PIE0.1, MBOX, OPML, ATOM0.3, HTML, JS
if ( $type == "rss" ) $typestr = "RSS0.91";
elseif ( $type == "rss1" ) $typestr = "RSS1.0";
elseif ( $type == "rss2" ) $typestr = "RSS2.0";
elseif ( $type == "pie" ) $typestr = "PIE0.1";
elseif ( $type == "mbox" ) $typestr = "MBOX";
elseif ( $type == "opml" ) $typestr = "OPML";
elseif ( $type == "atom" ) $typestr = "ATOM0.3";
elseif ( $type == "html" ) $typestr = "HTML";
elseif ( $type == "js" ) $typestr = "JS";
if ( !isset($typestr) ) {
diewell( "This gallery is capable of providing RSS feeds for those who wish to view this gallery with their RSS reader.<br /><br />
Select from the types of feeds below or Copy Link to your reader:<br /><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss&cat=$cat\">RSS0.91</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss1&cat=$cat\">RSS1.0</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=rss2&cat=$cat\">RSS2.0</a><br />
<a href=\"{$Globals['maindir']}/rss.php?type=js&cat=$cat\">JavaScript</a><br />" );
}
echo $rss->saveFeed($typestr, "{$Globals['datafull']}feed.xml");
?>