Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 02-07-2012, 05:07 AM
risestar risestar is offline
 
Join Date: Oct 2001
Posts: 31
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default parse_bb change from 4.0.1 and 4.1.10?

I have a external, script that pulls data and parses bbcode and display content on an external page. After upgrading from Vbulletin 4.0.1 to the latest 4.1.10 it no longer works and just outputs a blank white page. Has there been a change in the way bb code is parsed or some other change that would kill the script?

I have the code of the external page

Thanks

---------------------------------------

<?php

ob_start();

// See bottom for more instructions.

// We need vB global for bbcode parsing.
// This scripts needs to be in the forums directory or you need to uncomment the chdir
// lines (and edit them).

chdir("/path/to/your/forum/");

require_once("./global.php");

chdir("/path/to/your/forum/");

// VARIABLES TO SET

//specify character limit
$topicchars = "275";

// hostname or ip of server
$servername="localhost";

// username and password to log onto db server
$dbusername="mysql_user";
$dbpassword="mysql_pass";

// name of database
$dbname="forum";

//path to your forums
$forumspath = "/forum";

require_once('./includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

function writenews($cats, $filetw, $newsitems=7){
global $servername;
global $dbusername;
global $dbpassword;
global $dbname;
global $forumspath;
global $bbcode_parser;
global $topicchars;

//Connect to the database
$connection = mysql_connect("$servername","$dbusername","$dbpass word") or die ("Cannot connect to server.");
$db = mysql_select_db("$dbname", $connection) or die ("Could not select database.");

//Create SQL statement this gets the title poster and other bits
$sql = "SELECT threadid, title, forumid, attach, replycount, postusername, postuserid, lastposter, dateline, iconid FROM thread WHERE forumid IN ($cats) AND sticky = '0' ORDER BY threadid DESC LIMIT $newsitems";

//execute sql query
$sql_result = mysql_query($sql, $connection) or die ("Could not execute query.");

if (!$sql_result) {
echo "Could not get news.";
}
$attachment=0;
while ($row = mysql_fetch_array($sql_result)) {
$threadid = $row["threadid"];
$title = $row["title"];
$forumid = $row["forumid"];
$attachment = $row["attach"];
$replycount = $row["replycount"];
$postusername = $row["postusername"];
$postuserid = $row["postuserid"];
$lastposter = $row["lastposter"];
$iconid = $row["iconid"];
$dateline = $row["dateline"];

//create the second SQL statement to pull the post from the thread it resides in
$sql2 = "SELECT postid, threadid, username, userid, title, dateline, pagetext, iconid FROM post WHERE threadid = \"$threadid\" ORDER BY postid ASC LIMIT 1";

//This gets the text of the post
$sql_result2 = mysql_query($sql2, $connection) or die ("Could not execute query in second sql statement.");
if (!$sql_result2) {
echo "Could not get news.";
}
while ($row2 = mysql_fetch_array($sql_result2)) {
$ptext = $row2["pagetext"];
$atlink= $row2["postid"];

//create a third conditional SQL statement to pull the image attachment from the thread

//VB4.x attachment sql statement
$sql3="";
$attachmentshow="";
if ($attachment == "1")
{
$sql3 = mysql_query("SELECT attachmentid, dateline, filename FROM attachment WHERE contentid=$atlink");

while($attachments_get=mysql_fetch_array($sql3))
{
$attachmentid = $attachments_get['attachmentid'];
}

//VB 4.x attachment show
$attachmentshow = ("<img src=\"$forumspath/attachment.php?attachmentid=$attachmentid&d=$datel ine\" width=\"100\" height=\"100\" align=\"left\" hspace=\"15\" vspace=\"0\"/>");
}
else
{echo "";
}

//Convert time
$dateposted = date("D j M Y, g:i A",$dateline);

//Comments or comment depending on number of replies
if ($replycount==1) {
$commenttext = "Comment";
}
else {
$commenttext = "Comments";
}

// This parses the bbcode
$outxt = $bbcode_parser->parse($ptext, $row['forumid']);

//$outxt=parse_bbcode2($ptext,"1","1","1","1","1");

//limit characters - Comment out if not needed
$outxt=substr($outxt,0,$topicchars);

// Uncomment next 4 lines if you want to limit the amount of text displayed to the first paragraph.
//$trimmed = explode("<br />", $outxt);
//$outxt=$trimmed[0];
//$trimmed = explode("</p>", $outxt);
//$outxt=$trimmed[0];

//$outxt=substr($outxt,0,1000);

// This is optional. It strips out unecessary tags if you wish and leaves those specified behind
$outxt = strip_tags($outxt, '<a>,<b>,<strong>,<i>,<em>,<br />,<br>,<p>');

// This sql gets the title of the forum
$sql3 = "SELECT title FROM forum WHERE forumid = \"$forumid\" LIMIT 1";
$sql_result3 = mysql_query($sql3, $connection) or die ("Could not execute query in second sql statement.");
$row3 = mysql_fetch_array($sql_result3);
$forumname = $row3["title"];

//EDIT the HTML OUTPUT HERE

$towrite .= "<div class=\"container\"><table border=\"0\" cellpadding=\"0\">
<tr>
<td>
<!-- Overall Table -->

<table border=\"0\" width=\"100%\" cellpadding=\"8\" class=\"tablefont\">
<tr>

<td align=\"right\" class=\"tablefont\" font size=\"2px\">
<a href=\"/forum/forumdisplay.php?f=$forumid\">$forumname</a>
</td>
<tr>

<td align=\"left\" valign=\"top\" class=\"contentheading\">
<img src=\"/images/newsposticon.gif\">&nbsp;<a class=\"contentheading\" href=\"$forumspath/showthread.php?s=&amp;threadid=$threadid\">$title</a>
</td><tr>

<td align=\"left\" class=\"tablefont\">

<table border=\"0\" width=\"100%\">
<td width=\"3%\" class=\"tablefont\"><img src=\"$forumspath/images/icons/icon1.gif\">&nbsp;</td>
<td width=\"40%\" class=\"tablefont\"><b>Posted by : <i><font color=#333333><i>$postusername , QuadCorral Administrator</b></i></font></td>
<td width=\"37%\" align=\"right\" class=\"tablefont\"><b>Posted On: <i><font color=#333333>$dateposted</i></b></font></td>
</tr>
</table>

<P><br>
</td>
<tr>

<td class=\"tablefont\" valign=\"top\">
<table border=\"0\" bgcolor=\"#e8e7e7\">

<td width=\"140\" valign=\"top\" class=\"insetcolor\"><P><br>$attachmentshow</td>
<td width=\"560\" valign=\"top\" class=\"insetcolor\"><P><br>$outxt <b>...</b>
<P align=\"right\"><a class=\"tablefont\" href=\"$forumspath/showthread.php?s=&amp;threadid=$threadid\">[ Read More ]</a><P></td>

</table>

</td>
</tr>
<td>
<table border=0 width=\"100%\">
<tr>

<td align=\"center\">

<script type=\"text/javascript\">
<!--
google_ad_client = \"pub-6975170640160199\";
/* 468x60, created 8/3/08 */
google_ad_slot = \"4601200771\";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>
</td></tr>

</tr></table>

</tr></table>
<center><hr></center>

<!-- /overall table -->
</td></tr></table></div>";
// END HTML EDIT
}
}

//disconnect
//mysql_free_result($sql_result);
//mysql_close($connection);

// If you want to wite out to a file - good idea to reduce db load
// Then uncomment this section and edit appropriately. You need
// to have a folder to stores the output file and they need to writeable (chmod 666)
// $filetw is name of output file.
// You may then want to call this file by cron so thing update reguarly.

//$tmpfile = fopen("/path/to/storafe/folder/".$filetw."","w+");
//$fp = fwrite($tmpfile,$towrite);
//fclose($tmpfile);
//flush ();

// If you are writing to a file comment the line below out.
echo $towrite;
}

// This calls the writenews function. Done as a function so can be called multiple times.
// First variable is forum id to get news from. One forum is like 1 and multiple forums
// like 1,2,3. Output file onyl applies if you are outputting a file (see just above)
// The last variable is the number of news itmes to grab / display. Deafults to 10.

@writenews("4", "outputfile.txt","5");

// Want another write out (useful for files etc?) just call function again as below
// @writenews("16,17", "outputfile.txt","10");

ob_end_flush();
?>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06863 seconds
  • Memory Usage 2,212KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete