View Single Post
  #177  
Old 04-10-2004, 02:58 PM
Slapyo Slapyo is offline
 
Join Date: Feb 2004
Location: Rancho Cucamonga
Posts: 370
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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_data1);
        
$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_titleENT_NOQUOTES);
                
$rss_description html_entity_decode($rss_descriptionENT_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);
    } 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01209 seconds
  • Memory Usage 1,865KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete