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();
}
$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);
Joined: Aug 30, 2005 Posts: 3137 Location: near Albany NY
Posted:
Tue Dec 23, 2008 8:41 am
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.
Joined: Aug 28, 2003 Posts: 6300 Location: Vsetin, Czech Republic
Posted:
Tue Dec 23, 2008 8:54 am
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();
}
$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);
Joined: Oct 11, 2004 Posts: 101 Location: Oregon, USA
Posted:
Tue Dec 23, 2008 1:22 pm
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
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.
Joined: Oct 11, 2004 Posts: 101 Location: Oregon, USA
Posted:
Tue Dec 23, 2008 2:13 pm
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 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 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();
}
$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);
Joined: Mar 30, 2006 Posts: 2405 Location: Pennsylvania
Posted:
Tue Dec 23, 2008 2:18 pm
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 to the forums!
Only registered users can see links on this board! Get registered or login to the forums!
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.
Joined: Oct 11, 2004 Posts: 101 Location: Oregon, USA
Posted:
Tue Dec 23, 2008 2:30 pm
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\"> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>";
$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
I then tried the block that Palbin had posted here:
Only registered users can see links on this board! Get registered or login to the forums!
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
Joined: Oct 11, 2004 Posts: 101 Location: Oregon, USA
Posted:
Tue Dec 23, 2008 10:31 pm
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?
Joined: Mar 30, 2006 Posts: 2405 Location: Pennsylvania
Posted:
Tue Dec 23, 2008 11:38 pm
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:
Joined: Mar 30, 2006 Posts: 2405 Location: Pennsylvania
Posted:
Wed Dec 24, 2008 10:32 am
Old ..... Maybe
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 . Why didn't I think of that lol.
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