vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   RSS News Feed Hack (https://vborg.vbsupport.ru/showthread.php?t=60899)

pgowder 04-09-2004 03:31 PM

And I don't have a rss.php file in my unzipped directory???

Slapyo 04-09-2004 04:19 PM

ok, here is the code to use the build_new_post function in vB to insert the data. this will make the post number increase automatically, make the posts searchable, make similar threads work. however, there is one tiny problem.

- the posts have \n\n in them, when they should be actual new lines. anyone know how to fix this?

other than that, it works just fine. i just need to figure this last thing out.

original authors code commented out:
PHP Code:

<?php

require('./global.php');
require(
'./includes/functions_newpost.php');

// RSS News Feed Hack
// ------------------------------
// By: Andrew Wickham of
// LiquidPro Inc.
//

// 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);

        
//$query2 = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = '$rss_userid'");
        //$data2 = $DB_site->fetch_array($query2);

        //$rss_user_data[username] = $data2[username];
        //$rss_user_data[posts] = $data2[posts];

        // get the bot`s username
        //$rss_user_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = '$rss_userid'");
        //$rss_user_data = $DB_site->fetch_array($rss_user_query);
        //$rss_username = $rss_user_data[username];
        //$rss_posts = $rss_user_data[posts];
        
$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]) {
                
// update the user profile
                //$rss_posts++;

                
$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_title = str_replace("&apos;", "\'", $rss_title);
                //$rss_description = str_replace("&apos;", "\'", $rss_description);
                //$rss_title = str_replace("?", "--", $rss_title);
                //$rss_description = str_replace("?", "--", $rss_description);
                //$rss_title = str_replace("$", "\$", $rss_title);
                //$rss_description = str_replace("$", "\$", $rss_description);
                //sql and php don't recognize the html escape strings.
                */
                
$rss_description=mysql_escape_string($rss_description);
                 
$rss_title=mysql_escape_string($rss_title);

                
// get the next available threadid
                //$rss_threadid_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "thread ORDER BY threadid DESC");
                //$rss_threadid_data = $DB_site->fetch_array($rss_threadid_query);
                //$rss_threadid = $rss_threadid_data[threadid] + 1;

                // get the next available postid
                //$rss_postid_query = $DB_site->query("SELECT * FROM " . TABLE_PREFIX . "post ORDER By postid DESC");
                //$rss_postid_data = $DB_site->fetch_array($rss_postid_query);
                //$rss_postid = $rss_postid_data[postid] + 1;

                //$DB_site->query("INSERT INTO " . TABLE_PREFIX . "post (`threadid`, `username`, `userid`, `title`, `dateline`, `pagetext`, `allowsmilie`, `showsignature`, `visible`) VALUES ('$rss_threadid', '$rss_username', '$rss_userid', '$rss_title', '$current_dateline', '$rss_description', '1', '1', '1')");
                //$DB_site->query("INSERT INTO " . TABLE_PREFIX . "thread (`title`, `forumid`, `firstpostid`, `lastpost`, `open`, `postusername`, `postuserid`, `lastposter`, `dateline`, `visible`, `rss_feed`, `rss_date`) VALUES ('$rss_title', '$rss_forumid', '$rss_postid', '$current_dateline', '1', '$rss_username', '$rss_userid', '$rss_username', '$current_dateline', '1', '1', '$rss_dateline')");
                //$DB_site->query("UPDATE " . TABLE_PREFIX . "forum SET lastpost = '$current_dateline', lastposter = '$rss_username', lastthread = '$rss_title', lastthreadid = '$rss_threadid' WHERE forumid = '$rss_forumid'");

                // 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);
            }
        }
        
// update the posts in the database
        //$DB_site->query("UPDATE " . TABLE_PREFIX . "user SET posts = '$rss_posts' WHERE userid = '$rss_userid'");
    
}
}

//
// ------------------------------
// End of RSS News Hack

?>

and in functions_newpost.php i added a variable into the function and wrapped the global statement around an IF/ELSE:
PHP Code:

// ###################### Start newpost #######################
function build_new_post($type 'thread'$foruminfo$threadinfo$parentid, &$post, &$errors$rss_userid '0')
{
    
//NOTE: permissions are not checked in this function

    // $post is passed by reference, so that any changes (wordwrap, censor, etc) here are reflected on the copy outside the function
    // $post[] includes:
    // title, iconid, message, parseurl, email, signature, preview, disablesmilies, rating
    // $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);
    } 


pgowder 04-09-2004 05:49 PM

Ok, went back and installed the new version posted in the thread. It seems to be working better.

Couple of questions now.

Will thread views increase??

Only one of my feeds is working. I have all of them going to the same forum with the same userid, is that a problem??

Here are all of my feeds:
http://IndianCountry.com/rss/index.php
http://rss.news.yahoo.com/rss/mostemailed
http://groups.yahoo.com/group/native...messages?rss=1
http://www.nativenationsnet.net/backend.php

The 2nd one is the only one that shows up in the forum.

When I run the cron job by hand through Admin CP I get this error:


Error:

Warning: file(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/virtual/site2/fst/var/www/html/gathering/includes/RSS/rss_update.php on line 36

Warning: file(http://www.nativenationsnet.net/backend.php): failed to open stream: Resource temporarily unavailable in /home/virtual/site2/fst/var/www/html/gathering/includes/RSS/rss_update.php on line 36

Warning: implode(): Bad arguments. in /home/virtual/site2/fst/var/www/html/gathering/includes/RSS/rss_update.php on line 36

vau7 04-10-2004 01:38 PM

I thin kit is a great great hack but I've a Problem with it.

If i let i generate the link from a backend.php it looks like this:

http://www.wavebone.net/modules.php?...le&amp;sid=118

But the real link is

http://www.wavebone.net/modules.php?...rder=0&thold=0

So it wont work for me.

How can i fix it?


Thanks in advance,

regardly

v7

dethfire 04-10-2004 02:46 PM

someone just needs to rewrite this :(

Slapyo 04-10-2004 02:58 PM

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);
    } 


vau7 04-10-2004 06:14 PM

If i do it your way i get just cryprtical signs on index.php

Slapyo 04-10-2004 06:58 PM

Quote:

Originally Posted by vau7
If i do it your way i get just cryprtical signs on index.php

what do you mean? i have no problems with it at all and i didn't touch index.php ... what are these cryptical signs you are talking about? do you have a screenshot or link so we can see. but like i said, i've made these changes and have had no problems at all with the bot making posts, users making posts/polls. the only problem i am running into, is pretty much getting the newlines to actually be newlines instead of just the text \n\n in the posts.

dethfire 04-10-2004 07:57 PM

Slapyo, thanks! Can you zip your final version?

AWS 04-11-2004 03:27 AM

Quote:

Originally Posted by dethfire
Slapyo, thanks! Can you zip your final version?

This should work to correct the newline problem. Create a replacement var.
{br} as the tag and text to replace with <br />.
I have a similiar tag for use when posting code on one of my forums. It will act as the break tag even in a forum that doesn't have html enabled.


All times are GMT. The time now is 09:43 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01512 seconds
  • Memory Usage 1,904KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete