|
|
|
|
|
Re: Looking for hack... [message #3262 is a reply to message #3260] |
Sat, 15 June 2002 07:09   |
Ilia
 Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Yeah, you need to modify the your code to something like this:
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
include_once "path/to/GLOBALS.php";
$cid = mysql_connect($MYSQL_SERVER, $MYSQL_LOGIN, $MYSQL_PASSWORD);
$r = mysql_db_query($MYSQL_DB, "SELECT resource_id FROM fud_group_cache WHERE user_id=0 AND p_VIEW='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($MYSQL_DB, "SELECT
fud_msg.id,
fud_msg.subject
FROM
fud_thread
INNER JOIN fud_msg
ON fud_thread.root_msg_id=fud_msg.id
WHERE
fud_thread.forum_id IN (".$lm.") AND
fud_msg.approved='Y'
ORDER by
fud_thread.id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
echo "<a href=\"".$WWW_ROOT."msg.php?goto=".$obj->id."\& quot;>".$obj->subject."</a><br>\n";
}
mysql_free_result($r);
}
FUDforum Core Developer
|
|
|
|
|
|
|
|
|
|
|
|
Re: Looking for hack... [message #4350 is a reply to message #3253] |
Wed, 24 July 2002 19:00   |
heidiott
 Messages: 34 Registered: May 2002
Karma: 0
|
Member |
|
|
I upgraded to the new forum version this morning and now I'm getting the following error with this code...
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/www.crafterscommunity.net/web/test.php on line 11
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/www.crafterscommunity.net/web/test.php on line 27
Warning: Supplied argument is not a valid MySQL result resource in /home/sites/www.crafterscommunity.net/web/test.php on line 32
Here is the code I have in test.php...
<?php
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
include_once "/path_removed_/GLOBALS.php";
$cid = mysql_connect($MYSQL_SERVER, $MYSQL_LOGIN, $MYSQL_PASSWORD);
$r = mysql_db_query($MYSQL_DB, "SELECT resource_id FROM fud_group_cache WHERE user_id='0' AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($MYSQL_DB, "SELECT
fud_msg.id,
fud_msg.subject
FROM
fud_thread
INNER JOIN fud_msg
ON fud_thread.root_msg_id=fud_msg.id
WHERE
fud_thread.forum_id IN (".$lm.") AND
fud_msg.approved='Y'
ORDER by
fud_thread.id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
echo "<img src=http://www.crafterscommunity.net/forum/styles/default/goto.gif vspace=3 align=middle> <a href=\"".$WWW_ROOT."msg.php?goto=".$obj->id."\& quot;>".$obj->subject."</a><br>\n";
}
mysql_free_result($r);
}
?>
|
|
|
|
Re: Looking for hack... [message #4385 is a reply to message #3253] |
Thu, 25 July 2002 02:22   |
heidiott
 Messages: 34 Registered: May 2002
Karma: 0
|
Member |
|
|
Ah ha... I got it Thanks to your help.
Here is the new code for others who would like to use it with version 2.2.3...
<?php
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
include_once "/path_to/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM fud_group_cache WHERE user_id='0' AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT
fud_msg.id,
fud_msg.subject
FROM
fud_thread
INNER JOIN fud_msg
ON fud_thread.root_msg_id=fud_msg.id
WHERE
fud_thread.forum_id IN (".$lm.") AND
fud_msg.approved='Y'
ORDER by
fud_thread.id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
echo "<img src=http://www.yoursite.com/forum/styles/default/goto.gif vspace=3 align=middle> <a href=\"".$WWW_ROOT."msg.php?goto=".$obj->id."\& quot;>".$obj->subject."</a><br>\n";
}
mysql_free_result($r);
}
?>
|
|
|
|
|
|
|
|
|
|
Re: Looking for hack... [message #5544 is a reply to message #5538] |
Sun, 08 September 2002 02:35   |
|
it's very good
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
include_once "/path_to/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$DBHOST_TBL_PREFIX."group_cache WHERE user_id=0 AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT
".$DBHOST_TBL_PREFIX."msg.id,
".$DBHOST_TBL_PREFIX."msg.subject
FROM
".$DBHOST_TBL_PREFIX."thread
INNER JOIN ".$DBHOST_TBL_PREFIX."msg
ON ".$DBHOST_TBL_PREFIX."thread.root_msg_id=".$DBHOST_TBL_PREFI X."msg.id
WHERE
".$DBHOST_TBL_PREFIX."thread.forum_id IN (".$lm.") AND
".$DBHOST_TBL_PREFIX."msg.approved='Y'
ORDER by
".$DBHOST_TBL_PREFIX."thread.id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
echo "<img src=http://fi7pyu.free.fr/bbs/theme/default/images/goto.gif vspace=3 align=middle> <a href=\"".$WWW_ROOT."index.php?t=msg&goto=".$obj-> ;id."\"& quot; target=\"_blank\">".$obj->subject."</a>< br>\n";
}
mysql_free_result($r);
}
http://fi7pyu.free.fr/bbs/lastpost.php
[Updated on: Sun, 08 September 2002 02:43] Report message to a moderator
|
|
|
Re: Looking for hack... [message #5630 is a reply to message #5544] |
Tue, 10 September 2002 21:55   |
kewlguy
 Messages: 9 Registered: August 2002 Location: Gainesville
Karma: 0
|
Junior Member |
|
|
Ok, finally got it to work, it took this code:
<?php
// n_posts is the number of messages you wish to fetch
function fetch_forum_posts($n_posts)
{
include_once "/path/to/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$DBHOST_TBL_PREFIX."group_cache WHERE user_id=0 AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT ".$DBHOST_TBL_PREFIX."msg.id, ".$DBHOST_TBL_PREFIX."msg.subject
FROM ".$DBHOST_TBL_PREFIX."thread INNER JOIN ".$DBHOST_TBL_PREFIX."msg
ON ".$DBHOST_TBL_PREFIX."thread.root_msg_id=".$DBHOST_TBL_PREFI X."msg.id
WHERE ".$DBHOST_TBL_PREFIX."thread.forum_id IN (".$lm.") AND
".$DBHOST_TBL_PREFIX."msg.approved='Y' ORDER by ".$DBHOST_TBL_PREFIX."thread.id DESC LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
// Here you do your actual code, below is a working example
print "� <a class =\"menubar\" href=\"";
print $WWW_ROOT . "index.php?t=msg&goto=" . $obj->id . "\" target=\"_blank\">" . $obj->subject;
print "</a><br>\n";
}
mysql_free_result($r);
}
?>
Thanks everyone!
[Updated on: Tue, 10 September 2002 21:56] Report message to a moderator
|
|
|
|
|
Re: Looking for hack... [message #8594 is a reply to message #5630] |
Mon, 10 February 2003 16:34   |
 |
Sergey
 Messages: 41 Registered: January 2003
Karma: 0
|
Member |
|
|
kewlguy wrote on Tue, 10 September 2002 17:55 | Ok, finally got it to work, it took this code:
<?php
// n_posts is the number of messages you wish to fetch
function fetch_forum_posts($n_posts)
{
include_once "/path/to/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$DBHOST_TBL_PREFIX."group_cache WHERE user_id=0 AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT ".$DBHOST_TBL_PREFIX."msg.id, ".$DBHOST_TBL_PREFIX."msg.subject
FROM ".$DBHOST_TBL_PREFIX."thread INNER JOIN ".$DBHOST_TBL_PREFIX."msg
ON ".$DBHOST_TBL_PREFIX."thread.root_msg_id=".$DBHOST_TBL_PREFI X."msg.id
WHERE ".$DBHOST_TBL_PREFIX."thread.forum_id IN (".$lm.") AND
".$DBHOST_TBL_PREFIX."msg.approved='Y' ORDER by ".$DBHOST_TBL_PREFIX."thread.id DESC LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
// Here you do your actual code, below is a working example
print "� <a class =\"menubar\" href=\"";
print $WWW_ROOT . "index.php?t=msg&goto=" . $obj->id . "\" target=\"_blank\">" . $obj->subject;
print "</a><br>\n";
}
mysql_free_result($r);
}
?>
Thanks everyone!
|
I am trying to do recent posts on my forum also, but can not to get it work correctly . Just getting a blank page...
Can I ask where I need to put this code :
1. As a separate .php page in forum/default directory?
2. As a some kind of template where all templates are?
3. As a .php somewhere and then call it as <? php include ?> in page where I want to see resent posts?
4. As a function somewhere in existing file?
Thanx everybody who can help me on this one!
-------------------
"If you really want something in this life you have to work for it.
Now quiet, they're about to announce the lottery numbers."
Author: Homer Simpson.
|
|
|
|
|
|
|
Re: Looking for hack... [message #9502 is a reply to message #3253] |
Wed, 02 April 2003 23:02   |
jonrocks
 Messages: 1 Registered: April 2003
Karma: 0
|
Junior Member |
|
|
Here is, at least what i think, an easier to use php script to do the samething. Just go though both php files and edit them. the ez_sql file you just need to edit these lines
// User Settings -- CHANGE HERE
define("EZSQL_DB_USER", "username"); // <-- mysql db user (change username)
define("EZSQL_DB_PASSWORD", "password"); // <-- mysql db password (change password)
define("EZSQL_DB_NAME", "dbname"); // <-- mysql db pname (change dbname)
define("EZSQL_DB_HOST", "localhost"); // <-- mysql server host (change localhost to your host, most likely is localhost though)
// ==================================================================
It should be quite straight forward. The other php script latest.php should not need to be changed, but it would be worthit to go though it just incase.
You can check out a working example here http://www.jonmm.com/latest.php
-
Attachment: latest.php
(Size: 1.43KB, Downloaded 1194 times)
-
Attachment: ez_sql.php
(Size: 14.12KB, Downloaded 1291 times)
[Updated on: Wed, 02 April 2003 23:03] Report message to a moderator
|
|
|
|
Re: Newest Posts with date and name ? Re: Looking for hack... [message #12061 is a reply to message #11584] |
Sun, 27 July 2003 13:37   |
 |
Wild_Cat
 Messages: 144 Registered: November 2002 Location: Odessa, Ukraine
Karma: 0
|
Senior Member |
|
|
Well, I needed the dates too, so, although I'm by far not a PHP pro, I optimised the code given by protoss to a template-like result: you don't have to watch your server_name/db_name/username/password/MySQL table prefixes any more - it takes it all from your GLOBALS.php
(it also pointed out to msg.php in the root dir which doesn't exist in version 2.5.0 which I use and for which this code is done consequently)
and I managed to add the date to the code, it turned out to be indeed easy enough. Well, it took me more than a couple of minutes, since I'm not an SQL pro either but I needed it myself, so... here you are:
function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{
include_once "forum/fud/include/GLOBALS.php";
$cid = mysql_connect($DBHOST, $DBHOST_USER, $DBHOST_PASSWORD);
$tbl = $DBHOST_TBL_PREFIX;
$r = mysql_db_query($DBHOST_DBNAME, "SELECT resource_id FROM ".$tbl."group_cache
WHERE user_id=0 AND p_READ='Y'", $cid);
$lm='';
while( list($id) = mysql_fetch_row($r) ) $lm .= $id.',';
$lm = substr($lm, 0, -1);
$r = mysql_db_query($DBHOST_DBNAME, "SELECT
".$tbl."msg.id,
".$tbl."msg.subject,
".$tbl."thread.last_post_date,
".$tbl."thread.last_post_id
FROM
".$tbl."thread
INNER JOIN ".$tbl."msg
ON ".$tbl."thread.root_msg_id=".$tbl."msg.id
WHERE
".$tbl."thread.forum_id IN (".$lm.") AND
".$tbl."msg.approved='Y'
ORDER by
".$tbl."thread.last_post_id DESC
LIMIT ".$n_posts, $cid);
while( $obj = mysql_fetch_object($r) ) {
/* Here you do your actual code, below is a working example */
$tm = date("d/m/Y H:i", $obj->last_post_date);
echo $tm." - <a href=\"".$WWW_ROOT."index.php?t=msg&goto=".$obj->id."\">".$obj->subject."</a>
<a href=\"".$WWW_ROOT."index.php?t=tree&goto=".$obj->last_post_id."\">»»»</a><br>\n";
}
mysql_free_result($r);
}
So then you only have to call on that function, indicating as parameter the number of posts you want to fetch. For changing the date-time format in the date() function - see the PHP help file.
Here is the working example (theme names in Russian but it's not essential) http://avalon.net.ua/forum.php calling fetch_forum_posts(5);
I have updated the script for myself with another feature and do so for you. Now you have two links:
1) [/u]thread root message subject[/u] - linking to the beginning of the theme in flat view;
2) [/u]>>>>>>[/u] - linking to the last message of the thread in tree view
(you may vary them at will/need)
[Updated on: Fri, 02 January 2004 03:54] Report message to a moderator
|
|
|
Re: Newest Posts with date and name ? Re: Looking for hack... [message #14378 is a reply to message #12061] |
Thu, 13 November 2003 13:39   |
pinion
 Messages: 2 Registered: November 2003
Karma: 0
|
Junior Member |
|
|
I'm strongly considering switching to this board software, but being able to install this hack is a must. "jonrocks" attachments seem to have been deleted, and every message in this thread has been posted quite a while ago so I'm worried it may no longer work with the latest version of the board.
Is there still an easy-to-install working version available? Please help.
[Updated on: Thu, 13 November 2003 13:45] Report message to a moderator
|
|
|
|
|