[ABD] lastRSS autoposting bot MOD (0.1.4)

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Jemme
Registered User
Posts: 52
Joined: Mon Jul 23, 2007 5:13 pm
Location: Belgium

Re: Correct Edits assigning a NEW MEMBER to EAch FEED

Post by Jemme »

subfighter wrote:somewhere around page 36 some posted on how to make some edits so that you can assign a certain member to each feed...

anyways you can compare there edits they posted as there was like 3 problems with errors in the syntax.. you can compare with my file and see what was messed up.. as i wasted some time figuring it out so trying to save anyone else the headache.

you can see here in action as i made a couple of other tweaks.. as i am using ABBC3 mod and have it Embed the PAGE and Link in the POST..

http://www.subfighter.tv/phpBB3/viewfor ... ef8d9dd405

actually even did some tweaking and got it to SEARCH on YOUTUBE for certain VIDEOS and Return the results in the API FEED and and had it embed them.. would be cool to have some option like this integration if we ever get an ACP. so i was dumping like 50 videos at time from the YOUTUBE feed into forum.

http://www.subfighter.tv/phpBB3/viewforum.php?f=32

Code: Select all

<?php
/**
*
* @package includes
* @version $Id: $
* @copyright (c) 2007-2008 Jiri Smika (Smix) http://phpbb3.smika.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/ 
 
/**
 *  Autopost functions
 *  Get the next feed to check
 *  return array $next_feed       
 */        
function get_next_feed_to_post()
{
  global $db;
  $sql = 'SELECT name, url, next_check, next_check_after, lastrss_ap_bot_id, destination_id, enabled
		      FROM ' . LASTRSS_AP_TABLE . '
		      WHERE next_check < "' . time() . '" AND enabled = "1"
		      ORDER BY next_check DESC 
          LIMIT 0,1';
  $result	= $db->sql_query($sql);
	$next_feed = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

  // feed was checked - do not check it again until ...
	$sql = 'UPDATE ' . LASTRSS_AP_TABLE . '
          SET next_check = "' . ( time() + $next_feed['next_check_after'] * 3600 ) . '"
          WHERE name = "' . $next_feed['name'] . '"';
  // for development reasons - do not update -> force to always load fresh data
  $db->sql_query($sql);
  return $next_feed;
} 

/**
 *  Autopost functions
 *  init lastRSS to get feed data and post the feed items! 
 *  @param mixed $feed - including url for downloading and other data 
 */   
function autopost_init($feed)
{
  global $rss;
  // get the feed data
  $result = $rss->parse($feed);
  // return full data collection
  if($result['items_count'] > 0)
  {
    $result = array_merge($feed, $result);
    // ... and try to post them  
    autopost($result);
  }
}

/**
 *  Autopost functions
 *  approve topic/post tables after posting 
 *  @param string $subject - subject which we want to approve 
 */
function autopost_approve($subject)
{				
  global $db;								
  $sql = 'UPDATE ' . POSTS_TABLE . '
  	      SET post_approved = 1
  	      WHERE post_subject = "' . $db->sql_escape($subject) . '"';
  $db->sql_query($sql);
  $sql = 'UPDATE ' . TOPICS_TABLE . '
  	      SET topic_approved = 1
  	      WHERE topic_title = "' . $db->sql_escape($subject) . '"';
  $db->sql_query($sql);
}  

/**
 *  Autopost functions
 *  posts new topic in forum 
 *  @param mixed $post_data - includes all data of feed  
 */  
function autopost($post_data)
{
	global $config, $user, $db, $phpbb_root_path, $phpEx;
  // require necessary functions for posting
	require($phpbb_root_path . 'includes/functions_posting.' . $phpEx);

	// prepare user data for lastRSS autopost bot
	$user_backup = $user->data;
	$sql = 'SELECT username, user_colour
		      FROM ' . USERS_TABLE . '
		      WHERE user_id = "' . $post_data['lastrss_ap_bot_id'] . '"';
	$result	= $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
	
	// change poster ...
	$user->data = array_merge($user->data, array(
		'user_id'		=> $post_data['lastrss_ap_bot_id'],
		'username'		=> $row['username'],
		'user_colour'	=> $row['user_colour'],
	));

  // do this only once ...
  // prepare post_data
  $post_data['copyright'] = (isset($post_data['copyright']) && ($post_data['copyright'] != '')) ? '&copy; ' . $post_data['copyright'] : '';

  // get image data if possible
	if( isset($post_data['image_link']) && isset($post_data['image_url']) ) 
	{
    $image = '[url='.$post_data['image_link'].'][img]'.$post_data['image_url'].'[/img][/url]';
  }
  elseif( isset($post_data['image_url']))
  {
  	$image = '[img]'.$post_data['image_url'].'[/img]';
  }
  else
  {
    $image = '';
  }

  // do the rest for every item in feed
  $count = (isset($post_data['items'])) ? count($post_data['items']) : 0;
  $i = $count-1;
  // backward posting (from the oldest to the newest)
  while($i >= 0)
  {
    // necessary vars 
    $uid = $bitfield = $options = $poll = ''; 
    
  	// prepare data for posting
		$subject = truncate_string($post_data['items'][$i]['title']);
		$subject = htmlspecialchars_decode($subject);

    generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false);
    
    // check if this topic is not already posted
  	$sql = 'SELECT topic_title
  		      FROM ' . TOPICS_TABLE . '
  		      WHERE topic_title = "' . $db->sql_escape($subject) . '"';
  	$result	= $db->sql_query($sql);
  	$row = $db->sql_fetchrow($result);
  	$db->sql_freeresult($result);	 	

  	// Do we have a new item to post ?
  	// TODO review later the comparing function
  	if (strnatcasecmp($row['topic_title'], $subject))
  	{ 
  	  // necessary recoding/styling of message
  	  
    	// do we have pubDate ? ... post will be posted with this time!
      $post_time = (sizeof($post_data['items'][$i]['pubDate']) > 0) ? strtotime($post_data['items'][$i]['pubDate']) : 0;
      
      $author = ( isset($post_data['items'][$i]['author']) && ($post_data['items'][$i]['author'] != '')) ? $post_data['items'][$i]['author'] : '';

      // this defines how the final post looks     
      // edit the $message if you wan´t to change it there
      $message = $image.'
                   [quote]' . $post_data['items'][$i]['description'] . ' [/quote]     	
                   ' . $post_data['copyright'] . ' ' . $author . '
                   [url]' . $post_data['items'][$i]['link'] . '[/url]
			       [web 100%,600]' . $post_data['items'][$i]['link'] . '[/web]';
//                 [BBvideo 720,480]' . $post_data['items'][$i]['link'] . '[/BBvideo]';    
                 

      // prepare post data
    	generate_text_for_storage($message, $uid, $bitfield, $options, true, true, true);
    	$data = array( 
      	'forum_id'			=> $post_data['destination_id'],
      	'icon_id'			=> false,
      	'enable_bbcode'		=> true,
      	'enable_smilies'	=> true,
      	'enable_urls'		=> true,
      	'enable_sig'		=> true,
      	'message'			=> $message,
      	'message_md5'		=> md5($message),
      	'bbcode_bitfield'	=> $bitfield,
      	'bbcode_uid'		=> $uid,
      	'post_edit_locked'	=> false,
      	'topic_title'		=> $subject,
      	'notify_set'		=> false,
      	'notify'			=> false,
      	// make a post in original time ;)
      	'post_time' 		=> $post_time,
      	'forum_name'		=> '',
      	'enable_indexing'	=> true,
      	// this is not working, but let´s try it
      	'post_approved' => true,
    	);
    	// submit and approve the post!
    	submit_post('post', $subject, '', POST_NORMAL, $poll, $data);
    	autopost_approve($subject);
    }
    // change $i to the next (ehm previous :D ) item
    $i--;
	}
	// reset user´s data after posting
	$user->data = array_merge($user->data, $user_backup);
}

// if lastrss autopost bot is enabled 
if($config['lastrss_ap_enabled'])
{
  // init & setup lastrss
  // $rss can be already initiated by lastRSS agregator mod by SmiX
  if(!isset($rss))
  {
    require $phpbb_root_path . 'includes/class_lastrss.' . $phpEx; 
    $rss = new lastrss;	
  }
  // init/change settings for lastrss autopost bot
  $rss->cache_time = 0;                                         // not used in this mod
  $rss->items_limit = $config['lastrss_ap_items_limit'];        // default limit of items to post
  $rss->type = $config['lastrss_type'];                         // connection type (fopen / curl)

  // init lastRSS autopost MOD !
  // check if we have some feeds in database to check
  $sql = 'SELECT *
		      FROM ' . LASTRSS_AP_TABLE . '
		      WHERE next_check < "' . time() . '" AND enabled = "1"';
  $result	= $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);
  // so do we have some feeds to post ?
  if(sizeof($row) > 0)
  {
    // we are already sure, that at least one feed exists!
    $feed = get_next_feed_to_post(); 
  }

  // do we have some feed data ?
  if (isset($feed) && (sizeof($feed) > 0))
  {  
    // we are sure, we have feed info for checking the feed!
    autopost_init($feed);
  }
}
?>
Impressive ! :shock: Would you mind indicating what part of the code you have modified?
subfighter
Registered User
Posts: 46
Joined: Wed Sep 05, 2007 9:10 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by subfighter »

just do a file compare and you can see the changes... between the original file and the small changes i made...
chase_turpin
Registered User
Posts: 469
Joined: Fri Jun 10, 2005 12:02 am
Location: South Carolina

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by chase_turpin »

Could anyone pm me a link to a place that can install this mod on more forums?
My current project Gamer Union Any and all help is welcome!
chase_turpin
Registered User
Posts: 469
Joined: Fri Jun 10, 2005 12:02 am
Location: South Carolina

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by chase_turpin »

I got the mod installed. Now I am trying to use phpmyadmin to work the mod.

I am trying to use this to do it but I don't know what I put in the fields.
http://phpbb3.smika.net/kb/kb_show.php?id=3

Could someone please give me an example of what it would look like working?

Thanks
My current project Gamer Union Any and all help is welcome!
User avatar
madmartyau
Registered User
Posts: 440
Joined: Sun Sep 12, 2004 12:42 pm
Location: Brisbane,Australia
Name: Marty

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by madmartyau »

Code: Select all

   1. INSERT INTO `phpbb_lastrss_autopost`
   2. (`name`, `url`, `next_check`, `next_check_after`, `destination_id`, `enabled`)
   3. VALUES
   4. ('name', 'http://feed.url', 0, 12, 2, 1);
Example:

Code: Select all

   1. INSERT INTO `phpbb_lastrss_autopost`
   2. (`name`, `url`, `next_check`, `next_check_after`, `destination_id`, `enabled`)
   3. VALUES
   4. ('Major Nelson', 'http://feeds.feedburner.com/MajorNelson', 0, 1, 'forum id' where you want to put it, 0 or 1(enable/disable);
Call me Grumpy.
User avatar
madmartyau
Registered User
Posts: 440
Joined: Sun Sep 12, 2004 12:42 pm
Location: Brisbane,Australia
Name: Marty

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by madmartyau »

I have a question myself. Is there any way to get this to post to the same topic id?
Call me Grumpy.
User avatar
Smix
Registered User
Posts: 482
Joined: Mon Sep 11, 2006 1:07 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Smix »

Hello,

no there is no a way to make it post to the same topic ...





btw. I´ve succesfully tested running this mod in cron.php ... I know it´s not the best way, but I didn´t have a better way ... So if anybody wants to try it ... Please try it and tell me how it works ...

Step one
: Remove edits from index.php ... (with ctrl + x)

Step two :

OPEN
cron.php
FIND

Code: Select all

// Do not update users last page entry
$user->session_begin(false);
$auth->acl($user->data);
AFTER ADD (ctrl + v)

Code: Select all

// lastrss autopost mod begin
include ($phpbb_root_path . 'includes/functions_lastrss_autopost.'.$phpEx);
// lastrss autopost mod end
Please test it and report how it works ... You can benefit from the fact that the mod is not initiated by users, but you´ll have to wait until the bot comes to your board ... (I´m checking how to add this into cron que, but I wasn´t succesfull yet) ...
blitztrading
Registered User
Posts: 39
Joined: Mon Sep 01, 2008 6:58 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by blitztrading »

Hi,

I have 2 feeds not working with the mod :
http://www.apprendrelabourse.org/rss-articles.xml
http://www.saxobanque.fr/rss

any idea why ?

Thx
User avatar
Smix
Registered User
Posts: 482
Joined: Mon Sep 11, 2006 1:07 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Smix »

Hello blitztrading,

... CDATA tag is still not parsed ... :(
alienbabeltech
Registered User
Posts: 415
Joined: Mon Sep 17, 2007 12:54 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by alienbabeltech »

no way to get this working on php4 ?
This is the best and most helpful community I have been on. You are some of the best people I have met. GOD Bless You ALL !
My Forum - http://alienbabeltech.com/abt/index.php
User avatar
Smix
Registered User
Posts: 482
Joined: Mon Sep 11, 2006 1:07 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by Smix »

mrose1120
Registered User
Posts: 45
Joined: Tue Jan 17, 2006 5:54 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by mrose1120 »

so i've got this installed...i battled through a few errors...
now i'm just trying to get it to post...
and I have the feeling i'm not understanding how its posting (under what name)

Right now , I have the database entry in as

name = my username
url = correct url
next_check = 0
next_check_after = 1
destination_id = 2
enabled = 0

I tried enabled = 1 also..but I feel like this is my culprit, but are there logs I can see its at least doing anything??
thanks
User avatar
madmartyau
Registered User
Posts: 440
Joined: Sun Sep 12, 2004 12:42 pm
Location: Brisbane,Australia
Name: Marty

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by madmartyau »

You definitely want enabled=1.
Call me Grumpy.
mrose1120
Registered User
Posts: 45
Joined: Tue Jan 17, 2006 5:54 am

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by mrose1120 »

yea...i figured...so now its back to 1....

should I have to wait up to an hour? I'm not positive what the next_check value means/does
alienbabeltech
Registered User
Posts: 415
Joined: Mon Sep 17, 2007 12:54 pm

Re: [DEV] lastRSS autoposting bot MOD (0.1.3)

Post by alienbabeltech »

How much development or time is left to a version with ACP ?
This is the best and most helpful community I have been on. You are some of the best people I have met. GOD Bless You ALL !
My Forum - http://alienbabeltech.com/abt/index.php

Return to “[3.0.x] Abandoned MODs”