Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> Converting/Creating Blocks
Author Message
Palbin
Site Admin



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

PostPosted: Fri Nov 07, 2008 11:03 pm Reply with quote

Well generally speaking there only a few general things you need do.

First is change the $dbi global (Your block my have more globals)
Code:


global $prefix, $dbi;


Code:


global $prefix, $db;



Then you need to remove the $dbi from all the quries.
Code:


$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by linkratingsummary DESC limit 0,$mainlinkstoshow", $dbi)


Code:


$result = sql_query("select lid, title, hits, url from ".$prefix."_links_links order by linkratingsummary DESC limit 0,$mainlinkstoshow")


Finally you have to change the "query functions"
Code:


sql_query("select lid, ti .........


Code:


$db->sql_query("select lid, ti .........


You need to be carefull because all the functions are not like sql_query were you just append the $db->. For example with the old $dbi way you used sql_fetch_row(), but with the new way it has to be written $db->sql_fetchrow(). There are only a couple of functions that you will need to change, so just check in the newer blocks if you need help with one. Off the top of my head I can't think of the other functions that are different from old to new.

OLD:
sql_query($sql, $dbi)
sql_num_rows($sql, $dbi)
sql_fetch_row($sql, $dbi)
sql_fetch_array($sql, $dbi)
sql_fetch_object($sql, $dbi)
sql_free_result($sql, $dbi)

NEW:
$db->sql_query($sql)
$db->sql_numrows($sql)
$db->sql_fetchrow($sql)
$db->sql_fetchrow($sql)
$db->sql_fetchrow($sql)
$db->sql_freeresult($sql)


Last edited by Palbin on Sat Feb 06, 2010 5:24 pm; edited 3 times in total 
View user's profile Send private message
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Sat Nov 08, 2008 1:02 am Reply with quote

Excellent. Thank You Palbin!
 
View user's profile Send private message
fkelly
Former Moderator in Good Standing



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

PostPosted: Sat Nov 08, 2008 7:37 am Reply with quote

You might also want to turn database error reporting on (see documentation in rnconfig) when you are doing the conversion and monitor the dblog file. Of course, if the function never gets to the database layer it won't show up in the log but it could show any function calls that aren't correct.

Just remember to turn the error reporting off when you are done or else monitor the dblog regularly.
 
View user's profile Send private message Visit poster's website
CodyG
Life Cycles Becoming CPU Cycles



Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island

PostPosted: Sat Nov 08, 2008 8:01 am Reply with quote

Excellent. I was totally confuddled about sql_fetch_anything. Smile Thank you.

_________________
"We want to see if life is ubiquitous." D.Goldin 
View user's profile Send private message
FireATST
RavenNuke(tm) Development Team



Joined: Jun 12, 2004
Posts: 654
Location: Ohio

PostPosted: Sun Nov 09, 2008 7:39 am Reply with quote

Ty Palbin!......my wife isn't to happy though....lol. I have spent a lot of time lately going through php files and code books. Thanks again for the nudge in the right direction..... Cheers
 
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Sun Nov 09, 2008 12:39 pm Reply with quote

Nice reminder, Palbin, thanks! I'm pretty sure Chatserv wrote a similar tutorial a few years ago on nukefixes or nukeresources.

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
dad7732
RavenNuke(tm) Development Team



Joined: Mar 18, 2007
Posts: 1242

PostPosted: Tue Dec 23, 2008 5:50 pm Reply with quote

Followed the instructions closely I think but my last 10 forums block, center down, in table format does not work. When activated, the left and right side blocks are missing altogether, here's the code:

Code:
<?php


########################################################################
# PHP-Nuke Block: fiplain Center Forum Block v.2             #
# Made for PHP-Nuke 6.5  and up                                  #
#                                                      #
# Made by mikem http://www.nukecops.com                                #
# This block is made only to match the fiplain Theme pack        #
#                                                                      #
########################################################################
# 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. =)                          #
######################################################################## 

if (eregi("block-fiplain-Forums.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
 }

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

$HideViewReadOnly = 1;
          
$Last_New_Topics  = 10;
$show = "  <tr><td bgcolor=\"#000000\" colspan=\"6\"></td></tr><tr>
    <td height=\"28\" colspan=\"6\" align=\"center\" class=\"catbottom\" bgcolor=\"#F3F4C6\">&nbsp;</td>
  </tr>
</table></td>
        </tr>
      </table></td>
  </tr>
</table>";

$Count_Topics = 0;
$coloralt = 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 DESC" );
while( list( $topic_id, $forum_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id ) = $db->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 ) = $db->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)=$db->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)=$db->sql_fetch_row($result3);

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

if ($coloralt == 0) {
    $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#C3C4FD\" class=\"row1\"><img src=\"themes/fiplain/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#E8E97F\" class=\"row1\">&nbsp;<a href=\"forums.html?file=viewtopic&t=$topic_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#9093FA\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#E8E97F\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#9093FA\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#E8E97F\" 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/fiplain/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Last Post\"></a></td>
  </tr>";
    $coloralt++;
} else {
    $viewlast .="  <tr>
    <td height=\"30\" nowrap bgcolor=\"#C3C4FD\" class=\"row1\"><img src=\"themes/fiplain/forums/images/folder_new.gif\" border=\"0\" /></td>
    <td width=\"100%\" bgcolor=\"#F4F587\" class=\"row1\">&nbsp;<a href=\"forums.html?file=viewtopic&t=$topic_id#$topic_last_post_id\">$topic_title</a></td>
    <td align=\"center\" bgcolor=\"#9093FA\" class=\"row2\">$topic_replies</td>
    <td align=\"center\" bgcolor=\"#F4F587\" class=\"row3\"><a href=\"profile-.html$sifra\">$avtor</a></td>
    <td align=\"center\" bgcolor=\"#9093FA\" class=\"row2\">$topic_views</td>
    <td align=\"center\" nowrap bgcolor=\"#F4F587\" 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/fiplain/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Last Post\"></a></td>
  </tr>";
    $coloralt = 0;
}

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

    $content .= "<table class=\"bodyline\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
  <tr>
    <td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
        <tr>
          <td bgcolor=\"#FFFFFF\"><table bgcolor=\"green\" width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
  <tr>
    <th height=\"25\" colspan=\"2\" align=\"center\" nowrap bgcolor=\"#9093FA\" class=\"thcornerl\"><font color=\"#000000\"><strong>Forum/Topic</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap bgcolor=\"#9093FA\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Replies&nbsp;</strong></font></th>
    <th width=\"100\" align=\"center\" nowrap bgcolor=\"#9093FA\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Author&nbsp;</strong></font></th>
    <th width=\"50\" align=\"center\" nowrap bgcolor=\"#9093FA\" class=\"thtop\"><font color=\"#000000\"><strong>&nbsp;Views&nbsp;</strong></font></th>
    <th align=\"center\" nowrap bgcolor=\"#9093FA\" class=\"thcornerr\"><font color=\"#000000\"><strong>&nbsp;Last Post&nbsp;</strong></font></th>
  </tr><tr><td bgcolor=\"#000000\" colspan=\"6\"></td></tr>";
    $content .= "$viewlast";

 $content .= "$show";

?>


What did I miss? It works just fine in the last RN version, running 2.3 now, default theme RavenIce.

Edit: I missed the fetch_row but changed it to fetchrow but didn't change anything.


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







PostPosted: Tue Dec 23, 2008 7:26 pm Reply with quote

I created the file "dblog". Is that it, no extension? Also did the permissions to 666 but I get nothing in the file when trying my top 10 forums file above.

Edit: Cripes, I placed it in the root instead of /rnlogs and there is already a dblog file there, just had to change the permissions. Sad

And nothing shows up in the dblog when the broken block is activated.

Cheers, Jay


Last edited by dad7732 on Wed Dec 24, 2008 8:11 am; edited 1 time in total 
TAd
Worker
Worker



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

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

Thank you again! I finished up with my latest forum block, then I updated the Admin module "VersionNumber" which took all of 1-2 minutes!

Best regards,
TAd
 
View user's profile Send private message Yahoo Messenger
gotcha
Regular
Regular



Joined: Mar 14, 2005
Posts: 91

PostPosted: Wed Dec 24, 2008 9:30 am Reply with quote

dad - change all instances of sql_fetch_row to sql_fetchrow and you should be good to go.
 
View user's profile Send private message Visit poster's website
dad7732







PostPosted: Wed Dec 24, 2008 11:19 am Reply with quote

gotcha - Note:

Edit: I missed the fetch_row but changed it to fetchrow but didn't change anything.

Already did that, no luck.

Cheers, Jay

EDIT: The block may be too "old" to modify. If that is the case I would like a compatible "Last Posts" block in table format, not like the "block-forums.php" that is included.
 
Palbin







PostPosted: Wed Dec 24, 2008 12:01 pm Reply with quote

Nothing is too "old".
 
Guardian2003
Site Admin



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

PostPosted: Wed Dec 24, 2008 3:06 pm Reply with quote

I think you can also do
Code:


  list( $auth_view, $auth_read ) = mysql_fetch_row( $result1 );
 
View user's profile Send private message Send e-mail
Palbin







PostPosted: Wed Dec 24, 2008 3:50 pm Reply with quote

yes, but this thread is about conversion Smile

$db->sql_fetchrow($sql)
 
dad7732







PostPosted: Wed Dec 24, 2008 5:03 pm Reply with quote

Nothing posted here is working to convert my particular block. Since when the block is activated, the right and left blocks are completely missing which leads me to believe that it's more serious than just DB conversion.

Cheers, Jay
 
Palbin







PostPosted: Wed Dec 24, 2008 9:40 pm Reply with quote

Give me a few days I'll fix it. Also I am going to split this into a new thread. It really shouldn't be in this one.
 
Guardian2003







PostPosted: Thu Dec 25, 2008 4:04 am Reply with quote

Palbin wrote:
yes, but this thread is about conversion Smile

$db->sql_fetchrow($sql)

Yes but
Code:


$result1 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'", );
      list( $auth_view, $auth_read ) = mysql_fetch_row( $result1 );
should still work as $result1 contains both a persistant connection and the query Wink
 
dad7732







PostPosted: Thu Dec 25, 2008 3:24 pm Reply with quote

Does not work, I don't think that's where the problem lies as there is no display of the table and both right and left blocks do not show.

Cheers, Jay
 
Palbin







PostPosted: Fri Dec 26, 2008 12:04 am Reply with quote

Try this:
[ Only registered users can see links on this board! Get registered or login! ]
 
dad7732







PostPosted: Fri Dec 26, 2008 7:44 am Reply with quote

Thank you, that works just fine. We're back in business. I compared the new to the old and quite a bit of difference.

Cheers, best of the holidays.
 
Palbin







PostPosted: Fri Dec 26, 2008 10:20 am Reply with quote

The big difference is that I added in some code to allow the block to consider the users time zone. The times in the block should match the times in the forums.
 
Display posts from previous:       
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 ©