Seite 1 von 1

lastRSS autoposting bot MOD

Verfasst: 31.03.2009 21:23
von rPaHzPeBrB
Hallo!

Ich benutze den folgenden Mod:
lastRSS autoposting bot MOD

Leider wird der Text nach etwa 400 Symbolen gekuerzt. Wie schaffe ich es, das zu umgehen?

Ich denke, diese Datei koennte wichtig sein:

Code: Alles auswählen

<?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
*
*/ 
 
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
 *  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, 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 = "' . $config['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'		=> $config['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['name'] . ' | ' . $post_data['items'][$i]['title'], 255);
    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.'
                   [b]' . $post_data['items'][$i]['description'] . ' [/b] 
    	
                   ' . $post_data['copyright'] . ' ' . $author . '
                   [url]' . $post_data['items'][$i]['link'] . '[/url]';
           
      // 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'	=> true,
      	'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
      	'rss_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);
}

// Smix requests you retain the full copyright notice below including the links
// to phpbb3.smika.net. This gives respect to the large amount of time given freely
// for creating this RSS autoposting bot MOD free for you to use. If you refuse
// to include even this then support from Smix may be affected.
// This language file change is the only visible credit for this mod. Thanks
// Notice : It may cause HTML code invalidity, because it´s xHTML valid ...

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

Re: lastRSS autoposting bot MOD

Verfasst: 02.04.2009 14:50
von rPaHzPeBrB
And BUMP!

Re: lastRSS autoposting bot MOD

Verfasst: 03.04.2009 12:28
von Alufu
Ich würde sagen, das muss man in der Datenbank ändern.

Re: lastRSS autoposting bot MOD

Verfasst: 03.04.2009 13:46
von rPaHzPeBrB
Hallo! Erstmal: DANKE FUER DEINE HILFE!

Aber ich glaube nicht, dass es an der DB liegt, denn es gibt diese Zeilen in der DB bei phpbb_9lastrss:
`name` - name of the feed - is also used in posting
`url` - URL of the feed ...
`next_check` - next check time (from PHP function time())
`next_check_after` - number of hours between checks
`destination_id` - forum_id where BOT will try to post
`enabled` INT( 1 ) - boolean - if true, this feed will be checked
Und diese in der config:
$config['lastrss_ap_enabled'] = 1; (boolean - if true, ap is enabled and feeds are checked)
$config['lastrss_ap_items_limit'] = 5; (number of items which is bot trying to post)
$config['lastrss_ap_bot_id'] = 143; (user_id of user, which will post it to forum)
Danke fuer jegliche Hilfe!

P.S. Bin auch bereit auf einen anderen Mod umzusteigen, falls es einen gibt!

Re: lastRSS autoposting bot MOD

Verfasst: 03.04.2009 14:05
von Alufu
Ich habe auch Probleme mit diesem Mod.
siehe hier: http://www.phpbb.de/community/viewtopic ... 6&t=188831

Leider gibt es soweit ich weiß keinen anderen. :cry:

Re: lastRSS autoposting bot MOD

Verfasst: 03.04.2009 16:46
von rPaHzPeBrB
Frage: Macht dieser Mod:
http://www.phpbb.com/community/viewtopic.php?t=130271
das selbe, oder liege ich da falsch? Danke!

EDIT: Oder dieser:
http://www.phpbb.com/community/viewtopi ... &start=180

Re: lastRSS autoposting bot MOD

Verfasst: 05.04.2009 17:12
von rPaHzPeBrB
Es gibt wohl noch mehr Interessenten, eine Loesung waere wohl sehr hilfreich!

Re: lastRSS autoposting bot MOD

Verfasst: 08.04.2009 01:36
von rPaHzPeBrB
Hust

Re: lastRSS autoposting bot MOD

Verfasst: 08.04.2009 14:34
von Alufu
Scheinen nicht viele diese Mods zu benutzen. :(

Re: lastRSS autoposting bot MOD

Verfasst: 08.04.2009 15:00
von rPaHzPeBrB
Waere sehr schade.