Taking Posts made in PHPBB and putting them outside the foru

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
TanisLinkEragon
Registered User
Posts: 6
Joined: Sat Feb 25, 2006 12:39 am

Taking Posts made in PHPBB and putting them outside the foru

Post by TanisLinkEragon » Thu Dec 21, 2006 12:27 am

Hey guys, I'm attempting to take some posts made in PHPBB3 and put them outside of the form (like a portal).

Its working fine, and I get the posts, the only problem is BB code...

say someone posts

Cool.


When I get it out of my database, and put it somewhere, it shows up as

Code: Select all

[b]cool[/b]
It does the same thing if you use HTML in your post.

HTML it gets stored into the database with < and > while BB code gets put it as regular BB code.

The best solution would probably be some way to decode the BBcode and change it into HTML. Any suggestion?

Current code on testing page:

Code: Select all

<?php
$con = mysql_connect("my host","my username","my password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my DB", $con);

$result = mysql_query("SELECT * FROM phpbb_posts WHERE forum_id='39' ORDER BY post_subject");

while($row = mysql_fetch_array($result))
  {
  ?><font color=#C7C7C7>
  <?php
  echo $row['post_text'];?>
  <br><br>
<img src="/divide.jpg"><br><br>
<?php

  }

mysql_close($con);
?>
note: the <br><br>
<img src="/divide.jpg"><br><br> is there to separate the posts, and the font color tag is there to, well, change the font color.


Argg... If only phpBB3 supported HTML...

profpete
Registered User
Posts: 140
Joined: Wed Dec 08, 2004 10:49 pm
Location: Wales, UK

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by profpete » Thu Dec 21, 2006 12:51 am

Include the bbcode class, and call it to decode the post?

User avatar
Highway of Life
Registered User
Posts: 1399
Joined: Tue Feb 08, 2005 10:18 pm
Location: I'd love to change the World, but they won't give me the Source Code
Contact:

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by Highway of Life » Thu Dec 21, 2006 12:56 am

I'll be very brief, as phpBB does not support Modifications at this time, but here is what you need to do.

There are literally dozens of ways you can do it, but I think the best way is to include your "portal" in phpBB.

Code: Select all

<?php define('IN_PHPBB', true);
$phpbb_root_path = './forum/'; // make sure this goes to the path that phpBB is installed.
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
Then if you want to use sessions to control elements of your page:

Code: Select all

// Start session management
$user->session_begin();
$auth->acl($user->data);
Then use the BBCode parsing method found in the viewtopic.php page to parse your bbcode in your page.
Hint:

Code: Select all

<?php $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
Image

TanisLinkEragon
Registered User
Posts: 6
Joined: Sat Feb 25, 2006 12:39 am

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by TanisLinkEragon » Thu Dec 21, 2006 9:14 pm

I know that mods are currently not supported.

But anyways, where would I put

Code: Select all

$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
?




Script so far:

Code: Select all

<?php define('IN_PHPBB', true);
$phpbb_root_path = '/forums/'; // make sure this goes to the path that phpBB is installed.
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);

$con = mysql_connect("db536.perfora.net","gone","gone.");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("gone", $con);

$result = mysql_query("SELECT * FROM phpbb_posts WHERE forum_id='39' ORDER BY post_subject");

while($row = mysql_fetch_array($result))
  {
  ?><font color=#C7C7C7>
  <?php

  echo $row['post_text'];?>
  <br><br>
<img src="/divide.jpg"><br><br>
<?php

  }

mysql_close($con);
?>
Last edited by karlsemple on Sun Dec 24, 2006 5:41 pm, edited 1 time in total.
Reason: Removed your database username and pasword ;)

ChALkeR
Registered User
Posts: 176
Joined: Tue Mar 15, 2005 4:38 pm
Location: Russia

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by ChALkeR » Thu Dec 21, 2006 9:26 pm

Use the phpBB class, do not do manual changing to html. :D
Rember about security and custom bbcodes. ;)
Image
Sorry for my bad English....

TanisLinkEragon
Registered User
Posts: 6
Joined: Sat Feb 25, 2006 12:39 am

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by TanisLinkEragon » Sun Dec 24, 2006 2:55 pm

ChALkeR wrote: Use the phpBB class, do not do manual changing to html. :D
Rember about security and custom bbcodes. ;)

How does that help?

That really didnt answer my question....

Ectoman
Registered User
Posts: 192
Joined: Sat Dec 15, 2001 3:53 pm
Location: Denver CO
Contact:

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by Ectoman » Sun Dec 24, 2006 4:07 pm

Maybe not post your database username and password in a forum?

User avatar
Tienchen
Registered User
Posts: 91
Joined: Thu Sep 14, 2006 5:23 pm
Location: Germany
Contact:

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by Tienchen » Sun Dec 24, 2006 4:37 pm

Well, that's not so clever. But perhaps some moderator is in Christmas mood and will delete the certain database passwords in his code. :)
I don't like these cold, precise, perfect people, who, in order not to speak wrong, never speak at all, and in order not to do wrong, never do anything. (Henry Ward Beecher)
Die Stifthelden

TanisLinkEragon
Registered User
Posts: 6
Joined: Sat Feb 25, 2006 12:39 am

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by TanisLinkEragon » Tue Dec 26, 2006 10:45 pm

First: as it isn't a live forum and the database will be deleted in a month or two anyways, I dont really care.

Second: Only one person has even ATTEMPTED to help.
Last edited by TanisLinkEragon on Thu Dec 28, 2006 3:34 am, edited 1 time in total.

muse-ic
Registered User
Posts: 95
Joined: Sun Aug 21, 2005 12:23 am

Re: Taking Posts made in PHPBB and putting them outside the foru

Post by muse-ic » Wed Dec 27, 2006 9:53 pm

^ that doesn't make sense

Post Reply