vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   About RSS Poster Hooks (https://vborg.vbsupport.ru/showthread.php?t=277692)

omerfarukak 01-28-2012 10:03 PM

About RSS Poster Hooks
 
Hi i want to write a plugin which is adds my wordpress posts a link which is rss posted on forum. And now i'm using rssfeeddata_postsave hook but how can i take new forum posts link? :)

kh99 01-28-2012 10:24 PM

I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).

omerfarukak 01-28-2012 10:41 PM

Quote:

Originally Posted by kh99 (Post 2293598)
I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).

so, which hook i can use?

kh99 01-28-2012 11:01 PM

Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.

omerfarukak 01-28-2012 11:25 PM

Quote:

Originally Posted by kh99 (Post 2293608)
Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.

Well, i'm trying again to explain. :) I'm using rss poster in vBulletin, it's getting data from my wordpress's rss feed. And opens a thread for each one. And i want to add this thread's link to end of my wordpress posts'. Is it sufficently clear? :)

kh99 01-28-2012 11:53 PM

OK - there are no hooks in the rss poster code, but you might be able to use threadfpdata_postsave. That gets called every time a thread is created so you have to check something to make sure it's one of your wordpress threads. I think the feed url might be available using something like:

Code:

global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{
  // add your link
}


omerfarukak 01-29-2012 07:13 AM

What about the rssposter_parse_rss? Is there any guide about hooks?

--------------- Added [DATE]1327827918[/DATE] at [TIME]1327827918[/TIME] ---------------

Is this code works? Or what i have to do?
Code:

global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{  if (!empty($threadinfo['item_id'])) {
        require_once(DIR . '/includes/class_bbcode.php');
        $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
        mysql_connect('localhost', 'root', '');
        mysql_select_db('_wp');
        mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br>                                                          {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
    mysql_close();
}


kh99 01-29-2012 12:42 PM

Quote:

Originally Posted by omerfarukak (Post 2293730)
What about the rssposter_parse_rss? Is there any guide about hooks?

You're right, I missed that. You might be able to do something in rssposter_parse_rss. But the problem may be that you don't have the threadid yet so I'm not sure how you'd create a link.

I don't know of any guide to hooks, but there could be one. I just look at the php code to see where they are.


Quote:

Is this code works? Or what i have to do?
Code:

global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{  if (!empty($threadinfo['item_id'])) {
        require_once(DIR . '/includes/class_bbcode.php');
        $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
        mysql_connect('localhost', 'root', '');
        mysql_select_db('_wp');
        mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br>                                                          {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
    mysql_close();
}


I'm not sure - I don't see how {feed:title} or {feed:link} will be substituted for the actual values. If you're trying to link back to the vb thread that gets created, then I think you'd want to do something like:

PHP Code:

if (is_array($feed) AND strncmp($feed['url'], 'something'len) == 0)
{  
    
$title $this->thread['title'];
    
$link '</ br></ br></ br> <a href="' $this->registry->options['bburl'] . '/showthread.php?t=' $this->thread['threadid'] . '">' htmlentities($title) . '</a>';
    
         
mysql_connect('localhost''root''');
         
mysql_select_db('_wp');
         
mysql_query("update wp_posts set post_content=concat(post_content,'" mysql_real_escape_string($link) . "') where post_title = '" mysql_real_escape_string($title) . "'");
    
mysql_close();



Also, you need to replace 'something' and 'len' in the above if statement to be something that would check to see if the feed url is the url of your wordpress feed.

omerfarukak 01-30-2012 06:03 PM

PHP Code:

ini_set('display_errors'1);
    if(!
$link mysql_connect('localhost''root'''))
        echo 
fails_connection;
mysql_set_charset('utf8',$link);
        if(!
mysql_select_db('_wp'$link))
        echo 
fails_selection;
$link2 '<a href="http://bburl.co/showthread.php?t=threadid">link</a>';
        
mysql_query("update wp_posts set post_content = concat(post_content,"mysql_real_escape_string($link2) .") where id = 1794");
        echo 
mysql_error();
        
mysql_close(); 

When i try something like this, i get this error
Code:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<a href=\"http://bburl.co/showthread.php?t=threadid\">link</a>) where id = 1794' at line 1
What can we do?

kh99 01-30-2012 06:54 PM

Oh, I think the mysql line is missing quotes around the link string. So something like:

PHP Code:

mysql_query("update wp_posts set post_content = concat(post_content,'"mysql_real_escape_string($link2) ."') where id = 1794"); 


(I fixed it above as well).


All times are GMT. The time now is 09:24 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.01391 seconds
  • Memory Usage 1,757KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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