Impressive !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'] != '')) ? '© ' . $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); } } ?>
