FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Looking for hack...
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Looking for hack... [message #29203 is a reply to message #26336] Sat, 03 December 2005 23:17 Go to previous messageGo to previous message
Wild_Cat is currently offline  Wild_Cat   Ukraine
Messages: 144
Registered: November 2002
Location: Odessa, Ukraine
Karma:
Senior Member
cire

I got the right code on "wild cats" post a few up! I wish he said 2.6.x code in his post.


She (me) does not run FUDforum currently on her (my) site.

However, the latest version I had was 2.6.0 and the code did run OK. I attach the latest code I used (to not verify if I made any changes).

If it doesn't work with newest 2.7.x, would Ilya please take a look and may be it's quick to put in the needed modifications (reminding that my code was done on and thanks to your intial example)? Or at least give guidance for others who'd wish to use it as to what've been changed and needs to be modified (or that it will work - anyone's feedback in help for newcomers?)

function fetch_forum_posts($n_posts) /* n_posts is the number of messages you wish to fetch */
{       /* change the following for your forum GLOBALS paths!!! */
        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 group_cache_opt>>1&1=1", $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.apr=1
                                        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 "<p><SPAN CLASS=\"date\">".$tm."</SPAN> - <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."\">&raquo;&raquo;</a></p>\n";
        }
        mysql_free_result($r);
}

/*Here goes the actual call of the function!
Insert the number of posts you wish to pull instead of 10
And insert the call in the place you wish it to show the list */
fetch_forum_posts(10);



Lady of Avalon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message
Previous Topic: New threads on the front page of the site
Next Topic: General Hacking Recommendation please
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 19:04:53 GMT 2024

Total time taken to generate the page: 0.04662 seconds