God, I hope someone here can help me. I have been at this for the better part of today.
Let me first say that I am a newbie with php so I hope my search for help forums has brought me to the right place.
The script I am trying to use is this:
<?php
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Applet : phpBB Latest Topic Displayer
# Author : Jonathan Wolf <jonathanw@hotmail.com>, M.S.
# Version : v1.0 (2-20-06)
# Changes : v1.0 (2-20-06): Brand new.
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Control Constants
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
// forum_id to grab topics from (must be a valid forum_id integer)
$forum_id = 3;
// How many of the newest topics to display
$limit_count = 5;
// Date and time format (used in PHP strftime() routine)
$date_time_format = "%b %e at %I:%M %p"; // e.x. 20 Feb 12:29 am
// Path to phpBB's base directory (usually "forum/" or "phpBB/")
// Note: This is !required! to be set correctly for this script to work
// (phpBB's include files will reference this variable many times).
$phpbb_root_path = "forum/";
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# phpBB Connection Section
# This will give us a MySQL database connection ($db) to work with that
# is already initialized with the correct phpBB database for access.
# This also gives us some useful setup values such as the table prefix.
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
if(!defined("IN_PHPBB"))
{
define("IN_PHPBB", true);
include($phpbb_root_path . "extension.inc");
include($phpbb_root_path . "common.".$phpEx);
include($phpbb_root_path . "config.".$phpEx);
}
if($db) // Database connection check
{
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Database Query Section
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
// Grab our topics using a singular query
$topics_query = $db->sql_query("
SELECT
{$table_prefix}topics.topic_title,
{$table_prefix}users.username AS poster_name,
{$table_prefix}topics.topic_time,
{$table_prefix}posts_text.post_text AS topic_text,
{$table_prefix}topics.topic_views,
{$table_prefix}topics.topic_replies,
{$table_prefix}topics.topic_id,
{$table_prefix}posts_text.post_id,
{$table_prefix}topics.topic_poster AS poster_id
FROM
{$table_prefix}topics,
{$table_prefix}users,
{$table_prefix}posts_text
WHERE
{$table_prefix}topics.forum_id = {$forum_id} AND
{$table_prefix}users.user_id =
{$table_prefix}topics.topic_poster AND
{$table_prefix}posts_text.post_id =
{$table_prefix}topics.topic_first_post_id
ORDER BY topic_time DESC
LIMIT {$limit_count};");
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Parsing Section
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
// Topic query-result existance check and non-zero row count check
if($topics_query && mysql_num_rows($topics_query))
{
// Now go through all our selected topics for processing and display
while($topic_entry = $db->sql_fetchrow($topics_query))
{
// The first thing we have to do is pre-process some things...
// The post_text needs to have its BB-code replaced with actual
// HTML code, which is a bit tricky and involves some fancy foot
// work. Some of the following processing code is, as mentioned,
// adapted from clericvash's "Topic Extraction" script. Cheers.
// Set up some easy to use variables for parsing and displaying.
$topic_title = $topic_entry["topic_title"];
$poster_name = $topic_entry["poster_name"];
$topic_time = strftime($date_time_format, $topic_entry["topic_time"]);
$topic_text = $topic_entry["topic_text"];
$topic_views = $topic_entry["topic_views"];
$topic_replies = $topic_entry["topic_replies"];
$topic_id = $topic_entry["topic_id"];
$post_id = $topic_entry["post_id"];
$poster_id = $topic_entry["poster_id"];
$view_link = "{$phpbb_root_path}viewtopic.{$phpEx}?p={$post_id}";
$reply_link = "{$phpbb_root_path}posting.{$phpEx}?mode=reply&t={$topic_id}";
$poster_link = "{$phpbb_root_path}profile.{$phpEx}?mode=viewprofile&u={$poster_id}";
// BB-Code processing
// Extra character removal (these characters are identifiers that
// are concatenated into the BB-code commands themselves in order
// to help phpBB track appropriated opening and closing commands).
$topic_text = preg_replace("/\:[0-9a-z\:]+\]/si", "]", $topic_text);
// Bold
$topic_text = str_replace("[b]", "<B>", $topic_text);
$topic_text = str_replace("[/b]", "</B>", $topic_text);
// Italics
$topic_text = str_replace("[i]", "<I>", $topic_text);
$topic_text = str_replace("[/i]", "</I>", $topic_text);
// Underline
$topic_text = str_replace("[u]", "<U>", $topic_text);
$topic_text = str_replace("[/u]", "</U>", $topic_text);
// Quote (style #1)
$topic_text = preg_replace("/\[quote=(.*)\](.*)\[\/quote\]/Usi", "<DIV STYLE=\"padding: 7px\">$2</DIV>", $topic_text);
// Quote (style #2)
$topic_text = str_replace("[quote]", "<B>Quote:</B><BR><I>", $topic_text);
$topic_text = str_replace("[/quote]", "</I>", $topic_text);
// Code
$topic_text = str_replace("[code]", "<B>Code:</B><BR><I>", $topic_text);
$topic_text = str_replace("
", "</I>", $topic_text);
// List
$topic_text = preg_replace("/[list](.*)[\/list]/si", "<DIV STYLE=\"padding: 7px\">$1</DIV>", $topic_text);
$topic_text = preg_replace("/[list=(.*)](.*)[\/list]/si", "<DIV STYLE=\"padding: 7px\">$1</DIV>", $topic_text);
// Image
$topic_text = str_replace("
", "\" ALT=\"Image\">", $topic_text);
// URL
$topic_text = preg_replace("/[url](.*)[\/url]/Usi", "<A HREF=\"$1\" TARGET=\"_blank\">$1</A>", $topic_text);
$topic_text = preg_replace("/[url=(.*)](.*)[\/url]/Usi", "<A HREF=\"$2\" TARGET=\"_blank\">$2</A>", $topic_text);
// Endlines
$topic_text = str_replace("\n", "<BR>\n", $topic_text);
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Displaying Section
# Modify this section to your liking. Currently, this section
# just contains a dummy displayer. The following variables have
# been pre-initialized to help with this section, and include:
# $topic_title - (text) Title of topic
# $poster_name - (text) Username of original poster
# $topic_time - (text) Time of post creation (converted string)
# $topic_text - (text) Actual text of the topic (already in HTML)
# $topic_views - (int) Number of topic views (in the forum)
# $topic_replies - (int) Number of replies for topic
# $topic_id - (int) Topic's id # (from database)
# $post_id - (int) Post's id # (from database)
# $poster_id - (int) Poster's user id # (from database)
# $view_link - (text) An http link to the forum view topic page
# $reply_link - (text) An http link to the forum reply-to page
# $poster_link - (text) An http link to the poster's info page
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
// Head banner (poster, date)
echo("<table>\n");
echo("<tr>\n");
echo("<td bgcolor=4D5459>\n");
echo("<A HREF=\"{$view_link}\" TARGET=\"_blank\">{$topic_title}</A> <br> Posted on {$topic_time}<BR>\n");
echo("</td>\n");
echo("</tr>\n");
echo("</table>\n");
echo("<P>\n");
}
}
else
{
// No topics exist in this forum. Display some sort of error message.
echo("<P>No topics exist in the forum.<BR>\n");
}
}
?>
[/code]
I am trying to add this to a page I have been working on by using iframe:
<tr>
<td bgcolor="4D5459"><br><br>
<img src="images/kimscorner.gif" border="0"><br>
<iframe width=245 src="grabber1.php" align=middle frameborder=0 scrolling=auto name=viewpoint></iframe></td>
</tr>
1st question, Is there a better way to do this?
2nd question, How can I, or will someone help me to change the font color and size of the font that is displayed by the php script? ({$topic_title} & {$topic_time})
3rd question, If you look at the working demo with ie there is a white bg that I cannot get rid of, but with firefox the white bg is not there. http://www.midwestcheeranddance.com/index2.html
My plan is to get rid of the scroll bar and still show 5 latest topics without making the page any bigger then it is....
Thanks in Advance....
zach