Firefox PHP

Hack to display last posts in another document

Posted by Rene 

$i = 0;
while($subject[$i]) {
if(strlen($subject[$i]) >= 15){ $subject[$i] = substr ($subject[$i], 0, 15)."..."; }
Hi, I also want to limit the lenght of subject at the original phorum,default set to 255 chatrecters but it mess my table..
I dont know where to put this code
Do you how to display the "number of messages" posted in each forum, in another document


You should count post on each database table of the forum, for example in two tables "table1" and "music:

$cvbn = @mysql_fetch_row(@mysql_query("select count(id) from table1"));
$cvbna = @mysql_fetch_row(@mysql_query("select count(id) from music"));

echo "In the Phorum".($cvbn[0]+$cvbna[0])."posts";

If you want display number of registered user, try use the follow:

$cusr = @mysql_fetch_row(@mysql_query("select count(id) from forums_auth"));

echo "Registered users $cusr";
Thanks a lot, it works well
I'm running into similar problems as those mentioned above. To be more specific, I'm getting no output in the browser. Absolutely nothing displays. I know this question has already been posted, but I didn't see a resolution throughout the thread.

I'm using the exact code (I've checked and rechecked many times) that Rene originally posted and the script is in the following location:

I've named the script get_posts.php. I'm a new PHP coder, so I wouldn't be surprised if I missing something very basic and I apologize if I am. Is this code supposed to be somewhere else?

Any help is very much appreciated!
Well, I figured out my problem, other than the fact that I'm a newbie PHP coder.. :]

The reason why it wasn't displaying anything was because my query had a typo. The query I had was:

$SQL="select id, thread, author, subject, datestamp from $Forum TableName order by datestamp desc limit $number";

The problem was the fact that I had a space between "$Forum" and "TableName", which makes it an invalid query and thus the reason for nothing being displayed. Once I made the correction to "$ForumTableName", my browser displayed the last 5 posts.

That's what I get for typing the code in myself and not doing a copy/paste. Sorry for cluttering up the newsgroup, but I hope someone learned something from my idiotic mistake... :]
I've been up for four hours or so trying to find way of doing this, without success. What I am trying to do is to have the five latest topics for four different forums on my main page as well as every other, including the forum pages. This can easily be achieved with an include.

My problem is that I can't come up with some code that displays topics for multiple forums, I have written tons of code that "should" work, in theory anyway....

The closest I came were multiple instances of the same forum's topics, and if I include it on a phorum page, it only displays the topics of the active forum.

Can someone please help me, I have a deadline in one month.

Best Regards
Lasse Jellum
I forgot to tick the "Email replies to this thread, to the address above." box, ignore this.
I used the hack posted by Rene to come up with the hack to display the last 3 postings in all forums. Postings are displayed according to their folders if any.
open | download - last_post_multiple_forums.txt (1.5 KB)
I just figured it out, check out the txtfile. But your solution is much more efficient Diana.
open | download - lasshack.txt (1.8 KB)
meaning2say: is there a way of displaying last N last threads instead of posts?
Is there a way to avoid using common.php? What would my code be to skip this file. I'm trying to include this code but since I already have a database opened I get all sorts of errors since it then tries to use my phorum db afterwards.

I want to include this code independent of the other phorum code. Is this possible, and if so, how?

- Ståle
I move the phorum tables to the same database as my application and in SQL asks I not use the connection parameter.
meta-script that does all forums
September 10, 2001 04:51PM

Attached is something called 'quickphorum.php' that we use at RPGnet to show "all the forums at a glance". It recursively uses the main index (set as $baseurl) and displays the 5 (or whatever you set $limit to) most recent posts. An example in use is:

The nice thing is it uses the main phorum index and which forums are active, ergo, you don't need to recode it for specific sites.


(p.s. I'd submitted this way back when the phorum@ email list was up, I guess it never became semi-official).
open | download - quickphorum.txt (2.3 KB)
Re: meta-script that does all forums
September 10, 2001 06:08PM
spank you very much!
Re: meta-script that does all forums
January 21, 2002 12:52PM
Thank you very much, this is what i was looking for!
I'm too stoopid and need someone to hold my hand. Here is the section of code...

$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
$limit=" limit $ForumDisplay";

The file says:

# required phorum mode: add to list.php
# 'elseif (isset($limit)) {
# $limit=" limit $limit";'
# right before '$limit=" limit $ForumDisplay"'

does this then mean that the code should read..

$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
elseif (isset($limit)) {
$limit=" limit $limit";'
$limit=" limit $ForumDisplay";


It should read like this:

$q->query($DB, "set QUERY_LIMIT TO '$ForumDisplay'");
elseif (isset($limit)) {
$limit=" limit $limit";
} else{
$limit=" limit $ForumDisplay";

January 31, 2002 08:31PM
following error:

Warning: file("[] &limit=5") - Success in /home/httpd/vhosts/ on line 28

Warning: Variable passed to each() is not an array or object in /home/httpd/vhosts/ on line 30

Hi All,

After all I've made a complete rewrite of Dianas Hack (there've been just the PHP Short Open Tags and the include-statement left ...).

My Script Lists now the latest $number Headers of all Forums, that are not "secured". There are two ways to use the Script:
With or without own Output.
Without Output? Yes!
If you put it into a secured Directory (or out of the Webservers accessible Path), so no external Websites can abuse your Phorums Messages, you will have to "include" it and build the "visual" Data on your own. I'll come back to this later ...

You will possibly want to edit the default Date format $dfmt into the one you prefer (reference:
The other Settings would be the default number $number of shown messages, the time format $tfmt, and the path chdir(...).

1.) Access via http:
$lastpostings = "[$SERVER_NAME];;
[array] = file($lastpostings);
into the page you want it to be (the function readfile() would put it directly on the stdout ->
The parameter "number" is optional.
I've written two routines (show=1, show=2) to generate output:
they are not pretty, but demonstrate how it works.
show=1 generates for each message header a new line and show=2 generates a full Table.

2.) Include in your Script:
Here you have to use $number definition set in my script.
If the (your) calling script already includes other parts of Phorum, you will have to replace 'include("./common.php");' with 'include_once("./common.php")'.

After the include statement in Your Script, you can grab the data out of the array $sorted[$i]; $i=0 points to the most recent message.
Each element of this array is again an array! Here the keys and values:

$sorted[$i][name] // name of the forum where the message resides
$sorted[$i][timestamp] // unix timestamp of the message to use with date();
$sorted[$i][author] // the authors name
$sorted[$i][subject] // Subject of the message
$sorted[$i][ ]
Sorry, you do not have permission to post/reply in this forum.