phpbb2 - phpbb3 help [1/3 SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

phpbb2 - phpbb3 help [1/3 SOLVED]

Post by gaogier »

Hello...

News [Unsolved]
I have code which shows the first post in a topic in a forum (we have set it up to the news forums). We are now using phpbb3 forum software, where the code works with phpbb2 forum software. I have tried to convert the code to phpbb3 forum software, but no errors or data shows.

Can someone convert it for me? Or help me do it?



Code: Select all

<?php
# News Db script - index.php
# Created on 21 January 2005
# Created by Joseph Jeffery

include('header.inc');




//function displayNews($all = 0) {
//global $sitestyle;
   require_once ('../mysql_connect1.php');//connect to db
    if ($all == 0) {   
          $topic_query = "SELECT * FROM `phpbb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC LIMIT 7"; // do topic query
    }else{
         $topic_query = "SELECT * FROM `phpbb_topics` WHERE `forum_id`= '63' ORDER BY `topic_time` DESC"; // do topic query
   }
      $topic_result = mysql_query ($topic_query);
         while ($topic_row = mysql_fetch_assoc($topic_result)) {
            $tt = $topic_row['topic_time'];
            $topic = $topic_row['topic_id'];
              $poster = $topic_row['topic_poster'];
            $first = $topic_row['topic_first_post_id'];
            $title = $topic_row['topic_title'];
            $topic_replies = $topic_row['topic_replies'];
            $topic_runescape = $topic_row['topic_runescape'];
            $post_query = "SELECT * FROM `phpbb_posts` WHERE  `topic_id` = '$topic' AND `poster_id` = '$poster' AND `post_id` = '$first'"; // do post subject query
            $post_result = mysql_query($post_query);
            while ($post_row = mysql_fetch_assoc($post_result)){
               $post_id = $post_row['post_id'];
            }
            $use_query = "SELECT `username`, `user_avatar`, `user_email`, `user_rank` FROM `phpbb_users` WHERE `user_id` = '$poster'"; // do user query
            $use_result = mysql_query($use_query);
            while ($use_row = mysql_fetch_assoc($use_result)){
                $user = $use_row['username'];
                $user_avatar = $use_row['user_avatar'];
                $user_email = $use_row['user_email'];
                $rank = $use_row['user_rank'];               
            }
            $news_query = "SELECT `post_text` FROM `phpbb_posts_text` WHERE `post_id`='$post_id'";
            $news_result = mysql_query($news_query);
            while ($news_row = mysql_fetch_assoc($news_result)){
               $news = $news_row['post_text'];
            }
            $rank_result = mysql_query("SELECT `rank_title` FROM `phpbb_ranks` WHERE `rank_id`='$rank'");
            while($rank_row = mysql_fetch_assoc($rank_result)){
               $ranks = $rank_row['rank_title'];
            }
            $date = date("D M jS, Y g:i a", $tt);
            if ($topic_replies == 0){
            $reply = '<a href="http://www.runehints.com/phpbb/posting.php?mode=reply&t='.$topic.'">Nobody has commented on this piece of news yet. Be the first!</a>';
            $post_new ="";
            }else{
            $reply =  'comments(<a href="http://www.runehints.com/phpbb/viewtopic.php?t='.$topic.'">'.$topic_replies.'</a>) |';
            $post_new = '<a href="http://www.runehints.com/phpbb/posting.php?mode=reply&t='.$topic.'">Post a comment</a>';
            }
            if ($topic_runescape == 1){
               $news1 = 'This news topic is taken straight from <a href="http://runescape.com">Runescape.com</a><br />_____________________________________________<br /><br />'.$news;
            }else{
               $news1 = $news;
            }
            // Replace newlines //
            $news2 = str_replace("\n", "\n<br />\n", $news1);
      ?>
   
       <table border="0" cellpadding="0" cellspacing="0" width="100%" class="news">
        <tr>
          <td background="images/<?php echo $sitestyle.'_';?>tabletopl.jpg" height="25" width="30"></td>
          <td background="images/<?php echo $sitestyle.'_';?>tabletopm.jpg" height="25"><div align="center"><p class="small2"><a href="http://www.runehints.com/phpbb/viewtopic.php?t=<?php echo $topic; ?>" class="news"><?php echo $title; ?></a> posted by <a href="http://www.runehints.com/phpbb/profile.php?mode=viewprofile&u=<?php echo $poster; ?>"><?php echo $user; ?></a> on <?php echo $date;?></p></font></div></td>
          <td background="images/<?php echo $sitestyle.'_';?>tabletopr.jpg" height="25" width="30"></td>
           </tr>
      </table>

             <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td background="images/<?php echo $sitestyle.'_';?>tablemidl.jpg" width="16"></td>
         <td align="center" border="0" cellpadding="0" cellspacing="0"> 
        
            <img src="<?php echo $user_avatar; ?>" ><br /><center><font class="small2"><?php echo $ranks; ?></font></center></td>
          <td width="429"> <p><font class="small2">
      <p><?php echo $news2; ?></p><br>
     <br /><font class="small2"><?php echo $reply. ' '. $post_new;?>
<td background="images/<?php echo $sitestyle.'_';?>tablemidr.jpg" width="16"></td>
          </tr>
          </table>
      
      <table border="0" cellpadding="0" cellspacing="0" width="100%">

       <tr>
                          <td width="16"><img src="images/<?php echo $sitestyle.'_';?>tablebottoml.jpg" height="13" width="16"></td>
                          <td background="images/<?php echo $sitestyle.'_';?>tablebottomm.jpg" height="13"><img src="images/<?php echo $sitestyle.'_';?>tablebottomm.jpg" height="13" width="1"></td>
                          <td width="16"><img src="images/<?php echo $sitestyle.'_';?>tablebottomr.jpg" height="13" width="16"></td>
        </tr>
      </table></div><br />
   <?php
    }
    
    /* if we aren't displaying all news, 
     * then give a link to do so */
    if ($all == 0) {
        echo "<center><a href=\"{$_SERVER['PHP_SELF']}" .
             "?action=all\">View all news</a></center>\n";
    }
   //mysql_close();
//}

include('footer.inc');
?>

Forum Stats [Unsolved]

Here is a little script that shows data from the forums on the main pages. Again this code works fine with phpbb2 forums, but not phpbb3.

Code: Select all

<head> 
<link rel="shortcut icon" href="images/icon/favicon.ico" type="image/x-icon" />
<!--<link rel="stylesheet" type="text/css" href="darkblue.css">-->
<link rel="stylesheet" type="text/css" media="screen" title="User Defined Style" href="<?php echo (!$sitestyle)?'darkblue':$sitestyle ?>.css" />
<?php
if (!$sitestyle){
$sitestyle = "darkblue";
}
?>
</head>
<body >
<?php
require_once ('../mysql_connect1.php');//connect to db
define('IN_PHPBB', true);
define('PHPBB_INSTALLED', true);
$phpbb_root_path = 'forums/';
include('forums/extension.inc');
include('forums/common.php');

$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];

$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, u.user_whosonline_color, s.session_logged_in, s.session_time, s.session_page, s.session_ip
	FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
	WHERE u.user_id = s.session_user_id
		AND s.session_time >= ".( time() - 300 ) . "
	ORDER BY u.username ASC, s.session_ip ASC";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}

$guest_users = 0;
$registered_users = 0;
$hidden_users = 0;

$reg_counter = 0;
$guest_counter = 0;
$prev_user = 0;
$prev_ip = '';

while ( $row = $db->sql_fetchrow($result) )
{
	$view_online = false;

	if ( $row['session_logged_in'] ) 
	{
		$user_id = $row['user_id'];

		if ( $user_id != $prev_user )
		{
			$username = $row['username'];

			$style_color = '';
			if ( $row['user_whosonline_color'] )
			{
				$username = '<b style="color:' . $id_color[$row[user_whosonline_color]] . '">' . $username . '</b>';
			}
			else if ( $row['user_level'] == ADMIN )
			{
				$username = '<b style="color:#' . $theme['fontcolor3'] . '">' . $username . '</b>';
			}
			else if ( $row['user_level'] == MOD )
			{
				$username = '<b style="color:#' . $theme['fontcolor2'] . '">' . $username . '</b>';
			}
						else if ( $user_group_color[$row['user_id']])
			{
				$username = '<b style="color:' . $user_group_color[ $row['user_id'] ] . '">' . $username . '</b>';
			}

			if ( !$row['user_allow_viewonline'] )
			{
				$view_online = ( $userdata['user_level'] == ADMIN ) ? true : false;
				$hidden_users++;

				$username = '<i>' . $username . '</i>';
			}
			else
			{
				$view_online = true;
				$registered_users++;
			}

			$which_counter = 'reg_counter';
			$which_row = 'reg_user_row';
			$prev_user = $user_id;
		}
	}
	else
	{
		if ( $row['session_ip'] != $prev_ip )
		{
			$username = $lang['Guest'];
			$view_online = true;
			$guest_users++;
	
			$which_counter = 'guest_counter';
			$which_row = 'guest_user_row';
		}
	}

	$prev_ip = $row['session_ip'];
}

echo '<font class="small">';
echo 'Registered Users:</font> <font class="small2">'.$total_users;
echo '</font><font class="small">';
echo '<br />Newest User:</font> <a href="forums/profile.php?mode=viewprofile&u='.$newest_uid.'">'.$newest_user.'</a>';
echo '<font class="small">';
echo '<br />Total Posts:</font> <font class="small2">'.$total_posts.'</font>';
echo '<font class="small">';
echo '<br />Users online:</font> <font class="small2">'.$registered_users.'</font>';
echo '<font class="small">';
echo '<br />Guests online:</font> <font class="small2">'.$guest_users.'</font>';

				?>


Recent Posts [SOLVED]

Again as the other 2, i have some code that works fine with phpbb2 but not phpbb3.

Code: Select all

<marquee scrollamount="2" align="center" direction="up" height="200" width="140" bgcolor="#000000" scrolldelay="1" onmouseover="this.stop()" onmouseout="this.start()">
<font face=verdana color=white size=1>
<center>
<b>
Last 20 Forum Messages
</b><br />
</center>
</font>
<?php
require_once ('../mysql_connect1.php');//connect to db
    
    $topic_query = "SELECT * 
FROM `phpbb_posts` 
ORDER BY `post_time` DESC 
LIMIT 0 , 20"; // do topic query
    
    $topic_result = mysql_query ($topic_query);
	    while ($topic_row = mysql_fetch_assoc($topic_result)) {
$topic = $topic_row['topic_id'];
$poster = $topic_row['poster_id'];

		      $post_query = "SELECT `topic_title`, `forum_id` FROM `phpbb_topics` WHERE  `topic_id` = '$topic'"; // do post subject query

$post_result = mysql_query($post_query);
while ($post_row = mysql_fetch_assoc($post_result)){
$post_subject = $post_row['topic_title'];
$forum_id = $post_row['forum_id'];
}
if ($forum_id == 56){
$use_query = "SELECT `username` FROM `phpbb_users` WHERE `user_id` = '$poster'"; // do user query

$use_result = mysql_query($use_query);
while ($use_row = mysql_fetch_assoc($use_result)){
 $user = $use_row['username'];
 }
echo '<img src="images/none.gif" height="10" width="10">&nbsp;';
		 	echo "<b><a href=\"http://www.runehints.com/forums/viewtopic.php?t=$topic\">$post_subject</a><br /><font face=verdana color=white size=1>Author: </font></b><font face=verdana color=white size=1><i>$user</i></font><br />";  //display all the info

}elseif ($forum_id ==63){
$use_query = "SELECT `username` FROM `phpbb_users` WHERE `user_id` = '$poster'"; // do user query

$use_result = mysql_query($use_query);
while ($use_row = mysql_fetch_assoc($use_result)){
 $user = $use_row['username'];
 }
echo '<img src="images/dot.gif" height="10" width="10">&nbsp;';
		 	echo "<b><a href=\"http://www.runehints.com/forums/viewtopic.php?t=$topic\">$post_subject</a><br /><font face=verdana color=white size=1>Author: </font></b><font face=verdana color=white size=1><i>$user</i></font><br />";  //display all the info
}else{
$forum_query = "SELECT `auth_view`, `auth_post` FROM `phpbb_forums` WHERE `forum_id` = '$forum_id'";
$forum_result = mysql_query($forum_query);
while ($forum_row = mysql_fetch_assoc($forum_result)){
$auth_view = $forum_row['auth_view'];
$auth_post = $forum_row['auth_post'];
}
if ($auth_post == 1 && $auth_view == 0){
$use_query = "SELECT `username` FROM `phpbb_users` WHERE `user_id` = '$poster'"; // do user query

$use_result = mysql_query($use_query);
while ($use_row = mysql_fetch_assoc($use_result)){
 $user = $use_row['username'];
 }
?>


<img src="images/dot.gif" height="10" width="10">&nbsp;<?php
		 	echo "<b><a href=\"http://www.runehints.com/forums/viewtopic.php?t=$topic\">$post_subject</a><br /><font face=verdana color=white size=1>Author: </font></b><font face=verdana color=white size=1><i>$user</i></font><br />";  //display all the info
			    
}else{
echo '<img src="images/none.gif" height="10" width="10">&nbsp;<font class="small2">Post is in a restricted access forum</font><br />';
}
}
}
	?>	
<font face=verdana color=white size=1>
<center>
<br /><br />
<b>
<a href="/forums/">RuneHints<br />
The Solution to all your RuneScape Problems</a><br /></b>
</center>
</font>
</marquee>




What i have tried to do is change all of the forums to phpbb3 and all of the phpbb to phpbb3. The code shows no data or errors. What do i do? or can someone help me sort this out via msn, AIm or Yim?
Post Reply