that is what i am trying to do. i am at the last step basically. i just need to figure out how to insert the post with newlines. the way i wrote it uses vB's build_new_post function so that it works. look at post #174 in this thread. here is the code i have been working with. i just need to find out how i can insert the post with actual newlines, instead of viewing \n\n on the post. otherwise it works just fine and it uses vB's build_new_post function which means it will be searchable, post counts go up, similiar threads will work ... everything.
modified rss_update.php, my new way to insert the post:
PHP Code:
<?php
require('./global.php');
require('./includes/functions_newpost.php');
// RSS News Feed Hack
// ------------------------------
// By: Andrew Wickham of
// LiquidPro Inc.
// Updated By: Donnie La Curan
//
// get the rss settings
$query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "rss_settings");
$data = $DB_site->fetch_array($query);
$rss_enabled = $data[enabled];
if($rss_enabled == 1) {
// include the RSS class
require_once('class.RSS.php');
$query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "rss_user WHERE enabled = '1'");
while($data = $DB_site->fetch_array($query)) {
$rss_source = $data[source];
$rss_forumid = $data[forumid];
$rss_userid = $data[userid];
$foruminfo = fetch_foruminfo($rss_forumid);
$bbuserinfo = fetch_userinfo($rss_userid);
$rss_data = implode("",file($rss_source));
$rss = new RSS($rss_data, 1);
$rss_allItems = $rss->getAllItems();
// check and see what items are in the database, and mark the old ones as old
$rss_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "thread WHERE rss_feed = '1' AND postuserid = '$rss_userid'");
for($i = count($rss_allItems) - 1; $i >= 0; $i--) {
$rss_allItems[$i][OLD] = false;
}
// if there's no items in the database
if($DB_site->num_rows($rss_query) == 0) {
for($i = count($rss_allItems) - 1; $i >= 0; $i--) {
$rss_allItems[$i][OLD] = false;
}
}
// filter out the old items
while($rss_thread_data = $DB_site->fetch_array($rss_query)) {
for($j = count($rss_allItems) - 1; $j >= 0; $j--) {
if($rss_thread_data[title] == $rss_allItems[$j][TITLE] &&
$rss_thread_data[rss_date] == $rss_allItems[$j][pubDate]) {
$rss_allItems[$j][OLD] = true;
}
}
}
// insert the new items into the database
for($j = count($rss_allItems) - 1; $j >= 0; $j--) {
if(!$rss_allItems[$j][OLD]) {
$rss_title = $rss_allItems[$j][TITLE];
$rss_dateline = $rss_allItems[$j]['pubDate'];
$current_dateline = time();
$rss_description = $rss_allItems[$j][DESCRIPTION];
$rss_description .= "\r\n\r\n[url=" . $rss_allItems[$j][LINK] . "]View the Entire Article[/url]\r\n";
// change <br> tags to newline
$rss_description = str_replace("<br>", \n, $rss_description);
$rss_description = str_replace("<br />", \n, $rss_description);
$rss_title = html_entity_decode($rss_title, ENT_NOQUOTES);
$rss_description = html_entity_decode($rss_description, ENT_NOQUOTES);
$rss_description=mysql_escape_string($rss_description);
$rss_title=mysql_escape_string($rss_title);
// Setup the thread
$post['signature'] = true;
$post[title] = $rss_title;
$post[message] = $rss_description;
$post[poststarttime] = TIMENOW;
$post[posthash] = md5($post[poststarttime] . $bbuserinfo['userid'] . $bbuserinfo['salt']);
// build the thread
build_new_post('thread', $foruminfo, array(), 0, $post, $errors, $rss_userid);
}
}
}
}
//
// ------------------------------
// End of RSS News Hack
?>
and in functions_newpost.php i did this:
FIND:
PHP Code:
function build_new_post($type = 'thread', $foruminfo, $threadinfo, $parentid, &$post, &$errors)
REPLACE WITH:
PHP Code:
function build_new_post($type = 'thread', $foruminfo, $threadinfo, $parentid, &$post, &$errors, $rss_userid = '0')
FIND:
PHP Code:
// $errors will become any error messages that come from the checks before preview kicks in
global $DB_site, $vboptions, $vbphrase, $bbuserinfo, $forumperms, $usergroupcache, $_REQUEST;
REPLACE WITH:
PHP Code:
// $errors will become any error messages that come from the checks before preview kicks in
if ($rss_userid == '0')
{
global $DB_site, $vboptions, $vbphrase, $bbuserinfo, $forumperms, $usergroupcache, $_REQUEST;
}
else
{
global $DB_site, $vboptions, $vbphrase, $bbuserinfo, $forumperms, $usergroupcache, $_REQUEST;
$bbuserinfo = fetch_userinfo($rss_userid);
}