Activity Stream
48,167 MEMBERS
64140 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member

    Default I need help with this code

    Hello guys,

    I have a forum in MyBB and Im using this plugin to auto post content:
    http://mods.mybb.com/view/rss-feed-poster

    But I need a little change and I dont know how to do It...

    This is an example of one of my auto posts:


    I want to change the source link http:// with "Read More...".
    I think that we need to modify ['link'] in task rssfeedposter.php file, but dont know how to do It...
    Can someone please help me?
    Thank you!

    rssfeedposter.php code:
    PHP Code: 
    <?php
    /*
    RSS Feed Poster
    by: vbgamer45
    http://www.mybbhacks.com
    Copyright 2010  MyBBHacks.com

    ############################################
    License Information:

    Links to http://www.mybbhacks.com must remain unless
    branding free option is purchased.
    #############################################
    */

    $feedcount 0;
    $maxitemcount 0;
    $tag '';
    $tag_attrs '';
    $insideitem false;
    $depth = array();



    function 
    verify_rss_url($url)
    {
        global 
    $txt$depth;

        
    // Rss Data storage
        
    $finalrss '';
        
    $failed true;

            
    $fp2 = @fopen($url"r");
            if (
    $fp2)
            {
                
    $failed false;
                
    $contents '';
                while (!
    feof($fp2))
                {
                  
    $contents .= fread($fp28192);
                }
        
                
    fclose($fp2);
        
                
    $finalrss $contents;
            }
        



            if(
    $failed == true)
            {
                
    $url_array parse_url($url);
        
                
    $fp = @fsockopen($url_array['host'], 80$errno$errstr30);
                if (!
    $fp)
                {
        
                }
                else
                {
                    
    $failed false;
        
                   
    $out "GET " $url_array['path'] . (@$url_array['query'] != '' '?' $url_array['query'] : '') . "  HTTP/1.1\r\n";
                   
    $out .= "Host: " $url_array['host'] . "\r\n";
                   
    $out .= "Connection: Close\r\n\r\n";
        
                   
    fwrite($fp$out);
        
                   
    $rssdata '';
                   
               
    $header '';
               
    // Remove stupid headers.
                   
    do 
                {
                    
    $header .= fgets ($fp128 );

                  } while ( 
    strpos($header"\r\n\r\n" ) === false );
        
                   while (!
    feof($fp))
                   {
                       
    $rssdata .= fgets($fp128);
                   }
                   
    fclose($fp);
        
                   @
    $finalrss = @$rssdata;
        
                }
            }
        

        
    // Use cURL

            
    if($failed == true)
            {
                if(
    function_exists("curl_init"))
                {
                    
    $failed false;
                    
    // Last but not least try cUrl
                    
    $ch curl_init();
        
                    
    // set URL and other appropriate options
                    
    curl_setopt($chCURLOPT_URL$url);
                    
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
                    
    // grab URL, and return output
                    
    $output curl_exec($ch);
        
                    
    // close curl resource, and free up system resources
                    
    curl_close($ch);
                    return 
    $output;
                }
            }




        
    // XML Parser functions to verify the XML Feed
        
    if($failed == false)
        {
            
    $depth = array();

            
    $xml_parser xml_parser_create();
            
    xml_set_element_handler($xml_parser"startElement2""endElement2");


               if (!
    xml_parse($xml_parser$finalrss)) {
                  
    fatal_error(sprintf($txt['feedposter_err_xmlerror'],
                               
    xml_error_string(xml_get_error_code($xml_parser)),
                               
    xml_get_current_line_number($xml_parser)), false);
               }

            
    xml_parser_free($xml_parser);
        }
        else
        {
            
    // We were not able to download the feed :(
            
        
    }


    }


    function 
    startElement2($parser$name$attrs)
    {
       global 
    $depth;
       
    $depth[$parser]++;
    }

    function 
    endElement2($parser$name)
    {
       global 
    $depth;
       
    $depth[$parser]--;
    }

    function 
    UpdateRSSFeedBots($task)
    {
        global 
    $db$context$feedcount$maxitemcount$insideitem$tag$tag_attrs;

        
    // First get all the enabled bots
        
    $context['feeds'] = array();
        
    $request $db->write_query("
                SELECT
                    ID_FEED, fid, feedurl, title, postername, updatetime, enabled, html,
                    uid, locked, articlelink, topicprefix, numbertoimport, importevery, markasread 
                FROM "
    .TABLE_PREFIX."feedbot
                WHERE enabled = 1"
    );

        while (
    $row $db->fetch_array($request))
        {
            
    $context['feeds'][] = $row;
        }

        

        require_once 
    MYBB_ROOT."inc/datahandlers/post.php";
        

        
    // Check if a field expired
        
    foreach ($context['feeds'] as $key => $feed)
        {

            
    $current_time time();


            
    // If the feedbot time to next import has expired
            //add_task_log($task, "Check " . ($current_time + (60 * $feed['importevery'])) . " :" . $feed['updatetime']);
            
            
    if ($current_time $feed['updatetime'])
            {

                
    $feeddata GetRSSData($feed['feedurl']);



                if (
    $feeddata != false)
                {

                    
    // Process the XML
                        
    $xml_parser xml_parser_create();
                        
    $context['feeditems'] = array();
                        
    $feedcount 0;
                        
    $maxitemcount $feed['numbertoimport'];
                        
    $tag '';
                        
    $tag_attrs '';
                        
    $insideitem false;
                        
    $context['feeditems'][0] = array();
                        
    $context['feeditems'][0][] = array();
                        
    $context['feeditems'][0]['title'] = '';
                        
    $context['feeditems'][0]['description'] = '';
                        
    $context['feeditems'][0]['link'] = '';



                        
    xml_set_element_handler($xml_parser"startElement1""endElement1");
                        
    xml_set_character_data_handler($xml_parser"characterData1");

                        if (!
    xml_parse($xml_parser$feeddata))
                         {
                            
    // Error reading xml data

                             
    xml_parser_free($xml_parser);
                         }
                        else
                        {
                               
    // Data must be valid lets extra some information from it
                               // RSS Feeds are a list of items that might contain title, description, and link


                               // Free the xml parser memory
                            
    xml_parser_free($xml_parser);

                            
    // Loop though all the items
                            
    $myfeedcount 0;

                            for (
    $i 0$i < ($feedcount); $i++)
                            {
                                

                                if (
    $myfeedcount >= $maxitemcount)
                                {
                                    continue;
                                }
                                
                                
    //add_task_log($task, "NotSkip: $myfeedcount : $maxitemcount : $feedcount  T:" . $context['feeditems'][$i]['title']);

                                
                                // Check feed Log
                                // Generate the hash for the log
                                
    if(!isset($context['feeditems'][$i]['title']) || !isset($context['feeditems'][$i]['description']))
                                    continue;
                                    
                                if(empty(
    $context['feeditems'][$i]['title']) && empty($context['feeditems'][$i]['description']))
                                    continue;    
                                    
                                

                                
    $itemhash md5($context['feeditems'][$i]['title'] . $context['feeditems'][$i]['description']);
                                
    $request $db->write_query("
                                SELECT
                                    feedtime
                                FROM "
    .TABLE_PREFIX."feedbot_log
                                WHERE feedhash = '
    $itemhash'");


                                
    // If no has has found that means no duplicate entry
                                
    if ($db->num_rows($request) == 0)
                                {

                                    
    // Create the Post
                                    
    $msg_title = ($feed['html'] ? $context['feeditems'][$i]['title'] : strip_tags($context['feeditems'][$i]['title']));

                                    
    $msg_body =  ($feed['html'] ? $context['feeditems'][$i]['description'] . "\n\n" $context['feeditems'][$i]['link']  : strip_tags($context['feeditems'][$i]['description'] .  "\n\n" $context['feeditems'][$i]['link']));
                                
                                        
                                    
    $posthandler = new PostDataHandler("insert");
                                    
    $posthandler->action "thread";
                                    
                                    if (
    strlen($msg_title) > 120)
                                        
    $msg_title substr($msg_title,0,115);
                                    
                                    
    $msg_title trim($msg_title);
                                

                                    
    $new_thread = array(
                                        
    "fid" => $feed['fid'],
                                        
    "subject" => $feed['topicprefix'] . $msg_title,
                                        
    "icon" => '',
                                        
    "uid" => $feed['uid'],
                                        
    "username" => $feed['postername'],
                                        
    "message" => '[b]' $msg_title "[/b]\n\n" $msg_body,
                                        
    "ipaddress" => '127.0.0.1',
                                        
    "posthash" => ''
                                    
    );
                                    
                                    
    $new_thread['modoptions']  = array('closethread' => $feed['locked']);
                                    
                                    
    $posthandler->set_data($new_thread);
                                    
    $valid_thread $posthandler->validate_thread();
                                    
                                    if(!
    $valid_thread)
                                    {
                                        
    $post_errors $posthandler->get_friendly_errors();
                                    }
                                    else 
                                        
    $thread_info $posthandler->insert_thread();
                                        
                                        
                                    
    $tid = (int) $thread_info['tid'];
                                    
    $pid = (int)  $thread_info['pid'];
                                    
                                    if (
    $feed['markasread'])
                                    {
                                        
    // Mark thread as read
                                        
    require_once MYBB_ROOT."inc/functions_indicators.php";
                                        
    mark_thread_read($tid$feed['fid']);
                                    }

                                    
    // Add Feed Log
                                    
    $fid $feed['ID_FEED'];
                                    
    $ftime time();

                                    
    $db->write_query("
                                    INSERT INTO "
    .TABLE_PREFIX."feedbot_log
                                        (ID_FEED, feedhash, feedtime, tid, pid)
                                    VALUES
                                        (
    $fid,'$itemhash',$ftime,$tid,$pid)");
                                    
                                    
    $myfeedcount++;

                                }
                            }

                         } 
    // End valid XML check



                
    }  // End get feed data
                
                
                
                // Set the RSS Feed Update time
                
    $updatetime time() +  (60 $feed['importevery']);
                
                
                
    $db->write_query("
                UPDATE "
    .TABLE_PREFIX."feedbot 
                SET 
                    updatetime = '
    $updatetime'
            
                WHERE ID_FEED = " 
    $feed['ID_FEED']);

            } 
    // End expire check


        
    // End for each feed

    }

    function 
    GetRSSData($url)
    {
        
    $url_array parse_url($url);
        

            
    $fp2 = @fopen($url"r");
            if (
    $fp2)
            {
                
    $contents '';
                while (!
    feof($fp2))
                {
                  
    $contents .= fread($fp28192);
                }
        
                
    fclose($fp2);
        
                return 
    $contents;
            }



            
    $fp fsockopen($url_array['host'], 80$errno$errstr30);
            if (!
    $fp)
            {
        
            }
            else
            {
        
        
               
    $out "GET " $url_array['path'] . (@$url_array['query'] != '' '?' $url_array['query'] : '') . "  HTTP/1.1\r\n";
               
    $out .= "Host: " $url_array['host'] . "\r\n";
               
    $out .= "Connection: Close\r\n\r\n";
        
               
    fwrite($fp$out);
        
               
    $rssdata '';
               
               
    $header '';
               
    // Remove stupid headers.
                   
    do 
                {
                    
    $header .= fgets ($fp128 );

                  } while ( 
    strpos($header"\r\n\r\n" ) === false );
        
               while (!
    feof($fp))
               {
                   
    $rssdata .= fgets($fp128);
               }
               
    fclose($fp);

               
    $finalrss $rssdata;
        
               return  
    $finalrss;
            }
        


            if(
    function_exists("curl_init"))
            {
                
    // Last but not least try cUrl
                
    $ch curl_init();
        
                
    // set URL and other appropriate options
                
    curl_setopt($chCURLOPT_URL$url);
                
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
                
    // grab URL, and return output
                
    $output curl_exec($ch);
        
                
    // close curl resource, and free up system resources
                
    curl_close($ch);
                
                return 
    $output;
            }
        


        
    // Failure return false
        
    return false;

    }

    function 
    startElement1($parser$name$attrs)
     {
        global 
    $insideitem$tag$tag_attrs;
        if (
    $insideitem)
        {
            
    $tag $name;
            
    $tag_attrs =  $attrs;
        }
        elseif (
    $name == "ITEM"  || $name == "ENTRY")
        {
            
    $insideitem true;
        }
    }

    function 
    endElement1($parser$name)
    {
        global 
    $insideitem$tag$feedcount$context$tag_attrs;

        if (
    $name == "ITEM" || $name == "ENTRY")
        {
            
    $feedcount++;
            
    $context['feeditems'][$feedcount] = array();
            
    $context['feeditems'][$feedcount][] = array();
            
    $context['feeditems'][$feedcount]['title'] = '';
            
    $context['feeditems'][$feedcount]['description'] = '';
            
    $context['feeditems'][$feedcount]['link'] = '';
            
    $tag_attrs '';
            
    $insideitem false;
        }
    }

    function 
    characterData1($parser$data)
     {
        global 
    $insideitem$tag,  $feedcount$context$maxitemcount$tag_attrs;

        if (
    $insideitem )
         {
            switch (
    $tag)
            {
                case 
    "TITLE":
                    
    $context['feeditems'][$feedcount]['title'] .= $data;
                break;

                case 
    "DESCRIPTION":
                    
    $context['feeditems'][$feedcount]['description'] .= $data;

                break;

                case 
    "LINK":
                    
    $context['feeditems'][$feedcount]['link'] .= $data;
                break;
                
                case 
    "SUMMARY":
                
    $context['feeditems'][$feedcount]['description'] .= $data;

                break;
                case 
    "CONTENT":
                
    $context['feeditems'][$feedcount]['description'] .= $data;

                break;

                case 
    "LINK":
                    
    $data trim($data);
                    
    $context['feeditems'][$feedcount]['link'] .= $data;
                    IF (empty(
    $data) && isset($tag_attrs['HREF']))
                        
    $context['feeditems'][$feedcount]['link'] .= $tag_attrs['HREF'];
                    
                    
                break;
                
            }
        }
    }



    function 
    task_rssfeedposter($task)
    {
        global 
    $lang;
        
        
    $lang->load('rssfeedposter');
        
        
    UpdateRSSFeedBots($task);
        
        
    add_task_log($task$lang->rssfeedposter_taskran);
    }
    ?>
    Can someone please help me?
    Thank you!
    Divvy Reviewed by Divvy on . I need help with this code Hello guys, I have a forum in MyBB and Im using this plugin to auto post content: http://mods.mybb.com/view/rss-feed-poster But I need a little change and I dont know how to do It... This is an example of one of my auto posts: http://i.imgur.com/EbT8t.png Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    tehMoviez.com 0Senes.com GeekFaceGames.com
    change
    PHP Code: 
                                    $msg_body =  ($feed['html'] ? $context['feeditems'][$i]['description'] . "\n\n" $context['feeditems'][$i]['link']  : strip_tags($context['feeditems'][$i]['description'] .  "\n\n" $context['feeditems'][$i]['link'])); 
    to
    PHP Code: 
                                    $msg_body =  ($feed['html'] ? $context['feeditems'][$i]['description'] . "\n\n[URL=" $context['feeditems'][$i]['link'] ."]Read More[/URL]"  strip_tags($context['feeditems'][$i]['description'] .  "\n\n[URL=" $context['feeditems'][$i]['link'] ."]Read More[/URL]")); 
    tell us if that works

  4.     
    #3
    Member
    I think that will work

    The new posts appeared like that:


    I changed the code to:
    PHP Code: 
    $msg_body =  ($feed['html'] ? $context['feeditems'][$i]['description'] . "\n\n<a target="_blank" href=" $context['feeditems'][$i]['link'] .">Read More</a>"  strip_tags($context['feeditems'][$i]['description'] .  "\n\n<a href=" $context['feeditems'][$i]['link'] ."]Read More</a>")); 
    Im waiting for the next posts to see If works.
    Thank you mate!

  5.     
    #4
    Member
    Hmmm first I will try to change URL to url.

  6.     
    #5
    Member
    Hmmm didnt worked, because when I edit the post appears like that:


    Because the extra spaces... any fix for this?

    PHP Code: 
    $msg_body =  ($feed['html'] ? $context['feeditems'][$i]['description'] . "\n\n[url=" $context['feeditems'][$i]['link'] ."]Read...[/url]"  strip_tags($context['feeditems'][$i]['description'] .  "\n\n[url=" $context['feeditems'][$i]['link'] ."]Read More[/url]")); 

  7.     
    #6
    Member
    Website's:
    tehMoviez.com 0Senes.com GeekFaceGames.com
    change
    PHP Code: 
    $context['feeditems'][$i]['link'
    to
    PHP Code: 
    trim($context['feeditems'][$i]['link']) 

  8.     
    #7
    Member
    Fixed, thank you mate!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 3rd Apr 2012, 09:50 AM
  2. need help with php code
    By itmees in forum Web Development Area
    Replies: 6
    Last Post: 22nd Mar 2012, 10:01 AM
  3. Replies: 1
    Last Post: 27th Aug 2011, 01:45 PM
  4. {LF} a code
    By DeathNote in forum Web Application/Script Support
    Replies: 2
    Last Post: 23rd Oct 2010, 04:18 AM
  5. [vBulletin BB Code] Moderated Message: (Like W-BB's Staff BB Code!)
    By Ghost Dog 13 in forum Webmaster Resources
    Replies: 13
    Last Post: 26th Sep 2009, 06:19 PM

Tags for this Thread

BE SOCIAL