View Single Post
  #1  
Old 06-24-2013, 01:22 PM
KaitenV's Avatar
KaitenV KaitenV is offline
 
Join Date: Apr 2009
Posts: 36
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default parse bbcode on external webpage

I'm looking for an upgrade of vbulletin external for vbulletin 3 to vbulletin 4. I was was running vbulletin 3.7.2, and I am now running 4.2.1. The script worked perfectly, but now it shows the vbulletin forum shut down page. I'm looking for a way to export the vbulletin bbcode parser to an external page so the posts fetched via my query can have their bbcode parsed.

This is the code that now shuts down:
PHP Code:
<?php

error_reporting
(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''vBExternal');

$phrasegroups = array();

$specialtemplates = array(
    
'options',
);

$actiontemplates = array();

$globaltemplates = array();

if( !
file_exists('./includes/config.php')) {
    echo 
"includes/config.php does not exist. Cannot continue.";
    exit;
}

require_once(
'./includes/class_core.php');
require(
'./includes/config.php');

DEFINE('DIR','.');
DEFINE('TABLE_PREFIX',$config['Database']['tableprefix']);

$vbulletin =& new vB_Registry();

switch (
strtolower($config['Database']['dbtype']))
{
    case 
'mysql':
    case 
'':
    {
        
$db =& new vB_Database($vbulletin);
        break;
    }
    case 
'mysqli':
    {
        
$db =& new vB_Database_MySQLi($vbulletin);
        break;
    }
    default:
    {
        die(
'Fatal error: Database class not found');
    }
}

require_once(
'./includes/functions.php');


$db->connect(
    
$config['Database']['dbname'],
    
$config['MasterServer']['servername'],
    
$config['MasterServer']['port'],
    
$config['MasterServer']['username'],
    
$config['MasterServer']['password'],
    
$config['MasterServer']['usepconnect'],
    
$config['SlaveServer']['servername'],
    
$config['SlaveServer']['port'],
    
$config['SlaveServer']['username'],
    
$config['SlaveServer']['password'],
    
$config['SlaveServer']['usepconnect'],
    
$config['Mysqli']['ini_file']
);

$vbulletin->db =& $db;

define('TIMENOW'time());
require_once(
'./includes/class_bbcode.php');
$Data "";

/*
$datastore_class = (!empty($config['Misc']['datastore'])) ? $config['Misc']['datastore'] : 'vB_Datastore';

if ($datastore_class != 'vB_Datastore')
{
    require_once('./includes/class_datastore.php');
}

$vbulletin->datastore =& new $datastore_class($vbulletin, $db);
$vbulletin->datastore->fetch($specialtemplates);*/

function RunError($message "") {
    echo 
"<font size='1' face='verdana'>There was an error while processing vBExternal:<br />{$message}</font>";
    exit;
}

function 
output_News($a 5,$f ""){
    global 
$db,$vbulletin,$cmsstyle;

    
$Amount = ($a) ? intval($a) : 5;
    
    
$Forum $f;

    if(!
$ForumRunError("No specified forum to pull news from.");

    
$NewestNews $db->query("
    select t.*,p.pagetext
    from "
.TABLE_PREFIX."thread t
    left join "
.TABLE_PREFIX."post p on(p.postid=t.firstpostid)
    where t.forumid in(
$Forum)
    order by dateline desc
    limit 0,
$Amount");


    
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());

    while(
$News $db->fetch_array($NewestNews)) {
        
        
$News['date'] = date"l M j Y"$News['dateline']);
        
$News['time'] = vbdate($vbulletin->options['timeformat'], $News['dateline']);
        
$News['replycount'] = vb_number_format($News['replycount']);
        
        
$spt explode('[read more]',$News['pagetext']);
        
        
$News['pagetext'] = &$spt[0];

        
$News['pagetext'] = $bbcode_parser->parse(unhtmlspecialchars($News['pagetext']), $f);
        
        eval(
'$Data .= "'.$cmsstyle.'";');
        
    }
    
    
$Data str_replace('images/smilies/',"{$vbulletin->options[bburl]}/images/smilies/",$Data);
    
    return 
$Data;

}

?>
PHP Code:
echo output_news(5,2); 
https://vborg.vbsupport.ru/showthread.php?t=81943
https://vborg.vbsupport.ru/showthrea...t=83005&page=4

Does anyone know of an already existing script to export threads to a php web page and parse the bbcode? I'm looking to export threads as news.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01656 seconds
  • Memory Usage 1,839KB
  • 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
  • (2)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