Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
TAd
Worker
Worker



Joined: Oct 11, 2004
Posts: 127
Location: Oregon, USA

PostPosted: Tue Dec 23, 2008 7:25 am Reply with quote

Yes I read the FAQ!!! Very Happy

But I have not been doing much of any scripting lately and just updated my site. I am having to un-/ out these two lines from the mainfile.php file:



Code:
@require_once(INCLUDE_PATH.'includes/sql_layer.php');

$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);


I would like some help converting from $dbi logic to $db logic as per the FAQ as the following recent forums block that I had previously modified caused problems with the right blocks showing up.

Original Block: fiapple Center Forum Block v.9

Code:


<?php

########################################################################
# PHP-Nuke Block: fiapple Center Forum Block v.9              #
# Made for PHP-Nuke 6.5 ONLY!!                                         #
#                                                                      #
# Made by mikem http://www.nukemods.com                                #
# Edited by William Wickings http://www.amateur-online.net             #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License.       #
# If you modify this, let me know for fun. =)                          #
########################################################################
# PHP-Nuke Block modified from fiapple to Coldsteel theme.             #
# Tested on RavenNuke[tm] v2.10.01 and working as of 10/08/2007        #
# Modifications made on 10-08-2007                                     #
# Modified by TAd                                                      #
########################################################################

if (eregi("block-Coldsteel2-Forums.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

global $prefix, $dbi, $sitename, $admin;

$HideViewReadOnly = 1;
$Last_New_Topics  = 10;
$show = "  <tr>
    <td height=\"25\" colspan=\"6\" align=\"center\" class=\"catbottom\" background=\"themes/Coldsteel/forums/images/catbg3.gif\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";

$result = sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id", $dbi );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result, $dbi ) )

{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result1 = sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'", $dbi );
      list( $auth_view, $auth_read ) = sql_fetch_row( $result1, $dbi );
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }

   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }

   if( $skip_display == 0 )
   {
     $Count_Topics += 1;

$result2 = sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'", $dbi);
list($username, $user_id)=sql_fetch_row($result2, $dbi);
$avtor=$username;
$sifra=$user_id;

$result3 = sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%m/%d/%Y at %H:%i') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'", $dbi);
list($poster_id, $post_time)=sql_fetch_row($result3, $dbi);

$result4 = sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'", $dbi);
list($username, $user_id)=sql_fetch_row($result4, $dbi);

                         $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#c0c0c0\" class=\"row1\"><img src=\"themes/Coldsteel/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#c0c0c0\" class=\"row1\">&nbsp;<a href=\"forums.html?file=viewtopic&t=$topic_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#CCCCCC\" class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br>
      <a href=\"profile-.html$user_id\">$username</a>&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/Coldsteel/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Latest Post\"></a></td>
  </tr>";
}

   if( $Last_New_Topics == $Count_Topics ) { break 1; }

}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap background=\"themes/Coldsteel/images/catbg.gif\" class=\"thcornerl\"><font color=\"#000000\"><strong>Topics</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thcornerr\"><font color=\"#000000\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>


Any help would be greatly appreciated! Currently using Ravens rn2.30.00

Best regards,
TAd


Last edited by TAd on Tue Dec 23, 2008 1:18 pm; edited 2 times in total 
View user's profile Send private message Yahoo Messenger
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Tue Dec 23, 2008 8:41 am Reply with quote

What problem are you experiencing with making these changes? You just need to uncomment those two lines in mainfile and dbi should work. This means removing the two // characters at the start of those two lines, saving the file and putting the saved version on your server.
 
View user's profile Send private message Visit poster's website
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Tue Dec 23, 2008 8:54 am Reply with quote

fkelly is correct, you only need to make that modification to mainfile but that will only keep the block working whilst RN supports the old abstraction layer.
You can try this in a new block file (don't over write your old one as I have not tested this).
Code:


<?php

########################################################################
# PHP-Nuke Block: fiapple Center Forum Block v.9              #
# Made for PHP-Nuke 6.5 ONLY!!                                         #
#                                                                      #
# Made by mikem http://www.nukemods.com                                #
# Edited by William Wickings http://www.amateur-online.net             #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License.       #
# If you modify this, let me know for fun. =)                          #
########################################################################
# PHP-Nuke Block modified from fiapple to Coldsteel theme.             #
# Tested on RavenNuke[tm] v2.10.01 and working as of 10/08/2007        #
# Modifications made on 10-08-2007                                     #
# Modified by TAd                                                      #
########################################################################

if (eregi("block-Coldsteel2-Forums.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

global $prefix, $db, $sitename, $admin;

$HideViewReadOnly = 1;
$Last_New_Topics  = 10;
$show = "  <tr>
    <td height=\"25\" colspan=\"6\" align=\"center\" class=\"catbottom\" background=\"themes/Coldsteel/forums/images/catbg3.gif\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";

$result = $db->sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id", $dbi );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result) )

{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'");
      list( $auth_view, $auth_read ) = sql_fetch_row( $result1);
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }

   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }

   if( $skip_display == 0 )
   {
     $Count_Topics += 1;

$result2 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'");
list($username, $user_id)=sql_fetch_row($result2);
$avtor=$username;
$sifra=$user_id;

$result3 = $db->sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%m/%d/%Y at %H:%i') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'");
list($poster_id, $post_time)=sql_fetch_row($result3);

$result4 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'");
list($username, $user_id)=sql_fetch_row($result4);

                         $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#c0c0c0\" class=\"row1\"><img src=\"themes/Coldsteel/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#c0c0c0\" class=\"row1\">&nbsp;<a href=\"forums.html?file=viewtopic&t=$topic_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#CCCCCC\" class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br>
      <a href=\"profile-.html$user_id\">$username</a>&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/Coldsteel/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Latest Post\"></a></td>
  </tr>";
}

   if( $Last_New_Topics == $Count_Topics ) { break 1; }

}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap background=\"themes/Coldsteel/images/catbg.gif\" class=\"thcornerl\"><font color=\"#000000\"><strong>Topics</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thcornerr\"><font color=\"#000000\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>
 
View user's profile Send private message Send e-mail
TAd







PostPosted: Tue Dec 23, 2008 1:22 pm Reply with quote

My apologies, I knew I was tired last night when I wrote this. I have edited the original post to hopefully make it more clear. Seem like I either dipped into a coma and did not finish it, or it got cut off Smile

In any case, I would like to update the block so that it uses the "current" $db logic, so I do not have to comment out the 2 lines mentioned previously in the mainfile.php . I attempted to change the $dbi to $db and it did not work correctly.

Thank you!
TAd
 
Guardian2003







PostPosted: Tue Dec 23, 2008 1:39 pm Reply with quote

It might be my eyes but your post looks the same to me but you should have all the info there to do it now Smile
 
TAd







PostPosted: Tue Dec 23, 2008 2:13 pm Reply with quote

Gaurdian2003,

Thank you and I think you are correct, I believe you hit the nail on the head and understand what I was trying (failing Very Happy at) to say.

To clear things up. Uncommenting out the lines with the original block, everything works perfectly.

As Guardian2003 states, it will only work this way till this old logic is removed entirely from RN, so I was seeking to revise the file to utilize the new $db logic.


I did not realize earlier you had edited the original block Guardian2003 Embarassed and I have uploaded it to my site and gave it a try.

I am still getting an error (as found in error_log) albeit a slightly different error.

Error with original block:
Quote:
[22-Dec-2008 11:14:47] PHP Fatal error: Call to undefined function sql_query() in /home/thomas/public_html/blocks/block-Coldsteel2-Forums.php on line 42


Error using the $db logic block as modified by Guardian2003 above:


Quote:
[23-Dec-2008 13:52:11] PHP Fatal error: Call to undefined function sql_fetch_row() in /home/thomas/public_html/blocks/block-Coldsteel2-Forums.php on line 44


I did locate 1 remaining $dbi and changed it to $db around line 43 here is the current code in use:

Code:



<?php

########################################################################
# PHP-Nuke Block: fiapple Center Forum Block v.9              #
# Made for PHP-Nuke 6.5 ONLY!!                                         #
#                                                                      #
# Made by mikem http://www.nukemods.com                                #
# Edited by William Wickings http://www.amateur-online.net             #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License.       #
# If you modify this, let me know for fun. =)                          #
########################################################################
# PHP-Nuke Block modified from fiapple to Coldsteel theme.             #
# Tested on RavenNuke[tm] v2.10.01 and working as of 10/08/2007        #
# Modifications made on 10-08-2007                                     #
# Modified by TAd                                                      #
########################################################################

if (eregi("block-Coldsteel2-Forums.php",$PHP_SELF)) {
    Header("Location: index.php");
    die();
}

global $prefix, $db, $sitename, $admin;

$HideViewReadOnly = 1;
$Last_New_Topics  = 10;
$show = "  <tr>
    <td height=\"25\" colspan=\"6\" align=\"center\" class=\"catbottom\" background=\"themes/Coldsteel/forums/images/catbg3.gif\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";

$result = $db->sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id", $db );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = sql_fetch_row( $result))

{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'");
      list( $auth_view, $auth_read ) = sql_fetch_row( $result1);
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
   }

   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }

   if( $skip_display == 0 )
   {
     $Count_Topics += 1;

$result2 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'");
list($username, $user_id)=sql_fetch_row($result2);
$avtor=$username;
$sifra=$user_id;

$result3 = $db->sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%m/%d/%Y at %H:%i') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'");
list($poster_id, $post_time)=sql_fetch_row($result3);

$result4 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'");
list($username, $user_id)=sql_fetch_row($result4);

                         $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#c0c0c0\" class=\"row1\"><img src=\"themes/Coldsteel/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#c0c0c0\" class=\"row1\">&nbsp;<a href=\"forums.html?file=viewtopic&t=$topic_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#CCCCCC\" class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br>
      <a href=\"profile-.html$user_id\">$username</a>&nbsp;<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/Coldsteel/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Latest Post\"></a></td>
  </tr>";
}

   if( $Last_New_Topics == $Count_Topics ) { break 1; }

}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap background=\"themes/Coldsteel/images/catbg.gif\" class=\"thcornerl\"><font color=\"#000000\"><strong>Topics</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thcornerr\"><font color=\"#000000\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>
 
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Tue Dec 23, 2008 2:18 pm Reply with quote

Refer to the two following threads. I have done this for other people already. On of the post I modified the block to reflect the user's timezone. That is the one that I recommend.
[ Only registered users can see links on this board! Get registered or login! ] [ Only registered users can see links on this board! Get registered or login! ]

Note: make sure you correct the urls in the posted code before uplaoding to your site. If you read the one thread it talks about how this site rewrites the urls in the posted code. If you still need help post back to this thread.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
Palbin







PostPosted: Tue Dec 23, 2008 2:20 pm Reply with quote

Also I just made this a sticky.
[ Only registered users can see links on this board! Get registered or login! ]
 
TAd







PostPosted: Tue Dec 23, 2008 2:30 pm Reply with quote

Thank you Palbin, fkelly, and Guardian2003 for your help! I appreciate it greatly!

Best regards,
TAd

Updated code:

Code:



<?php

########################################################################
# PHP-Nuke Block: fiapple Center Forum Block v.9                       #
# Made for PHP-Nuke 6.5 ONLY!!                                         #
#                                                                      #
# Made by mikem http://www.nukemods.com                                #
# Edited by William Wickings http://www.amateur-online.net             #
########################################################################
# This program is free software. You can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License.       #
# If you modify this, let me know for fun. =)                          #
########################################################################
# PHP-Nuke Block modified from fiapple to Coldsteel theme.             #
# Tested on RavenNuke[tm] v2.10.01 and working as of 10/08/2007        #
# Modifications made on 10-08-2007                                     #
# Modified by TAd                                                      #
########################################################################
# Updated block to use new $db logic and removed                       #
# old sql ($dbi) abstraction layer.                                    #
# Tested on RavenNuke[tm] V2.30.00                                     #
# Modified by TAd with help from palbin, Guardian2003, and fkelly      #
# Modifications made on 12-23-2008                                     #
########################################################################
if (!defined('BLOCK_FILE')) {  //Updated eregi logic to BLOCK_FILE
    Header("Location: ../index.php");  // Added ../
    die();
}

global $user_prefix, $prefix, $db, $sitename, $admin; //altered $dbi to $db

$HideViewReadOnly = 1;
$Last_New_Topics  = 10;  // How many topics to be displayed are entered here, default is 10
$show = "  <tr>
    <td height=\"25\" colspan=\"6\" align=\"center\" class=\"catbottom\" background=\"themes/Coldsteel/forums/images/catbg3.gif\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$Topic_Buffer = "";
$viewlast = ""; // Added

$result = $db->sql_query( "SELECT topic_id, forum_id, topic_last_post_id, topic_title, topic_poster, topic_views, topic_replies, topic_moved_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC", $db );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = $db->sql_fetchrow( $result))  //Updated $dbi to $db, sql query string, and sql fetchrow

{
   $skip_display = 0;
   if( $HideViewReadOnly == 1 )
   {
      $result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'");
      list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result1);
      if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; } //Updated $dbi to $db, sql query string, and sql fetchrow
   }

   if( $topic_moved_id != 0 )
   {
     // Shadow Topic !!
      $skip_display = 1;
   }

   if( $skip_display == 0 )
   {
     $Count_Topics += 1;

$result2 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'");
list($username, $user_id)=$db->sql_fetchrow($result2);  //Updated $dbi to $db, sql query string, and sql fetchrow
$avtor=$username;
$sifra=$user_id;

$result3 = $db->sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%m/%d/%Y at %H:%i') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'");  //Updated $dbi to $db, sql query string, and sql fetchrow
list($poster_id, $post_time)=$db->sql_fetchrow($result3);  //Updated to sql fetchrow

$result4 = $db->sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'");
list($username, $user_id)=$db->sql_fetchrow($result4);  //Updated $dbi to $db, sql query string, and sql fetchrow
//  <a href=\"ftopict-$topic_id.html\">$topic_title</a>
                         $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#c0c0c0\" class=\"row1\"><img src=\"themes/Coldsteel/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#c0c0c0\" class=\"row1\">&nbsp;<a href=\"ftopict-$topic_id.html\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row3\"><a href=\"forum-userprofile-$sifra.html\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#CCCCCC\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#CCCCCC\" class=\"row3\"><font size=\"-2\"><i>&nbsp;&nbsp;$post_time&nbsp;</i></font><br>
      <a href=\"forum-userprofile-$user_id.html\">$username</a>&nbsp;<a href=\"ftopicp-$topic_last_post_id.html#$topic_last_post_id\"><img src=\"themes/Coldsteel/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Latest Post\"></a></td>
  </tr>";
}
//
   if( $Last_New_Topics == $Count_Topics ) { break 1; }

}

    $content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#000000\"><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap background=\"themes/Coldsteel/images/catbg.gif\" class=\"thcornerl\"><font color=\"#000000\"><strong>Topics</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap background=\"themes/Coldsteel/forums/images/catbg.gif\" class=\"thcornerr\"><font color=\"#000000\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>



RavensScripts


Last edited by TAd on Wed Dec 24, 2008 3:54 am; edited 1 time in total 
TAd







PostPosted: Tue Dec 23, 2008 10:20 pm Reply with quote

I spoke to soon, while the block shows correctly and allows the right side blocks to be displayed, the links lead to a 404 error.

The links generated appear as follows:

Code:
http://www.mysitename.com/forums.html?file=viewtopic&t=1#1


while the actual link is like this:

Code:
http://www.mysitename.com/modules.php?name=Forums&file=viewtopic&p=1#1


I then tried the block that Palbin had posted here: [ Only registered users can see links on this board! Get registered or login! ]

And that also produces a 404 error, having the links generated appear as such:
Code:
http://www.photosbytom.com/ftopict-25.html


I am thinking it is due to not using the shortlinks to some degree for Palbin's edited block. In any case, the edits I have tried do not seem to solve the issue, and would appreciate being pointed in the right direction Smile

Thank you and again, I appreciate the help!
TAd
 
TAd







PostPosted: Tue Dec 23, 2008 10:31 pm Reply with quote

An update, with the Shortlinks code posted into the .htaccess file the links from Palbin's code work!

Mine do not, but now lead to the forums main page (not the indicated post/topic). Pablin, may I edit/use your code to fix the ColdSteel theme block please?

Thank you!
TAd
 
Palbin







PostPosted: Tue Dec 23, 2008 11:38 pm Reply with quote

Anything I ever posted you can do what ever you want with.

I tried to explain this problem in my post above. The problem is when the code was posted on this site the mod rewrite rules for shortlinks rewrote the code. You need to go back through the code and find links like this:
Code:


<a href=\"forums.html?file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">


and edit them to there proper url:
Code:


<a href=\"modules. php?name=Forums&file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">


Last edited by Palbin on Wed Dec 24, 2008 10:34 am; edited 2 times in total 
TAd







PostPosted: Wed Dec 24, 2008 3:53 am Reply with quote

Palbin,

Thank you so much for your help, and the links provided were very helpful! I did not thoroughly read your previous post/link, so that is my fault. Embarassed

Thank you!!!!!!
TAd


Note: I edited the original finished block to represent what I have currently.
 
dad7732
RavenNuke(tm) Development Team



Joined: Mar 18, 2007
Posts: 1242

PostPosted: Wed Dec 24, 2008 8:18 am Reply with quote

Are my eyes THAT old or is there really a difference in the unedited and edited links above ?? Wink

Cheers, Jay
 
View user's profile Send private message
Palbin







PostPosted: Wed Dec 24, 2008 10:32 am Reply with quote

Old ..... Maybe Very Happy

I fixed my post above. It should have said this for the corrected one. Note I added a space to display it because DUH I can't put the correct url Laughing. Why didn't I think of that lol.
Code:


<a href=\"modules. php?name=Forums&file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©