Firefox PHP

Hack that displayes x last postes from x forums

Posted by Sonny 
Hack that displayes x last postes from x forums
January 03, 2002 12:56PM
Hi!

We are a coupel that just has made a hack that displayes x number of latest post from a forum folder

tha hack is testet in ver. 3.3.1a

in phorum you can create "new folder" where you can place forums inside....

IT IS THE FOLDER ID YOU SHOUD USE to get this hack to work!
ant then it takes a look al ALL the forums that are "asigned" to the folder and displays the number you want!

Here are the hack :
<?
// This hack is made for phrum.org forums ver. 3.3.1a and will finde x numbers of posts from forum.
// Syntax: get_new_posts.php?parent=1&number=5
// Gets the 5 newest posts from forum FOLDER 1.

// wision & Testet by cyberdude.
// Made by The_NESt.

$parent=1; // Here you write the FOLDER id number
$number=5; // here you write the number of postes that you want to display
chdir("phorum/"); // the place where phorum is "instaled"
include "common.php";
$SQL="select id, table_name from forums where parent='$parent'";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)) {
$tables[] = $rec["table_name"];
$forumids[$rec["table_name"]] = $rec["id"];
$rec=$q->getrow();
}
while(list($key, $table) = each($tables)) {
$SQL="select id, thread, author, subject, datestamp from $table order by datestamp desc limit $number";
$q->query($DB, $SQL);
$rec=$q->getrow();
while(is_array($rec)) {
$posts[$rec["datestamp"]][] = $rec;
$loop = 0;
while($posts[$rec["datestamp"]][$loop] != $rec) {
$loop++;
}
$posts[$rec["datestamp"]][$loop]["forumid"] = $forumids[$table];
$rec=$q->getrow();
}
}
ksort($posts);
$posts = array_reverse($posts);
$loop = 0;
while($loop <= (sizeof($posts) - 1) && $loop <= ($number - 1) && list($key, $date) = each($posts)){
while($loop <= ($number - 1) && list($key, $rec) = each($date)) {
echo "<a href=\"$forum_url/$read_page.$ext?f=$rec[forumid]&i=$rec[id]&t=$rec[thread]\"> $rec[subject] </a> - $rec[author] - $rec[datestamp]<br>\n";
$loop++;
}
}
?>


HINT if you want to use this hack in an other place
you can use
<?
include("[server.com];);
?>
But remember to outcoment this lines in the hack
$parent=1; // Here you write the FOLDER id number
$number=5; // here you write the number of postes that you want to

Hope you enjoye this hack!

Re: Hack that displayes x last postes from x forums
January 03, 2002 05:33PM
I found an "error" in the postet script......
you might want to make changes to this line....

$SQL="select id, table_name from forums where parent='$parent'";

especaly "forums" this MUST be changed to the table name of your main table for phorum...........

Warning: Wrong datatype in ksort() call in ...../httpdocs/forum.php on line 35

Warning: Argument to array_reverse() should be an array in ...../httpdocs/forum.php on line 36

What can I do? Please help me :)
Re: Hack that displayes x last postes from x forums
January 05, 2002 09:08AM
Hi!!


It is WERRY IMPORTENT that the $parent number is set to a FOLDER id..... if it is set to a spwcific forum it wont work!

And remember to change the select from ...... in the first query to what your main forum table is called.

if you are sure it parent is set to a FOLDER id and it wont wort then send me your file and dump of the database witch contain the main table for the forum (in most cases called forums)

Hi,
I applied your changes. But it isn' t work again :( I tried all of view last messages hacks, in this forum, but I couldn' t do it...

I set my database,

forum_1
forum_2
forum_3
....
forum
forum_moderator
....

I haven' t got information about mysql db. Please help..
Is there any help :)
Re: Hack that displayes x last postes from x forums
January 07, 2002 09:56AM
Is there somwhere i can see your forum in action, it woud make it a bit more easy for me to say what you shoud put in where... :-)


You can write to my e-mail adress if you dont want to post your site adress in here!
gonzzo@writeme.com

>Is there somwhere i can see your forum in action, it woud make it a bit >more easy for me to say what you shoud put in where... :-)
>
>
>You can write to my e-mail adress if you dont want to post your site >adress in here!
>gonzzo@writeme.com
>
>Regards
>// Cyberdude

I read your message and I sent you an e-mail :)
Re: Hack that displayes x last postes from x forums
January 08, 2002 07:44AM
i have just sent you a mail with the content i supose woud work on your site!

Thanks Sonny, your hack code is really great :)
I am trying to adapt this for another situation and I am having trouble understanding the logic of the last pair of while loops.
I dont quite follow why there are two whiles and why
inside the inner while the variable $rec is used, but the loop is on $posts and the $rec was last set inside the previous set of whiles.
Thanks Martin West
I'm also getting the same errors The-King got. I'm slightly modifying your code so that it will work in PostNuke, but that should not matter to the functionality...

Here is the link to my testsite: [www.savage.no]

Hope you could help :)
Hello,

Where can I see it in action ??

Thanks

Fred
Re: Hack that displayes x last postes from x forums
April 13, 2002 09:18AM
hi Fred!!

You can see it in action on [www.bryllup.dk]
at the front page are the last 5 postes from the 9 forums that are active on the site!

The site are in danish... i don't know if anny other is using it in an other languige!

I'm new to PHP. I tried several times on coding this, but failed. also, if the subject is a bit long, it will break the small image line and messed up the page. I tried to change the images with unordered lists, but also failed.:(

Any suggestions?
Hi,

Does your hack work on Phorum 3.2.11 ?

Vynstar
This hack seems to work, but it shows all posts, even if I use

$limit = 1; # default max number of threads to list

You can see what I mean here: [www.deutsch-online.com]

Do you know whats wrong in this case?

Maybe the problem is that I dont understand the first lines of the script:

<?

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

Of course I want in include the last posts into another *.php-document, how van that be done?

Probably the solution to my problems is hidden in those 4 lines, but absolute beginners like me often get into troubles like this ...

Can anyone help me, please?
Thanks, that works. All I did was to change
$parent=1;
to
$parent=0;


I also added something to make it show the German Date, which is
19.08.2003 14:00:00
instead of
2003-08-19 14:00:00

Replace
echo "<a href=\"$forum_url/$read_page.$ext?f=$rec[forumid]&i=$rec[id]&t=$rec[thread]\">

with
$_neu_datestamp = eregi_replace ("([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})" ,"\\3.\\2.\\1 \\4:\\5:\\6",$rec[datestamp]);

echo "<a href=\"$forum_url/$read_page.$ext?f=$rec[forumid]&i=$rec[id]&t=$rec[thread]\">$rec[subject]</a> von: $rec[author], geschrieben am $_neu_datestamp<br>\n";
Sorry, you do not have permission to post/reply in this forum.