Thread: Article Bot
View Single Post
  #458  
Old 01-09-2005, 10:39 AM
Gandolfe Gandolfe is offline
 
Join Date: Jan 2005
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Everything works fine, seems like would be a great hack, thats if it was syndicating with the .xml .rss feeds - I get this error from articlebot.php


Fatal error: Call to a member function on a non-object in /hsphere/local/home/williamk/cs-elite.net/forums/articlebot/articlebot.php on line 92

PHP Code:
<?php



/* +------------------------------------------------------------------+
   | articlebot.php, v1.1, 07/25/04                                   |
   +------------------------------------------------------------------+
   | Support:   www.vbulletin.org/forum/showthread.php?t=67078        |
   +------------------------------------------------------------------+
   | Author:    velocd                                                |
   |            www.animesystem.com                                   |
   +------------------------------------------------------------------+ */



/* +---------------------------------+
   | Environment                     |
   +---------------------------------+ */



error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS'1);

$globaltemplates = array(
    
'articlebot_post'
);



/* +---------------------------------+
   | Dependencies                    |
   +---------------------------------+ */



// Provide absolute server path to forums.
// e.g. /home/cjohn/public_html/forums/


// chdir('/hsphere/local/home/williamk/cs-elite.net/forums/');
// require_once './global.php';

include_once '/hsphere/local/home/williamk/cs-elite.net/forums/articlebot/rss_fetch.inc';


// If you intend to call this script by placing a
// include_once './articlebot/articlebot.php'; in your
// phpinclude_end template, then comment out:
//
// chdir('/path/to/forums/');
// require_once './global.php';
//
// Note, recommended usage for this script is by
// crontab with this shell command in mind:
//
// e.g. /usr/local/bin/php /path/to/forums/articlebot/articlebot.php
// (substituting the paths with their correct location)
//
// If /usr/local/bin/php is not the correct path (generally it is),
// use PuTTY to SSH in and use the command "whereis php" to find
// the correct path.
//
// Explanation on crontabs:
// http://www.cpanel.net/docs/cp/cronJobs.htm
//
// By this method you are not calling an extra query on every page
// to check for ready-to-post article bots.


if ($vboptions['similarthreadsearch'])
{
    require_once 
'./includes/functions_search.php';
}



/* +------------------------------------------+
   | Request: article bot syndication         |
   +------------------------------------------+ */



if (!$_REQUEST['do'])
{
    
/* +---------------------------------+
       | Query: fetch article bots       |
       +---------------------------------+ */


    
$result_articlebots $DB_site->query("
        SELECT articlebot_rss.*, articlebot.userid,
            articlebot.articlebotid,
            articlebot.regex_title_search AS global_regex_title_search,
            articlebot.regex_title_replace AS global_regex_title_replace,
            articlebot.regex_desc_search AS global_regex_desc_search,
            articlebot.regex_desc_replace AS global_regex_desc_replace,
            "
.TABLE_PREFIX."user.username
        FROM articlebot_rss
        LEFT JOIN articlebot
            USING (articlebotid)
        LEFT JOIN "
.TABLE_PREFIX."user
            USING (userid)
        WHERE nextpost <= "
.TIMENOW."
            AND articlebot_rss.enabled = 1
            AND articlebot.enabled = 1
    "
);


    if (
$DB_site->num_rows($result_articlebots))
    {
        
$fetch_days 20;
        
$timecut TIMENOW - ((60*60*24) * $fetch_days);

        
/* +---------------------------------+
           | Query: fetch threads            |
           +---------------------------------+ */


        
$result_threads $DB_site->query("
            SELECT title
            FROM articlebot_rss_cache
            WHERE dateline >= 
$timecut
        "
);


        while (
$thread $DB_site->fetch_array($result_threads))
        {
            
$threads[] = trim($thread['title']);
        }

        while (
$articlebot $DB_site->fetch_array($result_articlebots))
        {
            
$rss fetch_rss($articlebot['rss_path']);

            
$articles array_reverse($rss->items);

            
$count 0;

            foreach (
$articles as $article)
            {
                
$article['title'] = trim($article['title']);

                if (!
$article['link'] || !$article['title'])
                {
                    continue;
                }

                if (
$articlebot['desc_required'] && !$article['description'])
                {
                    continue;
                }

                if (
is_array($threads) && in_array($article['title'], $threads))
                {
                    continue;
                }

                if (!
$articlebot['lastpost'] && (--$articlebot['initialtrim'] > 0))
                {
                    
/* +---------------------------------------+
                       | Query: insert unused cache threads    |
                       +---------------------------------------+ */


                    
$DB_site->query("
                        INSERT INTO articlebot_rss_cache
                            (title, dateline)
                        VALUES
                            ('"
.addslashes($article['title'])."', ".TIMENOW.")
                    "
);


                    continue;
                }


                
/* +---------------------------------+
                   | Query: insert cache thread      |
                   +---------------------------------+ */


                
$DB_site->query("
                    INSERT INTO articlebot_rss_cache
                        (title, dateline)
                    VALUES
                        ('"
.addslashes($article['title'])."', ".TIMENOW.")
                "
);


                if (
$articlebot['global_regex_title_search'] || $articlebot['regex_title_search'])
                {
                    if (
$articlebot['regex_title_search'])
                    {
                        
$articlebot['global_regex_title_search']   = $articlebot['regex_title_search'];
                        
$articlebot['global_regex_title_replace']  = $articlebot['regex_title_replace'];
                    }

                    
$article['title'] = @preg_replace(
                        
"$articlebot[global_regex_title_search]",
                        
"$articlebot[global_regex_title_replace]",
                        
$article['title']
                    );
                }

                if (
$vboptions['similarthreadsearch'] && $articlebot['build_similar_threads'])
                {
                    
$similarthreads fetch_similar_threads($article['title']);
                }
                else
                {
                    
$similarthreads '';
                }

                if (
$articlebot['label'])
                {
                    
$article['title'] = $articlebot['label'] . ' ' $article['title'];
                }


                
/* +---------------------------------+
                   | Query: insert thread            |
                   +---------------------------------+ */


                
$DB_site->query("
                    INSERT INTO "
.TABLE_PREFIX."thread
                        (title, lastpost, forumid, open,
                        replycount, postusername, postuserid, lastposter, dateline, iconid,
                        visible, attach, similar, is_rss)
                    VALUES
                        ('"
.addslashes($article['title'])."', ".TIMENOW.", $articlebot[forumid],
                         1, 0, '"
.addslashes($articlebot['username']) . "', $articlebot[userid],
                         '"
.addslashes($articlebot['username']) . "', ".TIMENOW.", $articlebot[iconid], 1, 0,
                         '"
.addslashes($similarthreads)."', 1)
                "
);


                
$thread_id $DB_site->insert_id();

                
$article['description'] = strip_tags(html_entity_decode(trim($article['description'])));

                if (
$articlebot['global_regex_desc_search'] || $articlebot['regex_desc_search'])
                {
                    if (
$articlebot['regex_desc_search'])
                    {
                        
$articlebot['global_regex_desc_search']   = $articlebot['regex_desc_search'];
                        
$articlebot['global_regex_desc_replace']  = $articlebot['regex_desc_replace'];
                    }

                    
$article['description'] = @preg_replace(
                        
"$articlebot[global_regex_desc_search]",
                        
"$articlebot[global_regex_desc_replace]",
                        
$article['description']
                    );
                }

                eval(
'$articlebot_post = "' fetch_template('articlebot_post'00) . '";');


                
/* +---------------------------------+
                   | Query: insert post              |
                   +---------------------------------+ */


                
$DB_site->query("
                    INSERT INTO "
.TABLE_PREFIX."post
                        (threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie,
                         showsignature, ipaddress, iconid, visible, attach)
                    VALUES
                        (
$thread_id, 0, '".addslashes($article['title'])."',
                         '"
.addslashes($articlebot['username'])."', $articlebot[userid],
                         "
.TIMENOW.", '" addslashes($articlebot_post)."', 0, 1,
                         '"
.addslashes($_SERVER['SERVER_ADDR'])."', $articlebot[iconid], 1, 0)
                "
);


                
$post_id $DB_site->insert_id();


                
/* +---------------------------------+
                   | Query: update thread            |
                   +---------------------------------+ */


                
$DB_site->query("
                    UPDATE "
.TABLE_PREFIX."thread
                    SET firstpostid = 
$post_id
                    WHERE threadid = 
$thread_id
                "
);


                require_once 
'./includes/functions_databuild.php';

                
$foruminfo['indexposts'] = 1;

                
build_post_index($post_id$foruminfo1);

                if (
$forums[$articlebot['forumid']])
                {
                    
$forum_posts = ++$forums[$articlebot['forumid']]['forum_posts'];

                    unset(
$forums[$articlebot['forumid']]);
                }
                else
                {
                    
$forum_posts 1;
                }

                
$forums[$articlebot['forumid']] = array(
                    
'lastposter'    => $articlebot['username'],
                    
'lastthread'    => $article['title'],
                    
'lastthreadid'  => $thread_id,
                    
'lasticonid'    => $articlebot['iconid'],
                    
'forum_posts'   => $forum_posts
                
);

                if (
$users[$articlebot['userid']])
                {
                    
$users[$articlebot['userid']]++;
                }
                else
                {
                    
$users[$articlebot['userid']] = 1;
                }

                if (++
$count >= $articlebot['fetchlimit'])
                    break;
            }

            
$nextpost TIMENOW + ($articlebot['postinterval'] * 60);


            
/* +-------------------------+
               | Query: update rss       |
               +-------------------------+ */


            
$DB_site->query("
                UPDATE articlebot_rss
                SET lastpost = "
.TIMENOW.",
                    nextpost = 
$nextpost
                WHERE rssid = 
$articlebot[rssid]
            "
);


            unset(
$rss);
        }

        if (
is_array($users))
        {
            foreach (
$users as $userid => $user_posts)
            {
                
/* +---------------------------------+
                   | Query: update article bot(s)    |
                   +---------------------------------+ */


                
$DB_site->query("
                    UPDATE "
.TABLE_PREFIX."user
                    SET posts = posts + 
$user_posts
                    WHERE userid = 
$userid
                "
);
            }
        }

        if (
is_array($forums))
        {
            foreach (
$forums as $forumid => $forum)
            {
                
/* +---------------------------------------+
                   | Query: update affected forum(s)       |
                   +---------------------------------------+ */


                
$DB_site->query("
                    UPDATE "
.TABLE_PREFIX."forum
                    SET replycount = replycount + 
$forum[forum_posts],
                        threadcount = threadcount + 
$forum[forum_posts],
                        lastpost = "
.TIMENOW.",
                        lastposter = '" 
addslashes($forum['lastposter']) . "',
                        lastthread = '" 
addslashes($forum['lastthread']) . "',
                        lastthreadid = 
$forum[lastthreadid],
                        lasticonid = 
$forum[lasticonid]
                    WHERE forumid = 
$forumid
                "
);
            }
        }
    }
}



?>
That's a copy of how articlebot.php is at the moment. Any ideas?
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01211 seconds
  • Memory Usage 2,007KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete